SimpleAccount

Simple implementation of the {@link hunt.shiro.authc.Account} interface that contains principal and credential and authorization information (roles and permissions) as instance variables and exposes them via getters and setters using standard JavaBean notation.

class SimpleAccount : Account , MergableAuthenticationInfo , SaltedAuthenticationInfo {}

Constructors

this
this()

Default no-argument constructor.

this
this(Object principal, Object credentials, string realmName)

Constructs a SimpleAccount instance for the specified realm with the given principals and credentials.

this
this(Object principal, Object hashedCredentials, ByteSource credentialsSalt, string realmName)

Constructs a SimpleAccount instance for the specified realm with the given principals, hashedCredentials and credentials salt used when hashing the credentials.

this
this(Collection!Object principals, Object credentials, string realmName)

Constructs a SimpleAccount instance for the specified realm with the given principals and credentials.

this
this(PrincipalCollection principals, Object credentials)

Constructs a SimpleAccount instance for the specified principals and credentials.

this
this(PrincipalCollection principals, Object hashedCredentials, ByteSource credentialsSalt)

Constructs a SimpleAccount instance for the specified principals and credentials.

this
this(PrincipalCollection principals, Object credentials, Set!(string) roles)

Constructs a SimpleAccount instance for the specified principals and credentials, with the assigned roles.

this
this(Object principal, Object credentials, string realmName, Set!(string) roleNames, Set!(Permission) permissions)

Constructs a SimpleAccount instance for the specified realm with the given principal and credentials, with the the assigned roles and permissions.

this
this(Collection!Object principals, Object credentials, string realmName, Set!(string) roleNames, Set!(Permission) permissions)

Constructs a SimpleAccount instance for the specified realm with the given principals and credentials, with the the assigned roles and permissions.

this
this(PrincipalCollection principals, Object credentials, Set!(string) roleNames, Set!(Permission) permissions)

Constructs a SimpleAccount instance from the given principals and credentials, with the the assigned roles and permissions.

Members

Functions

addObjectPermission
void addObjectPermission(Permission permission)

Assigns an object-based permission directly to this Account (not any of its realms).

addObjectPermissions
void addObjectPermissions(Collection!(Permission) permissions)

Assigns one or more object-based permissions directly to this Account (not any of its realms).

addRole
void addRole(string role)

Adds a role to this Account's set of assigned roles. Simply delegates to <code>this.authzInfo.addRole(role)</code>.

addRole
void addRole(Collection!(string) roles)

Adds one or more roles to this Account's set of assigned roles. Simply delegates to <code>this.authzInfo.addRoles(roles)</code>.

addStringPermission
void addStringPermission(string permission)

Assigns a string-based permission directly to this Account (not to any of its realms).

addStringPermissions
void addStringPermissions(Collection!(string) permissions)

Assigns one or more string-based permissions directly to this Account (not to any of its realms).

getCredentials
Object getCredentials()

Simply returns <code>this.authcInfo.getCredentials</code>. The <code>authcInfo</code> attribute is constructed via the constructors to wrap the input arguments.

getCredentialsSalt
ByteSource getCredentialsSalt()

Returns the salt used to hash this Account's credentials (eg for password hashing), or {@code null} if no salt was used or credentials were not hashed at all.

getObjectPermissions
Collection!(Permission) getObjectPermissions()

Returns all object-based permissions assigned directly to this Account (not any of its realms).

getPrincipals
PrincipalCollection getPrincipals()

Returns the principals, aka the identifying attributes (username, user id, first name, last name, etc) of this Account.

getRoles
Collection!(string) getRoles()

Returns <code>this.authzInfo.getRoles();</code>

getStringPermissions
Collection!(string) getStringPermissions()

Returns all string-based permissions assigned to this Account. Simply delegates to <code>this.authzInfo.getStringPermissions()</code>.

isCredentialsExpired
bool isCredentialsExpired()

Returns whether or not the Account's credentials are expired. This usually indicates that the Subject or an application administrator would need to change the credentials before the account could be used.

isLocked
bool isLocked()

Returns <code>true</code> if this Account is locked and thus cannot be used to login, <code>false</code> otherwise.

merge
void merge(AuthenticationInfo info)

Merges the specified <code>AuthenticationInfo</code> into this <code>Account</code>. <p/> If the specified argument is also an instance of {@link SimpleAccount SimpleAccount}, the {@link #isLocked()} and {@link #isCredentialsExpired()} attributes are merged (set on this instance) as well (only if their values are <code>true</code>).

opEquals
bool opEquals(Object o)

Returns <code>true</code> if the specified object is also a {@link SimpleAccount SimpleAccount} and its {@link #getPrincipals() principals} are equal to this object's <code>principals</code>, <code>false</code> otherwise.

setCredentials
void setCredentials(Object credentials)

Sets this Account's credentials that verify one or more of the Account's {@link #getPrincipals() principals}, such as a password or private key.

setCredentialsExpired
void setCredentialsExpired(bool credentialsExpired)

Sets whether or not the Account's credentials are expired. A <code>true</code> value indicates that the Subject or application administrator would need to change their credentials before the account could be used.

setCredentialsSalt
void setCredentialsSalt(ByteSource salt)

Sets the salt to use to hash this Account's credentials (eg for password hashing), or {@code null} if no salt is used or credentials are not hashed at all.

setLocked
void setLocked(bool locked)

Sets whether or not the account is locked and can be used to login.

setObjectPermissions
void setObjectPermissions(Set!(Permission) permissions)

Sets all object-based permissions assigned directly to this Account (not any of its realms).

setPrincipals
void setPrincipals(PrincipalCollection principals)

Sets the principals, aka the identifying attributes (username, user id, first name, last name, etc) of this Account.

setRoles
void setRoles(Set!(string) roles)

Sets the Account's assigned roles. Simply calls <code>this.authzInfo.setRoles(roles)</code>.

setStringPermissions
void setStringPermissions(Set!(string) permissions)

Sets the string-based permissions assigned to this Account. Simply delegates to <code>this.authzInfo.setStringPermissions(permissions)</code>.

toHash
size_t toHash()

If the {@link #getPrincipals() principals} are not null, returns <code>principals.hashCode()</code>, otherwise returns 0 (zero).

toString
string toString()

Returns {@link #getPrincipals() principals}.toString() if they are not null, otherwise prints out the string &quot;empty&quot;

Inherited Members

From MergableAuthenticationInfo

merge
void merge(AuthenticationInfo info)

Merges the given {@link AuthenticationInfo} into this instance. The specific way that the merge occurs is up to the implementation, but typically it involves combining the principals and credentials together in this instance. The <code>info</code> argument should not be modified in any way.

From SaltedAuthenticationInfo

getCredentialsSalt
ByteSource getCredentialsSalt()

Returns the salt used to salt the account's credentials or {@code null} if no salt was used.

Meta