Class SamlAssertionValidator.Builder
- Enclosing class:
- SamlAssertionValidator
SamlAssertionValidator.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalgorithms(String... values) Replaces the default signature-algorithm allowlist with the supplied URIs.build()Builds the validator.Overrides theClockused for timestamp validation.Sets the clock-skew tolerance forNotBefore/NotOnOrAftervalidation.decryptionCredential(org.opensaml.security.credential.Credential value) Sets the credential used to decrypt<EncryptedAssertion>elements.digestAlgorithms(String... values) Replaces the default reference-digest allowlist with the supplied URIs.expectedInResponseTo(String value) Sets the request ID a bearer<SubjectConfirmationData>must echo in itsInResponseToattribute.expectedIssuer(String value) Sets the expected IdP issuer (the<Issuer>element).metadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver value) Sets theMetadataResolverused to resolve the IdP's signing credential at validation time.Sets the expectedRecipient(this SP's Assertion Consumer Service URL) and, by doing so, enables bearer<SubjectConfirmation>validation.replayCache(ReplayCache value) Overrides theReplayCacheused to enforce one-time use of each assertion ID.signingCredential(org.opensaml.security.credential.Credential value) Sets a static IdP signing credential.spEntityId(String value) Sets the Service Provider entity ID used to validate<AudienceRestriction>.subjectAddress(String value) Sets the client address a bearer<SubjectConfirmationData>must name in itsAddressattribute.
-
Constructor Details
-
Builder
protected Builder()Constructor.
-
-
Method Details
-
metadataResolver
public SamlAssertionValidator.Builder metadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver value) Sets theMetadataResolverused to resolve the IdP's signing credential at validation time.Mutually exclusive with
signingCredential(Credential).- Parameters:
value- The metadata resolver. Must not benull .- Returns:
- This object.
-
signingCredential
public SamlAssertionValidator.Builder signingCredential(org.opensaml.security.credential.Credential value) Sets a static IdP signing credential. Useful when metadata is not available.Mutually exclusive with
metadataResolver(MetadataResolver).- Parameters:
value- The IdP signing credential. Must not benull .- Returns:
- This object.
-
decryptionCredential
public SamlAssertionValidator.Builder decryptionCredential(org.opensaml.security.credential.Credential value) Sets the credential used to decrypt<EncryptedAssertion>elements.If the response contains encrypted assertions and no decryption credential is configured, validation fails with
AuthenticationException.- Parameters:
value- The SP decryption credential. Must not benull .- Returns:
- This object.
-
spEntityId
Sets the Service Provider entity ID used to validate<AudienceRestriction>.- Parameters:
value- The SP entity ID. Must not benull or blank.- Returns:
- This object.
-
expectedIssuer
Sets the expected IdP issuer (the<Issuer>element). Required.- Parameters:
value- The expected IdP entity ID. Must not benull or blank.- Returns:
- This object.
-
algorithms
Replaces the default signature-algorithm allowlist with the supplied URIs.SHA-1 algorithms are silently filtered out (permanent rejection).
- Parameters:
values- The XML-DSig algorithm URIs to allow. Must contain at least one non-SHA-1 entry.- Returns:
- This object.
-
digestAlgorithms
Replaces the default reference-digest allowlist with the supplied URIs.The reference
DigestMethodof the enveloped signature must appear in this set. SHA-1 algorithms are silently filtered out (permanent rejection), mirroringalgorithms(String...).- Parameters:
values- The XML-DSig digest algorithm URIs to allow. Must contain at least one non-SHA-1 entry.- Returns:
- This object.
-
recipient
Sets the expectedRecipient(this SP's Assertion Consumer Service URL) and, by doing so, enables bearer<SubjectConfirmation>validation.When set, every validated assertion must carry a
bearer<SubjectConfirmation>whose<SubjectConfirmationData>names this exactRecipient, is within itsNotBefore/NotOnOrAfterwindow, and satisfies theexpectedInResponseTo(String)/subjectAddress(String)expectations. When left unset (the default), subject-confirmation validation is skipped for calls toSamlAssertionValidator.validate(String)— safe only for assertion-only / non-browser callers. A validator reached throughSamlAuthFilterenforces bearer confirmation regardless of this setting, since the filter derives the recipient from the request and callsSamlAssertionValidator.validate(String, String).- Parameters:
value- The expected ACS URL. Must not benull or blank.- Returns:
- This object.
-
expectedInResponseTo
Sets the request ID a bearer<SubjectConfirmationData>must echo in itsInResponseToattribute.Only consulted when
recipient(String)is configured. When set, the confirmation'sInResponseTomust equal this value (a solicited, SP-initiated flow). When left unset (the default), the confirmation must not carry anInResponseToat all (an unsolicited, IdP-initiated flow) — a captured solicited assertion cannot be injected into the unsolicited path.- Parameters:
value- The expected request ID. Must not benull or blank.- Returns:
- This object.
-
subjectAddress
Sets the client address a bearer<SubjectConfirmationData>must name in itsAddressattribute.Only consulted when
recipient(String)is configured. When set, the confirmation'sAddressmust equal this value; when unset (the default) theAddressattribute is not checked.- Parameters:
value- The expected client address. Must not benull or blank.- Returns:
- This object.
-
replayCache
Overrides theReplayCacheused to enforce one-time use of each assertion ID.Defaults to a per-process
InMemoryReplayCache, which enforces single-use within one JVM. Multi-node deployments should inject aReplayCachebacked by a store shared across every node so an assertion consumed against one node cannot be replayed against another. The check is always fail-closed: a cache that cannot answer causes the assertion to be rejected.- Parameters:
value- The replay cache. Must not benull .- Returns:
- This object.
-
clockSkew
Sets the clock-skew tolerance forNotBefore/NotOnOrAftervalidation.- Parameters:
value- The tolerance. Must be non-negative and not exceed 5 minutes.- Returns:
- This object.
-
clock
Overrides theClockused for timestamp validation. Useful in tests.- Parameters:
value- The clock. Must not benull .- Returns:
- This object.
-
build
Builds the validator.- Returns:
- A new
SamlAssertionValidator.
-