Class SamlServiceProvider
java.lang.Object
com.revetsec.saml.SamlServiceProvider
An immutable SAML 2.0 service provider for Redirect or POST login requests, POST assertion
response completion and signed Redirect or POST logout. The application owns browser cookies or pending storage,
account linking and application sessions. The replay cache is supplied explicitly and must
be shared across nodes for a distributed deployment.
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classMutable configuration before creating an immutable SP. -
Method Summary
Modifier and TypeMethodDescriptionacceptLogoutRequestResult(@NonNull SamlPostBindingMessage message, @NonNull SamlIdentityProvider identityProvider) Validates an IdP-initiated POST LogoutRequest whose XML signature covers its exact root.acceptLogoutRequestResult(@NonNull SamlRedirectBindingMessage message, @NonNull SamlIdentityProvider identityProvider) Validates a signed IdP-initiated HTTP-Redirect LogoutRequest.beginAuthenticationResult(@NonNull SamlIdentityProvider identityProvider) Creates one outbound Redirect AuthnRequest with a fresh request ID and RelayState handle.beginAuthenticationResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlAuthenticationRequestOptions options) Begins a Redirect AuthnRequest with explicit freshness, context and application state.beginLogoutResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlSessionReference session) Begins signed SP-initiated front-channel logout for a stored session reference.beginPostAuthenticationResult(@NonNull SamlIdentityProvider identityProvider) Begins a POST-binding AuthnRequest.beginPostAuthenticationResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlAuthenticationRequestOptions options) Begins a POST AuthnRequest with explicit freshness, context and application state.beginPostLogoutResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlSessionReference session) Prepares a signed POST LogoutRequest and browser-bound pending state.completeAuthenticationResult(@NonNull SamlPostBindingMessage message, @NonNull PendingSamlAuthenticationSource pendingSource, @NonNull SamlIdentityProvider identityProvider) Completes an SP-initiated login.completeLogoutResult(@NonNull SamlPostBindingMessage message, @NonNull PendingSamlLogoutSource pendingSource, @NonNull SamlIdentityProvider identityProvider) Completes SP-initiated logout after verifying a POST response's exact-root XML signature.completeLogoutResult(@NonNull SamlRedirectBindingMessage message, @NonNull PendingSamlLogoutSource pendingSource, @NonNull SamlIdentityProvider identityProvider) Completes SP-initiated logout after authenticating browser pending state and the signed IdP Redirect response.completeUnsolicitedAuthenticationResult(@NonNull SamlPostBindingMessage message, @NonNull SamlIdentityProvider identityProvider) Completes an IdP-initiated login only for a connection that explicitly enables it.respondToLogoutRequestResult(@NonNull SamlLogoutRequest request, @NonNull SamlIdentityProvider identityProvider, @NonNull SamlLogoutStatus status) Prepares a signed response after the application has handled a verified IdP-initiated logout request.respondToPostLogoutRequestResult(@NonNull SamlLogoutRequest request, @NonNull SamlIdentityProvider identityProvider, @NonNull SamlLogoutStatus status) Prepares a signed POST response after the application handles a checked IdP logout request.toString()Redacts configuration and keys.withEntityId(@NonNull String entityId) Begins SP configuration with its exact entity ID.
-
Method Details
-
withEntityId
Begins SP configuration with its exact entity ID.- Parameters:
entityId- nonempty SP entity ID, well-formed text of at most 2048 UTF-16 code units- Returns:
- a builder
- Since:
- 1.0.0
-
beginAuthenticationResult
public @NonNull SamlAuthenticationRequestResult beginAuthenticationResult(@NonNull SamlIdentityProvider identityProvider) Creates one outbound Redirect AuthnRequest with a fresh request ID and RelayState handle. Persist its pending state in the initiating browser before sending the redirect.- Parameters:
identityProvider- approved IdP connection- Returns:
- a prepared redirect and pending state, rejection, or unavailability
- Since:
- 1.0.0
-
beginAuthenticationResult
public @NonNull SamlAuthenticationRequestResult beginAuthenticationResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlAuthenticationRequestOptions options) Begins a Redirect AuthnRequest with explicit freshness, context and application state.- Parameters:
identityProvider- approved IdP connectionoptions- request policy sealed into pending state- Returns:
- prepared request and pending state, rejection or unavailability
- Since:
- 1.0.0
-
beginPostAuthenticationResult
public @NonNull SamlAuthenticationRequestResult beginPostAuthenticationResult(@NonNull SamlIdentityProvider identityProvider) Begins a POST-binding AuthnRequest. The returned form contains a signed XML request when this SP has a signing key. Persist pending state before delivering the form page.- Parameters:
identityProvider- approved IdP connection with a POST endpoint- Returns:
- prepared form and pending state, rejection or unavailability
- Since:
- 1.0.0
-
beginPostAuthenticationResult
public @NonNull SamlAuthenticationRequestResult beginPostAuthenticationResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlAuthenticationRequestOptions options) Begins a POST AuthnRequest with explicit freshness, context and application state.- Parameters:
identityProvider- approved IdP connection with a POST endpointoptions- request policy sealed into pending state- Returns:
- prepared form and pending state, rejection or unavailability
- Since:
- 1.0.0
-
completeAuthenticationResult
public @NonNull SamlAuthenticationResult completeAuthenticationResult(@NonNull SamlPostBindingMessage message, @NonNull PendingSamlAuthenticationSource pendingSource, @NonNull SamlIdentityProvider identityProvider) Completes an SP-initiated login. It authenticates the browser's pending record and RelayState before parsing XML. Identity is returned only after a successful atomic replay insertion. The application clears the pending cookie on every terminal outcome. The fixed assertion attribute profile is described bySamlAttribute. An exceeded attribute limit rejects the entire login before replay insertion; store-backed pending state has already been consumed before XML parsing. Start a new login after rejection.- Parameters:
message- opaque POST-binding messagependingSource- pending state received from the initiating browseridentityProvider- approved IdP connection- Returns:
- a result with identity only on success
- Since:
- 1.0.0
-
completeUnsolicitedAuthenticationResult
public @NonNull SamlAuthenticationResult completeUnsolicitedAuthenticationResult(@NonNull SamlPostBindingMessage message, @NonNull SamlIdentityProvider identityProvider) Completes an IdP-initiated login only for a connection that explicitly enables it. RelayState is rejected and never treated as an application return destination. The assertion age is limited to two minutes before skew. The same fixedSamlAttributelimits apply as for an SP-initiated login.- Parameters:
message- POST-binding messageidentityProvider- approved IdP connection- Returns:
- validated identity or a fixed non-success outcome
- Since:
- 1.0.0
-
acceptLogoutRequestResult
public @NonNull SamlLogoutRequestResult acceptLogoutRequestResult(@NonNull SamlRedirectBindingMessage message, @NonNull SamlIdentityProvider identityProvider) Validates a signed IdP-initiated HTTP-Redirect LogoutRequest. A successful result only identifies sessions; the application remains responsible for ending them.- Parameters:
message- parsed raw-query Redirect messageidentityProvider- approved IdP connection- Returns:
- checked logout request or a fixed failure
- Since:
- 1.0.0
-
acceptLogoutRequestResult
public @NonNull SamlLogoutRequestResult acceptLogoutRequestResult(@NonNull SamlPostBindingMessage message, @NonNull SamlIdentityProvider identityProvider) Validates an IdP-initiated POST LogoutRequest whose XML signature covers its exact root. The application matches the checked session fields and ends only matching local sessions.- Parameters:
message- parsed logout form messageidentityProvider- approved IdP connection- Returns:
- checked logout request or a fixed failure
- Since:
- 1.0.0
-
beginLogoutResult
public @NonNull SamlLogoutRedirectResult beginLogoutResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlSessionReference session) Begins signed SP-initiated front-channel logout for a stored session reference. The application saves the returned pending state in the initiating browser and ends its local session before sending the redirect. A missing or failed IdP return never restores that session.- Parameters:
identityProvider- approved IdP connectionsession- checked reference retained with the application session- Returns:
- signed Redirect and pending state, or a fixed failure
- Since:
- 1.0.0
-
completeLogoutResult
public @NonNull SamlLogoutResult completeLogoutResult(@NonNull SamlRedirectBindingMessage message, @NonNull PendingSamlLogoutSource pendingSource, @NonNull SamlIdentityProvider identityProvider) Completes SP-initiated logout after authenticating browser pending state and the signed IdP Redirect response. The application still owns its local session lifecycle.- Parameters:
message- parsed raw-query Redirect messagependingSource- source bound to the initiating browseridentityProvider- approved IdP connection- Returns:
- verified IdP status or a fixed failure
- Since:
- 1.0.0
-
completeLogoutResult
public @NonNull SamlLogoutResult completeLogoutResult(@NonNull SamlPostBindingMessage message, @NonNull PendingSamlLogoutSource pendingSource, @NonNull SamlIdentityProvider identityProvider) Completes SP-initiated logout after verifying a POST response's exact-root XML signature. Invalid signatures or response semantics never consume pending state. POST browser callbacks require SameSite=None; Secure on the application-owned pending cookie. Clear that cookie after a verified terminal status; rejected callbacks do not end a valid pending attempt.- Parameters:
message- parsed logout form messagependingSource- source bound to the initiating browseridentityProvider- approved IdP connection- Returns:
- verified IdP status or a fixed failure
- Since:
- 1.0.0
-
respondToLogoutRequestResult
public @NonNull SamlLogoutResponseRedirectResult respondToLogoutRequestResult(@NonNull SamlLogoutRequest request, @NonNull SamlIdentityProvider identityProvider, @NonNull SamlLogoutStatus status) Prepares a signed response after the application has handled a verified IdP-initiated logout request. The application chooses the status based on its session termination result.- Parameters:
request- checked request returned by this SPidentityProvider- approved IdP connectionstatus- application-selected outcome- Returns:
- signed Redirect or fixed failure
- Since:
- 1.0.0
-
beginPostLogoutResult
public @NonNull SamlLogoutPostResult beginPostLogoutResult(@NonNull SamlIdentityProvider identityProvider, @NonNull SamlSessionReference session) Prepares a signed POST LogoutRequest and browser-bound pending state. Save pending state and end the local session before sending the form; a failed IdP return never restores the session.- Parameters:
identityProvider- approved IdP connectionsession- checked reference retained with the application session- Returns:
- signed POST form and pending state, or a fixed failure
- Since:
- 1.0.0
-
respondToPostLogoutRequestResult
public @NonNull SamlLogoutResponsePostResult respondToPostLogoutRequestResult(@NonNull SamlLogoutRequest request, @NonNull SamlIdentityProvider identityProvider, @NonNull SamlLogoutStatus status) Prepares a signed POST response after the application handles a checked IdP logout request.- Parameters:
request- checked request returned by this SPidentityProvider- approved IdP connectionstatus- application-selected outcome- Returns:
- signed POST form or fixed failure
- Since:
- 1.0.0
-
toString
-