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)
PortofinoRealmverifyUser in interface PortofinoRealmuser - the user object.public void changePassword(Serializable user, String oldPassword, String newPassword)
PortofinoRealmchangePassword in interface PortofinoRealmuser - 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)
PortofinoRealmgenerateOneTimeToken in interface PortofinoRealmuser - the user object.public String encryptPassword(String password)
PortofinoRealmencryptPassword in interface PortofinoRealmpassword - the plaintext password.public Map<Serializable,String> getUsers()
PortofinoRealmgetUsers in interface PortofinoRealmpublic Serializable getUserById(String encodedUserId)
PortofinoRealmgetUserById in interface PortofinoRealmencodedUserId - 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)
PortofinoRealmgetUserByEmail in interface PortofinoRealmemail - the email address of the user.public ClassAccessor getSelfRegisteredUserClassAccessor()
PortofinoRealmgetSelfRegisteredUserClassAccessor in interface PortofinoRealmpublic String saveSelfRegisteredUser(Object user)
PortofinoRealmsaveSelfRegisteredUser in interface PortofinoRealmuser - the user object to save. It is the same kind of object known by getSelfRegisteredUserClassAccessor().public String getUserPrettyName(Serializable user)
PortofinoRealmgetUserPrettyName in interface PortofinoRealmuser - the user's primary principal (as returned by loadAuthenticationInfo()).public Serializable getUserId(Serializable user)
PortofinoRealmgetUserId in interface PortofinoRealmuser - the user's primary principal (as returned by loadAuthenticationInfo()).public Set<String> getGroups()
PortofinoRealmgetGroups in interface PortofinoRealmpublic boolean supports(AuthenticationToken token)
public AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException
getAuthenticationInfo in interface RealmAuthenticationExceptionpublic boolean isPermitted(PrincipalCollection principals, String permission)
isPermitted in interface Authorizerpublic boolean isPermitted(PrincipalCollection subjectPrincipal, Permission permission)
isPermitted in interface Authorizerpublic boolean[] isPermitted(PrincipalCollection subjectPrincipal, String... permissions)
isPermitted in interface Authorizerpublic boolean[] isPermitted(PrincipalCollection subjectPrincipal, List<Permission> permissions)
isPermitted in interface Authorizerpublic boolean isPermittedAll(PrincipalCollection subjectPrincipal, String... permissions)
isPermittedAll in interface Authorizerpublic boolean isPermittedAll(PrincipalCollection subjectPrincipal, Collection<Permission> permissions)
isPermittedAll in interface Authorizerpublic void checkPermission(PrincipalCollection subjectPrincipal, String permission) throws AuthorizationException
checkPermission in interface AuthorizerAuthorizationExceptionpublic void checkPermission(PrincipalCollection subjectPrincipal, Permission permission) throws AuthorizationException
checkPermission in interface AuthorizerAuthorizationExceptionpublic void checkPermissions(PrincipalCollection subjectPrincipal, String... permissions) throws AuthorizationException
checkPermissions in interface AuthorizerAuthorizationExceptionpublic void checkPermissions(PrincipalCollection subjectPrincipal, Collection<Permission> permissions) throws AuthorizationException
checkPermissions in interface AuthorizerAuthorizationExceptionpublic boolean hasRole(PrincipalCollection subjectPrincipal, String roleIdentifier)
hasRole in interface Authorizerpublic boolean[] hasRoles(PrincipalCollection subjectPrincipal, List<String> roleIdentifiers)
hasRoles in interface Authorizerpublic boolean hasAllRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers)
hasAllRoles in interface Authorizerpublic void checkRole(PrincipalCollection subjectPrincipal, String roleIdentifier) throws AuthorizationException
checkRole in interface AuthorizerAuthorizationExceptionpublic void checkRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers) throws AuthorizationException
checkRoles in interface AuthorizerAuthorizationExceptionpublic void checkRoles(PrincipalCollection subjectPrincipal, String... roleIdentifiers) throws AuthorizationException
checkRoles in interface AuthorizerAuthorizationExceptionpublic void setCacheManager(CacheManager cacheManager)
setCacheManager in interface CacheManagerAwarepublic void destroy()
destroy in interface Destroyable