Class ValidateAssertions
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.profile.action.AbstractProfileAction
-
- org.opensaml.saml.saml2.profile.impl.ValidateAssertions
-
- All Implemented Interfaces:
net.shibboleth.utilities.java.support.component.Component,net.shibboleth.utilities.java.support.component.DestructableComponent,net.shibboleth.utilities.java.support.component.InitializableComponent,org.opensaml.profile.action.ProfileAction
public class ValidateAssertions extends org.opensaml.profile.action.AbstractProfileActionA profile action which resolves SAML 2.0 Assertions from the profile request context and validates them using a resolved or configured instance ofSAML20AssertionValidator.The
ValidationResultalong with theValidationContextused are stored in the assertion'sXMLObject.getObjectMetadata()as instance ofValidationProcessingData.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classValidateAssertions.AssertionValidationInputClass which holds data relevant to validating a SAML 2.0 Assertion.classValidateAssertions.DefaultAssertionResolverThe default assertion resolver function.
-
Field Summary
Fields Modifier and Type Field Description private Function<org.opensaml.profile.context.ProfileRequestContext,List<org.opensaml.saml.saml2.core.Assertion>>assertionResolverThe resolver for the list of assertions to be validated.private List<org.opensaml.saml.saml2.core.Assertion>assertionsThe resolved assertions to be validated.private org.opensaml.saml.saml2.assertion.SAML20AssertionValidatorassertionValidatorThe SAML 2.0 Assertion validator, may be null.private Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,org.opensaml.saml.saml2.core.Assertion>,org.opensaml.saml.saml2.assertion.SAML20AssertionValidator>assertionValidatorLookupThe SAML 2.0 Assertion validator lookup function, may be null.private javax.servlet.http.HttpServletRequesthttpServletRequestThe HttpServletRequest being processed.private booleaninvalidFatalFlag which indicates whether a failure of Assertion validation should be considered fatal.private LoggerlogClass logger.private Function<ValidateAssertions.AssertionValidationInput,org.opensaml.saml.common.assertion.ValidationContext>validationContextBuilderFunction that builds aValidationContextinstance based on aValidateAssertions.AssertionValidationInputinstance.
-
Constructor Summary
Constructors Constructor Description ValidateAssertions()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.opensaml.saml.common.assertion.ValidationContextbuildValidationContext(org.opensaml.profile.context.ProfileRequestContext profileContext, org.opensaml.saml.saml2.core.Assertion assertion)Build the Assertion ValidationContext.protected voiddoDestroy()protected voiddoExecute(org.opensaml.profile.context.ProfileRequestContext profileContext)protected voiddoInitialize()protected booleandoPreExecute(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)Function<org.opensaml.profile.context.ProfileRequestContext,List<org.opensaml.saml.saml2.core.Assertion>>getAssertionResolver()Get the function which resolves the list of assertions to validate.org.opensaml.saml.saml2.assertion.SAML20AssertionValidatorgetAssertionValidator()Get the locally-configured Assertion validator.Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,org.opensaml.saml.saml2.core.Assertion>,org.opensaml.saml.saml2.assertion.SAML20AssertionValidator>getAssertionValidatorLookup()Get the Assertion validator lookup function.javax.servlet.http.HttpServletRequestgetHttpServletRequest()Get the HTTP servlet request being processed.Function<ValidateAssertions.AssertionValidationInput,org.opensaml.saml.common.assertion.ValidationContext>getValidationContextBuilder()Get the function that builds aValidationContextinstance based on aValidateAssertions.AssertionValidationInputinstance.booleanisInvalidFatal()Get flag which indicates whether a failure of Assertion validation should be considered a fatal processing error.protected voidprocessResult(org.opensaml.saml.common.assertion.ValidationContext validationContext, org.opensaml.saml.common.assertion.ValidationResult validationResult, org.opensaml.saml.saml2.core.Assertion assertion, org.opensaml.profile.context.ProfileRequestContext profileContext)Process the result of the assertion validation.protected org.opensaml.saml.saml2.assertion.SAML20AssertionValidatorresolveValidator(org.opensaml.profile.context.ProfileRequestContext profileContext, org.opensaml.saml.saml2.core.Assertion assertion)Resolve the Assertion token validator to use with the specified Assertion.voidsetAssertionResolver(Function<org.opensaml.profile.context.ProfileRequestContext,List<org.opensaml.saml.saml2.core.Assertion>> function)Set the function which resolves the list of assertions to validate.voidsetAssertionValidator(org.opensaml.saml.saml2.assertion.SAML20AssertionValidator validator)Set the locally-configured Assertion validator.voidsetAssertionValidatorLookup(Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,org.opensaml.saml.saml2.core.Assertion>,org.opensaml.saml.saml2.assertion.SAML20AssertionValidator> function)Set the Assertion validator lookup function.voidsetHttpServletRequest(javax.servlet.http.HttpServletRequest request)Set the HTTP servlet request being processed.voidsetInvalidFatal(boolean flag)Set flag which indicates whether a failure of Assertion validation should be considered a fatal processing error.voidsetValidationContextBuilder(Function<ValidateAssertions.AssertionValidationInput,org.opensaml.saml.common.assertion.ValidationContext> builder)Set the function that builds aValidationContextinstance based on aValidateAssertions.AssertionValidationInputinstance.-
Methods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, execute, getHttpServletResponse, getLogPrefix, setHttpServletResponse
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, initialize, isDestroyed, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private final Logger log
Class logger.
-
httpServletRequest
@NonnullAfterInit private javax.servlet.http.HttpServletRequest httpServletRequest
The HttpServletRequest being processed.
-
invalidFatal
private boolean invalidFatal
Flag which indicates whether a failure of Assertion validation should be considered fatal.
-
assertionValidator
@Nullable private org.opensaml.saml.saml2.assertion.SAML20AssertionValidator assertionValidator
The SAML 2.0 Assertion validator, may be null.
-
assertionValidatorLookup
@Nullable private Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,org.opensaml.saml.saml2.core.Assertion>,org.opensaml.saml.saml2.assertion.SAML20AssertionValidator> assertionValidatorLookup
The SAML 2.0 Assertion validator lookup function, may be null.
-
validationContextBuilder
@NonnullAfterInit private Function<ValidateAssertions.AssertionValidationInput,org.opensaml.saml.common.assertion.ValidationContext> validationContextBuilder
Function that builds aValidationContextinstance based on aValidateAssertions.AssertionValidationInputinstance.
-
assertionResolver
@Nonnull private Function<org.opensaml.profile.context.ProfileRequestContext,List<org.opensaml.saml.saml2.core.Assertion>> assertionResolver
The resolver for the list of assertions to be validated.
-
assertions
private List<org.opensaml.saml.saml2.core.Assertion> assertions
The resolved assertions to be validated.
-
-
Method Detail
-
getAssertionResolver
@Nonnull public Function<org.opensaml.profile.context.ProfileRequestContext,List<org.opensaml.saml.saml2.core.Assertion>> getAssertionResolver()
Get the function which resolves the list of assertions to validate.- Returns:
- the assertion resolver function
-
setAssertionResolver
public void setAssertionResolver(@Nonnull Function<org.opensaml.profile.context.ProfileRequestContext,List<org.opensaml.saml.saml2.core.Assertion>> function)Set the function which resolves the list of assertions to validate.- Parameters:
function- the new assertion resolver function
-
getValidationContextBuilder
@NonnullAfterInit public Function<ValidateAssertions.AssertionValidationInput,org.opensaml.saml.common.assertion.ValidationContext> getValidationContextBuilder()
Get the function that builds aValidationContextinstance based on aValidateAssertions.AssertionValidationInputinstance.Defaults to an instance of
DefaultAssertionValidationContextBuilder.- Returns:
- the builder function
-
setValidationContextBuilder
public void setValidationContextBuilder(@Nonnull Function<ValidateAssertions.AssertionValidationInput,org.opensaml.saml.common.assertion.ValidationContext> builder)Set the function that builds aValidationContextinstance based on aValidateAssertions.AssertionValidationInputinstance.Defaults to an instance of
DefaultAssertionValidationContextBuilder.- Parameters:
builder- the builder function
-
getHttpServletRequest
@NonnullAfterInit public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Get the HTTP servlet request being processed.- Overrides:
getHttpServletRequestin classorg.opensaml.profile.action.AbstractProfileAction- Returns:
- the HTTP servlet request
-
setHttpServletRequest
public void setHttpServletRequest(@Nonnull javax.servlet.http.HttpServletRequest request)Set the HTTP servlet request being processed.- Overrides:
setHttpServletRequestin classorg.opensaml.profile.action.AbstractProfileAction- Parameters:
request- The HTTP servlet request
-
isInvalidFatal
public boolean isInvalidFatal()
Get flag which indicates whether a failure of Assertion validation should be considered a fatal processing error.Defaults to:
true.- Returns:
- Returns the invalidFatal.
-
setInvalidFatal
public void setInvalidFatal(boolean flag)
Set flag which indicates whether a failure of Assertion validation should be considered a fatal processing error.Defaults to:
true.- Parameters:
flag- The invalidFatal to set.
-
getAssertionValidator
@Nullable public org.opensaml.saml.saml2.assertion.SAML20AssertionValidator getAssertionValidator()
Get the locally-configured Assertion validator.- Returns:
- the local Assertion validator, or null
-
setAssertionValidator
public void setAssertionValidator(@Nullable org.opensaml.saml.saml2.assertion.SAML20AssertionValidator validator)Set the locally-configured Assertion validator.- Parameters:
validator- the local Assertion validator, may be null
-
getAssertionValidatorLookup
@Nullable public Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,org.opensaml.saml.saml2.core.Assertion>,org.opensaml.saml.saml2.assertion.SAML20AssertionValidator> getAssertionValidatorLookup()
Get the Assertion validator lookup function.- Returns:
- the Assertion validator lookup function, or null
-
setAssertionValidatorLookup
public void setAssertionValidatorLookup(@Nullable Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,org.opensaml.saml.saml2.core.Assertion>,org.opensaml.saml.saml2.assertion.SAML20AssertionValidator> function)Set the Assertion validator lookup function.- Parameters:
function- the Assertion validator lookup function, may be null
-
doInitialize
protected void doInitialize() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException- Overrides:
doInitializein classnet.shibboleth.utilities.java.support.component.AbstractInitializableComponent- Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroyin classnet.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
doPreExecute
protected boolean doPreExecute(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext)- Overrides:
doPreExecutein classorg.opensaml.profile.action.AbstractProfileAction
-
doExecute
protected void doExecute(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileContext)- Overrides:
doExecutein classorg.opensaml.profile.action.AbstractProfileAction
-
processResult
protected void processResult(@Nonnull org.opensaml.saml.common.assertion.ValidationContext validationContext, @Nonnull org.opensaml.saml.common.assertion.ValidationResult validationResult, @Nonnull org.opensaml.saml.saml2.core.Assertion assertion, @Nonnull org.opensaml.profile.context.ProfileRequestContext profileContext)Process the result of the assertion validation.- Parameters:
validationContext- the Assertion validation contextvalidationResult- the Assertion validation resultassertion- the assertion being evaluated producedprofileContext- the current profile request context
-
resolveValidator
@Nullable protected org.opensaml.saml.saml2.assertion.SAML20AssertionValidator resolveValidator(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileContext, @Nonnull org.opensaml.saml.saml2.core.Assertion assertion)Resolve the Assertion token validator to use with the specified Assertion.- Parameters:
profileContext- the current profile contextassertion- the assertion being evaluated- Returns:
- the token validator
-
buildValidationContext
@Nonnull protected org.opensaml.saml.common.assertion.ValidationContext buildValidationContext(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileContext, @Nonnull org.opensaml.saml.saml2.core.Assertion assertion) throws org.opensaml.saml.common.assertion.AssertionValidationExceptionBuild the Assertion ValidationContext.- Parameters:
profileContext- the current profile contextassertion- the assertion which is to be validated- Returns:
- the new Assertion validation context to use
- Throws:
org.opensaml.saml.common.assertion.AssertionValidationException- if no validation context instance could be built
-
-