Authorizer

An <tt>Authorizer</tt> performs authorization (access control) operations for any given Subject (aka 'application user').

<p>Each method requires a subject principal to perform the action for the corresponding Subject/user.

<p>This principal argument is usually an object representing a user database primary key or a string username or something similar that uniquely identifies an application user. The runtime value of the this principal is application-specific and provided by the application's configured Realms.

<p>Note that there are many *Permission methods in this interface overloaded to accept string arguments instead of {@link Permission Permission} instances. They are a convenience allowing the caller to use a string representation of a {@link Permission Permission} if desired. Most implementations of this interface will simply convert these string values to {@link Permission Permission} instances and then just call the corresponding type-safe method. (Shiro's default implementations do string-to-Permission conversion for these methods using {@link hunt.shiro.authz.permission.PermissionResolver PermissionResolver}s.)

<p>These overloaded *Permission methods <em>do</em> forego type-safety for the benefit of convenience and simplicity, so you should choose which ones to use based on your preferences and needs.

interface Authorizer {}

Members

Functions

checkPermission
void checkPermission(PrincipalCollection subjectPrincipal, string permission)

Ensures the corresponding Subject/user implies the specified permission string.

checkPermission
void checkPermission(PrincipalCollection subjectPrincipal, Permission permission)

Ensures a subject/user {@link Permission#implies(Permission)} implies} the specified <tt>Permission</tt>. If the subject's existing associated permissions do not {@link Permission#implies(Permission)} imply} the given permission, an {@link AuthorizationException} will be thrown.

checkPermissions
void checkPermissions(PrincipalCollection subjectPrincipal, string[] permissions)

Ensures the corresponding Subject/user {@link Permission#implies(Permission) implies} all of the specified permission strings.

checkPermissions
void checkPermissions(PrincipalCollection subjectPrincipal, Collection!(Permission) permissions)

Ensures the corresponding Subject/user {@link Permission#implies(Permission) implies} all of the specified permission strings.

checkRole
void checkRole(PrincipalCollection subjectPrincipal, string roleIdentifier)

Asserts the corresponding Subject/user has the specified role by returning quietly if they do or throwing an {@link AuthorizationException} if they do not.

checkRoles
void checkRoles(PrincipalCollection subjectPrincipal, Collection!(string) roleIdentifiers)

Asserts the corresponding Subject/user has all of the specified roles by returning quietly if they do or throwing an {@link AuthorizationException} if they do not.

checkRoles
void checkRoles(PrincipalCollection subjectPrincipal, string[] roleIdentifiers)

Same as {@link #checkRoles(hunt.shiro.subject.PrincipalCollection, java.util.Collection) checkRoles(PrincipalCollection subjectPrincipal, Collection&lt;string&gt; roleIdentifiers)} but doesn't require a collection as an argument. Asserts the corresponding Subject/user has all of the specified roles by returning quietly if they do or throwing an {@link AuthorizationException} if they do not.

hasAllRoles
bool hasAllRoles(PrincipalCollection subjectPrincipal, Collection!(string) roleIdentifiers)
bool hasAllRoles(PrincipalCollection subjectPrincipal, string[] roleIdentifiers)

Returns <tt>true</tt> if the corresponding Subject/user has all of the specified roles, <tt>false</tt> otherwise.

hasRole
bool hasRole(PrincipalCollection subjectPrincipal, string roleIdentifier)

Returns <tt>true</tt> if the corresponding Subject/user has the specified role, <tt>false</tt> otherwise.

hasRoles
bool[] hasRoles(PrincipalCollection subjectPrincipal, List!(string) roleIdentifiers)
bool[] hasRoles(PrincipalCollection subjectPrincipal, string[] roleIdentifiers)

Checks if the corresponding Subject/user has the specified roles, returning a bool array indicating which roles are associated with the given subject.

isPermitted
bool isPermitted(PrincipalCollection principals, string permission)

Returns <tt>true</tt> if the corresponding subject/user is permitted to perform an action or access a resource summarized by the specified permission string.

isPermitted
bool isPermitted(PrincipalCollection subjectPrincipal, Permission permission)

Returns <tt>true</tt> if the corresponding subject/user is permitted to perform an action or access a resource summarized by the specified permission.

isPermitted
bool[] isPermitted(PrincipalCollection subjectPrincipal, string[] permissions)

Checks if the corresponding Subject implies the given permission strings and returns a bool array indicating which permissions are implied.

isPermitted
bool[] isPermitted(PrincipalCollection subjectPrincipal, List!(Permission) permissions)

Checks if the corresponding Subject/user implies the given Permissions and returns a bool array indicating which permissions are implied.

isPermittedAll
bool isPermittedAll(PrincipalCollection subjectPrincipal, string[] permissions)

Returns <tt>true</tt> if the corresponding Subject/user implies all of the specified permission strings, <tt>false</tt> otherwise.

isPermittedAll
bool isPermittedAll(PrincipalCollection subjectPrincipal, Collection!(Permission) permissions)

Returns <tt>true</tt> if the corresponding Subject/user implies all of the specified permissions, <tt>false</tt> otherwise.

Meta