org.openpermis.subject.assignment
Class CachingRoleAssignmentController<T extends RoleAssignmentContext>

java.lang.Object
  extended by org.openpermis.subject.assignment.RoleAssignmentController<T>
      extended by org.openpermis.subject.assignment.CachingRoleAssignmentController<T>
Type Parameters:
T - the role assignment context.
All Implemented Interfaces:
SubjectIdentityNormalizer
Direct Known Subclasses:
FileController, LdapController, UrlController

public abstract class CachingRoleAssignmentController<T extends RoleAssignmentContext>
extends RoleAssignmentController<T>

Controller that cache role assignments and handles encoding and decoding.

Since:
0.9.0

Constructor Summary
CachingRoleAssignmentController(Decoder<T> decoder)
          Creates a controller which use decoder for decoding role assignments.
CachingRoleAssignmentController(Decoder<T> decoder, Encoder encoder)
          Creates a controller which use decoder for decoding and encoder for encoding role assignments.
 
Method Summary
protected  T createContext(URI identity, URI issuer, Set<RoleDefinition> roles, Date validFrom, Date validTo)
          Creates a context for a role assignment.
protected abstract  T creatingNewContext(URI identity, URI issuer, Set<RoleDefinition> roles, Date validFrom, Date validTo)
          Creates a context for a role assignment.
protected abstract  List<T> getContexts()
          Returns all contexts of this controller.
 RoleAssignment<T> issue(URI identity, URI issuer, Set<RoleDefinition> roles, Date validFrom, Date validTo)
          Issues a new role assignment.
 List<RoleAssignment<T>> list(URI identity)
          Searches the local cache for role assignments for holder with identity.
 URI normalize(URI identity)
          Normalize the specified identity.
protected abstract  byte[] readFromContext(T context)
          Reads the content of a context.
 void refresh()
          Refreshes the the cache.
 void revoke(RoleAssignment<T> roleAssignment)
          Revokes a role assignment.
protected abstract  void revokingAssignment(RoleAssignment<T> roleAssignment)
          Revoking the specified role assignment.
protected abstract  void writeToContext(T context, byte[] content)
          Writes the a byte array into a context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingRoleAssignmentController

public CachingRoleAssignmentController(Decoder<T> decoder)
Creates a controller which use decoder for decoding role assignments.

Notes:
Controller without encoder throws a UnsupportedOperationException if method RoleAssignmentController.issue(URI, URI, Set, Date, Date) is called.
Parameters:
decoder - used to decode role assignments.
Since:
0.9.0

CachingRoleAssignmentController

public CachingRoleAssignmentController(Decoder<T> decoder,
                                       Encoder encoder)
Creates a controller which use decoder for decoding and encoder for encoding role assignments.

Parameters:
decoder - used to decode role assignments.
encoder - used to encode role assignments.
Since:
0.9.0
Method Detail

getContexts

protected abstract List<T> getContexts()
Returns all contexts of this controller.

Returns:
all contexts of this controller.
Since:
0.9.0

readFromContext

protected abstract byte[] readFromContext(T context)
                                   throws RoleAssignmentControllerException
Reads the content of a context.

Parameters:
context - the context whose content is returned.
Returns:
the content of the context.
Throws:
RoleAssignmentControllerException - signals that the assignment failed.
Since:
0.9.0

writeToContext

protected abstract void writeToContext(T context,
                                       byte[] content)
                                throws RoleAssignmentControllerException
Writes the a byte array into a context.

Parameters:
context - the context in which the byte array is written.
content - the byte array that gets written into the context.
Throws:
RoleAssignmentControllerException - signals that the assignment failed.
Since:
0.9.0

creatingNewContext

protected abstract T creatingNewContext(URI identity,
                                        URI issuer,
                                        Set<RoleDefinition> roles,
                                        Date validFrom,
                                        Date validTo)
                                                               throws RoleAssignmentControllerException
Creates a context for a role assignment.

Notes:
Delegates method RoleAssignmentController.createContext(URI, URI, Set, Date, Date).
Parameters:
identity - holder of the role assignment.
issuer - the issuer of the role assignment.
roles - roles of the role assignment,
validFrom - the validity start of the role assignment.
validTo - the validity end of the role assignment.
Returns:
the context for the role assignment.
Throws:
RoleAssignmentControllerException - signals that the assignment failed.
Since:
0.9.0

revokingAssignment

protected abstract void revokingAssignment(RoleAssignment<T> roleAssignment)
                                    throws RoleAssignmentControllerException
Revoking the specified role assignment.

Parameters:
roleAssignment - the role assignment to revoke.
Throws:
RoleAssignmentControllerException - signals that the specified role assignment could not be revoked.
Since:
0.9.0

refresh

public void refresh()
Refreshes the the cache.

Since:
0.9.0

issue

public RoleAssignment<T> issue(URI identity,
                               URI issuer,
                               Set<RoleDefinition> roles,
                               Date validFrom,
                               Date validTo)
                                                      throws RoleAssignmentControllerException
Description copied from class: RoleAssignmentController
Issues a new role assignment.

Overrides:
issue in class RoleAssignmentController<T extends RoleAssignmentContext>
Parameters:
identity - holder of the role assignment.
issuer - the issuer of the role assignment.
roles - roles of the role assignment,
validFrom - validity start of the role assignment.
validTo - validity end of the role assignment.
Returns:
the role assignment.
Throws:
RoleAssignmentControllerException - signals that the assignment failed.
Since:
0.9.0

revoke

public final void revoke(RoleAssignment<T> roleAssignment)
                  throws RoleAssignmentControllerException
Description copied from class: RoleAssignmentController
Revokes a role assignment.

Specified by:
revoke in class RoleAssignmentController<T extends RoleAssignmentContext>
Parameters:
roleAssignment - the role assignment to revoke.
Throws:
RoleAssignmentControllerException - signals that the revocation failed.
Since:
0.9.0

list

public final List<RoleAssignment<T>> list(URI identity)
Searches the local cache for role assignments for holder with identity.

Specified by:
list in class RoleAssignmentController<T extends RoleAssignmentContext>
Parameters:
identity - an URI that specifies the holder of role assignments.
Returns:
list of role assignments that are held by identity.
Since:
0.9.0

createContext

protected final T createContext(URI identity,
                                URI issuer,
                                Set<RoleDefinition> roles,
                                Date validFrom,
                                Date validTo)
                                                       throws RoleAssignmentControllerException
Description copied from class: RoleAssignmentController
Creates a context for a role assignment.

Specified by:
createContext in class RoleAssignmentController<T extends RoleAssignmentContext>
Parameters:
identity - holder of the role assignment.
issuer - the issuer of the role assignment.
roles - roles of the role assignment,
validFrom - validity start of the role assignment.
validTo - validity end of the role assignment.
Returns:
the context for the role assignment.
Throws:
RoleAssignmentControllerException - signals that the assignment failed.
Since:
0.9.0

normalize

public URI normalize(URI identity)
Description copied from interface: SubjectIdentityNormalizer
Normalize the specified identity.

In case that identity is null or could not be normalized, identity is returned.

Parameters:
identity - to normalize.
Returns:
the normalized identity.
Since:
0.9.0


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:16:59
Copyright (c) 2002-2007 Ergon Informatik AG