Class AssertionValidator
java.lang.Object
se.swedenconnect.opensaml.common.validation.AbstractObjectValidator<Assertion>
se.swedenconnect.opensaml.common.validation.AbstractSignableObjectValidator<Assertion>
se.swedenconnect.opensaml.saml2.assertion.validation.AssertionValidator
- All Implemented Interfaces:
ObjectValidator<Assertion>
A validator for
Assertion objects.
Supports the following ValidationContext static parameters:
- The static parameters defined for
AbstractSignableObjectValidator. CoreValidatorParameters.SP_METADATA: Required. The SP metadata.CoreValidatorParameters.IDP_METADATA: Required. The IdP metadata.CoreValidatorParameters.STRICT_VALIDATION: Optional. If not supplied, defaults to 'false'. Tells whether strict validation should be performed.SAML2AssertionValidationParameters.CLOCK_SKEW: Optional. Gives the number of milliseconds that is the maximum allowed clock skew. If not givenSAML20AssertionValidator.DEFAULT_CLOCK_SKEWis used.CoreValidatorParameters.MAX_AGE_MESSAGE: Optional. Gives the maximum age (difference between issuance time and the validation time). If not given, theAbstractObjectValidator.DEFAULT_MAX_AGE_RECEIVED_MESSAGEis used.CoreValidatorParameters.RECEIVE_INSTANT: Optional. Gives the timestamp (Instant) for when the response message was received. If not given the current time is used.CoreValidatorParameters.AUTHN_REQUEST: Required. Will be used in a number of validations when information from the correspondingAuthnRequestis needed.CoreValidatorParameters.AUTHN_REQUEST_ID: Required if theCoreValidatorParameters.AUTHN_REQUESTis not assigned. Is used when validating theInResponseToattribute of the response.CoreValidatorParameters.RECEIVE_URL: Required. A String holding the URL on which we received the response message. Is used when theDestinationattribute is validated.CoreValidatorParameters.EXPECTED_ISSUER: Optional. If set, is used when the issuer of the response is validated. If not set, the issuer from theCoreValidatorParameters.AUTHN_REQUESTis used (if available).RESPONSE_ISSUE_INSTANT: Optional. If set, the IssueInstant of the Assertion being validated is compared with the corresponding response issue instant.
Supports the following ValidationContext dynamic parameters:
SAML2AssertionValidationParameters.CONFIRMED_SUBJECT_CONFIRMATION: Optional. Will be present after validation if subject confirmation was successfully performed.HOK_PROFILE_ACTIVE: Is set to indicate whether the holder-of-key WebSSO profile is active.
Note: Also check the validation context parameters defined by the SubjectConfirmationValidator and
ConditionValidator instances that are installed.
- Author:
- Martin Lindström (martin@idsec.se)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<QName, ConditionValidator> RegisteredConditionvalidators.static final StringTells whether the AuthnRequest corresponding to this assertion was sent to the IdP's holder of key-endpoints, i.e., whether the Holder-of-key profile is in use.static final StringCarries aInstantholding the issue instant of the Response that contained the assertion being validated.protected Map<String, SubjectConfirmationValidator> RegisteredSubjectConfirmationvalidators.Fields inherited from class se.swedenconnect.opensaml.common.validation.AbstractSignableObjectValidator
signaturePrevalidator, trustEngineFields inherited from class se.swedenconnect.opensaml.common.validation.AbstractObjectValidator
DEFAULT_MAX_AGE_RECEIVED_MESSAGE -
Constructor Summary
ConstructorsConstructorDescriptionAssertionValidator(SignatureTrustEngine trustEngine, SignaturePrevalidator signaturePrevalidator, Collection<SubjectConfirmationValidator> confirmationValidators, Collection<ConditionValidator> conditionValidators, Collection<StatementValidator> statementValidators) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringReturns the Assertion ID.protected StringReturns the Assertion issuer.protected StringReturns the name of the object being validated, e.g.protected InstantgetResponseIssueInstant(ValidationContext context) Gets theRESPONSE_ISSUE_INSTANTsetting.validate(Assertion assertion, ValidationContext context) Validates the assertion.protected ValidationResultvalidateConditions(Assertion assertion, ValidationContext context) Validates theConditionselements of the assertion.protected ValidationResultvalidateConditionsTimeBounds(Assertion assertion, ValidationContext context) Validates the NotBefore and NotOnOrAfter Conditions constraints on the assertion.protected ValidationResultvalidateHolderOfKeyRequirement(Assertion assertion, ValidationContext context) Performs initial validation concerning the Holder-of-key WebSSO Profile.protected ValidationResultvalidateID(Assertion assertion, ValidationContext context) Validates that theAssertionobject has an ID attribute.protected ValidationResultvalidateIssueInstant(Assertion assertion, ValidationContext context) Validates that theAssertionobject has a IssueInstant attribute and checks that its value is OK.protected ValidationResultvalidateIssuer(Assertion assertion, ValidationContext context) Ensures that theIssuerelement is present and matches the expected issuer (if set in the context under theCoreValidatorParameters.EXPECTED_ISSUERkey).protected ValidationResultvalidateStatements(Assertion assertion, ValidationContext context) Validates the statements of the assertion using the registeredStatementValidatorinstance.protected ValidationResultvalidateSubject(Assertion assertion, ValidationContext context) Validates theSubjectelement of the assertion.protected ValidationResultvalidateSubjectConfirmations(Assertion assertion, List<SubjectConfirmation> subjectConfirmations, ValidationContext context) Validates the subject confirmations and for the one that is confirmed, it is saved in the validation context under theSAML2AssertionValidationParameters.CONFIRMED_SUBJECT_CONFIRMATIONkey.protected ValidationResultvalidateVersion(Assertion assertion, ValidationContext context) Validates that theResponseobject has a valid Version attribute.Methods inherited from class se.swedenconnect.opensaml.common.validation.AbstractSignableObjectValidator
getSignatureValidationCriteriaSet, performSignatureValidation, validateSignatureMethods inherited from class se.swedenconnect.opensaml.common.validation.AbstractObjectValidator
getAllowedClockSkew, getMaxAgeReceivedMessage, getReceiveInstant, isStrictValidation
-
Field Details
-
RESPONSE_ISSUE_INSTANT
Carries aInstantholding the issue instant of the Response that contained the assertion being validated.- See Also:
-
HOK_PROFILE_ACTIVE
Tells whether the AuthnRequest corresponding to this assertion was sent to the IdP's holder of key-endpoints, i.e., whether the Holder-of-key profile is in use. Carries aBoolean.- See Also:
-
subjectConfirmationValidators
RegisteredSubjectConfirmationvalidators. -
conditionValidators
RegisteredConditionvalidators.
-
-
Constructor Details
-
AssertionValidator
public AssertionValidator(SignatureTrustEngine trustEngine, SignaturePrevalidator signaturePrevalidator, Collection<SubjectConfirmationValidator> confirmationValidators, Collection<ConditionValidator> conditionValidators, Collection<StatementValidator> statementValidators) Constructor.- Parameters:
trustEngine- the trust used to validate the object's signaturesignaturePrevalidator- the signature pre-validator used to pre-validate the object's signatureconfirmationValidators- validators used to validateSubjectConfirmationmethods within the assertionconditionValidators- validators used to validate theConditionelements within the assertionstatementValidators- validators used to validateStatements within the assertion
-
-
Method Details
-
validate
Validates the assertion.- Parameters:
assertion- object to be evaluatedcontext- current validation context- Returns:
- the result of the evaluation
-
validateID
Validates that theAssertionobject has an ID attribute.- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- a validation result
-
validateVersion
Validates that theResponseobject has a valid Version attribute.- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- a validation result
-
validateIssueInstant
Validates that theAssertionobject has a IssueInstant attribute and checks that its value is OK. If the response that contained the assertion was previously validated the static context parameterRESPONSE_ISSUE_INSTANTshould be passed. If so, the method checks that the assertion issue instant is not after the response issue instant. Otherwise, the method checks that the IssueInstant is not too old given theCoreValidatorParameters.MAX_AGE_MESSAGEandCoreValidatorParameters.RECEIVE_INSTANTcontext parameters.- Parameters:
assertion- the responsecontext- the validation context- Returns:
- a validation result
-
getResponseIssueInstant
Gets theRESPONSE_ISSUE_INSTANTsetting.- Parameters:
context- the context- Returns:
- the response issue instant, or null if it is not set
-
validateIssuer
Ensures that theIssuerelement is present and matches the expected issuer (if set in the context under theCoreValidatorParameters.EXPECTED_ISSUERkey).- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- a validation result
-
validateHolderOfKeyRequirement
protected ValidationResult validateHolderOfKeyRequirement(Assertion assertion, ValidationContext context) Performs initial validation concerning the Holder-of-key WebSSO Profile. The method checks that if the request was sent to an IdP HoK-endpoint, we verify that the SP received the response on an endpoint dedicated for HoK.The method also sets the dynamic validation parameter
HOK_PROFILE_ACTIVE.- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- a validation result
-
validateSubject
Validates theSubjectelement of the assertion. The default implementation returnsValidationResult.VALIDif there is noSubjectelement since it is optional according to the SAML 2.0 Core specifications.- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- a validation result
-
validateSubjectConfirmations
protected ValidationResult validateSubjectConfirmations(Assertion assertion, List<SubjectConfirmation> subjectConfirmations, ValidationContext context) Validates the subject confirmations and for the one that is confirmed, it is saved in the validation context under theSAML2AssertionValidationParameters.CONFIRMED_SUBJECT_CONFIRMATIONkey.- Parameters:
assertion- the assertionsubjectConfirmations- the subject confirmationscontext- the validation context- Returns:
- a validation result
-
validateConditions
Validates theConditionselements of the assertion.- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- the validation result
-
validateConditionsTimeBounds
protected ValidationResult validateConditionsTimeBounds(Assertion assertion, ValidationContext context) Validates the NotBefore and NotOnOrAfter Conditions constraints on the assertion.- Parameters:
assertion- the assertion whose conditions will be validatedcontext- current validation context- Returns:
- the result of the validation evaluation
-
validateStatements
Validates the statements of the assertion using the registeredStatementValidatorinstance.- Parameters:
assertion- the assertion to validatecontext- the validation context- Returns:
- validation result
-
getIssuer
Returns the Assertion issuer.- Specified by:
getIssuerin classAbstractSignableObjectValidator<Assertion>- Parameters:
signableObject- the object being verified- Returns:
- the issuer
-
getID
Returns the Assertion ID.- Specified by:
getIDin classAbstractSignableObjectValidator<Assertion>- Parameters:
signableObject- the object being verified- Returns:
- the ID
-
getObjectName
Returns the name of the object being validated, e.g. "Assertion". Used for logging.- Specified by:
getObjectNamein classAbstractSignableObjectValidator<Assertion>- Returns:
- the object name
-