public class Account extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected Authorizations |
authorizations |
protected Credentials |
credentials |
protected Set<String> |
emailAddresses |
static Account |
GUEST |
protected boolean |
isDisabled |
protected String |
name |
protected Set<String> |
tokens |
| Constructor and Description |
|---|
Account(String name,
Credentials credentials) |
Account(String name,
Credentials credentials,
Authorizations authorizations) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEmailAddress(String address) |
void |
addEmailAddresses(Collection<String> addresses) |
void |
addEmailAddresses(String... addresses) |
void |
addToken(String token) |
void |
addTokens(Collection<String> tokens) |
void |
addTokens(String... tokens) |
void |
checkAdministrator()
Ensures this Account is an administrator.
|
void |
checkAuthenticated()
Ensures this Account has actively authenticated.
|
void |
checkGuest()
Ensures this Account is the Guest account.
|
void |
checkPermission(String permission)
Ensures this Account implies the specified permission String.
|
void |
checkPermissions(Collection<String> permissions)
Ensures this Account
implies all of the
specified permission strings. |
void |
checkPermissions(String... permissions)
Ensures this Account
implies all of the
specified permission strings. |
void |
checkRole(String roleIdentifier)
Asserts this Account has the specified role by returning quietly if they do or throwing an
AuthorizationException if they do not. |
void |
checkRoles(Collection<String> roleIdentifiers)
Asserts this Account has all of the specified roles by returning quietly if they do or throwing an
AuthorizationException if they do not. |
void |
checkRoles(String... roleIdentifiers)
Asserts this Account has all of the specified roles by returning quietly if they do or throwing an
AuthorizationException if they do not. |
void |
checkToken(String token)
Asserts this Account has the specified token by returning quietly if they do or throwing an
AuthorizationException if they do not. |
Authorizations |
getAuthorizations() |
Credentials |
getCredentials() |
String |
getEmailAddress() |
Collection<String> |
getEmailAddresses() |
String |
getName() |
String |
getToken() |
Collection<String> |
getTokens() |
String |
getUsername() |
boolean |
hasRole(String roleIdentifier)
Returns
true if this Account has the specified role, false otherwise. |
boolean |
hasRoles(Collection<String> roleIdentifiers)
Returns
true if this Account has the specified roles, false otherwise. |
boolean |
hasRoles(String... roleIdentifiers)
Returns
true if this Account has the specified roles, false otherwise. |
boolean |
hasToken(String token)
Returns
true if this Account has the specified role, false otherwise. |
boolean |
isAdministrator()
Returns
true if this Account is an administrator. |
boolean |
isAuthenticated()
Returns
true if this Account is authenticated. |
boolean |
isDisabled()
Returns
true if this Account is disabled. |
boolean |
isEnabled()
Returns
true if this Account is enabled. |
boolean |
isGuest()
Returns
true if this Account is the GUEST account. |
boolean[] |
isPermitted(String... permissions)
Checks if this Account implies the given permission strings and returns a boolean array indicating which
permissions are implied.
|
boolean |
isPermitted(String permission)
Returns
true if this Account is permitted to perform an action or access a resource summarized by the
specified permission string. |
boolean |
isPermittedAll(Collection<String> permissions)
Returns
true if this Account implies all of the specified permission strings, false otherwise. |
boolean |
isPermittedAll(String... permissions)
Returns
true if this Account implies all of the specified permission strings, false otherwise. |
void |
setDisabled()
Disables this account.
|
void |
setEnabled()
Enables this account.
|
void |
setName(String name) |
String |
toString() |
public static final transient Account GUEST
protected final Credentials credentials
protected final Authorizations authorizations
protected String name
protected boolean isDisabled
public Account(String name, Credentials credentials)
public Account(String name, Credentials credentials, Authorizations authorizations)
public Credentials getCredentials()
public Authorizations getAuthorizations()
public String getName()
public void setName(String name)
public String getUsername()
public void addEmailAddress(String address)
public void addEmailAddresses(String... addresses)
public void addEmailAddresses(Collection<String> addresses)
public String getEmailAddress()
public Collection<String> getEmailAddresses()
public void addToken(String token)
public void addTokens(String... tokens)
public void addTokens(Collection<String> tokens)
public String getToken()
public Collection<String> getTokens()
public void setDisabled()
public void setEnabled()
public boolean isGuest()
true if this Account is the GUEST account.public boolean isAuthenticated()
true if this Account is authenticated.public boolean isAdministrator()
true if this Account is an administrator.public boolean isDisabled()
true if this Account is disabled.public boolean isEnabled()
true if this Account is enabled.public void checkGuest()
throws AuthenticationException
AuthenticationException - if the Account is not the Guest account.public void checkAuthenticated()
throws AuthenticationException
AuthenticationException - if the Account is not authenticated.public void checkAdministrator()
throws AuthenticationException
AuthenticationException - if the Account is not an administrator.public boolean isPermitted(String permission)
true if this Account is permitted to perform an action or access a resource summarized by the
specified permission string.
This is an overloaded method for the corresponding type-safe Permission variant.
Please see the class-level JavaDoc for more information on these String-based permission methods.
permission - the String representation of a Permission that is being checked.public boolean[] isPermitted(String... permissions)
This is an overloaded method for the corresponding type-safe Permission variant.
Please see the class-level JavaDoc for more information on these String-based permission methods.
permissions - the String representations of the Permissions that are being checked.Permission string in the list. A false value at an index
indicates otherwise.public boolean isPermittedAll(String... permissions)
true if this Account implies all of the specified permission strings, false otherwise.
This is an overloaded method for the corresponding type-safe Permission
variant. Please see the class-level JavaDoc for more information on these String-based permission methods.
permissions - the String representations of the Permissions that are being checked.public boolean isPermittedAll(Collection<String> permissions)
true if this Account implies all of the specified permission strings, false otherwise.
This is an overloaded method for the corresponding type-safe Permission
variant. Please see the class-level JavaDoc for more information on these String-based permission methods.
permissions - the String representations of the Permissions that are being checked.public void checkPermission(String permission) throws AuthorizationException
If this Account's existing associated permissions do not Permission.implies(fathom.authz.Permission) imply}
the given permission, an AuthorizationException will be thrown.
This is an overloaded method for the corresponding type-safe Permission variant.
Please see the class-level JavaDoc for more information on these String-based permission methods.
permission - the String representation of the Permission to check.AuthorizationException - if the user does not have the permission.public void checkPermissions(String... permissions) throws AuthorizationException
implies all of the
specified permission strings.
If this Account's existing associated permissions do not
imply all of the given permissions,
an AuthorizationException will be thrown.
This is an overloaded method for the corresponding type-safe Permission variant.
Please see the class-level JavaDoc for more information on these String-based permission methods.
permissions - the string representations of Permissions to check.AuthorizationException - if this Account does not have all of the given permissions.public void checkPermissions(Collection<String> permissions) throws AuthorizationException
implies all of the
specified permission strings.
If this Account's existing associated permissions do not
imply all of the given permissions,
an AuthorizationException will be thrown.
This is an overloaded method for the corresponding type-safe Permission variant.
Please see the class-level JavaDoc for more information on these String-based permission methods.
permissions - the string representations of Permissions to check.AuthorizationException - if this Account does not have all of the given permissions.public boolean hasRole(String roleIdentifier)
true if this Account has the specified role, false otherwise.roleIdentifier - the application-specific role identifier (usually a role id or role name).true if this Account has the specified role, false otherwise.public boolean hasRoles(String... roleIdentifiers)
true if this Account has the specified roles, false otherwise.roleIdentifiers - the application-specific role identifiers to check (usually role ids or role names).true if this Account has all the specified roles, false otherwise.public boolean hasRoles(Collection<String> roleIdentifiers)
true if this Account has the specified roles, false otherwise.roleIdentifiers - the application-specific role identifiers to check (usually role ids or role names).true if this Account has all the specified roles, false otherwise.public void checkRole(String roleIdentifier) throws AuthorizationException
AuthorizationException if they do not.roleIdentifier - the application-specific role identifier (usually a role id or role name ).AuthorizationException - if this Account does not have the role.public void checkRoles(String... roleIdentifiers) throws AuthorizationException
AuthorizationException if they do not.roleIdentifiers - roleIdentifiers the application-specific role identifiers to check (usually role ids or role names).AuthorizationException - fathom.authz.AuthorizationException
if this Account does not have all of the specified roles.public void checkRoles(Collection<String> roleIdentifiers) throws AuthorizationException
AuthorizationException if they do not.roleIdentifiers - roleIdentifiers the application-specific role identifiers to check (usually role ids or role names).AuthorizationException - fathom.authz.AuthorizationException
if this Account does not have all of the specified roles.public boolean hasToken(String token)
true if this Account has the specified role, false otherwise.token - the authentication token.true if this Account has the specified token, false otherwise.public void checkToken(String token) throws AuthorizationException
AuthorizationException if they do not.token - the authentication token.AuthorizationException - if this Account does not have the token.Copyright © 2017. All rights reserved.