Interface FederateCookieRedirector

  • All Known Implementing Classes:
    UtilProxyCookieRedirector

    public interface FederateCookieRedirector
    Interface to describe an object that can check a cookie and then perform SAML2 Redirect based on the result.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean ifNoCookieIsSetThenSetTheCookieThenRedirectToANewRequestAndReturnTrue​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean isIDP)
      Sets the cookie for the SAML2 Request and redirects the request.
      boolean isCookieSet​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean isIDP)
      Establishes whether the load balancer cookie still has to be added to this request.
      boolean needSetLBCookieAndRedirect​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean isIDP)
      Sets the cookie if required and then redirects the SAML2 request.
      void setCookieAndRedirect​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean isIDP)
      Sets the cookie for the SAML2 Request and redirects the request.
    • Method Detail

      • isCookieSet

        boolean isCookieSet​(jakarta.servlet.http.HttpServletRequest request,
                            jakarta.servlet.http.HttpServletResponse response,
                            boolean isIDP)
        Establishes whether the load balancer cookie still has to be added to this request.

        Note the sense: the only implementation returns true when the cookie is absent and the request is on a multi server platform, matching FSUtils.requireAddCookie(jakarta.servlet.http.HttpServletRequest). The name reads the other way round and is kept for compatibility.

        Parameters:
        request - the SAML2 request
        response - the saml2 Response
        isIDP - whether this request was from an IDP
        Returns:
        true if the request is on a multi server platform and carries no load balancer cookie
      • setCookieAndRedirect

        void setCookieAndRedirect​(jakarta.servlet.http.HttpServletRequest request,
                                  jakarta.servlet.http.HttpServletResponse response,
                                  boolean isIDP)
                           throws UnableToRedirectException
        Sets the cookie for the SAML2 Request and redirects the request.

        A normal return means the caller must stop and write nothing further: either the redirect was performed, or it failed after the response had already been committed, which leaves the caller nothing it can safely do with the response. The exception is raised only while the response is still usable, so that the caller can carry on with it.

        Parameters:
        request - the SAML2 Request object
        response - the SAML2 Resposne object
        isIDP - whether this request was from and idp
        Throws:
        UnableToRedirectException - if no redirect was performed and the caller still owns an uncommitted, usable response. Not an untouched one - the load balancer cookie is added before any of the throw paths, and a failed bounce leaves the sink's no-cache headers behind.
      • ifNoCookieIsSetThenSetTheCookieThenRedirectToANewRequestAndReturnTrue

        boolean ifNoCookieIsSetThenSetTheCookieThenRedirectToANewRequestAndReturnTrue​(jakarta.servlet.http.HttpServletRequest request,
                                                                                      jakarta.servlet.http.HttpServletResponse response,
                                                                                      boolean isIDP)
        Sets the cookie for the SAML2 Request and redirects the request.
        Parameters:
        request - the SAML2 Request object
        response - the SAML2 Resposne object
        isIDP - whether this request was from and idp
        Returns:
        true if the caller must return without writing anything further, see needSetLBCookieAndRedirect(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, boolean).
      • needSetLBCookieAndRedirect

        boolean needSetLBCookieAndRedirect​(jakarta.servlet.http.HttpServletRequest request,
                                           jakarta.servlet.http.HttpServletResponse response,
                                           boolean isIDP)
        Sets the cookie if required and then redirects the SAML2 request. Returns a boolean to indicate whether the caller still owns the response.

        true means the request has been answered and the caller must return without writing anything further. That covers a redirect that was performed, and also a redirect that failed after the response had already been committed - there is nothing the caller can do with a spoiled response but stop.

        Parameters:
        request - the SAML2 Request object
        response - the SAML2 Resposne object
        isIDP - whether this request was from and idp
        Returns:
        true if the caller must return without writing anything further, false if no redirect was needed and the caller still owns a usable response