public class JpaAuthorizationService extends Object implements AuthorizationService
DefaultAuthorizationService
which
refreshes the state of the service at certain time intervals.Constructor and Description |
---|
JpaAuthorizationService(String aName,
javax.persistence.EntityManager aEntityManager,
UserAccessor aAccessor,
UserAdministration aUserAdmin,
long aRefreshInterval)
Constructs the persistent service.
|
Modifier and Type | Method and Description |
---|---|
void |
appendRule(AuthorizationRule aRule)
Appends a new authorization rule to the end.
|
<T> T |
check(T aResource,
Operation aOperation)
Checks if the given operation is allowed on the resource.
|
AuthorizationRule[] |
getRules()
Gets the authorization rules.
|
void |
insertRuleAfter(int aIndex,
AuthorizationRule aRule)
Inserts a rule.
|
boolean |
isAllowed(Object aResource,
Operation aOperation)
Checks whether an operation is allowed on a resource.
|
void |
removeRule(int aIndex)
Removes a rule.
|
void |
setUserAccessor(UserAccessor aUserAccessor)
Sets the user accessor so that the authorization service can get access
to the logged in user.
|
void |
setUserAdministration(UserAdministration aUserAdmin)
Sets the user administration so that the authorization service can check
information for the the current user.
|
public JpaAuthorizationService(String aName, javax.persistence.EntityManager aEntityManager, UserAccessor aAccessor, UserAdministration aUserAdmin, long aRefreshInterval)
aName
- Name of the service.aEntityManager
- Entity manager.aAccessor
- User accessor.aUserAdmin
- User administration.aRefresh
- Whether or not to refresh the state of the service at the
start of every operation.public void setUserAccessor(UserAccessor aUserAccessor)
AuthorizationService
setUserAccessor
in interface AuthorizationService
aUserAccessor
- User accessor.public void setUserAdministration(UserAdministration aUserAdmin)
AuthorizationService
setUserAdministration
in interface AuthorizationService
aUserAdmin
- User administration.public boolean isAllowed(Object aResource, Operation aOperation)
AuthorizationService
isAllowed
in interface AuthorizationService
aResource
- Resource.aOperation
- Operation.public <T> T check(T aResource, Operation aOperation)
AuthorizationService
check
in interface AuthorizationService
T
- Type of resourceaResource
- Resource.aOperation
- Operation.public AuthorizationRule[] getRules()
AuthorizationService
getRules
in interface AuthorizationService
public void appendRule(AuthorizationRule aRule)
AuthorizationService
appendRule
in interface AuthorizationService
aRule
- Rule to append.public void removeRule(int aIndex)
AuthorizationService
removeRule
in interface AuthorizationService
aIndex
- Index of the rule to remove.public void insertRuleAfter(int aIndex, AuthorizationRule aRule)
AuthorizationService
insertRuleAfter
in interface AuthorizationService
aIndex
- Index of the position of the rule after insertion.aRule
- Rule to insert.Copyright © 2022. All rights reserved.