Class ServletSaml

java.lang.Object
com.revetsec.servlet.jakarta.ServletSaml

@ThreadSafe public final class ServletSaml extends Object
Thin SAML transport helpers for application-routed Jakarta Servlet endpoints. Core performs binding, signature, pending-state and replay validation; the application owns cookies, sessions and IdP selection. Call these before any servlet parameter parser consumes the body.
Since:
1.0.0
  • Method Details

    • postBindingResultFor

      @CheckReturnValue public static @NonNull SamlPostBindingParseResult postBindingResultFor(@NonNull jakarta.servlet.http.HttpServletRequest request) throws IOException
      Reads the original bounded POST body, at most two Content-Type values, and the raw query. A second occurrence preserves core's duplicate rejection without reading the enumeration tail or accessing the body. Trusted edge/container framing, allocation and time limits still apply.
      Parameters:
      request - application-routed ACS request
      Returns:
      core's untrusted POST-binding parse result
      Throws:
      IOException - if the servlet input stream fails
      Since:
      1.0.0
    • postLogoutBindingResultFor

      @CheckReturnValue public static @NonNull SamlPostBindingParseResult postLogoutBindingResultFor(@NonNull jakarta.servlet.http.HttpServletRequest request) throws IOException
      Reads the original bounded logout POST body, at most two Content-Type values and the raw query. A second occurrence preserves core's duplicate rejection without further header probes or body access. The application supplies browser-bound pending state to core when completing SP logout; a pending cookie for a cross-site POST requires Secure, HttpOnly and SameSite=None.
      Parameters:
      request - application-routed logout POST request
      Returns:
      core's untrusted logout POST-binding parse result
      Throws:
      IOException - if the servlet input stream fails
      Since:
      1.0.0
    • redirectBindingResultFor

      @CheckReturnValue public static @NonNull SamlRedirectBindingParseResult redirectBindingResultFor(@NonNull jakarta.servlet.http.HttpServletRequest request)
      Parses the original HTTP-Redirect query octets for signed logout messages.
      Parameters:
      request - application-routed logout request
      Returns:
      core's untrusted Redirect-binding parse result
      Since:
      1.0.0
    • writeAuthenticationRedirect

      public static void writeAuthenticationRedirect(@NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull SamlAuthenticationRequestResult.Prepared prepared)
      Writes a core-prepared authentication redirect without servlet URL rewriting.
      Parameters:
      response - application-owned response, including any pending cookie
      prepared - core-prepared authentication request
      Since:
      1.0.0
    • writeLogoutRedirect

      public static void writeLogoutRedirect(@NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull SamlLogoutRedirectResult.Prepared prepared)
      Writes a core-prepared SP logout redirect.
      Parameters:
      response - application-owned response
      prepared - core-prepared logout request
      Since:
      1.0.0
    • writeLogoutResponseRedirect

      public static void writeLogoutResponseRedirect(@NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull SamlLogoutResponseRedirectResult.Prepared prepared)
      Writes a core-prepared answer to an IdP logout request.
      Parameters:
      response - application-owned response
      prepared - core-prepared logout response
      Since:
      1.0.0
    • writeLogoutPostForm

      public static void writeLogoutPostForm(@NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull SamlLogoutPostResult.Prepared prepared, @Nullable String cspNonce) throws IOException
      Writes a core-prepared SP logout POST form. Set the browser-bound pending cookie and CSP before delivery; a cross-site POST pending cookie requires Secure, HttpOnly and SameSite=None.
      Parameters:
      response - application-owned response
      prepared - core-prepared logout request
      cspNonce - application-generated CSP nonce, or null for manual submission
      Throws:
      IOException - if the servlet output stream fails
      Since:
      1.0.0
    • writeLogoutResponsePostForm

      public static void writeLogoutResponsePostForm(@NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull SamlLogoutResponsePostResult.Prepared prepared, @Nullable String cspNonce) throws IOException
      Writes a core-prepared POST answer to an IdP logout request. The application sets its CSP.
      Parameters:
      response - application-owned response
      prepared - core-prepared logout response
      cspNonce - application-generated CSP nonce, or null for manual submission
      Throws:
      IOException - if the servlet output stream fails
      Since:
      1.0.0
    • writePostForm

      public static void writePostForm(@NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull SamlPostForm form, @Nullable String cspNonce) throws IOException
      Writes a core-prepared POST form. The application sets its CSP and pending cookie first.
      Parameters:
      response - application-owned response
      form - core-prepared SAML authentication or logout form
      cspNonce - application-generated CSP nonce, or null for manual submission
      Throws:
      IOException - if the servlet output stream fails
      Since:
      1.0.0