947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * Copyright (c) 2013 ForgeRock Inc. All Rights Reserved
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * The contents of this file are subject to the terms
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * of the Common Development and Distribution License
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * (the License). You may not use this file except in
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * See the License for the specific language governing
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * permission and limitations under the License.
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * When distributing Covered Code, include this CDDL
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * Header Notice in each file and include the License file
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * at http://forgerock.org/license/CDDLv1.0.html
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * If applicable, add the following below the CDDL Header,
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * with the fields enclosed by brackets [] replaced by
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs * "Portions Copyrighted [year] [name of copyright owner]"
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs<%@ Page Language="C#" MasterPageFile="~/site.master" %>
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs<%@ Import Namespace="Sun.Identity.Saml2.Exceptions" %>
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs<asp:Content ID="Content1" ContentPlaceHolderID="content" runat="server">
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs ServiceProviderUtility serviceProviderUtility = (ServiceProviderUtility)Cache["spu"];
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs serviceProviderUtility = new ServiceProviderUtility(Context);
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs NameValueCollection parameters = Saml2Utils.GetRequestParameters(Request);
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs string idpEntityId = parameters[Saml2Constants.IdpEntityId];
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs throw new ServiceProviderUtilityException("IDP Entity ID not specified.");
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs else if (String.IsNullOrEmpty(parameters[Saml2Constants.SubjectNameId]))
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs throw new ServiceProviderUtilityException("SubjectNameId not specified.");
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs List<SamlAttribute> attributes = new List<SamlAttribute>();
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs if (!String.IsNullOrEmpty(parameters["attr1"]))
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs attributes.Add(new SamlAttribute(parameters["attr1"]));
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs if (!String.IsNullOrEmpty(parameters["attr2"]))
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs attributes.Add(new SamlAttribute(parameters["attr2"]));
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs if (!String.IsNullOrEmpty(parameters["attr3"]))
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs attributes.Add(new SamlAttribute(parameters["attr3"]));
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs throw new ServiceProviderUtilityException("No Attributes specified.");
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs if (!String.IsNullOrEmpty(parameters["attr4"]))
3c4411ba18450cef1ac7fd5d7299441fe52dfd2aMareks Malnacs parameters.Add(Saml2Constants.X509SubjectName, Boolean.TrueString);
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs parameters[Saml2Constants.SubjectNameId] = parameters["attr4"];
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs queryResponse = serviceProviderUtility.SendAttributeQueryRequest(Context, idpEntityId, parameters, attributes);
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs queryResponse.Decrypt(serviceProviderUtility.ServiceProvider);
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs catch (Saml2Exception se)
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs errorTrace += "<br/>" + se.InnerException.StackTrace;
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs catch (ServiceProviderUtilityException spue)
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs errorTrace += "<br/>" + spue.InnerException.StackTrace;
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs <h1>Fedlet Attribute Query Response</h1><hr/>
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs Attribute Query error:
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs Response.Write(" <td colspan='2'><i>No attributes found in the response</i></td>\n");
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs foreach (string key in queryResponse.Attributes.Keys)
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs ArrayList values = (ArrayList)queryResponse.Attributes[key];
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs Response.Write("<td>" + Server.HtmlEncode(key) + "</td>\n");
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs Response.Write(Server.HtmlEncode(value) + "<br/>\n");
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs <%StringWriter stringWriter = new StringWriter();
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs XmlDocument xml = (XmlDocument)queryResponse.XmlDom;
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs Response.Write(Server.HtmlEncode(stringWriter.ToString()));%><br />
947af33fa9a6307636167a32e447bb4f9a12cd2bMareks Malnacs Return <a href="javascript:history.go(-1)">back</a> to try another set of Attributes.