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