Class TemplatedBodyBuilder
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.resolver.dc.http.impl.AbstractHTTPSearchBuilder
net.shibboleth.idp.attribute.resolver.dc.http.impl.TemplatedBodyBuilder
- All Implemented Interfaces:
ExecutableSearchBuilder<HTTPSearch>,Component,DestructableComponent,InitializableComponent
An
ExecutableSearchBuilder that generates a
request by evaluating Templates against the currently resolved attributes within an
AttributeResolutionContext to produce a URL and body, via GET or POST, and a configurable
cache key.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TemplateBody template to be evaluated.private StringText of body template to be evaluated.private TemplateCache key template to be evaluated.private StringText of cache key template to be evaluated.private StringCharacter set.private org.apache.hc.core5.http.ContentTypeContent type.private ObjectA custom object to inject into the template.private org.apache.velocity.app.VelocityEngineVelocityEngine.private final EscaperEscaper for fragments.private final org.slf4j.LoggerClass logger.private StringHTTP method.private StringMIME type.private final EscaperEscaper for form parameters.private final EscaperEscaper for path segments.private TemplateURL template to be evaluated.private StringText of URL template to be evaluated.private final EscaperEscaper for XML Attributes.private final EscaperEscaper for XML content. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidGet the body template to be evaluated.Get the body template text to be evaluated.Get the cache key template to be evaluated.Get the cache key template text to be evaluated.protected org.apache.hc.core5.http.ClassicHttpRequestgetHttpRequest(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Default implementation just supports GET and builds a request around a URL.protected StringgetResultCacheKey(org.apache.hc.core5.http.ClassicHttpRequest request, AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Default implementation just allows caching of GET requests and returns the URI itself.Get the URL template to be evaluated.Get the URL template text to be evaluated.org.apache.velocity.app.VelocityEngineGet theVelocityEngineto be used.protected StringInvokesTemplate.merge(org.apache.velocity.context.Context)on the supplied template and context.voidsetBodyTemplateText(String text) Set the body template to be evaluated.voidSet the cache key template to be evaluated.voidSet the character set.voidsetCustomObject(Object object) Set the custom (externally provided) object.voidSet the HTTP method.voidsetMIMEType(String type) Set the MIME type.voidsetURLTemplateText(String text) Set the URL 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, getURL, setHeaders, setHttpClientSecurityParametersMethods 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. -
urlTemplate
URL template to be evaluated. -
bodyTemplate
Body template to be evaluated. -
cacheKeyTemplate
Cache key template to be evaluated. -
urlTemplateText
Text of URL template to be evaluated. -
bodyTemplateText
Text of body template to be evaluated. -
cacheKeyTemplateText
Text of cache key template to be evaluated. -
engine
VelocityEngine. -
method
HTTP method. -
mimeType
MIME type. -
charset
Character set. -
contentType
Content type. -
paramEscaper
Escaper for form parameters. -
fragmentEscaper
Escaper for fragments. -
pathEscaper
Escaper for path segments. -
xmlAttributeEscaper
Escaper for XML Attributes. -
xmlContentEscaper
Escaper for XML content. -
customObject
A custom object to inject into the template.
-
-
Constructor Details
-
TemplatedBodyBuilder
public TemplatedBodyBuilder()Constructor.
-
-
Method Details
-
getURLTemplate
Get the URL template to be evaluated.- Returns:
- template
-
getBodyTemplate
Get the body template to be evaluated.- Returns:
- template
-
getCacheKeyTemplate
Get the cache key template to be evaluated.- Returns:
- template
-
getURLTemplateText
Get the URL template text to be evaluated.- Returns:
- template text
-
setURLTemplateText
Set the URL template to be evaluated.- Parameters:
text- template to be evaluated
-
getBodyTemplateText
Get the body template text to be evaluated.- Returns:
- template text
-
setBodyTemplateText
Set the body template to be evaluated.- Parameters:
text- template to be evaluated
-
getCacheKeyTemplateText
Get the cache key template text to be evaluated.- Returns:
- template text
-
setCacheKeyTemplateText
Set the cache 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
-
setMethod
Set the HTTP method.Defaults to "POST".
- Parameters:
m- method
-
setMIMEType
Set the MIME type.Defaults to "text/plain".
- Parameters:
type- MIME type
-
setCharacterSet
Set the character set.- Parameters:
c- character set
-
setCustomObject
Set the custom (externally provided) object.- Parameters:
object- the custom object
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
getHttpRequest
@Nonnull protected org.apache.hc.core5.http.ClassicHttpRequest getHttpRequest(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionExceptionDefault implementation just supports GET and builds a request around a URL.- Overrides:
getHttpRequestin classAbstractHTTPSearchBuilder- Parameters:
resolutionContext- the context of the resolutiondependencyAttributes- made available to the request- Returns:
- the
ClassicHttpRequestto use - Throws:
ResolutionException- if an error occurs
-
getResultCacheKey
@Nullable @NotEmpty protected String getResultCacheKey(@Nonnull org.apache.hc.core5.http.ClassicHttpRequest request, @Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) Default implementation just allows caching of GET requests and returns the URI itself.- Overrides:
getResultCacheKeyin classAbstractHTTPSearchBuilder- Parameters:
request- the HTTP request about to be executedresolutionContext- the attribute resolution contextdependencyAttributes- dependencies- Returns:
- the cache key
-