Class DefaultSAML20AssertionValidationContextBuilder
- All Implemented Interfaces:
Function<SAML20AssertionTokenValidationInput,
ValidationContext>
ValidationContext
from an instance of SAML20AssertionTokenValidationInput
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.slf4j.Logger
Logger.private Function<Pair<MessageContext,
Assertion>, CriteriaSet> A function for resolving the signature validation CriteriaSet for a particular function.private boolean
Flag indicating whether an Assertion signature is required. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuild the static parameters map for input to theValidationContext
.protected X509Certificate
Get the attesting entity'sX509Certificate
.protected String
Get the attester's IP address.protected PublicKey
Get the attesting entity'sPublicKey
.protected CriteriaSet
Get the signature validation criteria set.Get the function for resolving the signature validation CriteriaSet for a particular function.protected Set<InetAddress>
Get the set of addresses which are valid for subject confirmation.Get the valid audiences for attestation.Get the valid recipient endpoints for attestation.boolean
Get the flag indicating whether an Assertion signature is required.void
Set the function for resolving the signature validation CriteriaSet for a particular function.void
setSignatureRequired
(boolean flag) Set the flag indicating whether an Assertion signature is required.
-
Field Details
-
log
@Nullable private org.slf4j.Logger logLogger. -
signatureCriteriaSetFunction
A function for resolving the signature validation CriteriaSet for a particular function. -
signatureRequired
private boolean signatureRequiredFlag indicating whether an Assertion signature is required.
-
-
Constructor Details
-
DefaultSAML20AssertionValidationContextBuilder
public DefaultSAML20AssertionValidationContextBuilder()Constructor.
-
-
Method Details
-
isSignatureRequired
public boolean isSignatureRequired()Get the flag indicating whether an Assertion signature is required.Defaults to:
true
.- Returns:
- true if required, false if not
-
setSignatureRequired
public void setSignatureRequired(boolean flag) Set the flag indicating whether an Assertion signature is required.Defaults to:
true
.- Parameters:
flag
- true if required, false if not
-
getSignatureCriteriaSetFunction
@Nullable public Function<Pair<MessageContext,Assertion>, getSignatureCriteriaSetFunction()CriteriaSet> Get the function for resolving the signature validation CriteriaSet for a particular function.Defaults to:
null
.- Returns:
- a criteria set instance, or null
-
setSignatureCriteriaSetFunction
public void setSignatureCriteriaSetFunction(@Nullable Function<Pair<MessageContext, Assertion>, CriteriaSet> function) Set the function for resolving the signature validation CriteriaSet for a particular function.Defaults to:
null
.- Parameters:
function
- the resolving function, may be null
-
apply
- Specified by:
apply
in interfaceFunction<SAML20AssertionTokenValidationInput,
ValidationContext>
-
buildStaticParameters
@Nonnull protected Map<String,Object> buildStaticParameters(@Nonnull SAML20AssertionTokenValidationInput input) Build the static parameters map for input to theValidationContext
.- Parameters:
input
- the assertion validation input- Returns:
- the static parameters map
-
getSignatureCriteriaSet
@Nonnull protected CriteriaSet getSignatureCriteriaSet(@Nonnull SAML20AssertionTokenValidationInput input) Get the signature validation criteria set.This implementation first evaluates the result of applying the function
getSignatureCriteriaSetFunction()
, if configured. If that evaluation did not produce anEntityIdCriterion
, one is added based on the issuer of theAssertion
. If that evaluation did not produce an instance ofUsageCriterion
, one is added with the value ofUsageType.SIGNING
.- Parameters:
input
- the assertion validation input- Returns:
- the criteria set based on the message context data
-
getAttesterCertificate
@Nullable protected X509Certificate getAttesterCertificate(@Nonnull SAML20AssertionTokenValidationInput input) Get the attesting entity'sX509Certificate
.This implementation returns the client TLS certificate present in the
HttpServletRequest
, or null if one is not present.- Parameters:
input
- the assertion validation input- Returns:
- the entity certificate, or null
-
getAttesterPublicKey
@Nullable protected PublicKey getAttesterPublicKey(@Nonnull SAML20AssertionTokenValidationInput input) Get the attesting entity'sPublicKey
.This implementation returns null. Subclasses should override to implement specific logic.
- Parameters:
input
- the assertion validation input- Returns:
- the entity public key, or null
-
getValidRecipients
@Nonnull protected Set<String> getValidRecipients(@Nonnull SAML20AssertionTokenValidationInput input) Get the valid recipient endpoints for attestation.This implementation returns a set containing the 2 values;
-
HttpServletRequest.getRequestURL()
-
if present,
AbstractSAMLEntityContext.getEntityId()
- Parameters:
input
- the assertion validation input- Returns:
- set of recipient endpoint URI's
-
-
getValidAddresses
@Nonnull protected Set<InetAddress> getValidAddresses(@Nonnull SAML20AssertionTokenValidationInput input) Get the set of addresses which are valid for subject confirmation.This implementation simply returns the set based on
getAttesterIPAddress(SAML20AssertionTokenValidationInput)
, if that produces a value. Otherwise an empty set is returned.- Parameters:
input
- the assertion validation input- Returns:
- the set of valid addresses
-
getAttesterIPAddress
Get the attester's IP address.This implementation returns the value of
ServletRequest.getRemoteAddr()
.- Parameters:
input
- the assertion validation input- Returns:
- the IP address of the attester
-
getValidAudiences
@Nonnull protected Set<String> getValidAudiences(@Nonnull SAML20AssertionTokenValidationInput input) Get the valid audiences for attestation.This implementation returns a set containing the single entityID held by the message context's
AbstractSAMLEntityContext.getEntityId()
, if present. Otherwise an empty set is returned.- Parameters:
input
- the assertion validation input- Returns:
- set of audience URI's
-