4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster The contents of this file are subject to the terms
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster of the Common Development and Distribution License
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster (the License). You may not use this file except in
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster compliance with the License.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster You can obtain a copy of the License at
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster https://opensso.dev.java.net/public/CDDLv1.0.html or
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster See the License for the specific language governing
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster permission and limitations under the License.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster When distributing Covered Code, include this CDDL
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Header Notice in each file and include the License file
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster If applicable, add the following below the CDDL Header,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster with the fields enclosed by brackets [] replaced by
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster your own identifying information:
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster "Portions Copyrighted [year] [name of copyright owner]"
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster $Id: configure.jsp,v 1.6 2008/11/25 23:50:41 exu Exp $
45cbbdf2c42e20970c2539ba6cc4b94c2599c3d7Kohei Tamura Portions Copyrighted 2012 ForgeRock Inc
45cbbdf2c42e20970c2539ba6cc4b94c2599c3d7Kohei Tamura Portions Copyrighted 2012 Open Source Solution Technology Corporation
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<title>Configure Identity Provider</title>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<link rel="stylesheet" type="text/css" href="../../../com_sun_web_ui/css/css_ns6up.css" />
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String errorMsg = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<%@ include file="../util.jspf" %>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster import="com.sun.identity.federation.meta.IDFFMetaManager,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.multiprotocol.SingleLogoutManager,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.saml2.meta.SAML2MetaException,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (localAuthUrl != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster out.println("<script language=\"Javascript\">");
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster out.println("top.location.replace('" + localAuthUrl + "');");
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster boolean configured = false;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String hostedIDPEntityID = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String remoteSPEntityID = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String SAMPLE_COT_NAME = "samplemultiprotocolcot";
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String gotoURL = request.getRequestURL().toString();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String redirectURL = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster gotoURL = gotoURL + "?" + request.getQueryString();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((localAuthUrl == null) && (errorMsg == null)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String spBaseUrl = request.getParameter(SP_BASE_URL);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String fedProtocol = request.getParameter(PROTOCOL_PARAM_NAME);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster hostedIDPEntityID = baseURL.trim() + "/" + SAMPLE_PREFIX +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster fedProtocol + IDP_SUFFIX;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((spBaseUrl != null) && (fedProtocol != null)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster fedProtocol = fedProtocol.trim();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((spBaseUrl.length() > 0) && (fedProtocol.length() > 0)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster remoteSPEntityID = spBaseUrl + "/" + SAMPLE_PREFIX +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster fedProtocol + SP_SUFFIX;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster redirectURL = spBaseUrl +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster "/samples/multiprotocol/sp/configurationDone.jsp?" +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster STATUS + "=success";
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (fedProtocol.equals(SingleLogoutManager.SAML2)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster configureSAML2IdentityProvider(hostedIDPEntityID,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster remoteSPEntityID, request);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster configured = true;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster } else if (fedProtocol.equals(SingleLogoutManager.IDFF)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster configureIDFFIdentityProvider(hostedIDPEntityID,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster remoteSPEntityID, request);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster configured = true;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster } else if (fedProtocol.equals(SingleLogoutManager.WS_FED)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster configureWSFedIdentityProvider(hostedIDPEntityID,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster remoteSPEntityID, request);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster configured = true;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster errorMsg = "Invalid federation protocol " + fedProtocol;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster } catch (Exception clie) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster errorMsg = "Please initialize configuration from a Service Provider";
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<body class="DefBdy">
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<div class="MstDiv"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="MstTblTop" title="">
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<td nowrap="nowrap"> </td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<td nowrap="nowrap"> </td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster</tr></tbody></table>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<table width="100%" border="0" cellpadding="0" cellspacing="0" class="MstTblBot" title="">
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<td class="MstTdTtl" width="99%">
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<div class="MstDivTtl"><img name="ProdName" src="../../../console/images/PrimaryProductName.png" alt="" /></div></td><td class="MstTdLogo" width="1%"><img name="RMRealm.mhCommon.BrandLogo" src="../../../com_sun_web_ui/images/other/javalogo.gif" alt="Java(TM) Logo" border="0" height="55" width="31" /></td></tr></tbody></table>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<table class="MstTblEnd" border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td><img name="RMRealm.mhCommon.EndorserLogo" src="../../../com_sun_web_ui/images/masthead/masthead-sunname.gif" alt="Sun(TM) Microsystems, Inc." align="right" border="0" height="10" width="108" /></td></tr></tbody></table></div><div class="SkpMedGry1"><a name="SkipAnchor2089" id="SkipAnchor2089"></a></div>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<div class="SkpMedGry1"><a href="#SkipAnchor4928"><img src="../../../com_sun_web_ui/images/other/dot.gif" alt="Jump Over Tab Navigation Area. Current Selection is: Access Control" border="0" height="1" width="1" /></a></div>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<table border="0" cellpadding="10" cellspacing="0" width="100%">
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (!loggedIn) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <p> </p>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster You have not logged in to this Identity Provider. Click
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <a href=<%= baseURL + "/UI/Login?goto=" + URLEncoder.encode(gotoURL) %>>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster here</a> to login.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (!configured) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<h3>Configuring this instance as Identity Provider</h3>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster This sample will create and load metadata for a hosted Identity Provider and a remote Service Provider.<br/>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster It will also setup circle of trust for the two providers.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <p> </p>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Please initialize new configuration from a Service Provider.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <p> </p>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <table border=0 cellpadding=5 cellspacing=0>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (errorMsg != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td align="center">
45cbbdf2c42e20970c2539ba6cc4b94c2599c3d7Kohei Tamura <b><font color="red"><%= errorMsg %></font></b>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String saml2IDPEntityID = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String idffIDPEntityID = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String wsfedIDPEntityID = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Set saml2SPEntityIDs = new HashSet();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Set idffSPEntityIDs = new HashSet();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Set wsfedSPEntityIDs = new HashSet();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String REALM = "/";
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster CircleOfTrustManager cotManager = new CircleOfTrustManager();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster CircleOfTrustDescriptor cot = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster cot = cotManager.getCircleOfTrust(REALM, SAMPLE_COT_NAME);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster } catch (Exception e) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster // ignore, as COT might not be exists.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (cot != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Set saml2Provider = cot.getTrustedProviders(SingleLogoutManager.SAML2);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((saml2Provider != null) && !saml2Provider.isEmpty()) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String entityID = (String) it.next();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster SAML2MetaManager mm = SAML2Utils.getSAML2MetaManager();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster config3 = mm.getEntityConfig(REALM, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster idpConfig = mm.getIDPSSOConfig(REALM, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster spConfig = mm.getSPSSOConfig(REALM, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster // hosted provider
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (idpConfig != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster saml2IDPEntityID = config3.getEntityID();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (spConfig != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Set idffProvider = cot.getTrustedProviders(SingleLogoutManager.IDFF);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((idffProvider != null) && !idffProvider.isEmpty()) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String entityID = (String) it.next();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster IDFFMetaManager mm = new IDFFMetaManager(ssoToken);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster config2 = mm.getEntityConfig(REALM, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster idpConfig = mm.getIDPDescriptorConfig(REALM, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster spConfig = mm.getSPDescriptorConfig(REALM, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster // hosted provider
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (idpConfig != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster idffIDPEntityID = config2.getEntityID();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster // remote provider
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (spConfig != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Set wsfedProviders = cot.getTrustedProviders(SingleLogoutManager.WS_FED);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((wsfedProviders != null) && !wsfedProviders.isEmpty()) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String entityID = (String) it.next();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster WSFederationMetaManager wsfedMetaManager = new WSFederationMetaManager();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster config3 = wsfedMetaManager.getEntityConfig(defaultRealm, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.wsfederation.jaxb.entityconfig.IDPSSOConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster idpConfig = wsfedMetaManager.getIDPSSOConfig(defaultRealm, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.wsfederation.jaxb.entityconfig.SPSSOConfigElement
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster spConfig = wsfedMetaManager.getSPSSOConfig(defaultRealm, entityID);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster // hosted provider
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (idpConfig != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster wsfedIDPEntityID = config3.getFederationID();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster // remote provider
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (spConfig != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster wsfedSPEntityIDs.add(config3.getFederationID());
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((saml2IDPEntityID != null) || (idffIDPEntityID != null) ||
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster (wsfedIDPEntityID != null)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Current Protocol Configured:<br/><p>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <table border=2 cellpadding=5 cellspacing=0>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td><b>Protocol</b></td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td><b>Hosted Identity Provider ID</b></td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td><b>Remote Service provider ID</b></td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (saml2IDPEntityID != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td>SAML2</td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td><%= saml2IDPEntityID %></td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String spID = (String) it.next();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <%= spID %><br/>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (idffIDPEntityID != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td>ID-FF</td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td><%= idffIDPEntityID %></td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String spID = (String) it.next();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <%= spID %><br/>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (wsfedIDPEntityID != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td>WS-Federation</td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <td><%= wsfedIDPEntityID %></td>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String spID = (String) it.next();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster <%= spID %><br/>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster No federation protocol configured for this sample yet.<br/>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster</td></tr></table>