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 ofPrincipal
s from their source, the caching of the principals is done by this implementation.The
PrincipalProvider
methods that that involve searching likePrincipalProvider.getGroupMembership(Principal)
are not cached.
-
-
Field Summary
Fields Modifier and Type Field Description static String
MAXSIZE_KEY
Option name for the max size of the cache to usestatic String
NEGATIVE_ENTRY_KEY
Option name to enable negative cache entries (see JCR-2672)
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPrincipalProvider()
Create a new instance ofAbstractPrincipalProvider
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addToCache(Principal principal)
Add an entry to the principal cache.protected void
checkInitialized()
Check if the instance has been closedclose()
.protected void
clearCache()
Clear the principal cache.void
close()
Clears the cache and calls the implementation to close their resourcesPrincipal
getPrincipal(String principalName)
Returns the principal with the given name if is known to this providervoid
init(Properties options)
Initialize this provider.protected abstract Principal
providePrincipal(String principalName)
Called if the cache does not contain the principal requested.
Implementations should return aPrincipal
from 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 aPrincipal
from 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_KEY
configuration option), the cache will also store negative matches (asnull
values) in the principal cache.- Specified by:
getPrincipal
in 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:PrincipalProvider
Initialize this provider.- Specified by:
init
in 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:
close
in interfacePrincipalProvider
- See Also:
PrincipalProvider.close()
-
-