Class AssertionValidator
- java.lang.Object
-
- se.litsec.opensaml.common.validation.AbstractObjectValidator<T>
-
- se.litsec.opensaml.common.validation.AbstractSignableObjectValidator<Assertion>
-
- se.litsec.opensaml.saml2.common.assertion.AssertionValidator
-
- All Implemented Interfaces:
ObjectValidator<Assertion>
public class AssertionValidator extends AbstractSignableObjectValidator<Assertion>
A validator forAssertionobjects.Supports the following
ValidationContextstatic parameters:- The static parameters defined for
AbstractSignableObjectValidator. 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: Optional. If supplied will be used in a number of validations when information from the correspondingAuthnRequestis needed. If not supplied, other, more detailed parameters must be given.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
ValidationContextdynamic parameters:SAML2AssertionValidationParameters.CONFIRMED_SUBJECT_CONFIRMATION: Optional. Will be present after validation if subject confirmation was successfully performed.
Note: Also check the validation context parameters defined by the
SubjectConfirmationValidatorandConditionValidatorinstances that are installed.- Author:
- Martin Lindström (martin.lindstrom@litsec.se)
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<QName,ConditionValidator>conditionValidatorsRegisteredConditionvalidators.static StringRESPONSE_ISSUE_INSTANTCarries aInstantholding the issue instant of the Response that contained the assertion being validated.protected Map<String,SubjectConfirmationValidator>subjectConfirmationValidatorsRegisteredSubjectConfirmationvalidators.-
Fields inherited from class se.litsec.opensaml.common.validation.AbstractSignableObjectValidator
signaturePrevalidator, trustEngine
-
Fields inherited from class se.litsec.opensaml.common.validation.AbstractObjectValidator
DEFAULT_MAX_AGE_RECEIVED_MESSAGE
-
-
Constructor Summary
Constructors Constructor Description AssertionValidator(SignatureTrustEngine trustEngine, SignaturePrevalidator signaturePrevalidator, Collection<SubjectConfirmationValidator> confirmationValidators, Collection<ConditionValidator> conditionValidators, Collection<StatementValidator> statementValidators)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetID(Assertion signableObject)Returns the Assertion ID.protected StringgetIssuer(Assertion signableObject)Returns the Assertion issuer.protected StringgetObjectName()Returns the name of the object being validated, e.g.protected InstantgetResponseIssueInstant(ValidationContext context)Gets theRESPONSE_ISSUE_INSTANTsetting.ValidationResultvalidate(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 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.litsec.opensaml.common.validation.AbstractSignableObjectValidator
getSignatureValidationCriteriaSet, performSignatureValidation, validateSignature
-
Methods inherited from class se.litsec.opensaml.common.validation.AbstractObjectValidator
getAllowedClockSkew, getMaxAgeReceivedMessage, getReceiveInstant, isStrictValidation
-
-
-
-
Field Detail
-
RESPONSE_ISSUE_INSTANT
public static final String RESPONSE_ISSUE_INSTANT
Carries aInstantholding the issue instant of the Response that contained the assertion being validated.- See Also:
- Constant Field Values
-
subjectConfirmationValidators
protected Map<String,SubjectConfirmationValidator> subjectConfirmationValidators
RegisteredSubjectConfirmationvalidators.
-
conditionValidators
protected Map<QName,ConditionValidator> conditionValidators
RegisteredConditionvalidators.
-
-
Constructor Detail
-
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 Detail
-
validate
public ValidationResult validate(Assertion assertion, ValidationContext context)
Validates the assertion.- Parameters:
assertion- object to be evaluatedcontext- current validation context- Returns:
- the result of the evaluation
-
validateID
protected ValidationResult validateID(Assertion assertion, ValidationContext context)
Validates that theAssertionobject has an ID attribute.- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- a validation result
-
validateVersion
protected ValidationResult validateVersion(Assertion assertion, ValidationContext context)
Validates that theResponseobject has a valid Version attribute.- Parameters:
assertion- the assertioncontext- the validation context- Returns:
- a validation result
-
validateIssueInstant
protected ValidationResult validateIssueInstant(Assertion assertion, ValidationContext context)
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
protected Instant getResponseIssueInstant(ValidationContext context)
Gets theRESPONSE_ISSUE_INSTANTsetting.- 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 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
-
validateSubject
protected ValidationResult validateSubject(Assertion assertion, ValidationContext context)
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
protected ValidationResult validateConditions(Assertion assertion, ValidationContext context)
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
protected ValidationResult validateStatements(Assertion assertion, ValidationContext context)
Validates the statements of the assertion using the registeredStatementValidatorinstance.- Parameters:
assertion- the assertion to validatecontext- the validation context- Returns:
- validation result
-
getIssuer
protected String getIssuer(Assertion signableObject)
Returns the Assertion issuer.- Specified by:
getIssuerin classAbstractSignableObjectValidator<Assertion>- Parameters:
signableObject- the object being verified- Returns:
- the issuer
-
getID
protected String getID(Assertion signableObject)
Returns the Assertion ID.- Specified by:
getIDin classAbstractSignableObjectValidator<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:
getObjectNamein classAbstractSignableObjectValidator<Assertion>- Returns:
- the object name
-
-