@Singleton public class DefaultSecurityService extends java.lang.Object implements SecurityService
SecurityService. It uses ServerRequestContext.currentRequest() to retrieve the Authentication object if any.| Constructor and Description |
|---|
DefaultSecurityService() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<Authentication> |
getAuthentication()
Retrieves
Authentication if authenticated. |
boolean |
hasRole(java.lang.String role)
If the current user has a specific role.
|
boolean |
hasRole(java.lang.String role,
java.lang.String rolesKey)
If the current user has a specific role.
|
boolean |
isAuthenticated()
Check if a user is authenticated.
|
java.util.Optional<java.lang.String> |
username()
Get the username of the current user.
|
public java.util.Optional<java.lang.String> username()
username in interface SecurityServicepublic java.util.Optional<Authentication> getAuthentication()
Authentication if authenticated.getAuthentication in interface SecurityServiceAuthentication of the current userpublic boolean isAuthenticated()
isAuthenticated in interface SecurityServicepublic boolean hasRole(java.lang.String role)
hasRole in interface SecurityServicerole - the role to checkpublic boolean hasRole(java.lang.String role,
java.lang.String rolesKey)
hasRole in interface SecurityServicerole - the authority to checkrolesKey - The map key to be used in the authentications attributes. E.g. "roles".