public final class Authorizations extends Object implements Serializable, Cloneable
Authorizations represents an Account's Roles & Permissions.
This class was adapted from Apache Shiro.
Role,
Permission,
Account,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected Collection<Permission> |
aggregatePermissions |
protected Set<Permission> |
permissions |
protected Set<Role> |
roles |
| Constructor and Description |
|---|
Authorizations() |
Authorizations(Set<Role> roles,
Set<Permission> permissions)
Creates a new instance with the specified Roles and Permissions.
|
Authorizations(Set<String> roles)
Creates a new instance with the specified roles and no permissions.
|
| Modifier and Type | Method and Description |
|---|---|
Authorizations |
addPermission(String permission)
Adds (assigns) a permission to those directly associated with the Account.
|
Authorizations |
addPermissions(Collection<Permission> permissions)
Adds (assigns) a permission to those directly associated with the Account.
|
Authorizations |
addPermissions(String... permissions)
Adds (assigns) a permission to those directly associated with the Account.
|
Authorizations |
addRole(Role role)
Adds (assigns) multiple roles to those associated with the Account.
|
Authorizations |
addRole(String role)
Adds (assigns) multiple roles to those associated with the Account.
|
Authorizations |
addRoles(Collection<Role> roles)
Adds (assigns) multiple roles to those associated with the Account.
|
Authorizations |
addRoles(String... roles)
Adds roles to the Account Authorizations.
|
Authorizations |
clone() |
Collection<Permission> |
getAggregatePermissions()
Gets the collection of permissions including the role permissions and discrete permissions.
|
Set<Permission> |
getPermissions()
Returns all type-safe
Permissions assigned to the corresponding Account. |
Set<Role> |
getRoles()
Returns the Roles assigned to the corresponding Account.
|
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. |
protected boolean |
isPermitted(Permission permission) |
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 |
setPermissions(Collection<Permission> permissions)
Sets the string-based permissions assigned directly to the Account.
|
Authorizations |
setRoles(Set<Role> roles)
Sets the roles assigned to the Account.
|
protected final Set<Permission> permissions
protected transient Collection<Permission> aggregatePermissions
public Authorizations()
public Authorizations(Set<String> roles)
roles - the roles assigned to the Account.public Authorizations(Set<Role> roles, Set<Permission> permissions)
roles - the roles assigned to the Account.permissions - the permissions assigned to the Account.public Set<Role> getRoles()
public Authorizations setRoles(Set<Role> roles)
roles - the roles assigned to the Account.public Authorizations addRoles(String... roles)
roles - the roles to add.public Authorizations addRoles(Collection<Role> roles)
roles - the roles to add to those associated with the Account.public Authorizations addRole(String role)
role - the role to add to those associated with the Account.public Authorizations addRole(Role role)
role - the role to add to those associated with the Account.public Authorizations addPermissions(String... permissions)
permissions - the permissions to add to those directly assigned to the Account.public Authorizations addPermission(String permission)
permission - the permission to add to those directly assigned to the Account.public Authorizations addPermissions(Collection<Permission> permissions)
permissions - the permissions to add to those directly assigned to the Account.public Set<Permission> getPermissions()
Permissions assigned to the corresponding Account. The permissions
returned from this method plus any returned from getPermissions()
represent the total set of permissions. The aggregate set is used to perform a permission authorization check.Permissions assigned to the corresponding Account.public void setPermissions(Collection<Permission> permissions)
object permissions constitute the total permissions assigned directly to the
Account.permissions - the string-based permissions assigned directly to the Account.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.protected boolean isPermitted(Permission permission)
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 Collection<Permission> getAggregatePermissions()
public Authorizations clone()
Copyright © 2017. All rights reserved.