@Singleton public class DefaultSecurityService extends java.lang.Object implements SecurityService
SecurityService
. It uses ServerRequestContext.currentRequest()
to retrieve the Authentication
object if any.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ROLES
Deprecated.
This constant is no longer used and it will be removed in the next mayor version
|
Constructor and Description |
---|
DefaultSecurityService(RolesFinder rolesFinder) |
DefaultSecurityService(TokenConfiguration tokenConfiguration)
Deprecated.
Use
DefaultSecurityService( RolesFinder ) instead. |
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)
Deprecated.
use
instead |
boolean |
isAuthenticated()
Check if a user is authenticated.
|
java.util.Optional<java.lang.String> |
username()
Get the username of the current user.
|
@Deprecated public static final java.lang.String ROLES
@Deprecated public DefaultSecurityService(TokenConfiguration tokenConfiguration)
DefaultSecurityService( RolesFinder )
instead.tokenConfiguration
- Token Configuration@Inject public DefaultSecurityService(RolesFinder rolesFinder)
rolesFinder
- Roles Parserpublic java.util.Optional<java.lang.String> username()
username
in interface SecurityService
public java.util.Optional<Authentication> getAuthentication()
Authentication
if authenticated.getAuthentication
in interface SecurityService
Authentication
of the current userpublic boolean isAuthenticated()
isAuthenticated
in interface SecurityService
public boolean hasRole(java.lang.String role)
hasRole
in interface SecurityService
role
- the role to check@Deprecated public boolean hasRole(java.lang.String role, java.lang.String rolesKey)
instead
hasRole
in interface SecurityService
role
- the authority to checkrolesKey
- The map key to be used in the authentications attributes. E.g. "roles".