Class AbstractPrincipalProvider
- java.lang.Object
-
- 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 ofPrincipals from their source, the caching of the principals is done by this implementation.The
PrincipalProvidermethods that that involve searching likePrincipalProvider.getGroupMembership(Principal)are not cached.
-
-
Field Summary
Fields Modifier and Type Field Description static StringMAXSIZE_KEYOption name for the max size of the cache to usestatic StringNEGATIVE_ENTRY_KEYOption name to enable negative cache entries (see JCR-2672)
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPrincipalProvider()Create a new instance ofAbstractPrincipalProvider.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddToCache(Principal principal)Add an entry to the principal cache.protected voidcheckInitialized()Check if the instance has been closedclose().protected voidclearCache()Clear the principal cache.voidclose()Clears the cache and calls the implementation to close their resourcesPrincipalgetPrincipal(String principalName)Returns the principal with the given name if is known to this providervoidinit(Properties options)Initialize this provider.protected abstract PrincipalprovidePrincipal(String principalName)Called if the cache does not contain the principal requested.
Implementations should return aPrincipalfrom their source, if it contains one for the given name ornull.-
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 ofAbstractPrincipalProvider. Initialization and cache are set up uponinit(Properties)
-
-
Method Detail
-
checkInitialized
protected void checkInitialized()
Check if the instance has been closedclose().- 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 aPrincipalfrom their source, if it contains one for the given name ornull.- 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 providerprovidePrincipal(String)is called, if no matching entry is present in the cache.
NOTE: If the cache is enabled to contain negative entries (seeNEGATIVE_ENTRY_KEYconfiguration option), the cache will also store negative matches (asnullvalues) in the principal cache.- Specified by:
getPrincipalin interfacePrincipalProvider- 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:PrincipalProviderInitialize this provider.- Specified by:
initin interfacePrincipalProvider- 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:
closein interfacePrincipalProvider- See Also:
PrincipalProvider.close()
-
-