ModularRealmAuthorizer

A <tt>ModularRealmAuthorizer</tt> is an <tt>Authorizer</tt> implementation that consults one or more configured {@link Realm Realm}s during an authorization operation.

class ModularRealmAuthorizer : Authorizer , PermissionResolverAware , RolePermissionResolverAware {}

Constructors

this
this()

Default no-argument constructor, does nothing.

this
this(Realm[] realms)

Constructor that accepts the <code>Realm</code>s to consult during an authorization check. Immediately calls {@link #setRealms setRealms(realms)}.

Members

Functions

applyPermissionResolverToRealms
void applyPermissionResolverToRealms()

Sets the internal {@link #getPermissionResolver} on any internal configured {@link #getRealms Realms} that implement the {@link hunt.shiro.authz.permission.PermissionResolverAware PermissionResolverAware} interface. <p/> This method is called after setting a permissionResolver on this ModularRealmAuthorizer via the {@link #setPermissionResolver(hunt.shiro.authz.permission.PermissionResolver) setPermissionResolver} method. <p/> It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these newly available realms to be given the <code>PermissionResolver</code> already in use.

applyRolePermissionResolverToRealms
void applyRolePermissionResolverToRealms()

Sets the internal {@link #getRolePermissionResolver} on any internal configured {@link #getRealms Realms} that implement the {@link hunt.shiro.authz.permission.RolePermissionResolverAware RolePermissionResolverAware} interface. <p/> This method is called after setting a rolePermissionResolver on this ModularRealmAuthorizer via the {@link #setRolePermissionResolver(hunt.shiro.authz.permission.RolePermissionResolver) setRolePermissionResolver} method. <p/> It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these newly available realms to be given the <code>RolePermissionResolver</code> already in use.

assertRealmsConfigured
void assertRealmsConfigured()

Used by the {@link Authorizer Authorizer} implementation methods to ensure that the {@link #setRealms realms} has been set. The default implementation ensures the property is not null and not empty.

checkPermission
void checkPermission(PrincipalCollection principals, string permission)

If !{@link #isPermitted(hunt.shiro.subject.PrincipalCollection, string) isPermitted(permission)}, throws an <code>UnauthorizedException</code> otherwise returns quietly.

checkPermission
void checkPermission(PrincipalCollection principals, Permission permission)

If !{@link #isPermitted(hunt.shiro.subject.PrincipalCollection, Permission) isPermitted(permission)}, throws an <code>UnauthorizedException</code> otherwise returns quietly.

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

If !{@link #isPermitted(hunt.shiro.subject.PrincipalCollection, string...) isPermitted(permission)}, <code>UnauthorizedException</code> otherwise returns quietly.

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

If !{@link #isPermitted(hunt.shiro.subject.PrincipalCollection, Permission) isPermitted(permission)} for <em>all</em> the given Permissions, throws an <code>UnauthorizedException</code> otherwise returns quietly.

checkRole
void checkRole(PrincipalCollection principals, string role)

If !{@link #hasRole(hunt.shiro.subject.PrincipalCollection, string) hasRole(role)}, throws an <code>UnauthorizedException</code> otherwise returns quietly.

checkRoles
void checkRoles(PrincipalCollection principals, Collection!(string) roles)

Calls {@link #checkRoles(PrincipalCollection principals, string... roles) checkRoles(PrincipalCollection principals, string... roles) }.

checkRoles
void checkRoles(PrincipalCollection principals, string[] roles)

Calls {@link #checkRole(hunt.shiro.subject.PrincipalCollection, string) checkRole} for each role specified.

getPermissionResolver
PermissionResolver getPermissionResolver()

Returns the PermissionResolver to be used on <em>all</em> configured realms, or <code>null</code (the default) if all realm instances will each configure their own permission resolver.

getRealms
Realm[] getRealms()

Returns the realms wrapped by this <code>Authorizer</code> which are consulted during an authorization check.

getRolePermissionResolver
RolePermissionResolver getRolePermissionResolver()

Returns the RolePermissionResolver to be used on <em>all</em> configured realms, or <code>null</code (the default) if all realm instances will each configure their own permission resolver.

hasAllRoles
bool hasAllRoles(PrincipalCollection principals, Collection!(string) roleIdentifiers)

Returns <code>true</code> iff any of the configured realms' {@link #hasRole(hunt.shiro.subject.PrincipalCollection, string)} call returns <code>true</code> for <em>all</em> roles specified, <code>false</code> otherwise.

hasAllRoles
bool hasAllRoles(PrincipalCollection principals, string[] roleIdentifiers)
Undocumented in source. Be warned that the author may not have intended to support it.
hasRole
bool hasRole(PrincipalCollection principals, string roleIdentifier)

Returns <code>true</code> if any of the configured realms' {@link #hasRole(hunt.shiro.subject.PrincipalCollection, string)} call returns <code>true</code>, <code>false</code> otherwise.

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

Calls {@link #hasRole(hunt.shiro.subject.PrincipalCollection, string)} for each role name in the specified collection and places the return value from each call at the respective location in the returned array.

isPermitted
bool isPermitted(PrincipalCollection principals, string permission)

Returns <code>true</code> if any of the configured realms' {@link #isPermitted(hunt.shiro.subject.PrincipalCollection, string)} returns <code>true</code>, <code>false</code> otherwise.

isPermitted
bool isPermitted(PrincipalCollection principals, Permission permission)

Returns <code>true</code> if any of the configured realms' {@link #isPermitted(hunt.shiro.subject.PrincipalCollection, Permission)} call returns <code>true</code>, <code>false</code> otherwise.

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

Returns <code>true</code> if any of the configured realms' {@link #isPermittedAll(hunt.shiro.subject.PrincipalCollection, string...)} call returns <code>true</code>, <code>false</code> otherwise.

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

Returns <code>true</code> if any of the configured realms' {@link #isPermitted(hunt.shiro.subject.PrincipalCollection, List)} call returns <code>true</code>, <code>false</code> otherwise.

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

Returns <code>true</code> if any of the configured realms' {@link #isPermitted(hunt.shiro.subject.PrincipalCollection, string)} call returns <code>true</code> for <em>all</em> of the specified string permissions, <code>false</code> otherwise.

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

Returns <code>true</code> if any of the configured realms' {@link #isPermitted(hunt.shiro.subject.PrincipalCollection, Permission)} call returns <code>true</code> for <em>all</em> of the specified Permissions, <code>false</code> otherwise.

setPermissionResolver
void setPermissionResolver(PermissionResolver permissionResolver)

Sets the specified {@link PermissionResolver PermissionResolver} on <em>all</em> of the wrapped realms that implement the {@link hunt.shiro.authz.permission.PermissionResolverAware PermissionResolverAware} interface. <p/> Only call this method if you want the permission resolver to be passed to all realms that implement the <code>PermissionResolver</code> interface. If you do not want this to occur, the realms must configure themselves individually (or be configured individually).

setRealms
void setRealms(Realm[] realms)

Sets the realms wrapped by this <code>Authorizer</code> which are consulted during an authorization check.

setRolePermissionResolver
void setRolePermissionResolver(RolePermissionResolver rolePermissionResolver)

Sets the specified {@link RolePermissionResolver RolePermissionResolver} on <em>all</em> of the wrapped realms that implement the {@link hunt.shiro.authz.permission.RolePermissionResolverAware PermissionResolverAware} interface. <p/> Only call this method if you want the permission resolver to be passed to all realms that implement the <code>RolePermissionResolver</code> interface. If you do not want this to occur, the realms must configure themselves individually (or be configured individually).

Variables

permissionResolver
PermissionResolver permissionResolver;

A PermissionResolver to be used by <em>all</em> configured realms. Leave <code>null</code> if you wish to configure different resolvers for different realms.

realms
Realm[] realms;

The realms to consult during any authorization check.

rolePermissionResolver
RolePermissionResolver rolePermissionResolver;

A RolePermissionResolver to be used by <em>all</em> configured realms. Leave <code>null</code> if you wish to configure different resolvers for different realms.

Inherited Members

From Authorizer

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.

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.

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.

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.

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.

From PermissionResolverAware

setPermissionResolver
void setPermissionResolver(PermissionResolver pr)

Sets the specified <tt>PermissionResolver</tt> on this instance.

From RolePermissionResolverAware

setRolePermissionResolver
void setRolePermissionResolver(RolePermissionResolver rpr)

Sets the specified <tt>RolePermissionResolver</tt> on this instance.

Meta