This project is read-only.
<link rel="stylesheet" type="text/css" href="http://alexgorbatchev.com/pub/sh/2.1.364/styles/shCore.css"><link rel="stylesheet" type="text/css" href="http://alexgorbatchev.com/pub/sh/2.1.364/styles/shThemeDefault.css"><link rel="stylesheet" type="text/css" href="http://alexgorbatchev.com/pub/sh/2.1.364/styles/shThemeRDark.css"><script language='javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.1.364/scripts/clipboard.swf'; SyntaxHighlighter.all(); </script>

Relying Party Configuration

  1. Create a Asp.net Web Application (Empty)
  2. Add the following references:
    • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IdentityModel.dll
  3. Add Identity Model Configuration: http://localhost:58922/federationmetadata/2007-06/federationmetadata.xml
    image

    image
  4. Print claims on page: <script type="syntaxhighlighter" class="brush: c#"><![CDATA[ if (!Page.User.Identity.IsAuthenticated) return; ClaimsPrincipal claimsPrincipal = Page.User as ClaimsPrincipal; // The code below shows claims found in the IClaimsIdentity. Table claimsTable = new Table(); TableRow headerRow = new TableRow(); TableCell claimTypeCell = new TableCell(); claimTypeCell.Text = "Claim Type"; claimTypeCell.BorderStyle = BorderStyle.Solid; TableCell claimValueCell = new TableCell(); claimValueCell.Text = "Claim Value"; claimValueCell.BorderStyle = BorderStyle.Solid; headerRow.Cells.Add(claimTypeCell); headerRow.Cells.Add(claimValueCell); claimsTable.Rows.Add(headerRow); TableRow newRow; TableCell newClaimTypeCell, newClaimValueCell; foreach (Claim claim in claimsPrincipal.Claims) { newRow = new TableRow(); newClaimTypeCell = new TableCell(); newClaimTypeCell.Text = claim.Type.ToString(); newClaimValueCell = new TableCell(); newClaimValueCell.Text = claim.Value; newRow.Cells.Add(newClaimTypeCell); newRow.Cells.Add(newClaimValueCell); claimsTable.Rows.Add(newRow); } Controls.Add(claimsTable); ]]> </script>
  5. Add a certificate reference if necessary: <script type="syntaxhighlighter" class="brush: xml"><![CDATA[ <system.identityModel.services> <federationConfiguration> <cookieHandler requireSsl="false" /> <wsFederation passiveRedirectEnabled="true" issuer="http://localhost:58922/" realm="http://localhost:10248/" requireHttps="false" /> <serviceCertificate> <certificateReference x509FindType="FindByThumbprint" findValue="3DAB07E7265C30F0DF96A42E8B1DB5E811F55C33" storeLocation="LocalMachine" storeName="My" /> </serviceCertificate> </federationConfiguration> </system.identityModel.services> ]]> </script>

STS Config

<script type="syntaxhighlighter" class="brush: c#"><![CDATA[ <system.webServer> <rewrite> <rules> <rule name="Rewrite federation metadata url"> <match url="(federationmetadata/2007-06/federationmetadata.xml)"/> <action type="Rewrite" url="sts/meta.ashx/{R:1}"/> </rule> </rules> </rewrite> </system.webServer> ]]> </script>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IdentityModel.Services.dll <script type="syntaxhighlighter" class="brush: c#"><![CDATA[ protected void Page_Load(object sender, EventArgs e) { if (Page.User.Identity.IsAuthenticated) { FederatedPassiveSecurityTokenServiceOperations.ProcessRequest(Request, User as ClaimsPrincipal, CustomSecurityTokenServiceConfiguration.Current.CreateSecurityTokenService(), Response); } else { var provider = OpenAuth.GetProviderNameFromCurrentRequest(); FormsAuthentication.RedirectToLoginPage(); } } ]]> </script><script type="syntaxhighlighter" class="brush: c#"><![CDATA[ ]]> </script>

Last edited Jun 30, 2013 at 3:18 AM by xsolon, version 2

Comments

No comments yet.