public class SecurityGroovyRealm extends Object implements PortofinoRealm, Destroyable
Modifier and Type | Field and Description |
---|---|
protected CacheManager |
cacheManager |
static String |
copyright |
protected boolean |
destroyed |
protected GroovyScriptEngine |
groovyScriptEngine |
static org.slf4j.Logger |
logger |
protected String |
scriptUrl |
protected PortofinoRealm |
security |
protected ServletContext |
servletContext |
Constructor and Description |
---|
SecurityGroovyRealm(GroovyScriptEngine groovyScriptEngine,
String scriptUrl,
ServletContext servletContext) |
Modifier and Type | Method and Description |
---|---|
void |
changePassword(Serializable user,
String oldPassword,
String newPassword)
Changes a user's password
|
void |
checkPermission(PrincipalCollection subjectPrincipal,
Permission permission) |
void |
checkPermission(PrincipalCollection subjectPrincipal,
String permission) |
void |
checkPermissions(PrincipalCollection subjectPrincipal,
Collection<Permission> permissions) |
void |
checkPermissions(PrincipalCollection subjectPrincipal,
String... permissions) |
void |
checkRole(PrincipalCollection subjectPrincipal,
String roleIdentifier) |
void |
checkRoles(PrincipalCollection subjectPrincipal,
Collection<String> roleIdentifiers) |
void |
checkRoles(PrincipalCollection subjectPrincipal,
String... roleIdentifiers) |
protected void |
configureDelegate(PortofinoRealm security) |
void |
destroy() |
String |
encryptPassword(String password)
Returns an encrypted or hashed password.
|
String |
generateOneTimeToken(Serializable user)
Generates a one-time token, for use in email validation and password reset.
|
AuthenticationInfo |
getAuthenticationInfo(AuthenticationToken token) |
Set<String> |
getGroups()
Returns the list of groups known to the system.
|
String |
getName() |
ClassAccessor |
getSelfRegisteredUserClassAccessor()
Returns a ClassAccessor that describes the properties which a self-registered user must or can provide to
initiate the sign up process.
|
Serializable |
getUserByEmail(String email)
Loads a user by email address.
|
Serializable |
getUserById(String encodedUserId)
Loads a user by id.
|
Serializable |
getUserId(Serializable user)
Extracts a value that uniquely identifies the user.
|
String |
getUserPrettyName(Serializable user)
Computes a string describing the user, meant to be shown on the UI.
|
Map<Serializable,String> |
getUsers()
Returns the list of users known to the system.
|
boolean |
hasAllRoles(PrincipalCollection subjectPrincipal,
Collection<String> roleIdentifiers) |
boolean |
hasRole(PrincipalCollection subjectPrincipal,
String roleIdentifier) |
boolean[] |
hasRoles(PrincipalCollection subjectPrincipal,
List<String> roleIdentifiers) |
boolean[] |
isPermitted(PrincipalCollection subjectPrincipal,
List<Permission> permissions) |
boolean |
isPermitted(PrincipalCollection subjectPrincipal,
Permission permission) |
boolean[] |
isPermitted(PrincipalCollection subjectPrincipal,
String... permissions) |
boolean |
isPermitted(PrincipalCollection principals,
String permission) |
boolean |
isPermittedAll(PrincipalCollection subjectPrincipal,
Collection<Permission> permissions) |
boolean |
isPermittedAll(PrincipalCollection subjectPrincipal,
String... permissions) |
String |
saveSelfRegisteredUser(Object user)
Saves a self-registered user on the system.
|
void |
setCacheManager(CacheManager cacheManager) |
boolean |
supports(AuthenticationToken token) |
void |
verifyUser(Serializable user)
Marks the user as verified as a consequence of a user's action, e.g.
|
public static final String copyright
public static final org.slf4j.Logger logger
protected final GroovyScriptEngine groovyScriptEngine
protected final String scriptUrl
protected final ServletContext servletContext
protected volatile PortofinoRealm security
protected volatile boolean destroyed
protected CacheManager cacheManager
public SecurityGroovyRealm(GroovyScriptEngine groovyScriptEngine, String scriptUrl, ServletContext servletContext) throws ScriptException, ResourceException, InstantiationException, IllegalAccessException
protected void configureDelegate(PortofinoRealm security)
public void verifyUser(Serializable user)
PortofinoRealm
verifyUser
in interface PortofinoRealm
user
- the user object.public void changePassword(Serializable user, String oldPassword, String newPassword)
PortofinoRealm
changePassword
in interface PortofinoRealm
user
- the user object.oldPassword
- the old password provided by the user. Must match with the stored one.newPassword
- the new password.public String generateOneTimeToken(Serializable user)
PortofinoRealm
generateOneTimeToken
in interface PortofinoRealm
user
- the user object.public String encryptPassword(String password)
PortofinoRealm
encryptPassword
in interface PortofinoRealm
password
- the plaintext password.public Map<Serializable,String> getUsers()
PortofinoRealm
getUsers
in interface PortofinoRealm
public Serializable getUserById(String encodedUserId)
PortofinoRealm
getUserById
in interface PortofinoRealm
encodedUserId
- the user id as a String. The security implementation is expected to convert the String
to a value of the appropriate type.public Serializable getUserByEmail(String email)
PortofinoRealm
getUserByEmail
in interface PortofinoRealm
email
- the email address of the user.public ClassAccessor getSelfRegisteredUserClassAccessor()
PortofinoRealm
getSelfRegisteredUserClassAccessor
in interface PortofinoRealm
public String saveSelfRegisteredUser(Object user)
PortofinoRealm
saveSelfRegisteredUser
in interface PortofinoRealm
user
- the user object to save. It is the same kind of object known by getSelfRegisteredUserClassAccessor().public String getUserPrettyName(Serializable user)
PortofinoRealm
getUserPrettyName
in interface PortofinoRealm
user
- the user's primary principal (as returned by loadAuthenticationInfo()).public Serializable getUserId(Serializable user)
PortofinoRealm
getUserId
in interface PortofinoRealm
user
- the user's primary principal (as returned by loadAuthenticationInfo()).public Set<String> getGroups()
PortofinoRealm
getGroups
in interface PortofinoRealm
public boolean supports(AuthenticationToken token)
public AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException
getAuthenticationInfo
in interface Realm
AuthenticationException
public boolean isPermitted(PrincipalCollection principals, String permission)
isPermitted
in interface Authorizer
public boolean isPermitted(PrincipalCollection subjectPrincipal, Permission permission)
isPermitted
in interface Authorizer
public boolean[] isPermitted(PrincipalCollection subjectPrincipal, String... permissions)
isPermitted
in interface Authorizer
public boolean[] isPermitted(PrincipalCollection subjectPrincipal, List<Permission> permissions)
isPermitted
in interface Authorizer
public boolean isPermittedAll(PrincipalCollection subjectPrincipal, String... permissions)
isPermittedAll
in interface Authorizer
public boolean isPermittedAll(PrincipalCollection subjectPrincipal, Collection<Permission> permissions)
isPermittedAll
in interface Authorizer
public void checkPermission(PrincipalCollection subjectPrincipal, String permission) throws AuthorizationException
checkPermission
in interface Authorizer
AuthorizationException
public void checkPermission(PrincipalCollection subjectPrincipal, Permission permission) throws AuthorizationException
checkPermission
in interface Authorizer
AuthorizationException
public void checkPermissions(PrincipalCollection subjectPrincipal, String... permissions) throws AuthorizationException
checkPermissions
in interface Authorizer
AuthorizationException
public void checkPermissions(PrincipalCollection subjectPrincipal, Collection<Permission> permissions) throws AuthorizationException
checkPermissions
in interface Authorizer
AuthorizationException
public boolean hasRole(PrincipalCollection subjectPrincipal, String roleIdentifier)
hasRole
in interface Authorizer
public boolean[] hasRoles(PrincipalCollection subjectPrincipal, List<String> roleIdentifiers)
hasRoles
in interface Authorizer
public boolean hasAllRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers)
hasAllRoles
in interface Authorizer
public void checkRole(PrincipalCollection subjectPrincipal, String roleIdentifier) throws AuthorizationException
checkRole
in interface Authorizer
AuthorizationException
public void checkRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers) throws AuthorizationException
checkRoles
in interface Authorizer
AuthorizationException
public void checkRoles(PrincipalCollection subjectPrincipal, String... roleIdentifiers) throws AuthorizationException
checkRoles
in interface Authorizer
AuthorizationException
public void setCacheManager(CacheManager cacheManager)
setCacheManager
in interface CacheManagerAware
public void destroy()
destroy
in interface Destroyable