Class SlimSecurityManager
java.lang.Object
cloud.piranha.extension.slim.security.SlimSecurityManager
- All Implemented Interfaces:
SecurityManager
The SlimSecurityManager.
- Author:
- Manfred Riem ([email protected])
-
Nested Class Summary
Nested classes/interfaces inherited from interface cloud.piranha.core.api.SecurityManager
SecurityManager.AuthenticateSource, SecurityManager.UsernamePasswordLoginHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Stores the denyUncoveredHttpMethods flag.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
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Authenticate the request.void
declareRoles
(String[] roles) Declare roles.boolean
Get if we are denying uncovered HTTP methods.getRoles()
Get the declared rolesGet the web application.boolean
isUserInRole
(jakarta.servlet.http.HttpServletRequest request, String role) Is the user in the specific role.void
Login.void
logout
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.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.core.api.SecurityManager
authenticate, declareRoles, getAuthenticatedRequest, getAuthenticatedResponse, getAuthMethod, getFormErrorPage, getFormLoginPage, getRealmName, isCallerAuthorizedForResource, isRequestedResourcePublic, isRequestSecurityAsRequired, postRequestProcess, setAuthMethod, setFormErrorPage, setFormLoginPage, setRealmName, setUsernamePasswordLoginHandler
-
Field Details
-
denyUncoveredHttpMethods
protected boolean denyUncoveredHttpMethodsStores the denyUncoveredHttpMethods flag. -
logins
Stores the logins. -
roles
Stores the roles. -
userRoles
Stores the user roles. -
webApplication
Stores the web application.
-
-
Constructor Details
-
SlimSecurityManager
public SlimSecurityManager()
-
-
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(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException, jakarta.servlet.ServletException Description copied from interface:SecurityManager
Authenticate the request.- Specified by:
authenticate
in interfaceSecurityManager
- Parameters:
request
- the request.response
- the response.- Returns:
- true if authenticated.
- Throws:
IOException
- when an I/O error occurs.jakarta.servlet.ServletException
- when a servlet error occurs.
-
declareRoles
Description copied from interface:SecurityManager
Declare roles.- Specified by:
declareRoles
in interfaceSecurityManager
- Parameters:
roles
- the roles.
-
getDenyUncoveredHttpMethods
public boolean getDenyUncoveredHttpMethods()Description copied from interface:SecurityManager
Get if we are denying uncovered HTTP methods.- Specified by:
getDenyUncoveredHttpMethods
in interfaceSecurityManager
- Returns:
- true if we are, false otherwise.
-
getRoles
Description copied from interface:SecurityManager
Get the declared roles- Specified by:
getRoles
in interfaceSecurityManager
- Returns:
- the roles
-
getWebApplication
Description copied from interface:SecurityManager
Get the web application.- Specified by:
getWebApplication
in interfaceSecurityManager
- Returns:
- the web application.
-
isUserInRole
Description copied from interface:SecurityManager
Is the user in the specific 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(jakarta.servlet.http.HttpServletRequest request, String username, String password) throws jakarta.servlet.ServletException Description copied from interface:SecurityManager
Login.- Specified by:
login
in interfaceSecurityManager
- Parameters:
request
- the request.username
- the username.password
- the password.- Throws:
jakarta.servlet.ServletException
- when unable to login.
-
logout
public void logout(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException Description copied from interface:SecurityManager
Logout.- Specified by:
logout
in interfaceSecurityManager
- Parameters:
request
- the request.response
- the response.- Throws:
jakarta.servlet.ServletException
- when a servlet error occurs.
-
removeUser
Remove the given user.- Parameters:
username
- the username.
-
setDenyUncoveredHttpMethods
public void setDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods) Description copied from interface:SecurityManager
Set if we are denying uncovered HTTP methods.- Specified by:
setDenyUncoveredHttpMethods
in interfaceSecurityManager
- Parameters:
denyUncoveredHttpMethods
- the boolean value.
-
setWebApplication
Description copied from interface:SecurityManager
Set the web application.- Specified by:
setWebApplication
in interfaceSecurityManager
- Parameters:
webApplication
- the web application.
-