Class AbstractStorageServiceCredentialResolver<T extends Credential>
- Type Parameters:
T- the type of credential supported
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,Resolver<Credential,,CriteriaSet> OrderedCredentialResolver,CredentialResolver,Ordered
- Direct Known Subclasses:
X509CredentialStorageServiceResolver,X509KeyStoreStorageServiceResolver
StorageService to retrieve blobs
of information that its subclasses will understand how to turn into a
specifically known type of Credential.
Typically more than one object from storage will be required to construct
the expected type of Credential, and subclasses are expected to
govern exactly how that occurs.
The resolver functions by evaluating a Velocity Template with information
pulled from the supplied CriteriaSet to allow dynamic construction
of the storage context and key to retrieve. The resulting values are
passed to the subclass to further process into specific lookup values
to retrieve.
The resolver recognizes these Criterion types natively and
supplies them as input to the template:
ProfileRequestContextCriterion- generic extension pointAgentIDCriterion- used forAgent-based lookupApplicationIDCriterion- used forApplication-based lookupEntityIdCriterion- used for relying party-based lookupUsageCriterion- used for usage-based lookup
In addition, the entire CriteriaSet is also supplied as an extension point, and
if supplied, the entityID is transformed by a pluggable function, by default into a SHA-1
hash that is hex-encoded in lower case.
Note that subclasses are required to perform evaluation of intended usage based on
the UsageCriterion such that any resolved credentials are assumed to either
match the caller's expectations or not carry any usage designation at all.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classDefaults to SHA-1 hash.Nested classes/interfaces inherited from class net.shibboleth.sp.credential.AbstractOrderedCredentialResolver
AbstractOrderedCredentialResolver.UsageCriterionPredicate -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether to enable caching.static final StringThe Velocity context variable name for the Agent ID.static final StringThe Velocity context variable name for the Application ID.static final StringThe Velocity context variable name for the CriteriaSet.static final StringThe Velocity context variable name for the entity ID.static final StringThe Velocity context variable name for theProfileRequestContext.static final StringThe Velocity context variable name for the Protocol.static final StringThe Velocity context variable name for the transformed entity ID.static final StringThe Velocity context variable name for theUsageType.private TemplateVelocity template for context.private StringVelocity template source for context.Credential type.static final StringDefault prefix for default context value.Function to transform the entityID.private DurationSets cache expiration based on last access time.private DurationSets cache expiration based on entry creation.private final org.slf4j.LoggerClass logger.private IntegerSize of cache.Map of protocol values to template values.private Cache<CriteriaSet,List<Credential>> Credential resolution cache.private StorageServiceStorage service to use.Map of usage types to template values.private org.apache.velocity.app.VelocityEngineVelocity engine to use.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected Iterable<Credential>doResolve(CriteriaSet criteria) Subclasses implement this method to resolve the underlying objects.protected abstract Iterable<Credential>doResolve(org.apache.velocity.VelocityContext velocityContext, CriteriaSet criteria, String storageContext) Perform the resolution as required for the specific type ofCredential.Gets theStorageServiceto use.org.apache.velocity.app.VelocityEngineGets theVelocityEngineto use.protected org.apache.velocity.VelocityContextpopulateVelocityContext(CriteriaSet criteria) Populate and return aVelocityContextwith the necessary criteria information.voidsetCacheEnabled(boolean flag) Sets whether to enable caching.voidsetContextTemplate(String template) Sets the Velocity template to use to construct the storage context.voidsetEntityIDTransformStrategy(Function<String, String> strategy) Sets the transform to apply to the entityID if supplied.voidSets the cache policy to expire entries after access, with the time reset on each access.voidSets the cache policy to expire entries after creation.voidSets the maximum cache size.voidsetProtocolMap(Map<String, String> map) Sets a map from protocol constants to string tokens, allowing customizable injection of a string into the Velocity context to abbreviate or otherwise control what to resolve based on a suppliedProtocolCriterion.voidsetStorageService(StorageService storage) Sets theStorageServiceto use.voidsetUsageMap(Map<UsageType, String> map) Sets a map fromUsageTypeto string tokens, allowing customizable injection of a string into the Velocity context to abbreviate or otherwise control what to resolve based on a suppliedUsageCriterion.voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine engine) Sets theVelocityEngineto use.Methods inherited from class net.shibboleth.sp.credential.AbstractOrderedCredentialResolver
getOrder, resolve, resolveSingle, setFilterByUsage, setOrder, setProtocolsMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getId
-
Field Details
-
DEFAULT_CONTEXT_PREFIX
Default prefix for default context value.- See Also:
-
CONTEXT_KEY_CRITERIA
The Velocity context variable name for the CriteriaSet.- See Also:
-
CONTEXT_KEY_PROTOCOL
The Velocity context variable name for the Protocol.- See Also:
-
CONTEXT_KEY_AGENT_ID
The Velocity context variable name for the Agent ID.- See Also:
-
CONTEXT_KEY_APPLICATION_ID
The Velocity context variable name for the Application ID.- See Also:
-
CONTEXT_KEY_ENTITY_ID
The Velocity context variable name for the entity ID.- See Also:
-
CONTEXT_KEY_TX_ENTITY_ID
The Velocity context variable name for the transformed entity ID.- See Also:
-
CONTEXT_KEY_USAGE
The Velocity context variable name for theUsageType.- See Also:
-
CONTEXT_KEY_PRC
The Velocity context variable name for theProfileRequestContext.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
credentialType
Credential type. -
cacheEnabled
private boolean cacheEnabledWhether to enable caching. -
storageService
Storage service to use. -
velocityEngine
Velocity engine to use. -
entityIDTransformStrategy
Function to transform the entityID. -
maximumCachedElements
Size of cache. -
expireAfterAccess
Sets cache expiration based on last access time. -
expireAfterWrite
Sets cache expiration based on entry creation. -
resultsCache
Credential resolution cache. -
contextTemplateString
Velocity template source for context. -
contextTemplate
Velocity template for context. -
usageMap
Map of usage types to template values. -
protocolMap
Map of protocol values to template values.
-
-
Constructor Details
-
AbstractStorageServiceCredentialResolver
Constructor.- Parameters:
type- class type of generic parameter
-
-
Method Details
-
setCacheEnabled
public void setCacheEnabled(boolean flag) Sets whether to enable caching.Defaults to false.
When enabled, any
ProfileRequestContextCriterionis remoed from input criteria.- Parameters:
flag- flag to set
-
getStorageService
Gets theStorageServiceto use.- Returns:
- storage service
-
setStorageService
Sets theStorageServiceto use.- Parameters:
storage- storage service
-
getVelocityEngine
Gets theVelocityEngineto use.- Returns:
- Velocity engine
-
setVelocityEngine
public void setVelocityEngine(@Nonnull org.apache.velocity.app.VelocityEngine engine) Sets theVelocityEngineto use.- Parameters:
engine- Velocity engine
-
setEntityIDTransformStrategy
Sets the transform to apply to the entityID if supplied.Defaults to a SHA-1 hash as a hex-encoded lower-case string.
- Parameters:
strategy- transform strategy
-
setMaximumCachedElements
Sets the maximum cache size.Defaults to 500.
- Parameters:
max- maximum size
-
setExpireAfterAccess
Sets the cache policy to expire entries after access, with the time reset on each access.Defaults to 4 hours.
Mutually exclusive with
setExpireAfterWrite(Duration).- Parameters:
exp- threshold
-
setExpireAfterWrite
Sets the cache policy to expire entries after creation.Defaults to null.
Mutually exclusive with
setExpireAfterAccess(Duration).- Parameters:
exp- threshold
-
setContextTemplate
Sets the Velocity template to use to construct the storage context.Defaults to "net.shibboleth.sp.credential.resolver.id" where "id" is the component ID.
- Parameters:
template- template for storage context
-
setUsageMap
Sets a map fromUsageTypeto string tokens, allowing customizable injection of a string into the Velocity context to abbreviate or otherwise control what to resolve based on a suppliedUsageCriterion.Defaults to "-signing", "-encryption", and "-signing" for
UsageType.SIGNING,UsageType.ENCRYPTION, andUsageType.UNSPECIFIEDrespectively, which is compatible with the advisable step of separating keys by usage.- Parameters:
map- map of usage types to string values
-
setProtocolMap
Sets a map from protocol constants to string tokens, allowing customizable injection of a string into the Velocity context to abbreviate or otherwise control what to resolve based on a suppliedProtocolCriterion.Defaults to empty, as most resolvers are xepected to be protocol specific more generally.
- Parameters:
map- map of usage types to string values
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-