Class TemplatedSearchBuilder
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.resolver.dc.storage.impl.TemplatedSearchBuilder
- All Implemented Interfaces:
ExecutableSearchBuilder<StorageServiceSearch>,Component,DestructableComponent,InitializableComponent
public class TemplatedSearchBuilder
extends AbstractInitializableComponent
implements ExecutableSearchBuilder<StorageServiceSearch>
An
ExecutableSearchBuilder that generates the StorageService context and key
using Velocity templates.- Since:
- 4.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord encapsulating storage context and key. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TemplateContext template to be evaluated.private StringText of context template to be evaluated.private ObjectA custom object to inject into the template.private org.apache.velocity.app.VelocityEngineVelocityEngine.private TemplateKey template to be evaluated.private StringText of key template to be evaluated.private final org.slf4j.LoggerClass logger. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Creates an executable search that can be executed against a data source in order to produce results.protected voidgetContextAndKey(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Helper method to extract the parameters needed for theStorageServiceSearch.Get the context template to be evaluated.Get the context template text to be evaluated.Get the key template to be evaluated.Get the key template text to be evaluated.org.apache.velocity.app.VelocityEngineGet theVelocityEngineto be used.voidsetContextTemplateText(String text) Set the context template to be evaluated.voidsetCustomObject(Object object) Set the custom (externally provided) object.voidsetKeyTemplateText(String text) Set the key template to be evaluated.voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine) Set theVelocityEngineto be used.Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
contextTemplate
Context template to be evaluated. -
keyTemplate
Key template to be evaluated. -
contextTemplateText
Text of context template to be evaluated. -
keyTemplateText
Text of key template to be evaluated. -
engine
VelocityEngine. -
customObject
A custom object to inject into the template.
-
-
Constructor Details
-
TemplatedSearchBuilder
public TemplatedSearchBuilder()
-
-
Method Details
-
getContextTemplate
Get the context template to be evaluated.- Returns:
- template
-
getKeyTemplate
Get the key template to be evaluated.- Returns:
- template
-
getContextTemplateText
Get the context template text to be evaluated.- Returns:
- template text
-
setContextTemplateText
Set the context template to be evaluated.- Parameters:
text- template to be evaluated
-
getKeyTemplateText
Get the key template text to be evaluated.- Returns:
- template text
-
setKeyTemplateText
Set the key template to be evaluated.- Parameters:
text- template to be evaluated
-
getVelocityEngine
Get theVelocityEngineto be used.- Returns:
- template engine
-
setVelocityEngine
public void setVelocityEngine(@Nonnull org.apache.velocity.app.VelocityEngine velocityEngine) Set theVelocityEngineto be used.- Parameters:
velocityEngine- engine to be used
-
setCustomObject
Set the custom (externally provided) object.- Parameters:
object- the custom object
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
build
@Nonnull public StorageServiceSearch build(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionExceptionCreates an executable search that can be executed against a data source in order to produce results.- Specified by:
buildin interfaceExecutableSearchBuilder<StorageServiceSearch>- Parameters:
resolutionContext- current request contextdependencyAttributes- made available to the executable search- Returns:
- executable search
- Throws:
ResolutionException- throw if their is a problem creating the executable search
-
getContextAndKey
@Nonnull private TemplatedSearchBuilder.ContextAndKey getContextAndKey(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionExceptionHelper method to extract the parameters needed for theStorageServiceSearch.- Parameters:
resolutionContext- the context of the resolutiondependencyAttributes- the attributes we depend upon- Returns:
- the derived
StorageServicecontext and key - Throws:
ResolutionException- if the velocity operations failed resolution failed.
-