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
Authorization s to determine the final outcome as an AuthState Note that while evaluation Role are an extension of Authorization . |
Comparator<Authorization> |
getAuthComparator() |
Collection<Authorization> |
getAuthorizationsForUser(String authorizableId,
User user)
Get the
Authorization s 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 Authorization
s are truly equal.
a1
- as Authorization
a2
- as Authorization
protected IAuthorizationService.AuthState eval(IAuthorizationService.AuthState currentAuthState, Authorization reqAuth, Authorization userAuth) throws Continue
Authorization
s to determine the final outcome as an AuthState
Role
are an extension of Authorization
.Continue
public IAuthorizationService.AuthState isAuthorized(Collection<Authorization> featureRequiredAuths, Collection<Authorization> userAuthsForFeature)
isAuthorized
in interface IAuthorizationService
featureRequiredAuths
- as Collection of Authorization
@nullable trueuserAuthsForFeature
- as Collection of Authorization
@nullable trueIAuthorizationService.AuthState
public IAuthorizationService.AuthState isAuthorized(Authorization reqAuth, Collection<Authorization> userAuthsForFeature)
isAuthorized
in interface IAuthorizationService
reqAuth
- @nullable trueuserAuthsForFeature
- as Collection of Authorization
@nullable trueIAuthorizationService.AuthState
public Authorization getMostRestrictive(Collection<Authorization> userAuthsForFeature)
Authorization
getMostRestrictive
in interface IAuthorizationService
userAuthsForFeature
- as Collection
of Authorization
@nullable trueAuthorization
@nullable true if none foundpublic Authorization getLeastRestrictive(Collection<Authorization> userAuthsForFeature)
Authorization
getLeastRestrictive
in interface IAuthorizationService
userAuthsForFeature
- as Collection
of Authorization
@nullable trueAuthorization
@nullable true if none foundpublic List<Authorization> getInOrderOfRestriction(Collection<Authorization> userAuthsForFeature, boolean leastRestrictiveToMost)
Authorization
.getInOrderOfRestriction
in interface IAuthorizationService
userAuthsForFeature
- 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)
IAuthorizationService
Authorization
s granted to a user. If User.getRoleNames()
is not empty then append them.
Authorization
s 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 IAuthorizationService
authorizableId
- as String , which can be derived from any Authorizable.getAuthorizableId()
. Example(s): IModuleAware
or MountModuleUI
or a simple Authorizable
entity.user
- as User
Collection
of Authorization
public RoleService getRoleService()
IAuthorizationService
getRoleService
in interface IAuthorizationService
public void setRoleService(RoleService roleService)
Copyright © 2018. All rights reserved.