Class SAML2AssertionValidator
java.lang.Object
com.nimbusds.oauth2.sdk.assertions.saml2.SAML2AssertionValidator
SAML 2.0 assertion validator. Supports RSA signatures and HMAC. Provides
static methods for each validation step for putting together tailored
assertion validation strategies.
-
Constructor Summary
ConstructorsConstructorDescriptionSAML2AssertionValidator
(SAML2AssertionDetailsVerifier detailsVerifier) Creates a new SAML 2.0 assertion validator. -
Method Summary
Modifier and TypeMethodDescriptionGets the SAML 2.0 assertion details verifier.static org.opensaml.saml.saml2.core.Assertion
Parses a SAML 2.0 assertion from the specified XML string.org.opensaml.saml.saml2.core.Assertion
Validates the specified SAML 2.0 assertion.org.opensaml.saml.saml2.core.Assertion
Validates the specified SAML 2.0 assertion.static void
verifySignature
(org.opensaml.xmlsec.signature.Signature signature, Key key) Verifies the specified XML signature (HMAC, RSA or EC) with the provided key.
-
Constructor Details
-
SAML2AssertionValidator
Creates a new SAML 2.0 assertion validator.- Parameters:
detailsVerifier
- The SAML 2.0 assertion details verifier. Must not benull
.
-
-
Method Details
-
getDetailsVerifier
Gets the SAML 2.0 assertion details verifier.- Returns:
- The SAML 2.0 assertion details verifier.
-
parse
Parses a SAML 2.0 assertion from the specified XML string.- Parameters:
xml
- The XML string. Must not benull
.- Returns:
- The SAML 2.0 assertion.
- Throws:
ParseException
- If parsing of the assertion failed.
-
verifySignature
public static void verifySignature(org.opensaml.xmlsec.signature.Signature signature, Key key) throws BadSAML2AssertionException Verifies the specified XML signature (HMAC, RSA or EC) with the provided key.- Parameters:
signature
- The XML signature. Must not benull
.key
- The key to verify the signature. Should be anSecretKey
instance for HMAC,RSAPublicKey
for RSA signatures orECPublicKey
for EC signatures. Must not benull
.- Throws:
BadSAML2AssertionException
- If the key type doesn't match the signature, or the signature is invalid.
-
validate
public org.opensaml.saml.saml2.core.Assertion validate(org.opensaml.saml.saml2.core.Assertion assertion, Issuer expectedIssuer, Key key) throws BadSAML2AssertionException Validates the specified SAML 2.0 assertion.- Parameters:
assertion
- The SAML 2.0 assertion XML. Must not benull
.expectedIssuer
- The expected issuer. Must not benull
.key
- The key to verify the signature. Should be anSecretKey
instance for HMAC,RSAPublicKey
for RSA signatures orECPublicKey
for EC signatures. Must not benull
.- Returns:
- The validated SAML 2.0 assertion.
- Throws:
BadSAML2AssertionException
- If the assertion is invalid.
-
validate
public org.opensaml.saml.saml2.core.Assertion validate(String xml, Issuer expectedIssuer, Key key) throws BadSAML2AssertionException Validates the specified SAML 2.0 assertion.- Parameters:
xml
- The SAML 2.0 assertion XML. Must not benull
.expectedIssuer
- The expected issuer. Must not benull
.key
- The key to verify the signature. Should be anSecretKey
instance for HMAC,RSAPublicKey
for RSA signatures orECPublicKey
for EC signatures. Must not benull
.- Returns:
- The validated SAML 2.0 assertion.
- Throws:
BadSAML2AssertionException
- If the assertion is invalid.
-