Package io.micronaut.security.utils
Class DefaultSecurityService
java.lang.Object
io.micronaut.security.utils.DefaultSecurityService
- All Implemented Interfaces:
 SecurityService
Default implementation of 
SecurityService. It uses ServerRequestContext.currentRequest() to retrieve the Authentication object if any.- Since:
 - 1.0
 - Author:
 - Sergio del Amo
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionRetrievesAuthenticationif authenticated.booleanIf the current user has a specific role.booleanCheck if a user is authenticated.username()Get the username of the current user. 
- 
Constructor Details
- 
DefaultSecurityService
- Parameters:
 rolesFinder- Roles Parser
 
 - 
 - 
Method Details
- 
username
Get the username of the current user.- Specified by:
 usernamein interfaceSecurityService- Returns:
 - the username of the current user
 
 - 
getAuthentication
RetrievesAuthenticationif authenticated.- Specified by:
 getAuthenticationin interfaceSecurityService- Returns:
 - the 
Authenticationof the current user 
 - 
isAuthenticated
public boolean isAuthenticated()Check if a user is authenticated.- Specified by:
 isAuthenticatedin interfaceSecurityService- Returns:
 - true if the user is authenticated, false otherwise
 
 - 
hasRole
If the current user has a specific role.- Specified by:
 hasRolein interfaceSecurityService- Parameters:
 role- the role to check- Returns:
 - true if the current user has the role, false otherwise
 
 
 -