org.apache.jackrabbit.core.security.principal
Class AbstractPrincipalProvider

java.lang.Object
  extended by org.apache.jackrabbit.core.security.principal.AbstractPrincipalProvider
All Implemented Interfaces:
PrincipalProvider
Direct Known Subclasses:
DefaultPrincipalProvider

public abstract class AbstractPrincipalProvider
extends Object
implements PrincipalProvider

A base class of a principal provider implementing common tasks and a caching facility. Extending classes should only deal with the retrieval of Principals from their source, the caching of the principials is done by this implementation.

The PrincipalProvider mehtods that that involve searching like PrincipalProvider.getGroupMembership(Principal) are not cached.


Field Summary
static String MAXSIZE_KEY
          Option name for the max size of the cache to use
static String NEGATIVE_ENTRY_KEY
          Option name to enable negative cache entries (see JCR-2672)
 
Constructor Summary
protected AbstractPrincipalProvider()
          Create a new instance of AbstractPrincipalProvider.
 
Method Summary
protected  void addToCache(Principal principal)
          Add an entry to the principal cache.
protected  void checkInitialized()
          Check if the instance has been closed close().
protected  void clearCache()
          Clear the principal cache.
 void close()
          Clears the cache and calls the implementation to close their resources
 Principal getPrincipal(String principalName)
          Returns the principal with the given name if is known to this provider
 void init(Properties options)
          Initialize this provider.
protected abstract  Principal providePrincipal(String principalName)
          Called if the cache does not contain the principal requested.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jackrabbit.core.security.principal.PrincipalProvider
canReadPrincipal, findPrincipals, findPrincipals, getGroupMembership, getPrincipals
 

Field Detail

MAXSIZE_KEY

public static final String MAXSIZE_KEY
Option name for the max size of the cache to use

See Also:
Constant Field Values

NEGATIVE_ENTRY_KEY

public static final String NEGATIVE_ENTRY_KEY
Option name to enable negative cache entries (see JCR-2672)

See Also:
Constant Field Values
Constructor Detail

AbstractPrincipalProvider

protected AbstractPrincipalProvider()
Create a new instance of AbstractPrincipalProvider. Initialization and cache are set up upon init(Properties)

Method Detail

checkInitialized

protected void checkInitialized()
Check if the instance has been closed close().

Throws:
IllegalStateException - if this instance was closed.

clearCache

protected void clearCache()
Clear the principal cache.


addToCache

protected void addToCache(Principal principal)
Add an entry to the principal cache.

Parameters:
principal - to be cached.

providePrincipal

protected abstract Principal providePrincipal(String principalName)
Called if the cache does not contain the principal requested.
Implementations should return a Principal from their source, if it contains one for the given name or null.

Parameters:
principalName - Name of the principal to be returned.
Returns:
Principal or null, if non provided for the given name
See Also:
getPrincipal(String)

getPrincipal

public Principal getPrincipal(String principalName)
Returns the principal with the given name if is known to this provider providePrincipal(String) is called, if no matching entry is present in the cache.
NOTE: If the cache is enabled to contain negative entries (see NEGATIVE_ENTRY_KEY configuration option), the cache will also store negative matches (as null values) in the principal cache.

Specified by:
getPrincipal in interface PrincipalProvider
Parameters:
principalName - the name of the principal to retrieve
Returns:
return the requested principal or null

init

public void init(Properties options)
Description copied from interface: PrincipalProvider
Initialize this provider.

Specified by:
init in interface PrincipalProvider
Parameters:
options - the options that are set
See Also:
PrincipalProvider.init(java.util.Properties)

close

public void close()
Clears the cache and calls the implementation to close their resources

Specified by:
close in interface PrincipalProvider
See Also:
PrincipalProvider.close()


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.