proxyidpfinder.jsp revision e8721886dbfd32e88cc7077cbee4b6bb1b44b443
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews Copyright (c) 2010 ForgeRock AS. All Rights Reserved.
dd750c560ae48cf6caeb9a9fe81d33fc4746106dBrian Wellington The contents of this file are subject to the terms
dd750c560ae48cf6caeb9a9fe81d33fc4746106dBrian Wellington of the Common Development and Distribution License
dd750c560ae48cf6caeb9a9fe81d33fc4746106dBrian Wellington (the License). You may not use this file except in
dd750c560ae48cf6caeb9a9fe81d33fc4746106dBrian Wellington compliance with the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews You can obtain a copy of the License at
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews See the License for the specific language governing
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews permission and limitations under the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews When distributing Covered Code, include this CDDL
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley Header Notice in each file and include the License file
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews If applicable, add the following below the CDDL Header,
dd750c560ae48cf6caeb9a9fe81d33fc4746106dBrian Wellington with the fields enclosed by brackets [] replaced by
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley your own identifying information:
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley "Portions Copyrighted [year] [name of copyright owner]"
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley<%@ page import="com.sun.identity.shared.encode.Base64" %>
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley<%@ page import="com.sun.identity.saml2.common.SAML2Utils" %>
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley<%@ page import="java.util.List" %>
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <title>IdP Selection</title>
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley List idpList = null;
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley String errorURL = "idpfinderError.html";
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley String samlIdP = "";
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley String relayState = "";
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews String idpListSt = "";
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews String requestedAuthnContext ="";
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley HttpSession hts = request.getSession();
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley if (hts == null) {
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <jsp:forward page="<%= errorURL %>" />
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley String [] lista = null;
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley idpListSt = (String) hts.getAttribute("_IDPLIST_");
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley if (idpListSt != null && !idpListSt.isEmpty()) {
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <jsp:forward page="<%= errorURL %>" />
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley relayState = (String) hts.getAttribute("_RELAYSTATE_");
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley if (relayState == null) {
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <jsp:forward page="<%= errorURL %>" />
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <jsp:forward page="<%= errorURL %>" />
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley requestedAuthnContext = (String) hts.getAttribute("_REQAUTHNCONTEXT_");
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley if ( requestedAuthnContext == null) {
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews <jsp:forward page="<%= errorURL %>" />
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews <jsp:forward page="<%= errorURL %>" />
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews String spRequester = (String) hts.getAttribute("_SPREQUESTER_");
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews if (spRequester == null) response.sendRedirect(errorURL);
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews if (spRequester.isEmpty()) response.sendRedirect(errorURL);
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews samlIdP = request.getParameter("_saml_idp");
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews if (samlIdP != null && !samlIdP.isEmpty()) {
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews hts.removeAttribute("_RELAYSTATE_");
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews hts.removeAttribute("_SPREQUESTER_");
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews hts.removeAttribute("_REQAUTHNCONTEXT_");
0ffaee887ff5674b8c3bb0435ae838f641981706Mark Andrews if (relayState.indexOf("?") == -1) {
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley relayState += "?";
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley relayState += "&";
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley response.sendRedirect(relayState + "_saml_idp=" + samlIdP);
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <h2>Welcome to the Federation Broker</h2>
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <p>You are here because you initiated a request in the Service Provider <b><%= spRequester %></b> and
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <br>You asked for the Assurance level <b><%= requestedAuthnContext %></b>:
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <p>Please select your preferred IdP:</p>
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <form action="" method="POST">
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley if (lista != null && lista.length > 0) {
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley for(String preferredIDP : lista) {
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley String preferredIDPB64 = Base64.encode(preferredIDP.getBytes());
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <input type="radio" name="_saml_idp" value="<%= preferredIDPB64 %>"> <%= preferredIDP %>
6ea1b817e31b89a627e146fe69e23ea0a64c89ecBob Halley <p><input type="submit" value="Submit"></p>