proxyidpfinder.jsp revision 5fac30369015c5145d91de0ada477350ede05fd4
3853N/A<%--
3853N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3853N/A
3853N/A Copyright (c) 2010-2014 ForgeRock AS. All Rights Reserved.
3853N/A
3853N/A The contents of this file are subject to the terms
3853N/A of the Common Development and Distribution License
3853N/A (the License). You may not use this file except in
3853N/A compliance with the License.
3853N/A
3853N/A You can obtain a copy of the License at
3853N/A http://forgerock.org/license/CDDLv1.0.html
3853N/A See the License for the specific language governing
3853N/A permission and limitations under the License.
3853N/A
3853N/A When distributing Covered Code, include this CDDL
3853N/A Header Notice in each file and include the License file
3853N/A at http://forgerock.org/license/CDDLv1.0.html
3853N/A If applicable, add the following below the CDDL Header,
3853N/A with the fields enclosed by brackets [] replaced by
3853N/A your own identifying information:
3853N/A "Portions Copyrighted [year] [name of copyright owner]"
3853N/A--%>
3853N/A
5035N/A<%@ page import="com.sun.identity.shared.encode.Base64" %>
3853N/A<%@ page import="com.sun.identity.saml2.common.SAML2Constants" %>
3853N/A<%@ page import="com.sun.identity.saml2.common.SAML2Utils" %>
3853N/A<%@ page import="org.owasp.esapi.ESAPI"%>
3853N/A<%@ page import="org.apache.commons.lang.StringUtils"%>
3853N/A<%@ page import="java.util.List" %>
3853N/A
3853N/A<html>
3853N/A <head>
3853N/A <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
3853N/A <title>IdP Selection</title>
3853N/A </head>
3853N/A <body>
3853N/A <%
5035N/A List idpList = null;
3853N/A String errorURL = "idpfinderError.html";
3853N/A String samlIdP = "";
3853N/A String relayState = "";
3853N/A String idpListSt = "";
3853N/A List<String> requestedAuthnContext;
3853N/A
3853N/A HttpSession hts = request.getSession();
3853N/A if (hts == null) {
3853N/A %>
3853N/A <jsp:forward page="<%= errorURL %>" />
3853N/A
3853N/A <%
3853N/A }
3853N/A String [] lista = null;
3853N/A idpListSt = (String) hts.getAttribute("_IDPLIST_");
3853N/A if (idpListSt != null && !idpListSt.isEmpty()) {
3853N/A lista = idpListSt.split(" ");
3853N/A } else {
3853N/A %>
3853N/A <jsp:forward page="<%= errorURL %>" />
3853N/A <%
3853N/A }
3853N/A
3853N/A relayState = (String) hts.getAttribute("_RELAYSTATE_");
3853N/A if (relayState == null || relayState.isEmpty() ||
3853N/A !SAML2Utils.isRelayStateURLValid(request, relayState, SAML2Constants.IDP_ROLE)) {
3853N/A %>
3853N/A <jsp:forward page="<%= errorURL %>" />
3853N/A <%
3853N/A }
3853N/A
3853N/A requestedAuthnContext = (List<String>) hts.getAttribute("_REQAUTHNCONTEXT_");
3853N/A if (requestedAuthnContext != null && requestedAuthnContext.isEmpty()) {
3853N/A %>
3853N/A <jsp:forward page="<%= errorURL %>" />
3853N/A <%
3853N/A }
3853N/A
3853N/A String spRequester = (String) hts.getAttribute("_SPREQUESTER_");
3853N/A if (spRequester == null) response.sendRedirect(errorURL);
3853N/A if (spRequester.isEmpty()) response.sendRedirect(errorURL);
3853N/A
3853N/A samlIdP = request.getParameter("_saml_idp");
3853N/A if (!ESAPI.validator().isValidInput("HTTP Parameter Value: " + samlIdP, samlIdP,
3853N/A "HTTPParameterValue", 2000, true)){
3853N/A samlIdP = null;
3853N/A }
3853N/A
3853N/A if (samlIdP != null && !samlIdP.isEmpty()) {
3853N/A 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 <%= requestedAuthnContext == null ? "<b>default</b> " : "" %>Assurance level <b><%= requestedAuthnContext != null ? StringUtils.join(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>