spMNIRequestInit.jsp revision 0e107349d3f7763a9c67fb2f32c86c11364c72cf
0N/A<%--
2362N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0N/A
0N/A Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
0N/A
0N/A The contents of this file are subject to the terms
2362N/A of the Common Development and Distribution License
0N/A (the License). You may not use this file except in
2362N/A compliance with the License.
0N/A
0N/A You can obtain a copy of the License at
0N/A https://opensso.dev.java.net/public/CDDLv1.0.html or
0N/A opensso/legal/CDDLv1.0.txt
0N/A See the License for the specific language governing
0N/A permission and limitations under the License.
0N/A
0N/A When distributing Covered Code, include this CDDL
0N/A Header Notice in each file and include the License file
0N/A at opensso/legal/CDDLv1.0.txt.
0N/A If applicable, add the following below the CDDL Header,
2362N/A with the fields enclosed by brackets [] replaced by
2362N/A your own identifying information:
2362N/A "Portions Copyrighted [year] [name of copyright owner]"
0N/A
0N/A $Id: spMNIRequestInit.jsp,v 1.12 2009/10/15 00:00:41 exu Exp $
0N/A
0N/A--%>
0N/A
0N/A<%--
0N/A Portions Copyrighted 2013-2014 ForgeRock AS
0N/A--%>
0N/A
0N/A<%@ page import="com.sun.identity.federation.common.FSUtils" %>
0N/A<%@ page import="com.sun.identity.saml2.common.SAML2Constants" %>
0N/A<%@ page import="com.sun.identity.saml2.common.SAML2Utils" %>
0N/A<%@ page import="com.sun.identity.saml.common.SAMLUtils" %>
0N/A<%@ page import="com.sun.identity.saml2.common.SAML2Exception" %>
0N/A<%@ page import="com.sun.identity.saml2.meta.SAML2MetaManager" %>
0N/A<%@ page import="com.sun.identity.saml2.meta.SAML2MetaUtils" %>
0N/A<%@ page import="com.sun.identity.saml2.profile.DoManageNameID" %>
0N/A<%@ page import="java.util.HashMap" %>
0N/A<%@ page import="org.owasp.esapi.ESAPI" %>
0N/A
0N/A<%--
0N/A idpMNIRequestInit.jsp initiates the ManageNameIDRequest at
0N/A the Identity Provider.
0N/A Required parameters to this jsp are :
0N/A - metaAlias - identifier for Service Provider
0N/A - idpEntityID - identifier for Identity Provider
0N/A - requestType - the request type of ManageNameIDRequest (Terminate / NewID)
0N/A
0N/A Somce of the other optional parameters are :
0N/A - relayState - the target URL on successful complete of the Request
0N/A
0N/A Check the SAML2 Documentation for supported parameters.
0N/A
0N/A--%>
0N/A
0N/A<%
0N/A // Retreive the Request Query Parameters
0N/A // metaAlias, idpEntiyID and RequestType are the required query parameters
0N/A // metaAlias - Hosted Entity Id
0N/A // idpEntityID - Identity Provider Identifier
0N/A // requestType - the request type of ManageNameIDRequest (Terminate / NewID)
0N/A // affiliationID - affiliation entity ID
0N/A // Query parameters supported will be documented.
0N/A
0N/A if (FSUtils.needSetLBCookieAndRedirect(request, response, false)) {
0N/A return;
0N/A }
0N/A
try {
String metaAlias = request.getParameter("metaAlias");
if ((metaAlias == null) || (metaAlias.length() == 0)) {
SAMLUtils.sendError(request, response, response.SC_BAD_REQUEST,
"nullIDPEntityID",
SAML2Utils.bundle.getString("nullIDPEntityID"));
return;
}
String idpEntityID = request.getParameter("idpEntityID");
if ((idpEntityID == null) || (idpEntityID.length() == 0)) {
SAMLUtils.sendError(request, response, response.SC_BAD_REQUEST,
"nullIDPEntityID",
SAML2Utils.bundle.getString("nullIDPEntityID"));
return;
}
String binding = DoManageNameID.getMNIBindingInfo(request, metaAlias,
SAML2Constants.SP_ROLE, idpEntityID);
SAML2MetaManager metaManager= new SAML2MetaManager();
String hostEntity = metaManager.getEntityByMetaAlias(metaAlias);
String realm = SAML2MetaUtils.getRealmByMetaAlias(metaAlias);
if (!SAML2Utils.isSPProfileBindingSupported(
realm, hostEntity, SAML2Constants.MNI_SERVICE, binding))
{
SAMLUtils.sendError(request, response, response.SC_BAD_REQUEST,
"unsupportedBinding",
SAML2Utils.bundle.getString("unsupportedBinding"));
return;
}
String requestType = request.getParameter("requestType");
if ((requestType == null) || (requestType.length() == 0)) {
SAMLUtils.sendError(request, response, response.SC_BAD_REQUEST,
"nullRequestType",
SAML2Utils.bundle.getString("nullRequestType"));
return;
}
String relayState = request.getParameter(SAML2Constants.RELAY_STATE);
if (!ESAPI.validator().isValidInput("HTTP Query String: " + relayState, relayState, "HTTPQueryString", 2000, true)) {
relayState = null;
}
if ((relayState == null) || (relayState.isEmpty())) {
relayState = SAML2Utils.getAttributeValueFromSSOConfig(
realm, hostEntity, SAML2Constants.SP_ROLE,
SAML2Constants.DEFAULT_RELAY_STATE);
}
String affiliationID =
request.getParameter(SAML2Constants.AFFILIATION_ID);
HashMap paramsMap = new HashMap();
paramsMap.put("metaAlias", metaAlias);
paramsMap.put("idpEntityID", idpEntityID);
paramsMap.put("requestType", requestType);
paramsMap.put(SAML2Constants.ROLE, SAML2Constants.SP_ROLE);
paramsMap.put(SAML2Constants.BINDING, binding);
if (relayState != null && !relayState.isEmpty()) {
paramsMap.put(SAML2Constants.RELAY_STATE, relayState);
}
if (affiliationID != null) {
paramsMap.put(SAML2Constants.AFFILIATION_ID, affiliationID);
}
Object sess = SAML2Utils.checkSession(request,response,
metaAlias, paramsMap);
if (sess == null) {
return;
}
DoManageNameID.initiateManageNameIDRequest(request,response,
metaAlias, idpEntityID, paramsMap);
if (binding.equalsIgnoreCase(SAML2Constants.SOAP)) {
if (relayState != null && !relayState.isEmpty() &&
SAML2Utils.isRelayStateURLValid(request, relayState, SAML2Constants.SP_ROLE) &&
ESAPI.validator().isValidInput("HTTP URL Value: " + relayState, relayState, "URL", 2000, true)) {
response.sendRedirect(relayState);
} else {
%>
<jsp:forward page="/saml2/jsp/default.jsp?message=mniSuccess" />
<%
}
}
} catch (SAML2Exception e) {
SAML2Utils.debug.error("Error sending ManageNameIDRequest " , e);
SAMLUtils.sendError(request, response, response.SC_BAD_REQUEST,
"requestProcessingMNIError",
SAML2Utils.bundle.getString("requestProcessingMNIError") + " " +
e.getMessage());
return;
}
%>