Class SADParser.SADValidator
- java.lang.Object
-
- se.litsec.swedisheid.opensaml.saml2.signservice.SADParser.SADValidator
-
-
Constructor Summary
Constructors Constructor Description SADValidator(X509Certificate... certificates)Constructor initializing the validator with a set of certificates that are to be used for JWT signature validation.SADValidator(EntityDescriptor idpMetadata)Creates a SAD validator initialized with the IdPEntityDescriptor(metadata) from which the IdP signing key/certificate will be read (needed for JWT signature validation).SADValidator(MetadataProvider metadataProvider)Constructor creating a SAD validator initialized with aMetadataProviderinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SADvalidate(String sadJwt, String idpEntityID, String expectedRecipientEntityID, String expectedSubject, String expectedLoa, String sadRequestID, int expectedNoDocs, String signRequestID)Validates a SAD based on expected data.SADvalidate(AuthnRequest authnRequest, Assertion assertion)A method that validates the SAD issued in anAssertionbased on theAuthnRequestcontaining aSADRequest.voidverifyJwtSignature(String sadJwt, String idpEntityID)Verifies the signature on the supplied SAD JWT.
-
-
-
Constructor Detail
-
SADValidator
public SADValidator(X509Certificate... certificates)
Constructor initializing the validator with a set of certificates that are to be used for JWT signature validation. These certificates are the IdP signing certificates obtained from the IdP metadata entry.- Parameters:
certificates- certificate(s) to be used when verifying the JWT signature
-
SADValidator
public SADValidator(MetadataProvider metadataProvider)
Constructor creating a SAD validator initialized with aMetadataProviderinstance. During JWT signature validation the IdP signature certificate will be obtained from the IdP metadata entry held by the metadata provider.- Parameters:
metadataProvider- metadata provider
-
SADValidator
public SADValidator(EntityDescriptor idpMetadata)
Creates a SAD validator initialized with the IdPEntityDescriptor(metadata) from which the IdP signing key/certificate will be read (needed for JWT signature validation).- Parameters:
idpMetadata- the IdP metadata
-
-
Method Detail
-
validate
public SAD validate(AuthnRequest authnRequest, Assertion assertion) throws SADValidationException, IllegalArgumentException
A method that validates the SAD issued in anAssertionbased on theAuthnRequestcontaining aSADRequest.- Parameters:
authnRequest- theAuthnRequestholding theSADRequestassertion- theAssertionholding thesadattribute (as a encoded JWT)- Returns:
- a
SADobject, ornullif no SAD was requested (and issued) - Throws:
SADValidationException- for SAD validation errorsIllegalArgumentException- if the suppliedAuthnRequestdoes not contain aSADRequestextension, or is invalid by other means (e.g., missing LoA)- See Also:
validate(String, String, String, String, String, String, int, String)
-
validate
public SAD validate(String sadJwt, String idpEntityID, String expectedRecipientEntityID, String expectedSubject, String expectedLoa, String sadRequestID, int expectedNoDocs, String signRequestID) throws SADValidationException
Validates a SAD based on expected data. If theAuthnRequestand issuedAssertionis available, the methodvalidate(AuthnRequest, Assertion)is a better option.Note: It is assumed that the supplied
expectedSubjectparameter is a attribute value read from the assertion having the attribute name indicated in the 'attr' field of the SAD. If this attribute name is not known in advance, the SAD needs to be parsed (SADParser.parse(String)) so that the 'attr' field can be read, and the correct attribute value be located from the assertion.- Parameters:
sadJwt- the encoded SAD JWT (found in the sad attribute of a received assertion)idpEntityID- the entityID of the issuing IdP (the issuer of the received assertion holding the sad attribute)expectedRecipientEntityID- the entityID of the recipient (the signature service SP that issued the SADRequest)expectedSubject- the expected subject name (user ID). See note aboveexpectedLoa- the expected level of assurance to be found in the SAD (should be the LoA found in the assertion)sadRequestID- the ID of theSADRequestextension that was sent to the IdPexpectedNoDocs- expected number of documents (from theDocCountelement of theSADRequestsignRequestID- ID for theSignRequestthat was included in theSADRequest- Returns:
- a SAD object
- Throws:
SADValidationException- for validation errors
-
verifyJwtSignature
public void verifyJwtSignature(String sadJwt, String idpEntityID) throws SADValidationException
Verifies the signature on the supplied SAD JWT.- Parameters:
sadJwt- the SAD JWTidpEntityID- the entityID of the IdP that signed the JWT- Throws:
SADValidationException- for signature validation errors
-
-