java.lang.Object
cloud.piranha.webapp.impl.DefaultSecurityManager
- All Implemented Interfaces:
SecurityManager
The default SecurityManager.
This security manager implies the use of DefaultWebApplicationRequest, if your server / web application does not want to use DefaultWebApplicationRequest or subclass DefaultWebApplicationRequest you have to implement your own security manager.
- Author:
- Manfred Riem ([email protected])
-
Nested Class Summary
Nested classes/interfaces inherited from interface cloud.piranha.webapp.api.SecurityManager
SecurityManager.AuthenticateSource, SecurityManager.UsernamePasswordLoginHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Stores if we are denying uncovered HTTP methods.Stores the logins.Stores the roles.Stores the user roles.protected WebApplication
Stores the web application. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add user.void
addUserRole(String username, String... roles)
Add the user roles.boolean
authenticate(HttpServletRequest request, HttpServletResponse response)
Authenticate the request.void
declareRoles(String[] roles)
Declare roles.boolean
Get if we are denying uncovered HTTP methods.getRoles()
Get the declared rolesReturns the web application.boolean
isUserInRole(HttpServletRequest request, String role)
Is the user in the given role.void
login(HttpServletRequest request, String username, String password)
Login with the given username and password.void
logout(HttpServletRequest request, HttpServletResponse response)
Logout.void
removeUser(String username)
Remove the given user.void
setDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods)
Set if we are denying uncovered HTTP methods.void
setWebApplication(WebApplication webApplication)
Set the web application.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cloud.piranha.webapp.api.SecurityManager
authenticate, declareRoles, getAuthenticatedRequest, getAuthenticatedResponse, isCallerAuthorizedForResource, isRequestedResourcePublic, isRequestSecurityAsRequired, postRequestProcess, setUsernamePasswordLoginHandler
-
Field Details
-
denyUncoveredHttpMethods
protected boolean denyUncoveredHttpMethodsStores if we are denying uncovered HTTP methods. -
logins
Stores the logins. -
roles
Stores the roles. -
userRoles
Stores the user roles. -
webApplication
Stores the web application.
-
-
Constructor Details
-
DefaultSecurityManager
public DefaultSecurityManager()
-
-
Method Details
-
addUser
Add user.- Parameters:
username
- the username.password
- the password.roles
- the roles.
-
addUserRole
Add the user roles.- Parameters:
username
- the username.roles
- the roles.
-
authenticate
public boolean authenticate(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletExceptionAuthenticate the request.- Specified by:
authenticate
in interfaceSecurityManager
- Parameters:
request
- the request.response
- the response.- Returns:
- true if authenticated, false otherwise.
- Throws:
IOException
- when an I/O error occurs.ServletException
- when a Servlet error occurs.
-
declareRoles
Declare roles.- Specified by:
declareRoles
in interfaceSecurityManager
- Parameters:
roles
- the roles.
-
getRoles
Description copied from interface:SecurityManager
Get the declared roles- Specified by:
getRoles
in interfaceSecurityManager
- Returns:
- the roles
-
getDenyUncoveredHttpMethods
public boolean getDenyUncoveredHttpMethods()Get if we are denying uncovered HTTP methods.- Specified by:
getDenyUncoveredHttpMethods
in interfaceSecurityManager
- Returns:
- true if we are, false otherwise.
-
getWebApplication
Returns the web application.- Specified by:
getWebApplication
in interfaceSecurityManager
- Returns:
- the web application
-
isUserInRole
Is the user in the given role.- Specified by:
isUserInRole
in interfaceSecurityManager
- Parameters:
request
- the request.role
- the role.- Returns:
- true if in the role, false otherwise.
-
login
public void login(HttpServletRequest request, String username, String password) throws ServletExceptionLogin with the given username and password.- Specified by:
login
in interfaceSecurityManager
- Parameters:
request
- the servlet request.username
- the username.password
- the password.- Throws:
ServletException
- when a serious error occurs.
-
logout
public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletExceptionLogout.- Specified by:
logout
in interfaceSecurityManager
- Parameters:
request
- the request.response
- the response.- Throws:
ServletException
- when a serious error occurs.
-
removeUser
Remove the given user.- Parameters:
username
- the username.
-
setDenyUncoveredHttpMethods
public void setDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods)Set if we are denying uncovered HTTP methods.- Specified by:
setDenyUncoveredHttpMethods
in interfaceSecurityManager
- Parameters:
denyUncoveredHttpMethods
- the boolean value.
-
setWebApplication
Set the web application.- Specified by:
setWebApplication
in interfaceSecurityManager
- Parameters:
webApplication
- the web application.
-