org.wamblee.security.authorization.hibernate
Class PersistentAuthorizationService

java.lang.Object
  extended by org.wamblee.persistence.AbstractPersistent
      extended by org.wamblee.security.authorization.hibernate.PersistentAuthorizationService
All Implemented Interfaces:
Persistent, AuthorizationService

public class PersistentAuthorizationService
extends AbstractPersistent
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
PersistentAuthorizationService(java.lang.String aName, org.springframework.orm.hibernate3.HibernateTemplate aTemplate, UserAccessor aAccessor, 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)
          Same as AuthorizationService.isAllowed(Object, Operation) but throws a RuntimeException in case access is not allowed.
 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.
 
Methods inherited from class org.wamblee.persistence.AbstractPersistent
getPersistedVersion, getPrimaryKey, setPersistedVersion, setPrimaryKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.wamblee.persistence.Persistent
getPersistedVersion, getPrimaryKey, setPersistedVersion, setPrimaryKey
 

Constructor Detail

PersistentAuthorizationService

public PersistentAuthorizationService(java.lang.String aName,
                                      org.springframework.orm.hibernate3.HibernateTemplate aTemplate,
                                      UserAccessor aAccessor,
                                      long aRefreshInterval)
Constructs the persistent service.

Parameters:
aName - Name of the service.
aTemplate - Hibernate template for hibernate usage.
aAccessor - User accessor.
aRefresh - Whether or not to refresh the state of the service at the start of every operation.
Method Detail

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
Same as AuthorizationService.isAllowed(Object, Operation) but throws a RuntimeException in case access is not allowed.

Specified by:
check in interface AuthorizationService
Parameters:
aResource - Resource to check.
aOperation - Operation to perform.
Returns:
Resource that was checked.

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

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 © 2010. All Rights Reserved.