449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings/*
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* The contents of this file are subject to the terms of the Common Development and
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* Distribution License (the License). You may not use this file except in compliance with the
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* License.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings*
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* specific language governing permission and limitations under the License.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings*
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* When distributing Covered Software, include this CDDL Header Notice in each file and include
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* Header, with the fields enclosed by brackets [] replaced by your own identifying
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* information: "Portions copyright [year] [name of copyright owner]".
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings*
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings* Copyright 2015 ForgeRock AS.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings*/
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbingspackage com.sun.identity.saml2.profile;
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbingsimport javax.servlet.http.HttpServletRequest;
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbingsimport javax.servlet.http.HttpServletResponse;
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings/**
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * Interface to describe an object that can check a cookie and then perform SAML2 Redirect based on the result.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings */
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbingspublic interface FederateCookieRedirector {
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings /**
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * Establishes whether or not the SAML2 cookie is set.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings *
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param request the SAML2 request
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param response the saml2 Response
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param isIDP whether this request was from an IDP
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @return true if the cookie is set.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings */
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings boolean isCookieSet(
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings HttpServletRequest request, HttpServletResponse response,
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings boolean isIDP);
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings /**
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * Sets the cookie for the SAML2 Request and redirects the request.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings *
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param request the SAML2 Request object
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param response the SAML2 Resposne object
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param isIDP whether this request was from and idp
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @throws UnableToRedirectException if there was a problem preforming the redirect.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings */
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings void setCookieAndRedirect(HttpServletRequest request, HttpServletResponse response,
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings boolean isIDP) throws UnableToRedirectException;
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings /**
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * Sets the cookie for the SAML2 Request and redirects the request.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings *
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param request the SAML2 Request object
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param response the SAML2 Resposne object
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param isIDP whether this request was from and idp
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings */
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings boolean ifNoCookieIsSetThenSetTheCookieThenRedirectToANewRequestAndReturnTrue(
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings HttpServletRequest request, HttpServletResponse response,
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings boolean isIDP);
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings /**
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * Sets the cookie if required and then redirects the SAML2 request. Returns a boolean to indicate whether the
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * redirect action was taken.
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings *
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param request the SAML2 Request object
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param response the SAML2 Resposne object
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @param isIDP whether this request was from and idp
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings * @return true if the redirect action was performed
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings */
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings boolean needSetLBCookieAndRedirect(
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings HttpServletRequest request, HttpServletResponse response,
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings boolean isIDP);
449854c2a07b50ea64d9d6a8b03d18d4afeeee43Ken Stubbings}