Class AssertionValidator

All Implemented Interfaces:
ObjectValidator<Assertion>

public class AssertionValidator extends AbstractSignableObjectValidator<Assertion>
A validator for Assertion objects.

Supports the following ValidationContext static parameters:

Supports the following ValidationContext dynamic parameters:

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 Details

  • Constructor Details

  • Method Details

    • validate

      public ValidationResult validate(Assertion assertion, ValidationContext context)
      Validates the assertion.
      Parameters:
      assertion - object to be evaluated
      context - current validation context
      Returns:
      the result of the evaluation
    • validateID

      protected ValidationResult validateID(Assertion assertion, ValidationContext context)
      Validates that the Assertion object has an ID attribute.
      Parameters:
      assertion - the assertion
      context - the validation context
      Returns:
      a validation result
    • validateVersion

      protected ValidationResult validateVersion(Assertion assertion, ValidationContext context)
      Validates that the Response object has a valid Version attribute.
      Parameters:
      assertion - the assertion
      context - the validation context
      Returns:
      a validation result
    • validateIssueInstant

      protected ValidationResult validateIssueInstant(Assertion assertion, ValidationContext context)
      Validates that the Assertion object has a IssueInstant attribute and checks that its value is OK. If the response that contained the assertion was previously validated the static context parameter RESPONSE_ISSUE_INSTANT should 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 the CoreValidatorParameters.MAX_AGE_MESSAGE and CoreValidatorParameters.RECEIVE_INSTANT context parameters.
      Parameters:
      assertion - the response
      context - the validation context
      Returns:
      a validation result
    • getResponseIssueInstant

      protected Instant getResponseIssueInstant(ValidationContext context)
      Gets the RESPONSE_ISSUE_INSTANT setting.
      Parameters:
      context - the context
      Returns:
      the response issue instant, or null if it is not set
    • validateIssuer

      protected ValidationResult validateIssuer(Assertion assertion, ValidationContext context)
      Ensures that the Issuer element is present and matches the expected issuer (if set in the context under the CoreValidatorParameters.EXPECTED_ISSUER key).
      Parameters:
      assertion - the assertion
      context - 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 assertion
      context - the validation context
      Returns:
      a validation result
    • validateSubject

      protected ValidationResult validateSubject(Assertion assertion, ValidationContext context)
      Validates the Subject element of the assertion. The default implementation returns ValidationResult.VALID if there is no Subject element since it is optional according to the SAML 2.0 Core specifications.
      Parameters:
      assertion - the assertion
      context - 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 the SAML2AssertionValidationParameters.CONFIRMED_SUBJECT_CONFIRMATION key.
      Parameters:
      assertion - the assertion
      subjectConfirmations - the subject confirmations
      context - the validation context
      Returns:
      a validation result
    • validateConditions

      protected ValidationResult validateConditions(Assertion assertion, ValidationContext context)
      Validates the Conditions elements of the assertion.
      Parameters:
      assertion - the assertion
      context - 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 validated
      context - current validation context
      Returns:
      the result of the validation evaluation
    • validateStatements

      protected ValidationResult validateStatements(Assertion assertion, ValidationContext context)
      Validates the statements of the assertion using the registered StatementValidator instance.
      Parameters:
      assertion - the assertion to validate
      context - the validation context
      Returns:
      validation result
    • getIssuer

      protected String getIssuer(Assertion signableObject)
      Returns the Assertion issuer.
      Specified by:
      getIssuer in class AbstractSignableObjectValidator<Assertion>
      Parameters:
      signableObject - the object being verified
      Returns:
      the issuer
    • getID

      protected String getID(Assertion signableObject)
      Returns the Assertion ID.
      Specified by:
      getID in class AbstractSignableObjectValidator<Assertion>
      Parameters:
      signableObject - the object being verified
      Returns:
      the ID
    • getObjectName

      protected String getObjectName()
      Returns the name of the object being validated, e.g. "Assertion". Used for logging.
      Specified by:
      getObjectName in class AbstractSignableObjectValidator<Assertion>
      Returns:
      the object name