public class AuthorizationService extends Object implements IAuthorizationService, Serializable
IAuthorizationService. Authorizable component has multiple Authorizations; then it will check if the User is able to satisfy any of them.IAuthorizationService.AuthState| Constructor and Description |
|---|
AuthorizationService() |
| Modifier and Type | Method and Description |
|---|---|
protected IAuthorizationService.AuthState |
eval(IAuthorizationService.AuthState currentAuthState,
Authorization reqAuth,
Authorization userAuth)
Evaluate
Authorizations to determine the final outcome as an AuthStateNote that while evaluation Role are an extension of Authorization. |
Comparator<Authorization> |
getAuthComparator() |
Collection<Authorization> |
getAuthorizationsForUser(String authorizableId,
User user)
Get the
Authorizations granted to a user. |
List<Authorization> |
getInOrderOfRestriction(Collection<Authorization> userAuthsForFeature,
boolean leastRestrictiveToMost)
When confronted with multiple Authorizations return a new List of
Authorization.Max weight, i.e. |
Authorization |
getLeastRestrictive(Collection<Authorization> userAuthsForFeature)
When confronted with multiple Authorizations return the least restrictive
Authorization |
Authorization |
getMostRestrictive(Collection<Authorization> userAuthsForFeature)
When confronted with multiple Authorizations return the most restrictive
Authorization |
RoleService |
getRoleService()
|
IAuthorizationService.AuthState |
isAuthorized(Authorization reqAuth,
Collection<Authorization> userAuthsForFeature)
featureRequiredAuth is the Minimum required Authorization from the Collection of user auths
|
IAuthorizationService.AuthState |
isAuthorized(Collection<Authorization> featureRequiredAuths,
Collection<Authorization> userAuthsForFeature)
Check if userAuthsForFeature satisfies any one of the featureRequiredAuths
|
protected boolean |
isEqual(Authorization a1,
Authorization a2)
Authorization.equals(Object) is not expected to be commutative. |
void |
setAuthComparator(Comparator<Authorization> authComparator) |
void |
setRoleService(RoleService roleService) |
protected boolean isEqual(Authorization a1, Authorization a2)
Authorization.equals(Object) is not expected to be commutative. i.e. (a1 equals a2) may not imply (a2 equals a1)
hence we must provide a equals function that ensures Two Authorizations are truly equal.
a1 - as Authorizationa2 - as Authorizationprotected IAuthorizationService.AuthState eval(IAuthorizationService.AuthState currentAuthState, Authorization reqAuth, Authorization userAuth) throws Continue
Authorizations to determine the final outcome as an AuthStateRole are an extension of Authorization.Continuepublic IAuthorizationService.AuthState isAuthorized(Collection<Authorization> featureRequiredAuths, Collection<Authorization> userAuthsForFeature)
isAuthorized in interface IAuthorizationServicefeatureRequiredAuths - as Collection of Authorization @nullable trueuserAuthsForFeature - as Collection of Authorization @nullable trueIAuthorizationService.AuthStatepublic IAuthorizationService.AuthState isAuthorized(Authorization reqAuth, Collection<Authorization> userAuthsForFeature)
isAuthorized in interface IAuthorizationServicereqAuth - @nullable trueuserAuthsForFeature - as Collection of Authorization @nullable trueIAuthorizationService.AuthStatepublic Authorization getMostRestrictive(Collection<Authorization> userAuthsForFeature)
AuthorizationgetMostRestrictive in interface IAuthorizationServiceuserAuthsForFeature - as Collection of Authorization @nullable trueAuthorization @nullable true if none foundpublic Authorization getLeastRestrictive(Collection<Authorization> userAuthsForFeature)
AuthorizationgetLeastRestrictive in interface IAuthorizationServiceuserAuthsForFeature - as Collection of Authorization @nullable trueAuthorization @nullable true if none foundpublic List<Authorization> getInOrderOfRestriction(Collection<Authorization> userAuthsForFeature, boolean leastRestrictiveToMost)
Authorization.getInOrderOfRestriction in interface IAuthorizationServiceuserAuthsForFeature - as Collection of Authorization @nullable trueleastRestrictiveToMost - as boolean. If true Least restrictive element will be first and most restrictive, the last.public Comparator<Authorization> getAuthComparator()
public void setAuthComparator(Comparator<Authorization> authComparator)
public Collection<Authorization> getAuthorizationsForUser(String authorizableId, User user)
IAuthorizationServiceAuthorizations granted to a user. If User.getRoleNames() is not empty then append them.
Authorizations are determined at runtime, while direct auths are setup from the User object directly. This implis
that if we change a Role, then those changes will impact the user @ runtime and will be dynamic.getAuthorizationsForUser in interface IAuthorizationServiceauthorizableId - as String , which can be derived from any Authorizable.getAuthorizableId(). Example(s): IModuleAware or MountModuleUI or a simple Authorizable entity.user - as UserCollection of Authorizationpublic RoleService getRoleService()
IAuthorizationServicegetRoleService in interface IAuthorizationServicepublic void setRoleService(RoleService roleService)
Copyright © 2018. All rights reserved.