Class TemplatedURLBuilder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.idp.attribute.resolver.dc.http.impl.AbstractHTTPSearchBuilder
-
- net.shibboleth.idp.attribute.resolver.dc.http.impl.TemplatedURLBuilder
-
- All Implemented Interfaces:
ExecutableSearchBuilder<HTTPSearch>,Component,DestructableComponent,InitializableComponent
public class TemplatedURLBuilder extends AbstractHTTPSearchBuilder
AnExecutableSearchBuilderthat generates the URL to request by evaluating aTemplateagainst the currently resolved attributes within anAttributeResolutionContext.
-
-
Field Summary
Fields Modifier and Type Field Description private ObjectcustomObjectA custom object to inject into the template.private org.apache.velocity.app.VelocityEngineengineVelocityEngine.private EscaperfragmentEscaperEscaper for fragments.private org.slf4j.LoggerlogClass logger.private EscaperparamEscaperEscaper for form parameters.private EscaperpathEscaperEscaper for path segments.private TemplatetemplateTemplate to be evaluated.private StringtemplateTextText of template to be evaluated.
-
Constructor Summary
Constructors Constructor Description TemplatedURLBuilder()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInitialize()TemplategetTemplate()Get the template to be evaluated.StringgetTemplateText()Get the template text to be evaluated.protected StringgetURL(AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)Method to return the URL to access via GET.org.apache.velocity.app.VelocityEnginegetVelocityEngine()Get theVelocityEngineto be used.protected Stringmerge(org.apache.velocity.VelocityContext context)InvokesTemplate.merge(org.apache.velocity.context.Context)on the supplied context.voidsetCustomObject(Object object)Set the custom (externally provided) object.voidsetTemplateText(String text)Set the template to be evaluated.voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)Set theVelocityEngineto be used.-
Methods inherited from class net.shibboleth.idp.attribute.resolver.dc.http.impl.AbstractHTTPSearchBuilder
build, getHeaders, getHttpClientSecurityParameters, getHttpRequest, getResultCacheKey, setHeaders, setHttpClientSecurityParameters
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
template
@NonnullAfterInit private Template template
Template to be evaluated.
-
templateText
@NonnullAfterInit private String templateText
Text of template to be evaluated.
-
engine
@NonnullAfterInit private org.apache.velocity.app.VelocityEngine engine
VelocityEngine.
-
paramEscaper
@Nonnull private final Escaper paramEscaper
Escaper for form parameters.
-
fragmentEscaper
@Nonnull private final Escaper fragmentEscaper
Escaper for fragments.
-
pathEscaper
@Nonnull private final Escaper pathEscaper
Escaper for path segments.
-
customObject
@Nullable private Object customObject
A custom object to inject into the template.
-
-
Method Detail
-
getTemplate
@NonnullAfterInit public Template getTemplate()
Get the template to be evaluated.- Returns:
- template
-
getTemplateText
@NonnullAfterInit public String getTemplateText()
Get the template text to be evaluated.- Returns:
- template text
-
setTemplateText
public void setTemplateText(@Nullable String text)Set the template to be evaluated.- Parameters:
text- template to be evaluated
-
getVelocityEngine
@NonnullAfterInit public org.apache.velocity.app.VelocityEngine 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
public void setCustomObject(@Nullable Object object)Set the custom (externally provided) object.- Parameters:
object- the custom object
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
merge
@Nonnull @NotEmpty protected String merge(@Nonnull org.apache.velocity.VelocityContext context)
InvokesTemplate.merge(org.apache.velocity.context.Context)on the supplied context.- Parameters:
context- to merge- Returns:
- result of the merge operation
-
getURL
@Nonnull protected String getURL(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException
Method to return the URL to access via GET.Subclasses may override this method to support simple GET requests.
- Overrides:
getURLin classAbstractHTTPSearchBuilder- Parameters:
resolutionContext- the context of the resolutiondependencyAttributes- made available to the request- Returns:
- the URL to GET
- Throws:
ResolutionException- if an error occurs
-
-