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