com.metamatrix.platform.security.authorization.cache
Class AuthorizationCache

java.lang.Object
  extended by com.metamatrix.platform.security.authorization.cache.AuthorizationCache

public class AuthorizationCache
extends java.lang.Object

This class represents a local cache of access information, decreasing the time required to determine a particular user's access privileges for specific resources by maximizing the in-memory access and minimizing the calls to the service provider's persistent store.


Constructor Summary
AuthorizationCache(Cache policyCache, Cache principalCache, java.util.Properties env)
          Construct with cache properties.
 
Method Summary
 void cachePoliciesWithIDs(java.util.Collection policies)
          Cache the policies that have the specified IDs.
 void cachePolicyIDsForPrincipal(MetaMatrixPrincipalName userName, SessionToken session, java.util.Collection policyIDs)
          Load the principal and the policyIDs that apply to him.
 void cachePolicyWithID(AuthorizationPolicy policy)
          Cache the policy with the specified ID.
 void clearCaches()
          Clear both Authorization caches (principal cache and policy cache).
 void clearPoliciesFromCache()
          Remove from the cache all policies.
 void clearPrincipalsFromCache()
          Remove from the cache all accounts and the policyIDs they reference.
 java.util.Collection findPolicies(java.util.Collection policyIDs)
          Find the policies with the given IDs.
 AuthorizationPolicy findPolicy(AuthorizationPolicyID policyID)
          Find the policy with the given ID.
 java.util.Collection findPolicyIDs(MetaMatrixPrincipalName user, SessionToken session)
          Find the policyIDs associated with the given principal.
 java.util.Collection getPolicyIDsNotCached(java.util.Collection policyIDs)
          Get the collection of policy IDs that are part of this collection but are not found in the cache.
 int policyCacheSize()
          Return the size of the policy cache.
 int principalCacheSize()
          Return the size of the Principal cache.
 void removePolicyFromCache(AuthorizationPolicyID policyID)
          Remove from the cache the policy with the specified ID.
 void removePolicysFromCache(java.util.Collection policyIDs)
          Remove from the cache the policies with the specified IDs.
 void removePrincipalFromCache(MetaMatrixPrincipalName user)
          Remove from the cache any policy IDs referenced by the specified principal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthorizationCache

public AuthorizationCache(Cache policyCache,
                          Cache principalCache,
                          java.util.Properties env)
Construct with cache properties.

Parameters:
policyCacheName - The name that will be assigned to the policy cache for this Authorization service instance.
principalCacheName - The name that will be assigned to the principal cache for this Authorization service instance.
env - The cache properties - may be null.
Throws:
ObjectCacheException - if cache properties are incorrect.
Method Detail

findPolicy

public AuthorizationPolicy findPolicy(AuthorizationPolicyID policyID)
Find the policy with the given ID.

Parameters:
policyID - The ID of the policy looking for.
Returns:
The policy or null if none with given ID has been cached.

findPolicies

public java.util.Collection findPolicies(java.util.Collection policyIDs)
Find the policies with the given IDs.

Parameters:
policyIDs - The collection of poilicyIDs for the policies looking for.
Returns:
The collection of policies with the given IDs or an empty collection - never null.

findPolicyIDs

public java.util.Collection findPolicyIDs(MetaMatrixPrincipalName user,
                                          SessionToken session)
Find the policyIDs associated with the given principal.

Parameters:
userName - The user name of the principal.
Returns:
The collection of PolicyIDs associated with given principal or an empty collection - never null.

removePrincipalFromCache

public void removePrincipalFromCache(MetaMatrixPrincipalName user)
Remove from the cache any policy IDs referenced by the specified principal. This method does not remove from the cache any of the referenced policy objects.

Parameters:
userName - The user name of the principal.

clearPrincipalsFromCache

public void clearPrincipalsFromCache()
Remove from the cache all accounts and the policyIDs they reference. This method does not remove from the cache any of the referenced policy objects.


principalCacheSize

public int principalCacheSize()
Return the size of the Principal cache.

Returns:
the size of the Principal cache.

removePolicyFromCache

public void removePolicyFromCache(AuthorizationPolicyID policyID)
Remove from the cache the policy with the specified ID. This method does not remove from the cache any accounts that reference this policy.

Parameters:
policyID - the ID of the policy

removePolicysFromCache

public void removePolicysFromCache(java.util.Collection policyIDs)
Remove from the cache the policies with the specified IDs. This method does not remove from the cache any accounts that reference this policy.

Parameters:
policyID - the ID of the policy

clearPoliciesFromCache

public void clearPoliciesFromCache()
Remove from the cache all policies. This method does not remove from the cache any accounts that reference this policy.


policyCacheSize

public int policyCacheSize()
Return the size of the policy cache.

Returns:
the size of the policy cache.

getPolicyIDsNotCached

public java.util.Collection getPolicyIDsNotCached(java.util.Collection policyIDs)
Get the collection of policy IDs that are part of this collection but are not found in the cache.

Parameters:
sessionToken - The session token of the principal.
Returns:
The collection of PolicyIDs that are a subset of given policy ID collection but are not cached.

clearCaches

public void clearCaches()
Clear both Authorization caches (principal cache and policy cache).
Use this method when an AuthorizationPolicy has been modified, which should be infrequent in a stable system.

Since the authorization cache is distributed, a clear event will be broadcast to all AuthorizationCaches in the system.


cachePolicyIDsForPrincipal

public void cachePolicyIDsForPrincipal(MetaMatrixPrincipalName userName,
                                       SessionToken session,
                                       java.util.Collection policyIDs)
Load the principal and the policyIDs that apply to him.

Note: Any policyIDs for this user that were previously in the cache are not removed - the new policyIDs are added to them.

Parameters:
userName - the user name principal for which the applicable policyIDs are to be loaded.

cachePoliciesWithIDs

public void cachePoliciesWithIDs(java.util.Collection policies)
Cache the policies that have the specified IDs. Callers should ensure that all policies given are not already cached.

Parameters:
policies - The policies that are to be loaded.

cachePolicyWithID

public void cachePolicyWithID(AuthorizationPolicy policy)
Cache the policy with the specified ID. If the policy is already cached, it is not reloaded.

Parameters:
policyIDs - The IDs of the policies that are to be loaded.


Copyright © 2009. All Rights Reserved.