fedletAttrResp.jsp revision e8721886dbfd32e88cc7077cbee4b6bb1b44b443
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson The contents of this file are subject to the terms
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User of the Common Development and Distribution License
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein (the License). You may not use this file except in
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User compliance with the License.
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User You can obtain a copy of the License at
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson https://opensso.dev.java.net/public/CDDLv1.0.html or
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein See the License for the specific language governing
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein permission and limitations under the License.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User When distributing Covered Code, include this CDDL
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Header Notice in each file and include the License file
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User If applicable, add the following below the CDDL Header,
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User with the fields enclosed by brackets [] replaced by
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein your own identifying information:
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User "Portions Copyrighted [year] [name of copyright owner]"
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User $Id: fedletAttrResp.jsp,v 1.2 2009/07/24 22:53:20 madan_ranganath Exp $
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User Copyright 2009 Sun Microsystems Inc. All Rights Reserved
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This JSP used by the Fedlet performs the following:
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User 1) Retrieves the list of attributes from fedletAttrQuery.jsp
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein 2) Invokes the method to retrieve the attribute values
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein 3) Displays the attribute value pairs.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.shared.debug.Debug" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.saml.common.SAMLUtils" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.saml2.assertion.Assertion" %>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<%@ page import="com.sun.identity.saml2.assertion.AssertionFactory" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.saml2.assertion.Attribute" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.saml2.assertion.NameID" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.saml2.common.SAML2Constants" %>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<%@ page import="com.sun.identity.saml2.common.SAML2Utils" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.saml2.common.SAML2Exception" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="com.sun.identity.saml2.profile.AttributeQueryUtil" %>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<%@ page import="com.sun.identity.saml2.protocol.Response" %>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<%@ page import="java.util.ArrayList" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="java.util.Date" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="java.util.HashMap" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="java.util.Iterator" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<%@ page import="java.util.List" %>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<%@ page import="java.util.Map" %>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String deployuri = request.getRequestURI();
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User int slashLoc = deployuri.indexOf("/", 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (slashLoc != -1) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein deployuri = deployuri.substring(0, slashLoc);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User <title>Sample Fedlet Attribute Query Application</title>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <link rel="stylesheet" type="text/css" href="<%= deployuri %>/com_sun_web_ui/css/css_ns6up.css" />
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<div class="MstDiv"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="MstTblTop" title="">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td nowrap="nowrap"> </td>
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User<td nowrap="nowrap"> </td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</tr></tbody></table>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<table width="100%" border="0" cellpadding="0" cellspacing="0" class="MstTblBot" title="">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td class="MstTdTtl" width="99%">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<div class="MstDivTtl"><img name="ProdName" src="<%= deployuri %>/console/images/PrimaryProductName.png" alt="" /></div></td><td class="MstTdLogo" width="1%"><img name="RMRealm.mhCommon.BrandLogo" src="<%= deployuri %>/com_sun_web_ui/images/other/javalogo.gif" alt="Java(TM) Logo" border="0" height="55" width="31" /></td></tr></tbody></table>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<table class="MstTblEnd" border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td><img name="RMRealm.mhCommon.EndorserLogo" src="<%= deployuri %>/com_sun_web_ui/images/masthead/masthead-sunname.gif" alt="Sun(TM) Microsystems,
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox UserInc." align="right" border="0" height="10" width="108" /></td></tr></tbody></table></div><div class="SkpMedGry1"><a name="SkipAnchor2089" id="SkipAnchor2089"></a></div>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<div class="SkpMedGry1"><a href="#SkipAnchor4928"><img src="<%= deployuri %>/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>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String idpEntityID = request.getParameter("idpEntityID");
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User if ((idpEntityID == null) ||
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein SAML2Utils.bundle.getString("nullIDPEntityID"));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String spEntityID = request.getParameter("spEntityID");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if ((spEntityID == null) ||
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein SAML2Utils.bundle.getString("nullSPEntityID"));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String nameIDValue = request.getParameter("nameidvalue");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String newNameIDValue = nameIDValue.replace("%2F","/");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein AssertionFactory assertionFactory = AssertionFactory.getInstance();
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User List attrsList = new ArrayList();
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User if (request.getParameter("attr1").length() > 1 |
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User request.getParameter("attr2").length() > 1 |
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein request.getParameter("attr3").length() > 1) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (request.getParameter("attr1").length() > 1) {
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User if (request.getParameter("attr2").length() > 1) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (request.getParameter("attr3").length()>1) {
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User attrsList.add(request.getParameter("attr3"));
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User } catch (Exception e){
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User out.print("Requesting all available IDP attributes");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String attrQueryProfile = request.getParameter("attrQueryProfile");
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User String subjectDN = request.getParameter("subjectDN");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Map attrMap = AttributeQueryUtil.getAttributeMapForFedlet(
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein newNameIDValue,
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User attrQueryProfile,
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<h2> Fedlet Attribute Query Response </h2>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<table border="2" cellspacing="0" cellpadding="7">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<th>Attribute Query</th>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<th>Attribute Response</th>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein Iterator itr = attrMap.entrySet().iterator();
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String attrKey = (String)pairs.getKey();
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein out.println(attrKey + "<br>");
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein String attrValue = (String)pairs.getValue();
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein out.println(attrValue + "<br>");
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User } catch (Exception ex) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein SAML2Utils.debug.error("Error sending AttributeQuery " , ex);