<%--
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
*/
/*
* Portions Copyrighted 2013 ForgeRock Inc.
*/
--%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="Sun.Identity.Saml2" %>
<%@ Import Namespace="Sun.Identity.Saml2.Exceptions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="content" runat="server">
<%
string errorMessage = null;
string errorTrace = null;
AuthnResponse authnResponse = null;
ServiceProviderUtility serviceProviderUtility = null;
try
{
serviceProviderUtility = (ServiceProviderUtility)Cache["spu"];
if (serviceProviderUtility == null)
{
serviceProviderUtility = new ServiceProviderUtility(Context);
Cache["spu"] = serviceProviderUtility;
}
}
catch (Saml2Exception se)
{
errorTrace = se.StackTrace;
}
catch (ServiceProviderUtilityException spue)
{
errorTrace = spue.StackTrace;
}
%>
<h1>Fedlet Single Sign On Results</h1><hr/>
<p>
Once succesfully authenticated by your OpenAM deployment, your browser was redirected
to this location with a SAML response. This response can be consumed as follows:
</p>
<div class="code">
AuthnResponse authnResponse = null;
try
{
ServiceProviderUtility serviceProviderUtility = new ServiceProviderUtility(Context);
authnResponse = serviceProviderUtility.GetAuthnResponse(Context);
}
catch (Saml2Exception se)
{
// invalid AuthnResponse received
}
catch (ServiceProviderUtilityException spue)
{
// issues with deployment (reading metadata)
}
</div>
<% if (errorMessage != null) { %>
<p>
However, an error occured:
</p>
<div class="code">
<%=Server.HtmlEncode(errorTrace) %>
</div>
<% } else { %>
<p>
Once the <span class="resource">AuthnResponse</span> object has been retrieved, you could
easily access attributes from the response as demonstrated below:
</p>
<table class="output">
<tr>
<th>Method</th>
<th>Returns</th>
<th>Output</th>
</tr>
<tr>
<td>
<form action="javascript:void();" method="get">
<textarea rows="5" cols="60"><%
StringWriter stringWriter = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
%></textarea>
</form>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td>
<table class="samlAttributes">
<tr>
<th>key</th>
<th>value(s)</th>
</tr>
<%
{
Response.Write("<tr>\n");
Response.Write(" <td colspan='2'><i>No attributes found in the response</i></td>\n");
Response.Write("</tr>\n");
}
else
{
{
Response.Write("<tr>\n");
Response.Write("<td>\n");
foreach (string value in values)
{
}
Response.Write("</td>\n");
Response.Write("</tr>\n");
}
}
%>
</table>
</td>
</tr>
</table>
<%
string fedletUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1);
StringBuilder sloListItems = new StringBuilder();
string sloListItemFormat = "<li><a href=\"{0}\">Run {1} initiated Single Logout using {2} binding</a></li>";
if (idp != null)
{
string idpDeployment = null;
string idpMetaAlias = null;
{
if (location != null)
{
UriBuilder uri = new UriBuilder(location);
if (uri != null)
{
{
break;
}
}
}
}
if (!String.IsNullOrEmpty(idpDeployment) && !String.IsNullOrEmpty(idpMetaAlias))
{
string idpUrlFormat = "{0}/IDPSloInit?metaAlias={1}&binding={2}&RelayState={3}";
idpUrl = Server.HtmlEncode(String.Format(idpUrlFormat, idpDeployment, idpMetaAlias, Saml2Constants.HttpRedirectProtocolBinding, fedletUrl));
sloListItems.Append(String.Format(sloListItemFormat, idpUrl, "Identity Provider", "HTTP Redirect"));
idpUrl = Server.HtmlEncode(String.Format(idpUrlFormat, idpDeployment, idpMetaAlias, Saml2Constants.HttpPostProtocolBinding, fedletUrl));
idpUrl = Server.HtmlEncode(String.Format(idpUrlFormat, idpDeployment, idpMetaAlias, Saml2Constants.HttpSoapProtocolBinding, fedletUrl));
}
}
string spUrlFormat = "spinitiatedslo.aspx?idpEntityID={0}&SubjectNameId={1}&SessionIndex={2}&binding={3}&RelayState={4}";
spUrl = Server.HtmlEncode(String.Format(spUrlFormat, idp.EntityId, authnResponse.SubjectNameId, authnResponse.SessionIndex, Saml2Constants.HttpRedirectProtocolBinding, fedletUrl));
spUrl = Server.HtmlEncode(String.Format(spUrlFormat, idp.EntityId, authnResponse.SubjectNameId, authnResponse.SessionIndex, Saml2Constants.HttpPostProtocolBinding, fedletUrl));
spUrl = Server.HtmlEncode(String.Format(spUrlFormat, idp.EntityId, authnResponse.SubjectNameId, authnResponse.SessionIndex, Saml2Constants.HttpSoapProtocolBinding, fedletUrl));
%>
<h1>Fedlet Attribute Query</h1><hr/>
<table border="0">
<tbody>
<tr>
<td colspan="2"><b>Subject:</b></td>
</tr>
<tr>
<td colspan="2">SAML2 Token (Transient)</td>
</tr>
<tr>
<td>Attribute 1:</td>
<td>
<input id="Text1" type="text" name="attr1" value="CommonName" size="50" /></td>
</tr>
<tr>
<td>Attribute 2:</td>
<td>
<input id="Text2" type="text" name="attr2" value="EmailAddress" size="50" /></td>
</tr>
<tr>
<td>Attribute 3:</td>
<td>
<input id="Text3" type="text" name="attr3" value="UserStatus" size="50" /></td>
</tr>
<tr>
<td><b>Profile Name:</b></td>
<td><i>will use the Default when no X.509 Subject DN value below is entered</i></td>
</tr>
<tr>
<td>X.509 Subject DN:</td>
<td>
<input id="Text4" type="text" name="attr4" value="" size="100" /></td>
</tr>
<tr>
<td></td>
<td>
<input id="Text5" type="submit" value="send" /></td>
</tr>
</tbody>
</table>
</form>
<h1>Fedlet Single Log Out</h1><hr/>
<ul>
<%=sloListItems.ToString() %>
</ul>
<% } %>
<br/>
<p>
Return to the <a href="default.aspx">homepage</a> to try other examples available in this sample application.
</p>
</asp:Content>