public interface SecuritySupport
Modifier and Type | Method and Description |
---|---|
void |
checkPermission(String permission)
Checks if the connected user has the given permission : if the user does not have the permission, throws an
exception to block execution.
The permission is given as a String in the form "object:action[:id]" (e.g. |
void |
checkPermission(String permission,
Scope... scopes)
Checks if the connected user has the given permission on the given scopes : if the user does not have the
permission, throws an exception to
block execution.
The permission is given as a String in the form "object:action[:id]" (e.g. |
void |
checkPermissions(String... permissions)
Checks if the connected user has the given permissions : if the user does not have all the permissions, throws
an exception to block execution.
The permissions are given as Strings in the form "object:action[:id]" (e.g. |
void |
checkRole(String roleIdentifier)
Checks if the connected user has the given role : throws an exception otherwise.
Note that it is discouraged to test for roles in your application as role names are prone to change in the life span of your application. |
void |
checkRoles(String... roleIdentifiers)
Checks if the connected user has all the given roles : throws an exception otherwise.
Note that it is discouraged to test for roles in your application as role names are prone to change in the life span of your application. |
String |
getHost()
Returns the host name or IP string of the host of the connected user, or
null if the host is unknown. |
PrincipalProvider<?> |
getIdentityPrincipal()
Gets the principal provider that holds the user's identity.
|
Collection<PrincipalProvider<?>> |
getOtherPrincipals()
Retrieves all the PrincipalProviders containing the user's details.
|
<T extends Serializable> |
getPrincipalsByType(Class<T> principalClass)
Gets all the PrincipalProviders corresponding to a type of PrincipalProvider.
For example, you can use this method to get the LDAPUser by calling : getPrincipalsByType(LDAPUser.class) .Then on the first element of the collection : LDAPUser user =
ldapUserPrincipalProvider.getPrincipal() . |
Set<Role> |
getRoles()
Gives the roles given to the user.
|
SimplePrincipalProvider |
getSimplePrincipalByName(String principalName)
Gets the SimplePrincipalProvider which name is provided.
|
Collection<SimplePrincipalProvider> |
getSimplePrincipals()
Gets the user's SimplePrincipalProviders.
A SimplePrincipalProvider is a name/value principal. |
Set<SimpleScope> |
getSimpleScopes()
Gives all the simple scopes of the user found in all its roles.
|
boolean |
hasAllRoles(String... roleIdentifiers)
Tells if the connected user has all of the given roles.
Note that it is discouraged to test for roles in your application as role names are prone to change in the life span of your application. |
boolean |
hasAnyRole(String... roleIdentifiers)
Tells if the connected user has at least one of the given roles.
Note that it is discouraged to test for roles in your application as role names are prone to change in the life span of your application. |
boolean |
hasRole(String roleIdentifier)
Tells if the connected user has the given role.
Note that it is discouraged to test for roles in your application as role names are prone to change in the life span of your application. |
boolean |
hasRole(String roleIdentifier,
Scope... scopes)
Tells if the connected user has the given role on all the given scopes.
Note that it is discouraged to test for roles in your application as role names are prone to change in the life span of your application. |
boolean |
isAuthenticated()
Check if the current user is authenticated.
|
boolean |
isPermitted(String permission)
Tells if the connected user has the given permission.
The permission is given as a String in the form "object:action[:id]" (e.g. |
boolean |
isPermitted(String permission,
Scope... scopes)
Tells if the connected user has the given permission on the given scopes.
The permission is given as a String in the form "object:action[:id]" (e.g. |
boolean |
isPermittedAll(String... permissions)
Tells if the connected user has all of the given permissions.
The permissions are given as Strings in the form "object:action[:id]" (e.g. |
boolean |
isPermittedAny(String... permissions)
Tells if the connected user has at least one of the given permissions.
The permissions are given as Strings in the form "object:action[:id]" (e.g. |
boolean |
isRemembered()
Checks if the current user has logged successfully on a previous session
|
void |
logout()
Logs out the connected user and invalidates and/or removes any associated entities, such as a Session and
authorization data.
|
PrincipalProvider<?> getIdentityPrincipal()
Collection<PrincipalProvider<?>> getOtherPrincipals()
<T extends Serializable> Collection<PrincipalProvider<T>> getPrincipalsByType(Class<T> principalClass)
getPrincipalsByType(LDAPUser.class)
.LDAPUser user =
ldapUserPrincipalProvider.getPrincipal()
.T
- type of the principalprincipalClass
- the Principal type, not nullPrincipals.getPrincipalsByType(Collection, Class)
Collection<SimplePrincipalProvider> getSimplePrincipals()
SimplePrincipalProvider
is a name/value principal. A list of
common SimplePrincipalProviders names are found in class
Principals
.Principals.getSimplePrincipals(Collection)
SimplePrincipalProvider getSimplePrincipalByName(String principalName)
principalName
- the name of the principal. Null returns null.Principals.getSimplePrincipalByName(Collection, String)
boolean isPermitted(String permission)
permission
- the string permission to test. Not nullboolean isPermitted(String permission, Scope... scopes)
permission
- the string permission to test. Not nullscopes
- the scopes to verify the permission on. optionalboolean isPermittedAll(String... permissions)
permissions
- the string permissions to test. not nullboolean isPermittedAny(String... permissions)
permissions
- the string permissions to test. Not nullvoid checkPermission(String permission, Scope... scopes)
permission
- the string permission to test. Not null.scopes
- the scopes to verify the permission on. optionalAuthorizationException
- if the user does not have the permission.void checkPermission(String permission)
permission
- the string permission to test. Not null.AuthorizationException
- if the user does not have the permission.void checkPermissions(String... permissions)
permissions
- the string permissions to test. Not null.AuthorizationException
- if the user does not have all of the given permissions.boolean hasRole(String roleIdentifier, Scope... scopes)
roleIdentifier
- the id of the role to test. Not null.scopes
- the scopes to verify the role on. optionalboolean hasRole(String roleIdentifier)
roleIdentifier
- the id of the role to test. Not null.boolean hasAllRoles(String... roleIdentifiers)
roleIdentifiers
- the names of the roles to test. Not null.boolean hasAnyRole(String... roleIdentifiers)
roleIdentifiers
- the names of the roles to test. Not null.void checkRole(String roleIdentifier)
roleIdentifier
- the name of the role to check. Not null.AuthorizationException
- if the user does not have the given role.void checkRoles(String... roleIdentifiers)
roleIdentifiers
- the name of the roles to check. Not null.AuthorizationException
- if the user does not have all the given role.Set<Role> getRoles()
Set<SimpleScope> getSimpleScopes()
void logout()
The typical approach most applications use in this scenario is to redirect the user to a different location (e .g. home page) immediately after calling this method. This is an effect of the HTTP protocol itself and not a reflection of the implementation.
boolean isAuthenticated()
isRemembered()
boolean isRemembered()
String getHost()
null
if the host is unknown.null
if the host
address is unknown.Copyright © 2013-2018–2019 SeedStack. All rights reserved.