org.wamblee.security.authorization.jpa
Class JpaAuthorizationService

java.lang.Object
  extended by org.wamblee.security.authorization.jpa.JpaAuthorizationService
All Implemented Interfaces:
AuthorizationService

public class JpaAuthorizationService
extends java.lang.Object
implements AuthorizationService

Authorization service with persistent storage. This is a wrapper for DefaultAuthorizationService which refreshes the state of the service at certain time intervals.

Author:
Erik Brakkee

Constructor Summary
JpaAuthorizationService(java.lang.String aName, javax.persistence.EntityManager aEntityManager, UserAccessor aAccessor, UserAdministration aUserAdmin, long aRefreshInterval)
          Constructs the persistent service.
 
Method Summary
 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(java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpaAuthorizationService

public JpaAuthorizationService(java.lang.String aName,
                               javax.persistence.EntityManager aEntityManager,
                               UserAccessor aAccessor,
                               UserAdministration aUserAdmin,
                               long aRefreshInterval)
Constructs the persistent service.

Parameters:
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.
Method Detail

setUserAccessor

public void setUserAccessor(UserAccessor aUserAccessor)
Description copied from interface: AuthorizationService
Sets the user accessor so that the authorization service can get access to the logged in user.

Specified by:
setUserAccessor in interface AuthorizationService
Parameters:
aUserAccessor - User accessor.

setUserAdministration

public void setUserAdministration(UserAdministration aUserAdmin)
Description copied from interface: AuthorizationService
Sets the user administration so that the authorization service can check information for the the current user.

Specified by:
setUserAdministration in interface AuthorizationService
Parameters:
aUserAdmin - User administration.

isAllowed

public boolean isAllowed(java.lang.Object aResource,
                         Operation aOperation)
Description copied from interface: AuthorizationService
Checks whether an operation is allowed on a resource.

Specified by:
isAllowed in interface AuthorizationService
Parameters:
aResource - Resource.
aOperation - Operation.
Returns:
Checks whether the operation is allowed on a resource.

check

public <T> T check(T aResource,
                   Operation aOperation)
Description copied from interface: AuthorizationService
Checks if the given operation is allowed on the resource.

Specified by:
check in interface AuthorizationService
Type Parameters:
T - Type of resource
Parameters:
aResource - Resource.
aOperation - Operation.
Returns:
Resource passed in in case access is allowed

getRules

public AuthorizationRule[] getRules()
Description copied from interface: AuthorizationService
Gets the authorization rules.

Specified by:
getRules in interface AuthorizationService
Returns:
Rules.

appendRule

public void appendRule(AuthorizationRule aRule)
Description copied from interface: AuthorizationService
Appends a new authorization rule to the end.

Specified by:
appendRule in interface AuthorizationService
Parameters:
aRule - Rule to append.

removeRule

public void removeRule(int aIndex)
Description copied from interface: AuthorizationService
Removes a rule.

Specified by:
removeRule in interface AuthorizationService
Parameters:
aIndex - Index of the rule to remove.

insertRuleAfter

public void insertRuleAfter(int aIndex,
                            AuthorizationRule aRule)
Description copied from interface: AuthorizationService
Inserts a rule.

Specified by:
insertRuleAfter in interface AuthorizationService
Parameters:
aIndex - Index of the position of the rule after insertion.
aRule - Rule to insert.


Copyright © 2022. All Rights Reserved.