<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>www.leastprivilege.com</title>
  <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/" />
  <link rel="self" href="http://www.leastprivilege.com/SyndicationService.asmx/GetAtom" />
  <logo>http://www.leastprivilege.com/favicon.ico</logo>
  <icon>favicon.ico</icon>
  <updated>2009-07-03T11:37:41.0681529+02:00</updated>
  <author>
    <name>Dominick Baier</name>
  </author>
  <subtitle>dominick baier on .net, security and other stuff</subtitle>
  <id>http://www.leastprivilege.com/</id>
  <generator uri="http://www.dasblog.net" version="1.8.5223.2">DasBlog</generator>
  <entry>
    <title>A closer look at Sandboxing in (ASP.NET) V4</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ACloserLookAtSandboxingInASPNETV4.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=4ed1668f-d12c-4ca0-b3fc-5640a0db9f49</id>
    <published>2009-07-03T11:37:41.0681529+02:00</published>
    <updated>2009-07-03T11:37:41.0681529+02:00</updated>
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      In the last <a href="http://www.leastprivilege.com/PartialTrustASPNETIn40.aspx">two</a><a href="http://www.leastprivilege.com/PartialTrustASPNETIn40AdvancedScenarios.aspx">posts</a> I
      described how ASP.NET uses the homogenous <em>AppDomain</em> model to implement partially
      trusted apps.
   </p>
        <p>
      In ASP.NET you use the combination of a trust level (aka grant set) and a list of
      full trust assemblies to setup the homogenous <em>AppDomain</em>. This maps directly
      to the <em>AppDomain.Create()</em> call that allows the corresponding parameters to
      be passed in.
   </p>
        <p>
      Another option is to determine the trust level of application assemblies using a policy
      resolver. The resolver gets called when an assembly gets loaded into the <em>AppDomain</em> and
      you can dynamically specify if the assembly should run in full trust or the <em>AppDomain </em>grant
      set.
   </p>
        <p>
      The second option is implemented using the new features around <em>AppDomain</em> managers
      in .NET 4.0 (read more <a href="http://blogs.msdn.com/shawnfa/archive/2004/11/12/256550.aspx">here</a>, <a href="http://blogs.msdn.com/shawnfa/archive/2004/11/17/259105.aspx">here</a>, <a href="http://blogs.msdn.com/shawnfa/archive/2004/11/29/271948.aspx">here</a>).
      These new features basically boil down to two new ways to specify an <em>AppDomainManager</em> for
      the default or newly created <em>AppDomains</em>. You can now either use configuration
      (in the runtime section) or specify the <em>AppDomainManager</em> type on the <em>AppDomainSetup </em>object
      when manually creating <em>AppDomains</em>.
   </p>
        <p>
      This is exactly what ASP.NET is doing. The <em>AppDomainManager</em> implemented in <em>System.Web.Hosting.ApplicationManager+AspNetAppDomainManager</em> is
      used for ASP.NET created <em>AppDomains</em>. This manager in turn uses a custom <em>HostSecurityManager</em> (implemented
      in <em>System.Web.Hosting.ApplicationManager+AspNetHostSecurityManager</em>). This
      host security manager in in turn expresses his interest to resolve policy when assemblies
      get loaded (using the <em>Flags</em> property).
   </p>
        <p>
      In the <em>ResolvePolicy</em> method, the host security manager calls out to the policy
      resolver (if specified). The return is then parsed and turned into either full trust/appdomain
      trust/nothing permission sets. Nice.
   </p>
        <p>
      This mechanism is not special to ASP.NET – and can be used in arbitrary applications.
      Useful for writing hosts with more advanced requirements.
   </p>
        <p>
      (thanks to <a href="http://blogs.msdn.com/shawnfa">shawnfa</a>/stefsch)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=4ed1668f-d12c-4ca0-b3fc-5640a0db9f49" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Identity Metasystem Interoperability Version 1.0</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/IdentityMetasystemInteroperabilityVersion10.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=1998967c-3da8-413e-b51f-6256a5cb2b0d</id>
    <published>2009-07-02T09:25:29.1987183+02:00</published>
    <updated>2009-07-02T09:25:29.1987183+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The IMI spec is now approved. Grats!
   </p>
        <p>
      Read more <a href="http://self-issued.info/?p=163">here</a> and get the spec <a href="http://docs.oasis-open.org/imi/identity/v1.0/identity.html">here</a>.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=1998967c-3da8-413e-b51f-6256a5cb2b0d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Partial Trust ASP.NET in 4.0 (Advanced Scenarios)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/PartialTrustASPNETIn40AdvancedScenarios.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=25f9f09f-a6ac-4025-af8d-80cc20415ba2</id>
    <published>2009-07-01T08:40:07.3968608+02:00</published>
    <updated>2009-07-01T08:40:07.3968608+02:00</updated>
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   In the last post I showed you how to use the new CLR security model to do sandboxing
   in ASP.NET.
&lt;/p&gt;
&lt;p&gt;
   One new hook into this system is a custom host security policy resolver. A policy
   resolver is a class that derives from &lt;em&gt;System.Web.Hosting.HostSecurityPolicyResolver&lt;/em&gt;.
   The idea behind this extensibility point is, that a resolver can decide at runtime
   (as opposed to the static &lt;em&gt;fullTrustAssemblies&lt;/em&gt; configuration element) in which
   “permission bucket” the assembly should get loaded – AppDomain grant set, full trust
   or nothing.
&lt;/p&gt;
&lt;p&gt;
   A resolver has a single method called &lt;em&gt;ResolvePolicy&lt;/em&gt;. ASP.NET hands in the
   evidence of every application assembly that gets loaded into the resolver, and it
   is the implementer’s job to decide the “trust level”.
&lt;/p&gt;
&lt;p&gt;
   &lt;em&gt;ResolvePolicy&lt;/em&gt; returns a &lt;em&gt;HostSecurityPolicyResults&lt;/em&gt; enum which can
   have one of these values: DefaultPolicy, FullTrust, AppDomainTrust or Nothing.
&lt;/p&gt;
&lt;p&gt;
   You register the resolver using the following config element:
&lt;/p&gt;
&lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;
   &lt;span style="font-family: consolas; color: blue; mso-ansi-language: en-us" lang="EN-US"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: consolas; color: #a31515; mso-ansi-language: en-us" lang="EN-US"&gt;trust&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; mso-ansi-language: en-us" lang="EN-US"&gt; &lt;/span&gt;&lt;span style="font-family: consolas; color: red; mso-ansi-language: en-us" lang="EN-US"&gt;level&lt;/span&gt;&lt;span style="font-family: consolas; color: blue; mso-ansi-language: en-us" lang="EN-US"&gt;=&lt;/span&gt;&lt;span style="font-family: consolas; mso-ansi-language: en-us" lang="EN-US"&gt;"&lt;span style="color: blue"&gt;Medium&lt;/span&gt;"&lt;br&gt;
   &lt;span style="color: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: red"&gt;permissionSetName&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;ASP.Net&lt;/span&gt;"&lt;br&gt;
   &lt;span style="color: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: red"&gt;hostSecurityPolicyResolverType&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Policy.PolicyResolver,
   …&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   A resolver must be in the GAC – otherwise you may receive a strange exception saying
   “assembly still being loaded”…
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=25f9f09f-a6ac-4025-af8d-80cc20415ba2" /&gt;</content>
  </entry>
  <entry>
    <title>Partial Trust ASP.NET in 4.0</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/PartialTrustASPNETIn40.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=c3daa1fc-9b5c-4773-aba2-80275b3c7833</id>
    <published>2009-06-30T14:02:08.504+02:00</published>
    <updated>2009-06-30T22:59:26.5404816+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   In .NET v4 there are substantial changes to the CLR security model. Read about all
   the details &lt;a href="http://blogs.msdn.com/shawnfa/archive/2009/06/12/clr-v4-security-policy-roundup.aspx"&gt;here&lt;/a&gt;.
   With Beta 1 in hand I gave the new model a try in the probably most popular host for
   partial trust – ASP.NET.
&lt;/p&gt;
&lt;p&gt;
   You start with setting the trust level in &lt;em&gt;web.config&lt;/em&gt;. This works exactly
   the same as in pre-V4. Also the same &lt;em&gt;web_xytrust.config&lt;/em&gt; files from the framework
   configuration directory are used. Since policy levels and code groups are not in effect
   any longer in V4, ASP.NET by default uses the named permission set called&lt;em&gt; ASP.Net&lt;/em&gt; as
   the grant set for the AppDomain. 
   &lt;br&gt;
   You can also specify a different set via the new &lt;em&gt;permissionSetName&lt;/em&gt; attribute.
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-ansi-language: en-us" lang=EN-US&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: #a31515; mso-ansi-language: en-us" lang=EN-US&gt;trust&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-ansi-language: en-us" lang=EN-US&gt; &lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: red; mso-ansi-language: en-us" lang=EN-US&gt;level&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-ansi-language: en-us" lang=EN-US&gt;=&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-ansi-language: en-us" lang=EN-US&gt;"&lt;span style="COLOR: blue"&gt;Medium&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;permissionSetName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;ASP.Net&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="mso-ansi-language: en-us" lang=EN-US&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   So far everything behaves like in CLR2. Now a typical thing to do would be to factor
   out the “dangerous” code into separate assemblies and grant these assemblies full
   trust to do their work. In CLR2 you either GACed such an assembly or modified the
   security policy to grant whatever permissions were needed.
&lt;/p&gt;
&lt;p&gt;
   Since there is no security policy anymore in V4 and ASP.NET has moved to the homogenous
   AppDomain model – things work differently (and easier) now. In a homogenous AppDomain
   there are permission-wise two types of assemblies – ones constrained by the AppDomain
   grant set and full trust assemblies. With the new &lt;em&gt;fullTrustAssemblies&lt;/em&gt; configuration
   element, you can specify which assemblies should be loaded in full trust, e.g.:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-ansi-language: en-us" lang=EN-US&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: #a31515; mso-ansi-language: en-us" lang=EN-US&gt;fullTrustAssemblies&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-ansi-language: en-us" lang=EN-US&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-ansi-language: en-us" lang=EN-US&gt;
   &lt;br&gt;
   &lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;assemblyName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;HelperLib&lt;/span&gt;"&lt;br&gt;
   &lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: red"&gt;version&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;1.0.0.0&lt;/span&gt;"&lt;br&gt;
   &lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: red"&gt;publicKey&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;0024…cb0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;fullTrustAssemblies&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   To make &lt;em&gt;HelperLib&lt;/em&gt; callable from partial trust, you have to add the standard &lt;em&gt;[AllowPartiallyTrustedCallers]&lt;/em&gt; attribute
   to the assembly. With the new transparency model in V4, APTCA means that the library
   provides services to partially trusted code and can contain critical and safe critical
   code. All un-annotated code in an APTCA assembly becomes security transparent by default.
&lt;/p&gt;
&lt;p&gt;
   This is a huge improvement over the old model. Since partially trusted code is always
   transparent, it can only call transparent or safe critical code. The typical pattern
   is that you provide safe critical “gateways” in your library where you do all the
   security checks, input validation and asserts (if necessary). From there you then
   call into the critical code (e.g. a library function).
&lt;/p&gt;
&lt;p&gt;
   The following is a simple example of a library that provides read access to certain
   directories to partially trusted ASP.NET applications:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; mso-ansi-language: en-us" lang=EN-US&gt;[&lt;span style="COLOR: blue"&gt;assembly&lt;/span&gt;: &lt;span style="COLOR: #2b91af"&gt;AllowPartiallyTrustedCallers&lt;/span&gt;]&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; HelperLib&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Helper&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: #2b91af"&gt;SecuritySafeCritical&lt;/span&gt;]&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ReadFile(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; filename)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; perm
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;FileIOPermission&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;FileIOPermissionAccess&lt;/span&gt;.Read,
   GetAllowedContentDirs());&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;perm.Assert();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;File&lt;/span&gt;.ReadAllText(filename);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;}&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=c3daa1fc-9b5c-4773-aba2-80275b3c7833" /&gt;</content>
  </entry>
  <entry>
    <title>Updated Starter STS</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UpdatedStarterSTS.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=3ab0d566-84a6-4eee-bb6b-b32cdced9b52</id>
    <published>2009-06-17T09:21:52.9085567+02:00</published>
    <updated>2009-06-17T09:21:52.9085567+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I just uploaded a minor update to the Starter STS sample to codeplex. This release
      adds more options for realm checking (see the <em>allowKnownRealmsOnly</em> config
      switch) as well as Information Card issuance.
   </p>
        <p>
      As always – feedback is welcome!
   </p>
        <p>
          <a href="http://startersts.codeplex.com">http://startersts.codeplex.com</a>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=3ab0d566-84a6-4eee-bb6b-b32cdced9b52" />
      </div>
    </content>
  </entry>
  <entry>
    <title>.NET Access Control Service Talk from Troopers09</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/NETAccessControlServiceTalkFromTroopers09.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=719c0353-b68f-44d7-a69e-7cb2fe43b121</id>
    <published>2009-06-05T05:45:53.410397+02:00</published>
    <updated>2009-06-05T05:45:53.410397+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I did a talk about the ACS in May. It was interesting to present that topic to a non-Developer,
      non-Microsoft minded audience. 
   </p>
        <p>
      Here’s the outcome:<br /><a href="http://www.viddler.com/explore/TROOPERS/videos/1/">http://www.viddler.com/explore/TROOPERS/videos/1/</a></p>
        <p>
      _
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=719c0353-b68f-44d7-a69e-7cb2fe43b121" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Writing Custom Attribute Stores for Geneva Server (B2)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/WritingCustomAttributeStoresForGenevaServerB2.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=90f35935-27d1-4970-aef5-44d18b2b5aa9</id>
    <published>2009-06-04T08:31:37.0103484+02:00</published>
    <updated>2009-06-04T08:31:37.0103484+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="https://connect.microsoft.com/Downloads/DownloadDetails.aspx?SiteID=642&amp;DownloadID=18933">This</a> document
      appeard on the connect site. Interesting.
   </p>
        <p>
      _
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=90f35935-27d1-4970-aef5-44d18b2b5aa9" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Worker Process Accounts in IIS 7.5</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/WorkerProcessAccountsInIIS75.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=04c9ec88-03e7-4315-8a9e-e87ce4ed1aa2</id>
    <published>2009-06-03T20:59:03.9222101+02:00</published>
    <updated>2009-06-03T20:59:50.7812852+02:00</updated>
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Windows 7 and Windows Server 2008 R2 ship with IIS 7.5. While migrating the <a href="http://startersts.codeplex.com/">StarterSTS</a>,
      I made an interesting observation. I remember vaguely I read about that somewhere
      – but basically I got this error message:
   </p>
        <blockquote>
          <p>
            <font face="Courier">Cannot open database "aspnetdb" requested by the login. The login
      failed.Login failed for user '<strong>IIS APPPOOL\DefaultAppPool</strong>'. </font>
          </p>
        </blockquote>
        <p>
      That’s an interesting account. 
   </p>
        <p>
      A closer look reveals, that in IIS manager you now have five accounts to choose from
      when setting up an App Pool: System, Network Service, Local Service, Custom… and ApplicationPoolIdentity.
      The default value is ApplicationPoolIdentity. 
   </p>
        <p>
      With this new setting, a new primary SID is injected into the worker process – all
      Windows security checks are done against this new SID. Converting that NT Account
      to an SID reveals an S-1-5-82 – which was new to me. 
   </p>
        <p>
      So in the light of the recent problems with system account sharing (<a href="http://www.leastprivilege.com/SystemAccountsAndSQLServer2005.aspx">here</a> and <a href="http://www.leastprivilege.com/FixingTokenKidnapping.aspx">here</a>),
      this is a good change and makes it even easier to isolate worker processes. 
   </p>
        <p>
      HTH <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=04c9ec88-03e7-4315-8a9e-e87ce4ed1aa2" /></p>
      </div>
    </content>
  </entry>
  <entry>
    <title>Geneva Framework Quick Tip: How to access Configuration</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaFrameworkQuickTipHowToAccessConfiguration.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=f232f54a-f435-4684-a027-299caf95f1e8</id>
    <published>2009-05-28T07:21:31.3953592+02:00</published>
    <updated>2009-05-28T07:22:51.0042247+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Remember that Geneva framework is a framework – all the nice integration into WCF
      and ASP.NET is built on top of a public API. This also means that you can use Geneva
      framework for integration in arbitrary hosts and environments.
   </p>
        <p>
      One thing you most often need is access to the Geneva framework configuration (microsoft.identityModel
      section) from code – and again this is very easy:
   </p>
        <span style="line-height: 115%; font-family: consolas; color: #2b91af; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">ServiceConfiguration</span>
        <span style="line-height: 115%; font-family: consolas; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes"> config
   = <span style="color: blue">new</span><br /><span style="mso-spacerun: yes">  </span><span style="color: #2b91af">ServiceConfiguration</span>(<span style="color: #2b91af">ServiceConfiguration</span>.DefaultServiceName);</span>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=f232f54a-f435-4684-a027-299caf95f1e8" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Geneva Framework Quick Tip: Hosting a Security Token Service</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaFrameworkQuickTipHostingASecurityTokenService.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=9bc0129c-9979-4b86-8460-4d3cdd73bf9d</id>
    <published>2009-05-28T06:50:57.6414211+02:00</published>
    <updated>2009-05-28T06:52:46.8900227+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   The idea of the security token service infrastructure in Geneva is, that it is completely
   host agnostic. The STS itself expects a &lt;em&gt;RequestSecurityToken&lt;/em&gt; and returns
   a &lt;em&gt;RequestSecurityTokenResponse&lt;/em&gt;. It is the job of the host to translate some
   protocol back and forth to this technology independent representation.
&lt;/p&gt;
&lt;p&gt;
   The key to STS hosting (and that’s btw what the WCF &lt;em&gt;WSTrustServiceContract&lt;/em&gt; class
   or the &lt;em&gt;FederatedPassiveSignin&lt;/em&gt; web control does) is to create a token service
   from configuration. And this couldn’t be easier ;)
&lt;/p&gt;
&lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;
   &lt;span style="font-family: consolas; color: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;var&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; config
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TokenServiceConfiguration&lt;/span&gt;();&lt;br&gt;
   &lt;span style="color: blue"&gt;var&lt;/span&gt; sts = config.CreateSecurityTokenService();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;?xml:namespace prefix = o /&gt; rstr = sts.Issue(principal,
   rst);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=9bc0129c-9979-4b86-8460-4d3cdd73bf9d" /&gt;</content>
  </entry>
  <entry>
    <title>Starter STS Screencasts</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/StarterSTSScreencasts.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=9f03c141-23f0-4ab7-8cb9-ef442229b21a</id>
    <published>2009-05-27T15:54:12.0840721+02:00</published>
    <updated>2009-05-27T15:54:27.1308508+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      All two screencasts about the starter STS <a href="http://startersts.codeplex.com/">sample</a> are
      online now:
   </p>
        <ul>
          <li>
         Setup &amp; Overview (<a href="http://www.leastprivilege.com/startersts/StarterSTS_SetupAndOverview.wmv">download</a>)</li>
          <li>
         Advanced Topics &amp; Configuration (<a href="http://www.leastprivilege.com/startersts/StarterSTS_Advanced.wmv">download</a>)</li>
        </ul>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=9f03c141-23f0-4ab7-8cb9-ef442229b21a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Thinktecture Security Token Service Starter Kit</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ThinktectureSecurityTokenServiceStarterKit.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=863984d8-afcd-421e-a6e7-5b9cfb132d95</id>
    <published>2009-05-26T07:54:25.136+02:00</published>
    <updated>2009-05-26T13:46:06.3478819+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I am happy to announce the “Thinktecture STS Starter Kit” sample. The STS starter
      kit is a compact, easy to use identity provider that is completely based on the ASP.NET
      provider infrastructure. It is built using the Geneva framework Beta 2 bits and is
      a self contained web site with passive and active endpoints (Christian has some <a href="http://blogs.thinktecture.com/cweyer/archive/2009/05/26/415363.aspx">screenshots</a>).
   </p>
        <p>
          <img border="0" src="http://www.leastprivilege.com/content/binary/overview1.png" />
        </p>
        <p>
      The motivation behind writing this sample is twofold. First, writing a custom STS
      from scratch is not terribly hard – but it is also not a trivial task. In addition
      the full featured Geneva Server product may not fit your requirements (e.g. because
      your users are not stored in Active Directory). So a lot of people I spoke to mentioned
      that it would be nice to have a simple STS that uses membership, roles and profile
      and that is easy to setup and get going.
   </p>
        <p>
      The other reason is that starter STS is not terribly complex and could be used as
      a learning tool on how to write custom token services. You could e.g. replace the
      provider plumbing with your own libraries while you go.
   </p>
        <p>
      Some features:
   </p>
        <ul>
          <li>
         active and passive security token service 
      </li>
          <li>
         supports WS-Federation, WS-Trust 1.3 (message and mixed) and SAML 1.1/2.0 tokens 
      </li>
          <li>
         based on the standard membership, roles and profile provider infrastructure 
      </li>
          <li>
         membership provider is used to authenticate users and to provide a name and email
         claim 
      </li>
          <li>
         role provider is used for authorization in the web front-end and to provider role
         claims 
      </li>
          <li>
         profile provider is used to allow users to supply profile information which gets turned
         into claims 
      </li>
          <li>
         easy administration of the provider features using the IIS7 manager 
      </li>
          <li>
         easy configuration – you don’t have to deal with Geneva or WCF settings directly 
      </li>
          <li>
         control over security policy (SSL, encryption, SOAP security) 
      </li>
          <li>
         dynamic web UI to allow users to maintain their profile data 
      </li>
          <li>
         automatic generation of a WS-Federation metadata document to allow RPs to federate
         using e.g. FedUtil</li>
        </ul>
        <p>
      To make it even easier for you to setup and start using the STS, I have recorded a
      screencast that walks you through the installation and setup process. In the following
      posts I will focus more on on some of the feature areas and explain how they are used
      and implemented. Have fun!
   </p>
        <p>
          <a href="http://startersts.codeplex.com">
            <em>Download</em>
          </a>
          <em> STS Starter Kit
      Sample.</em>
          <br />
          <em>
            <a href="http://www.leastprivilege.com/startersts/StarterSTS_SetupAndOverview.wmv">Download</a> Setup&amp;Overview
      Screencast</em>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=863984d8-afcd-421e-a6e7-5b9cfb132d95" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Use Geneva Session Management for your own needs</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UseGenevaSessionManagementForYourOwnNeeds.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=01bcf5e9-af5f-477f-99a8-80f76ce8f266</id>
    <published>2009-05-24T16:04:32.1337352+02:00</published>
    <updated>2009-05-24T16:04:32.1337352+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   Geneva Framework is a Framework is a Framework.
&lt;/p&gt;
&lt;p&gt;
   One part of that framework is the &lt;em&gt;SessionAuthenticationModule&lt;/em&gt; for ASP.NET.
   In all the typical samples this is used to convert an incoming SAML token to a cookie
   to establish an authentication session.
&lt;/p&gt;
&lt;p&gt;
   A closer look reveals, that the purpose of this module is actually serializing &lt;em&gt;SessionSecurityToken&lt;/em&gt;s
   into cookies. A &lt;em&gt;SessionSecurityToken&lt;/em&gt; in turn is a container for an &lt;em&gt;IClaimsPrincipal&lt;/em&gt; and
   an additional &lt;em&gt;SecurityToken&lt;/em&gt; (the so called bootstrap token).
&lt;/p&gt;
&lt;p&gt;
   This means that the &lt;em&gt;SessionAuthenticationModule&lt;/em&gt; is a general module and API
   to serialize claims principals and security tokens into cookies. In addition there
   is an extensible architecture around how these cookies are layed out and protected.
   You can utilize this infrastructure whenever you need to serialize and round-trip
   an &lt;em&gt;IClaimsPrincipal&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
   Where can this be useful? Let’s do this little walkthrough…
&lt;/p&gt;
&lt;p&gt;
   First use the Visual Studio Geneva templates to create a simple “Claims-aware ASP.Net
   WebSite”. This sample uses the &lt;em&gt;ClaimsPrincipalHttpModule&lt;/em&gt; to create an &lt;em&gt;IClaimsPrincipal &lt;/em&gt;from
   the standard forms authentication principal.
&lt;/p&gt;
&lt;p&gt;
   In the next step add a &lt;em&gt;ClaimsAuthenticationManager&lt;/em&gt; to the web site and register
   it, e.g.:
&lt;/p&gt;
&lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;
   &lt;span style="font-family: consolas; color: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Transformer&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ClaimsAuthenticationManager&lt;br&gt;
   &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; Authenticate(&lt;span style="color: blue"&gt;string&lt;/span&gt; endpointUri, &lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; incomingPrincipal)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   expensive operation&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;incomingPrincipal.Identities[0].Claims.Add(&lt;span style="color: blue"&gt;new&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="color: #2b91af"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Claim&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"http://claims/expensive"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"expensive
   value"&lt;/span&gt;));&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; incomingPrincipal;&lt;span style="color: #2b91af"&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;
   &lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   The custom claims you are adding in the authentication manager might come from some
   remote data store and you probably want to avoid such a round-trip on every request.
   To optimize this, you could come up with some server-local caching strategy – or use
   the &lt;em&gt;SessionAuthenticationModule&lt;/em&gt; to serialize the &lt;em&gt;IClaimsPrincipal&lt;/em&gt; after
   transformation to a cookie. The module will then reconstruct the &lt;em&gt;IClaimsPrincipal&lt;/em&gt; on
   subsequest requests and set it as the current principal for the ASP.NET application.
&lt;/p&gt;
&lt;p&gt;
   First add the session authentication module to the modules section in web.config –
   then add this code to the authentication manager:
&lt;/p&gt;
&lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;
   &lt;span style="font-family: consolas; color: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;private&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; SetSessionCookie(&lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; incomingPrincipal)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SessionSecurityToken&lt;/span&gt; token
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SessionSecurityToken&lt;/span&gt;(incomingPrincipal);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;FederatedAuthentication&lt;/span&gt;.SessionAuthenticationModule.WriteSessionTokenToCookie(token);&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   Call this method before you return the transformed principal back to Geneva.
&lt;/p&gt;
&lt;p&gt;
   Note: When your app is not running over SSL – you need to set the &lt;em&gt;requireSsl&lt;/em&gt; setting
   for the cookie handler in web.config to &lt;em&gt;false&lt;/em&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=01bcf5e9-af5f-477f-99a8-80f76ce8f266" /&gt;</content>
  </entry>
  <entry>
    <title>Thinktecture WS-Federation Metadata Generator</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ThinktectureWSFederationMetadataGenerator.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=12685563-062d-4492-8b8f-2599cafe89df</id>
    <published>2009-05-22T13:43:30.66332+02:00</published>
    <updated>2009-05-22T13:44:25.4438688+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blogs.thinktecture.com/cweyer">Mr. Metadata</a> strikes back! This
      time with a generator/wizard for WS-Federation Metadata language. This makes it very
      easy to create documents that can be consumed by Geneva Server or FedUtil.
   </p>
        <p>
      More info <a href="http://blogs.thinktecture.com/cweyer/archive/2009/05/22/415362.aspx">here</a>.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=12685563-062d-4492-8b8f-2599cafe89df" />
      </div>
    </content>
  </entry>
  <entry>
    <title>.NET 4.0 Security</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/NET40Security.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=b2811990-e91a-4c87-bdff-5b0e5841207d</id>
    <published>2009-05-21T06:35:31.5464652+02:00</published>
    <updated>2009-05-21T06:36:28.7960988+02:00</updated>
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Now that Beta 1 has shipped I am finally allowed to talk about the new/changed security
      features in 4.0 – but there is no one who can explain these things more elaborate
      and insightful than <a href="http://blogs.msdn.com/shawnfa">Shawn</a>. I just saw
      that he is about to start a <a href="http://blogs.msdn.com/shawnfa/archive/2009/05/20/net-4-0-security.aspx">series</a> of
      posts on the new feature areas. So watch his space closely!
   </p>
        <p>
      (ah – and btw – leave a comment on his blog that he should write a book about security
      in .NET 4.0 – maybe we can convince him ;)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=b2811990-e91a-4c87-bdff-5b0e5841207d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>More Geneva Beta 2 Changes</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/MoreGenevaBeta2Changes.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=5a928c11-27b6-4d2e-87b7-471647eee9a5</id>
    <published>2009-05-18T15:45:21.6378911+02:00</published>
    <updated>2009-05-18T15:45:21.6378911+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Just came across <a href="https://connect.microsoft.com/Downloads/DownloadDetails.aspx?SiteID=642&amp;DownloadID=18672">this</a> document.
      Interesting read.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=5a928c11-27b6-4d2e-87b7-471647eee9a5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Geneva Beta 2 Update: ClaimsPrincipalHttpModule</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaBeta2UpdateClaimsPrincipalHttpModule.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=089d0149-1bae-4bd9-9438-dbbced7c6415</id>
    <published>2009-05-18T08:23:27.0504322+02:00</published>
    <updated>2009-05-18T08:23:27.0504322+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I am currently in the process of updating my Geneva code to Beta 2. There are some
      pretty substantial changes/additions in the new Beta – so I thought I’ll detail some
      of them while moving along. Today: <em>ClaimsPrincipalHttpModule</em>.
   </p>
        <p>
      For a basic understanding what the module does, I recommend reading my initial post <a href="http://www.leastprivilege.com/GenevaHTTPModulesClaimsPrincipalHttpModule.aspx">here</a>.
   </p>
        <p>
      Starting with Beta 2, <em>ClaimsPrincipalHttpModule</em> supports converting X509
      client certificates to an <em>IClaimsPrincipal</em>. This is done by using the ctor
      of <em>IClaimsIdentity</em> that takes an X509Certificate2 which results in an authenticated
      identity with an authentication type set to “SSL/PCT”.
   </p>
        <p>
      Now as always, certificate based authentication is a little different to e.g. username/password.
      In the strict sense a user is authenticated when you know “who he is”. For usernames/passwords
      authentication this means as soon as you have successfully validated the password
      against your data store (or put differently – as soon as the user provides a proof
      for his identity). Proofing identity in the certificate case basically means that
      the certificate is trusted and the client “knows” the corresponding private key. That’s
      why the <em>ClaimsPrincipalHttpModule</em> sets <em>IsAuthenticated=true</em> when
      the client certificate is valid.
   </p>
        <p>
      Now Windows/IIS supports a number of certificate issuers and a user can potentially
      present a client cert to IIS which is “valid” but the client may still not be a valid/registered
      user in your system. This results (depending on your design) in different semantics
      for “IsAuthenticated” checks like <em>Request.IsAuthenticated</em> or <em>&lt;deny
      users=”?” /&gt;</em>.
   </p>
        <p>
      A better way would be to replace blanket authentication checks with checks for specific
      claims (like a “User” role or some permission).
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=089d0149-1bae-4bd9-9438-dbbced7c6415" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Establishing Trust with the .NET Access Control Service (Geneva Beta 2)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/EstablishingTrustWithTheNETAccessControlServiceGenevaBeta2.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=1b0bbbaf-a8b7-4dd0-a6d0-d9c5788f94b9</id>
    <published>2009-05-15T07:59:42.3640872+02:00</published>
    <updated>2009-05-15T08:00:39.4258568+02:00</updated>
    <content type="html">&lt;p&gt;
   In Geneva you use a &lt;em&gt;IssuerNameRegistry&lt;/em&gt; to establish trust with token issuers.
   The job of the registry is to parse the issuer details and return a well-known string
   identifying that issuer. If the registry cannot determine that well known string,
   the issuer is considered non-trusted and request processing is stopped.
&lt;/p&gt;
&lt;p&gt;
   Typically it is enough to inspect the X509 certificate that was used to issue the
   SAML token, but with the Access Control Service the situation is a little different.
   The ACS uses a multi-tenant model and signs all outgoing tokens with the same certificate.
   This means it is not sufficient to check the signature only to determine that the
   token was issued by a specific instance of the ACS.
&lt;/p&gt;
&lt;p&gt;
   In addition you also have to check the value of the SAML issuer URI which contains
   the logical issuer name which in turn contains the ACS solution name. Prior to Geneva
   Beta 2 you had to use two different extensibility points to do both checks. I wrote
   about that &lt;a href="http://www.leastprivilege.com/UsingTheNETAccessControlServiceWithGeneva.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
   Starting with Beta 2, the issuer name registry now has the capability to parse both
   the physical and logical issuer. Great!
&lt;/p&gt;
&lt;p&gt;
   Find a sample implementation below:
&lt;/p&gt;
&lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;
   &lt;span style="font-family: consolas; color: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;class&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: #2b91af"&gt;AccessControlServiceIssuerNameRegistry&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;IssuerNameRegistry&lt;br&gt;
   &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; _solutionName
   = &lt;span style="color: #a31515"&gt;"leastprivilege"&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; _acsThumbprint
   = &lt;span style="color: #a31515"&gt;"6de1689a739d548a5690dbc3894b953ef6123d93"&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; _samlIssuer;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; AccessControlServiceIssuerNameRegistry()&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_samlIssuer
   = &lt;span style="color: #2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"http://{0}.accesscontrol.windows.net/"&lt;/span&gt;, 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_solutionName);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; GetIssuerName(&lt;span style="color: #2b91af"&gt;SecurityToken&lt;/span&gt; securityToken)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   should never get called&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;NotImplementedException&lt;/span&gt;();&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; GetIssuerName(&lt;span style="color: #2b91af"&gt;SecurityToken&lt;/span&gt; securityToken, &lt;span style="color: blue"&gt;string&lt;/span&gt; requestedIssuerName)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt; issuerToken
   = securityToken &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;X509SecurityToken&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (issuerToken
   == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"securityToken"&lt;/span&gt;);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (&lt;span style="color: blue"&gt;string&lt;/span&gt;.IsNullOrEmpty(requestedIssuerName))&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"requestedIssuerName"&lt;/span&gt;);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (!&lt;span style="color: blue"&gt;string&lt;/span&gt;.Equals(_acsThumbprint,
   issuerToken.Certificate.Thumbprint, &lt;span style="color: #2b91af"&gt;StringComparison&lt;/span&gt;.OrdinalIgnoreCase))&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SecurityTokenException&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #a31515"&gt;"Token
   not issued by the Access Control Service"&lt;/span&gt;);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (!&lt;span style="color: blue"&gt;string&lt;/span&gt;.Equals(_samlIssuer,
   requestedIssuerName, &lt;span style="color: #2b91af"&gt;StringComparison&lt;/span&gt;.OrdinalIgnoreCase))&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SecurityTokenException&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #a31515"&gt;"Token
   not issued by the requested instance of the Access Control Service"&lt;/span&gt;);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; _samlIssuer;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=1b0bbbaf-a8b7-4dd0-a6d0-d9c5788f94b9" /&gt;</content>
  </entry>
  <entry>
    <title>Die Information Card Foundation DACH-Initiative</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/DieInformationCardFoundationDACHInitiative.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=a4780d0d-5176-4639-b222-e1711008fcdd</id>
    <published>2009-05-11T16:21:01.1008027+02:00</published>
    <updated>2009-05-11T16:21:01.1008027+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Mehr Infos <a href="http://www.informationcard.de/"><font color="#669966">hier</font></a>…
   </p>
        <p>
       
   </p>
        <p>
          <img border="0" src="http://www.leastprivilege.com/content/binary/BannerLogos5.jpg" />
        </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=a4780d0d-5176-4639-b222-e1711008fcdd" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Sod This!</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SodThis.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=978433fa-94a5-4e60-b162-6bd3e0d894c9</id>
    <published>2009-04-16T22:10:05.0878119+02:00</published>
    <updated>2009-04-16T22:10:05.0878119+02:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I usually don’t listen to podcasts. But I must admit that <a href="http://www.sodthis.com/podcast/">Sod
      This!</a> is quite entertaining. Oliver along with his buddy Gary do a nice mixture
      of geek-ish talk, interviews and just plain nonsense. Very recommended!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=978433fa-94a5-4e60-b162-6bd3e0d894c9" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Fixing Token Kidnapping</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/FixingTokenKidnapping.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=0282efdc-2872-43ef-9e87-ffe78e5dec21</id>
    <published>2009-04-15T10:13:37.4170659+02:00</published>
    <updated>2009-04-15T10:13:37.4170659+02:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I while ago I <a href="http://www.leastprivilege.com/TokenKidnappingRevisited.aspx">wrote</a> about
      the “Token Kidnapping” vulnerability in Windows. By looking at the slides and POC
      it becomes clear that there is no easy fix for that. 
   </p>
        <p>
      According to Microsoft, the problem is fixed now – and indeed – it seemed to be a
      huge effort:
   </p>
        <blockquote>
          <p>
      “Addressing this issue required one of the most epic engineering efforts we have ever
      expended for a Microsoft security update. This security update changed parts of the
      Windows kernel; the COM, DCOM, and LSASS subsystems; the WMI and MSDTC built-in services;
      and the service control manager (SCM).”
   </p>
        </blockquote>
        <p>
      The details are described <a href="http://blogs.technet.com/srd/archive/2009/04/14/ms09-012-fixing-token-kidnapping.aspx">here</a>.
      Thanks for the information, MSRC!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=0282efdc-2872-43ef-9e87-ffe78e5dec21" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Krise? Nein! &amp;bdquo;Service-Orientierung heute und morgen&amp;ldquo;: 5 Tage volle Power und praktisches Wissen</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/KriseNeinBdquoServiceOrientierungHeuteUndMorgenldquo5TageVollePowerUndPraktischesWissen.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=f530fa7d-9f26-4402-97c9-b61d9858a944</id>
    <published>2009-04-07T14:02:31.9015153+02:00</published>
    <updated>2009-04-07T14:03:48.2296403+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="Work in Progress" label="Work in Progress" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="Conferences" label="Conferences" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Sind Sie auch müde, ständig von „Krise“ und „Einschränkungen“ zu lesen? Sind Sie nicht
      jemand, der sich immer weiter entwickeln möchte und fit für die heutigen Problemstellungen
      aber auch vorbereitet für zukünftige Herausforderungen sein möchte? Wir haben da was
      für Sie… 
   </p>
        <p>
          <br />
      Gemeinsam mit Referenten und Experten <a href="http://www.thinktecture.com">thinktecture</a> präsentiert <a href="http://www.develop.com/uk">DevelopMentor</a> fünf
      Tage voller Power, geballtem Wissen und praktischer Umsetzung mit dem „<strong>Service-Orientierung
      heute und morgen“</strong>-Kurs.
   </p>
        <p>
          <br />
          <a href="http://www.thinktecture.com/staff/dominick">Dominick Baier</a> und <a href="http://www.thinktecture.com/staff/christian">Christian
      Weyer</a> zeigen Ihnen in gewohnt praxisorientierter Art und Weise sowohl Grundlagen
      und Konzepte als auch deren konkrete und pragmatische Umsetzung, alles basierend auf
      jahrelanger Projekterfahrung.<br />
      Erleben Sie wie Sie Service-Orientierung heute und morgen - gemischt mit dem zukunftsweisenden
      Themenkomplex Cloud Computing - auf Basis der Windows- und .NET –Plattform lokal und
      in der Cloud realisieren können. In Hands-on-Labs können Sie selbst die Ärmel hochkrempeln
      und gleich das Gelernte in Form von Code in Tatsachen umsetzen.
   </p>
        <p>
          <br />
        </p>
        <p>
      Nach diesen fünf Tagen werden Sie basierend auf diesen Themenbereichen die ersten
      Schritte in der Welt von Service-Orientierung alleine gehen können und vor allem vorbereitet
      sein für kommende Projektaufgaben:
   </p>
        <ul>
          <li>
         Service-Orientierung 
      </li>
          <li>
         Cloud &amp; Cloud Computing 
      </li>
          <li>
         Identitäts-Management &amp; Claims-basierte Identität 
      </li>
          <li>
         Windows Communication Foundation (WCF) 
      </li>
          <li>
         Windows Workflow Foundation (WF) 
      </li>
          <li>
         Azure Services Plattform (mit Windows Azure und .NET Services)</li>
        </ul>
        <p>
      Die folgende Auflistung gibt Ihnen einen detaillierteren Überblick über die behandelten
      Themen:
   </p>
        <h4>
          <strong>Tag 1</strong>
        </h4>
        <ul>
          <li>
         Service-Orientierung 
      </li>
          <li>
         WCF-Architektur 
      </li>
          <li>
         Design-by-Contract</li>
        </ul>
        <h4>
          <strong>Tag 2</strong>
        </h4>
        <ul>
          <li>
         WCF Instances, Concurrency &amp; Session Management 
      </li>
          <li>
         WCF Security 
      </li>
          <li>
         WCF Hosting</li>
        </ul>
        <h4>
          <strong>Tag 3</strong>
        </h4>
        <ul>
          <li>
         WF Workflow Services 
      </li>
          <li>
         WCF REST 
      </li>
          <li>
         Azure-Services-Architektur</li>
        </ul>
        <h4>
          <strong>Tag 4</strong>
        </h4>
        <ul>
          <li>
         Windows Azure Development &amp; Deployment 
      </li>
          <li>
         Windows Azure Storage 
      </li>
          <li>
         Identitäts-Management</li>
        </ul>
        <h4>
          <strong>Tag 5</strong>
        </h4>
        <ul>
          <li>
         .NET Services Access Control Service 
      </li>
          <li>
         .NET Services Service Bus 
      </li>
          <li>
         NET Services Workflow Service</li>
        </ul>
        <p>
      Und hier noch die notwendigen Informationen für Ihre Planung: 
   </p>
        <p>
          <b>Wann?</b> 6.-10. Juli 2009<br /><b>Wo?</b><a href="http://www.haeckers-kurhotel.com/bad-ems/de/index.htm">Häckers
      Kurhotel</a>, Bad Ems 
      <br /><b>Wieviel?</b> 3200,- € (inkl. Übernachtungen, Frühstück, Mittagessen und Abendessen) 
   </p>
        <p>
          <em>
            <font size="1">Durchführender Veranstalter ist DevelopMentor.</font>
          </em>
        </p>
        <p>
        
   </p>
        <p>
      Für Fragen, Wünsche oder Buchungsanfragen kontaktieren Sie bitte <a href="mailto:office@thinktecture.com?subject=Anfrage:%20Service-Orientierung%20heute%20und%20morgen">thinktecture</a> oder <a href="mailto:salesuk@develop.com?subject=Anfrage:%20Service-Orientierung%20heute%20und%20morgen">DevelopMentor</a>. 
   </p>
        <p>
      Vielen Dank. <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=f530fa7d-9f26-4402-97c9-b61d9858a944" /></p>
      </div>
    </content>
  </entry>
  <entry>
    <title>PPID Information and Generation Examples</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/PPIDInformationAndGenerationExamples.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=861f1c92-d413-4347-836d-d60c6d9583fc</id>
    <published>2009-04-03T08:52:54.18618+02:00</published>
    <updated>2009-04-03T08:52:54.18618+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://support.microsoft.com/?scid=kb;en-us;969419&amp;x=15&amp;y=7">This</a> article
      provides useful information on generating interoperable PPIDs.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=861f1c92-d413-4347-836d-d60c6d9583fc" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Custom Principals in WCF with Geneva</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/CustomPrincipalsInWCFWithGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=edad167e-712b-4752-9043-e808948ffb4b</id>
    <published>2009-04-02T11:01:34.0984757+02:00</published>
    <updated>2009-04-02T11:01:34.0984757+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   WCF has an extensibility point to set your own IPrincipal implementation on Thread.CurrentPrincipal
   (I wrote about that &lt;a href="http://www.leastprivilege.com/CustomPrincipalsAndWCF.aspx"&gt;here&lt;/a&gt;).
   Geneva uses this mechanism to set its IClaimsPrincipal (wrote about that &lt;a href="http://www.leastprivilege.com/GenevaIntegrationIntoWCF.aspx"&gt;here&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
   Since the standard “slot” for custom principals is already used by Geneva, it was
   unclear to me how to set your own IPrincipal &lt;em&gt;after&lt;/em&gt; Geneva has done its work.
   With a little help from the Geneva team (thanks Jan) – I found a way that works.
&lt;/p&gt;
&lt;p&gt;
   You can replace the principal in a service authorization manager via the &lt;em&gt;Properties&lt;/em&gt; collection
   on the authorization context. Voodoo.
&lt;/p&gt;
&lt;p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"&gt;
   &lt;span style="font-family: consolas; color: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;class&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: #2b91af"&gt;AuthorizationManager&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;IdentityModelServiceAuthorizationManager&lt;br&gt;
   &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;bool&lt;/span&gt; CheckAccess(&lt;span style="color: #2b91af"&gt;OperationContext&lt;/span&gt; operationContext, &lt;span style="color: blue"&gt;ref&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Message&lt;/span&gt; message)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;base&lt;/span&gt;.CheckAccess(operationContext, &lt;span style="color: blue"&gt;ref&lt;/span&gt; message);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   action header to get to the request operation&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; action
   = operationContext.IncomingMessageHeaders.Action;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   properties collection holds the principal that goes on Thread.CurrentPrincipal&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt; properties
   = operationContext&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;.ServiceSecurityContext&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;.AuthorizationContext&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;.Properties;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   retrieve current principal&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; principal
   = properties[&lt;span style="color: #a31515"&gt;"Principal"&lt;/span&gt;] &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   create custom principal&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt; customPrincipal
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;CustomClaimsPrincipal&lt;/span&gt;(principal, &lt;span style="color: #a31515"&gt;"some
   value"&lt;/span&gt;);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   set the custom principal&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;properties[&lt;span style="color: #a31515"&gt;"Principal"&lt;/span&gt;]
   = customPrincipal;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; Authorize(action,
   customPrincipal);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;bool&lt;/span&gt; Authorize(&lt;span style="color: blue"&gt;string&lt;/span&gt; action, &lt;span style="color: #2b91af"&gt;CustomClaimsPrincipal&lt;/span&gt; principal)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   do whatever authZ logic you have&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;true&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;CustomClaimsPrincipal&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ClaimsPrincipal&lt;br&gt;
   &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; CustomClaimsPrincipal(&lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; principal, &lt;span style="color: blue"&gt;string&lt;/span&gt; customValue) 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: &lt;span style="color: blue"&gt;base&lt;/span&gt;(principal)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CustomPropery
   = customValue;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; CustomPropery
   { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   Afterwards register this class in the &lt;em&gt;ServiceAuthorizationBehavior&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
   Be aware that this gets called on every request – so don’t put expensive operations
   in the custom principal creation code.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=edad167e-712b-4752-9043-e808948ffb4b" /&gt;</content>
  </entry>
  <entry>
    <title>Client Generated SAML Tokens to Interact with the Access Control Service</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ClientGeneratedSAMLTokensToInteractWithTheAccessControlService.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=3f10e7af-5187-41d9-b92b-d752ee49f09b</id>
    <published>2009-03-29T07:34:35.4854162+02:00</published>
    <updated>2009-03-29T07:34:35.4854162+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I recently <a href="http://www.leastprivilege.com/UsingSAMLAsAClientCredentialTypeInWCFWithGeneva.aspx">wrote</a> about
      generating SAML tokens at the client. Justin showed a similar approach at Mix to interact
      with the Access Control Service.
   </p>
        <ul>
          <li>
         Mix <a href="http://videos.visitmix.com/MIX09/T02F">recording</a></li>
          <li>
         Blog <a href="http://blogs.msdn.com/justinjsmith/archive/2009/03/24/tokenclient-mix-introduction.aspx">post</a></li>
        </ul>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=3f10e7af-5187-41d9-b92b-d752ee49f09b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Get Skilled or get 0wned</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GetSkilledOrGet0wned.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=81e908dd-fb5e-4b0b-bb38-d2bab3a1e989</id>
    <published>2009-03-17T09:01:56.6142556+01:00</published>
    <updated>2009-03-17T09:01:56.6142556+01:00</updated>
    <category term="Conferences" label="Conferences" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Nice claim for a conference ;)
   </p>
        <p>
      I am happy to join my former colleagues from <a href="http://www.ernw.de">ERNW</a> for
      their yearly Troopers conference in Munich.
   </p>
        <p>
      Two days full of top notch security talks – should be big fun. I’ll add my 2c about
      the .NET Access Control Service (Microsoft’s R-STS in the cloud) to the mix.
   </p>
        <p>
          <a title="http://www.troopers09.org" href="http://www.troopers09.org">http://www.troopers09.org</a>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=81e908dd-fb5e-4b0b-bb38-d2bab3a1e989" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Geneva integration into ASP.NET</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaIntegrationIntoASPNET.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=60a62077-dcd4-4e22-b8a2-4a2f53a9bd85</id>
    <published>2009-03-12T22:21:38.6432879+01:00</published>
    <updated>2009-03-12T22:21:38.6432879+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Geneva is integrated in ASP.NET/IIS using the standard <em>IHttpModule</em> extensibility
      mechanism. Geneva ships with three HTTP modules:
   </p>
        <ul>
          <li>
            <em>ClaimsPrincipalHttpModule </em>(already wrote about it <a href="http://www.leastprivilege.com/GenevaHTTPModulesClaimsPrincipalHttpModule.aspx">here</a>). 
      </li>
          <li>
            <em>WSFederationAuthenticationModule </em>(implements WS-Federation authentication) 
      </li>
          <li>
            <em>SessionAuthenticationModule </em>(implements session authentication)</li>
        </ul>
        <p>
          <em>ClaimsPrincipalHttpModule</em> is special – but the other two are built upon a
      framework for handling token based authentication in ASP.NET. To integrate into this
      framework, one has to derive from a base class called <em>FederatedAuthenticationModuleBase</em>.
      This implements the <em>IHttpModule </em>interface, subscribes to the <em>AuthenticateRequest</em> and <em>EndRequest </em>pipeline
      events and provides some helper methods. This base class drives the core logic of
      how a typical redirection and token based authentication works. For the protocol specific
      details, the derived class has to implement a bunch of abstract methods. This is how
      WS-Federation is implemented – other protocols could be realized in a similar fashion.
   </p>
        <p>
      The core logic is as follows:
   </p>
        <p>
          <strong>AuthenticateRequest</strong>
        </p>
        <ul>
          <li>
         check if federated authentication is enabled 
      </li>
          <li>
         check if current request is a sign in request (abstract <em>CanReadSignInRequest</em>) 
      </li>
          <li>
         extract security token from request (abstract <em>GetSecurityToken</em>) 
         <ul><li>
               raise <em>SecurityTokenReceived </em>event</li></ul></li>
          <li>
         create <em>IClaimsPrincipal </em>from security token 
         <ul><li>
               raise <em><u>SecurityTokenValidated</u></em> event</li></ul></li>
          <li>
         set principal 
      </li>
          <li>
         create session security token 
      </li>
          <li>
         set session security token using the configured cookie handler 
         <ul><li>
               raise <em>SessionSecurityTokenCreated</em> event</li></ul></li>
          <li>
         raise <em>SignedIn </em>event 
      </li>
          <li>
         check for a return URL (abstract <em>GetReturnUrlFromResponse</em>) 
         <ul><li>
               do the redirect</li></ul></li>
        </ul>
        <p>
          <strong>EndRequest</strong>
        </p>
        <ul>
          <li>
         check if federated authentication is enabled 
      </li>
          <li>
         if a 401 response is found, redirect to identity provider (abstract <em>RedirectToIdentityProvider</em>)</li>
        </ul>
        <p>
      Now let’s have a close look what the two derived module do.
   </p>
        <p>
          <strong>WSFederationAuthenticationModule<br /></strong>As stated earlier, this module deals with WS-Federation redirects and token
      parsing.
   </p>
        <ul>
          <li>
            <strong>CanReadSigninRequest</strong>
            <br />
         checks for the WS-Federation messages (wsignin1.0 / wsignoutcleanup1.0) 
      </li>
          <li>
            <strong>GetSecurityToken</strong>
            <br />
         extracts the token from the STS response and uses the security token handler infrastructure
         to create a <em>SecurityToken</em></li>
          <li>
            <strong>GetReturnUrlFromResponse</strong>
            <br />
         parses the WS-Fed context field for a return URL- 
      </li>
          <li>
            <strong>RedirectToIdentityProvider</strong>
            <br />
         creates a <em>SignInRequest</em> message and redirects to the configured identity
         provider.</li>
        </ul>
        <p>
       
   </p>
        <p>
          <strong>SessionAuthenticationModule</strong>
          <br />
      After the module implementing the authentication protocol has done its job, the base
      class creates a session token. This session token contains the original token issued
      from the STS (the bootstrap token) as well as a serialized version of the <em>IClaimsPrincipal </em>(after
      transformation via the <em>ClaimsAuthenticationManager</em>). This session token gets
      persisted by a cookie handler (typically into a HTTP cookie). The session authentication
      module uses this cookie to re-create the <em>IClaimsPrincipal</em> on each request.
   </p>
        <p>
      Since the session token characteristics are a bit specific, the module builds upon
      the base framework and helper methods, but short-circuits the logic by overriding <em>AuthenticateCore</em> directly.
      This is what happens:
   </p>
        <ul>
          <li>
         check if cookie is present (using the configured cookie handler) 
      </li>
          <li>
         recreate the <em>SessionSecurityToken</em> from the cookie (using the session security
         token handler) 
      </li>
          <li>
         raise <em>SessionSecurityTokenReceived</em> event 
      </li>
          <li>
         based on the outcome of the event either renew the cookie and/or set the principal 
      </li>
          <li>
         raise <em>SignedIn </em>event</li>
        </ul>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=60a62077-dcd4-4e22-b8a2-4a2f53a9bd85" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Geneva integration into WCF</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaIntegrationIntoWCF.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=61de281b-d8ca-45f6-9807-eeb45f0bca90</id>
    <published>2009-03-12T10:56:01.1963933+01:00</published>
    <updated>2009-03-12T10:56:01.1963933+01:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Having done quite a bit of WCF customization myself, it is fun to see how Geneva framework
      wires itself up into the WCF runtime.
   </p>
        <p>
      The high-level goals are as follows:
   </p>
        <ul>
          <li>
         route the token provisioning, serialization and authentication through the Geneva
         pipeline</li>
          <li>
         make an <em>IClaimsPrincipal</em> available on the service side</li>
          <li>
         allow setting issued tokens directly on a <em>ChannelFactory</em></li>
        </ul>
        <p>
      On the service side this is achieved by passing in a <em>ServiceHost</em> instance
      into <em>FederatedServiceCredentials.ConfigureHost()</em>. What does exactly happen
      inside that call?
   </p>
        <ul>
          <li>
         replace the standard WCF <em>ServiceCredential</em> with a <em>FederatedServiceCredential</em></li>
          <ul>
            <li>
            the service credential drives the creation of a <em>SecurityTokenManager</em> (in
            this case the <em>FederatedSecurityTokenManager</em>)</li>
            <li>
            this in turn creates the token provider, serializer and authenticator. In Geneva all
            three functionalities are inside a <em>SecurityTokenHandler</em>.</li>
            <li>
            Geneva’s token manager dispatches the incoming requests to the corresponding methods
            of the token handler depending on the incoming token type</li>
          </ul>
          <li>
         set the service certificate</li>
          <ul>
            <li>
            either by copying the standard service certificate specified in the <em>ServiceCredential</em>.</li>
            <li>
            or by replacing the existing one with the certificate specified in the &lt;microsoft.IdentityModel
            /&gt; configuration section</li>
          </ul>
          <li>
         create token resolvers for</li>
          <ul>
            <li>
            the service certificate</li>
            <li>
            issuer certificates (if the WCF <em>knownIssuers</em> configuration element is set)</li>
          </ul>
          <li>
         set a <em>ClaimsAuthenticationManager</em> (either a pass-through one, or the one
         specified in code/config)</li>
          <li>
         set the <em>PrincipalPermissionMode</em> to <em>Custom</em>. This is necessary to
         populate <em>Thread.CurrentPrincipal</em> with an <em>IClaimsPrincipal</em>.</li>
          <li>
         set the service authorization manager. 
      </li>
          <ul>
            <li>
            service authorization managers drive the creation of authorization policies. 
         </li>
            <li>
            an authorization policy in turn can parse the WCF internal claims and set <em>Thread.CurrentPrincipal</em>.
            Persisting the bootstrap token also happens here. 
         </li>
            <li>
            to make this all work, Geneva has its own service authorization manager (<em>IdentityModelServiceAuthorizationManager</em>)
            and its own authorization policy (<em>Microsoft.IdentityModel.Tokens.AuthorizationPolicy</em>).</li>
          </ul>
        </ul>
        <p>
       
   </p>
        <p>
      On the client side things are much simpler. The main purpose of the Geneva client
      side plumbing is to allow more direct interaction with tokens. The standard WCF issued
      token client credential assumes you want to implicitly acquire a token from a WS-Trust
      token service.
   </p>
        <p>
      Token provisioning is driven by so called <em>SecurityTokenParameters</em>. Whereas
      the WCF built-in <em>IssuedSecurityTokenParameters</em> only allow specifying the
      details of the token issuer, the Geneva <em>FederatedClientCredentialsParameters</em> instead
      allows setting a pre-acquired token directly. 
   </p>
        <p>
      So when you call <em>FederatedClientCredentials.ConfigureChannelFactory&lt;T&gt;</em> all
      that is happening is, that the standard WCF <em>ClientCredentials</em> get replaced
      by the <em>FederatedClientCredentials</em> class. This creates a <em>FederatedClientCredentialsSecurityTokenManager </em>which
      in turn instantiates the token serializer (via the security token handlers) and a
      token provider that is aware of <em>FederatedClientCredentialsParameters</em>.
   </p>
        <p>
      To actually set the token on a channel, you call one of the extension methods for <em>ChannelFactory&lt;T&gt;</em>.
      They can be found in <em>Microsoft.IdentityModel.Protocols.WSTrust.ChannelFactoryOperations</em>.
      These extension methods take the token you pass in, create the token parameters and
      add them to the token parameters collection of the channel.
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=61de281b-d8ca-45f6-9807-eeb45f0bca90" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Using SAML as a Client Credential Type in WCF (with Geneva)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsingSAMLAsAClientCredentialTypeInWCFWithGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=b3dcbcb5-29a2-4e4b-a5f3-38b09e126a0a</id>
    <published>2009-03-10T07:24:52.217+01:00</published>
    <updated>2009-03-12T09:08:12.2708994+01:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   &lt;strong&gt;Disclaimer&lt;/strong&gt;
   &lt;br&gt;
   For the motivation for this article please read &lt;a href="http://www.leastprivilege.com/CustomWCFCredentialTypes.aspx"&gt;this&lt;/a&gt; here
   first. I am not advocating the use of client generated SAML tokens in general, and
   I also know that there is not much point in the client generating claims for a service.
   This whole article is about replacing the UserName token with a SAML token in situations
   where you need extensibility points that a UserName tokens cannot give you.
&lt;/p&gt;
&lt;p&gt;
   As I said in my previous post, SAML is an extensible and flexible token type - but
   not very accessible in plain WCF. Geneva abstracts the creation and consumption of
   tokens in so called token handlers. All you need is a description of the token that
   you want to generate and then you feed this description into the appropriate token
   handler. I wrote an article about the token generation pipeline in Geneva &lt;a href="http://www.leastprivilege.com/SAMLTokenCreationInAGenevaSTS.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
   Even better, Geneva has some client side plumbing for WCF that lets you use the generated
   token for service calls in a quite straightforward fashion.
&lt;/p&gt;
&lt;p&gt;
   So the simple scenario is this: the client credential consists of three pieces: username,
   password and a customer ID (think e.g. of multi-tenant apps). The service receiving
   this credential could be a normal WCF service or a STS that issues tokens based on
   the client credential. For future extensibility a general version of this would be
   a credential with a user name and an unlimited number of properties (e.g. password,
   customer ID etc.). In a SAML token this would map to the name identifier and a number
   of attributes.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Client&lt;/strong&gt;
   &lt;br&gt;
   Using Geneva you can generate a SAML token like this:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ClientToken&lt;br&gt;
   &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; _claimsUri
   = &lt;span style="COLOR: #a31515"&gt;&lt;a href="http://www.leastprivilege.com/claims/"&gt;http://www.leastprivilege.com/claims/&lt;/a&gt;&lt;/span&gt;;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SamlSecurityToken&lt;/span&gt; Create(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; subjectName, &lt;span style="COLOR: #2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;
   properties)&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ClaimsIdentity&lt;/span&gt; id
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ClaimsIdentity&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;from&lt;/span&gt; item &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; properties&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;select&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;(_claimsUri
   + item.Key, item.Value));&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;id.Claims.Add(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;WSIdentityConstants&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.NameIdentifier,
   subjectName));&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; description
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityTokenDescriptor&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Subject
   = id,&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;TokenIssuerName
   = &lt;span style="COLOR: #a31515"&gt;"http://self"&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;};&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; handler
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Saml11SecurityTokenHandler&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SamlSecurityTokenRequirement&lt;/span&gt;());&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SamlSecurityToken&lt;/span&gt;)handler.CreateToken(description);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   After creating the token you can use the Geneva extension methods for &lt;em&gt;ChannelFactory&amp;lt;T&amp;gt;&lt;/em&gt; to
   set the token as a client credential:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;static&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[]
   args)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; props
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{ &lt;span style="COLOR: #a31515"&gt;"password"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"secret"&lt;/span&gt; },&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{ &lt;span style="COLOR: #a31515"&gt;"customerId"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"42"&lt;/span&gt; }&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;};&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; token
   = &lt;span style="COLOR: #2b91af"&gt;ClientToken&lt;/span&gt;.Create(&lt;span style="COLOR: #a31515"&gt;"dominick"&lt;/span&gt;,
   props);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; factory
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ChannelFactory&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;IServiceClientChannel&lt;/span&gt;&amp;gt;(&lt;span style="COLOR: #a31515"&gt;"*"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="COLOR: #2b91af"&gt;&amp;nbsp; FederatedClientCredentials&lt;/span&gt;.ConfigureChannelFactory&amp;lt;&lt;span style="COLOR: #2b91af"&gt;IServiceClientChannel&lt;/span&gt;&amp;gt;(factory);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; proxy
   = factory.CreateChannelWithIssuedToken&amp;lt;&lt;span style="COLOR: #2b91af"&gt;IServiceClientChannel&lt;/span&gt;&amp;gt;(token);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;proxy.Operation(&lt;span style="COLOR: #a31515"&gt;"foo"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;proxy.Close();&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Service&lt;/strong&gt;
   &lt;br&gt;
   On the service side you need a corresponding token handler that “understands” the
   semantics of the SAML token. Geneva has a built-in handler for SAML tokens but it
   does not know how to authenticate the client based on the values of certain SAML attributes.
   Furthermore you need to make a decision which of the incoming attributes should become
   part of the claims identity in the service. Maybe you don’t want sensitive information
   like the password to flow to the service operations (maybe you want exactly that).
   Other customizations to the standard behavior would be to ignore audience URIs as
   well as signatures (since our client tokens won’t have them).
&lt;/p&gt;
&lt;p&gt;
   By deriving from the built-in token handler you can drive this logic while letting
   the base class do all the heavy lifting of token serialization and parsing:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;abstract&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ClientSaml11SecurityTokenHandlerBase&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Saml11SecurityTokenHandler&lt;br&gt;
   &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   disable audience URI checking&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; ClientSaml11SecurityTokenHandlerBase()&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SamlSecurityTokenRequirement&lt;/span&gt; {
   AudienceUriMode = &lt;span style="COLOR: #2b91af"&gt;AudienceUriMode&lt;/span&gt;.Never })&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{ }&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   extensibility point for authentication and claims filtering&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;abstract&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; ValidateUser(&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; subjectName, &lt;span style="COLOR: #2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;
   properties, &lt;span style="COLOR: blue"&gt;ref&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;
   claimsList);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   override signature handling&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityToken&lt;/span&gt; ReadToken(&lt;span style="COLOR: #2b91af"&gt;XmlReader&lt;/span&gt; reader)&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;Saml11Assertion&lt;/span&gt; assertion
   = &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.ReadAssertion(reader);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SamlSecurityToken&lt;/span&gt;(assertion);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ClaimsIdentityCollection&lt;/span&gt; ValidateToken(&lt;span style="COLOR: #2b91af"&gt;SecurityToken&lt;/span&gt; token)&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   call base class for token validation and serialization&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; ids
   = &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.ValidateToken(token);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; id
   = ids[0];&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   retrieve client name&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; subjectName
   = id.Claims.Where(&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;claim
   =&amp;gt; claim.ClaimType == &lt;span style="COLOR: #2b91af"&gt;WSIdentityConstants&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.NameIdentifier).First().Value;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   copy attributes to dictionary&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; properties
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;();&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;id.Claims.ToList().ForEach(&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;claim
   =&amp;gt; properties.Add(claim.ClaimType, claim.Value));&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   call authentication and filtering logic&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; claimsToKeep
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;();&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (ValidateUser(subjectName,
   properties, &lt;span style="COLOR: blue"&gt;ref&lt;/span&gt; claimsToKeep))&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ClaimsIdentity&lt;/span&gt; identity
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ClaimsIdentity&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"ClientSAML"&lt;/span&gt;);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   add client name&lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;identity.Claims.Add(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;(&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;WSIdentityConstants&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Name,
   subjectName, &lt;span style="COLOR: #2b91af"&gt;ClaimValueTypes&lt;/span&gt;.String, &lt;span style="COLOR: #a31515"&gt;"LOCAL"&lt;/span&gt;));&lt;span style="COLOR: #2b91af"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   copy "allowed" attributes&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;claimsToKeep.ForEach(claimType
   =&amp;gt;&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; value
   = id.Claims.Where(claim =&amp;gt; claim.ClaimType == claimType).FirstOrDefault().Value;&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.IsNullOrEmpty(value))&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;identity.Claims.Add(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;(claimType,
   value, &lt;span style="COLOR: #2b91af"&gt;ClaimValueTypes&lt;/span&gt;.String, &lt;span style="COLOR: #a31515"&gt;"LOCAL"&lt;/span&gt;));&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;});&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ClaimsIdentityCollection&lt;/span&gt;(identity);&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;else&lt;/span&gt;&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityTokenValidationException&lt;/span&gt;();&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: green"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="COLOR: green"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   The authentication logic and filtering could be implemented like this:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;class&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: #2b91af"&gt;ClientSaml11SecurityTokenHandler&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;ClientSaml11SecurityTokenHandlerBase&lt;br&gt;
   &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; ValidateUser(&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; subjectName, &lt;span style="COLOR: #2b91af"&gt;Dictionary&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;
   properties, &lt;span style="COLOR: blue"&gt;ref&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;
   claimsList)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; password
   = properties[_passwordClaimType];&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   sample password check – don’t just copy&amp;amp;paste this code ;)&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (subjectName
   != password)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;claimsList.Add(_customerIdClaimType);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   After wiring up the new token handler in the WCF service you get access to the claims
   in the operation via IClaimsPrincipal as usual.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Configuration&lt;br&gt;
   &lt;/strong&gt;The last step deals with setting up the security parameters on the binding.
   Since the client SAML token is much like a UserName token on steroids, we choose similar
   security configurations (and make the same security guarantees). You can either use
   message security where the client token gets encrypted with the service certificate
   – or mixed mode security where the transport is secured using SSL.
&lt;/p&gt;
&lt;p&gt;
   For mixed mode security you can use the &lt;em&gt;IssuedTokenOverTransport&lt;/em&gt; authentication
   mode. The custom binding looks like this:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: #a31515; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;customBinding&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: #a31515; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;binding&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: red; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;name&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;BearerTokenOverTransport&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;security&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;authenticationMode&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;IssuedTokenOverTransport&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;issuedTokenParameters&lt;/span&gt;&lt;span style="COLOR: blue"&gt; 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;tokenType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: red"&gt;keyType&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BearerKey&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;security&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;textMessageEncoding&lt;/span&gt;&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;httpsTransport&lt;/span&gt;&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;customBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   For message security, there is no built-in binding element helper – you have to construct
   it via code:
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; COLOR: blue; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityBindingElement&lt;/span&gt; CreateClientTokenForCertificateBindingElement()&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// protection
   token&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; element
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SymmetricSecurityBindingElement&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;X509SecurityTokenParameters&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;X509KeyIdentifierClauseType&lt;/span&gt;.Thumbprint,&amp;nbsp;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SecurityTokenInclusionMode&lt;/span&gt;.Never));&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;// client
   token&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; parameters
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IssuedSecurityTokenParameters&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;Saml11SecurityTokenHandler&lt;/span&gt;.OasisWssSamlTokenProfile11,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;EndpointAddress&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;&lt;a href="http://self"&gt;http://self&lt;/a&gt;&lt;/span&gt;),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;BasicHttpBinding&lt;/span&gt;());&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;parameters.KeyType = &lt;span style="COLOR: #2b91af"&gt;SecurityKeyType&lt;/span&gt;.BearerKey;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;parameters.InclusionMode = &lt;span style="COLOR: #2b91af"&gt;SecurityTokenInclusionMode&lt;/span&gt;.AlwaysToRecipient;&lt;br style="mso-special-character: line-break"&gt;
   &lt;br style="mso-special-character: line-break"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p style="LINE-HEIGHT: normal; MARGIN-BOTTOM: 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;
   &lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;element.EndpointSupportingTokenParameters.SignedEncrypted.Add(parameters);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;element.MessageSecurityVersion = 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;MessageSecurityVersion&lt;/span&gt;.WSSecurity11WSTrust13&lt;br&gt;
   &lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
   WSSecureConversation13&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WSSecurityPolicy12BasicSecurityProfile10;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; element;&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   You can then use this helper to construct a custom binding (see the download for the
   complete code).
&lt;/p&gt;
&lt;p&gt;
   That’s it. HTH
&lt;/p&gt;
&lt;p&gt;
   &lt;a href="http://www.leastprivilege.com/content/binary/ClientSamlCredential.zip"&gt;ClientSamlCredential.zip
   (450.94 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=b3dcbcb5-29a2-4e4b-a5f3-38b09e126a0a" /&gt;</content>
  </entry>
  <entry>
    <title>Custom WCF Credential Types</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/CustomWCFCredentialTypes.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=54c376a1-4c63-4d51-a2e3-dcd7302695a2</id>
    <published>2009-03-09T10:30:20.3014011+01:00</published>
    <updated>2009-03-09T10:30:20.3014011+01:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Every once in a while the question comes up how to extend WCF with custom credential
      types. It turns out that most of the time people don’t really want to invent custom
      tokens or credential types, but rather want to extend username/password style of credentials
      (e.g. username/password/customer ID). Unfortunately the UserName token does not support
      this type of extensibility but there are several options to accomplish this:
   </p>
        <ul>
          <li>
         If your extensibility requirements are very simple you could try to encode all the
         information into the username and password fields of a UserName credential. You’d
         need some extra plumbing on the service side (<em>UserNamePasswordValidator</em>,
         custom <em>IPrincipal</em>) to decode the information again and provide normalized
         user information. 
      </li>
          <li>
         You could use SOAP headers to transmit the additional information. This has the potential
         to pollute your business logic with security plumbing and needs some wrapping. There
         are also some gotchas around <a href="http://blogs.msdn.com/drnick/archive/2008/08/22/autoheader-extension.aspx">adding</a> headers
         on the fly, as well as <a href="http://blogs.msdn.com/drnick/archive/2007/01/18/securing-custom-headers-version-1.aspx">protecting</a> them. 
      </li>
          <li>
         You could write a full fledged custom credential that supports the extensibility you
         need. Unfortunately this is not the best documented area of WCF and you are mostly
         on your own. The WCF credential infrastructure is extremely flexible – but I wouldn’t
         call it an extensibility point – but rather a replacement point. You end up replacing
         a number of classes on the service and client side to make this happen (see <a href="http://www.pluralsight.com/community/blogs/tjanczuk/archive/2006/06/16/28046.aspx">here</a> for
         an overview). I did that for a username/password/namevalue credential and it wasn’t
         a pleasant experience. 
      </li>
          <li>
         You could use a standard token type in WCF that already supports all the extensibility
         needs you might have – e.g. SAML. The problem here is that SAML and issued tokens
         are not very accessible through plain WCF – but Geneva makes it much easier to use
         them - even without a security token service. That’s the option I am going to look
         at in the next post.</li>
        </ul>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=54c376a1-4c63-4d51-a2e3-dcd7302695a2" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Setting Key Identifiers in Geneva</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SettingKeyIdentifiersInGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=0ea99b6f-30e7-4244-8524-1fc9820040be</id>
    <published>2009-02-27T10:33:49.9175905+01:00</published>
    <updated>2009-02-27T10:33:49.9175905+01:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Keys used in tokens or RSTRs need to be identified somehow – common ways to do this
      is to use a thumbprint, a serial number or the subject key identifier.
   </p>
        <p>
      A “Geneva” based token service will use the combination of issuer name and certificate
      serial number by default. This is usually fine, but you may need to change that because
      of interop scenarios. Metro based web services e.g. prefer the subject key identifier
      method.
   </p>
        <p>
      Took me some time to figure it out – so maybe this info is useful to someone.
   </p>
        <p>
      There are two key identifiers you may want to modify – the signing and the encrypting
      key. These are represented in “Geneva” using the <em>SigningCredentials</em> and <em>EncryptingCredentials</em> classes
      respectively. The signing credentials are supplied in the <em>SecurityTokenServiceConfiguration</em> whereas
      the encrypting credentials are specified in the <em>GetScope</em> method. On these
      classes you can set the key identifier method using the <em>SecurityKeyIdentifier</em> property
      or the constructor. You can use the following code to create a subject key identifier
      clause for X509 certificates:
   </p>
        <p>
          <font face="Consolas">var ski = new SecurityKeyIdentifier(<br />
                  new SecurityKeyIdentifierClause[] 
      <br />
                  { 
      <br />
                     
      new X509SecurityToken(cert).CreateKeyIdentifierClause&lt;<font color="#0080c0">X509SubjectKeyIdentifierClause</font>&gt;()<br />
                  });</font>
        </p>
        <p>
      To see what other key identifier types are available, have a look at the inheritance
      hierarchy of the base class <em>System.IdentityModel.Tokens.SecurityKeyIdentifierClause</em>.
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=0ea99b6f-30e7-4244-8524-1fc9820040be" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Host Headers, SSL and WCF Metadata</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/HostHeadersSSLAndWCFMetadata.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=67a856e5-a198-4df0-8335-e8dfe00b3040</id>
    <published>2009-02-10T10:34:56.5031122+01:00</published>
    <updated>2009-02-10T10:34:56.5031122+01:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      One of my web servers here has a pretty common setup – a Windows machine name and
      a (different) DNS name (in this case dynamic DNS – but doesn’t matter). IIS has a
      single web site with bindings for HTTP and HTTPS. The common name of the SSL certificate
      matches the public DNS name. Everything looks good.
   </p>
        <p>
      The server also hosts some WCF services and I noticed that the imports and endpoint
      addresses in the WSDL point to the machine name and not to the DNS name. No big deal
      – simply set the host header for the site via the IIS GUI and I am done. That’s what
      I thought at least.
   </p>
        <p>
      And sure enough, after the configuration change my WSDL was correct and used the name
      configured in the host header.
   </p>
        <p>
      Some weeks later I added some more WCF endpoints to the machine, this time I was using
      SSL – including an SSL WSDL/MEX endpoint. After some weird error messages I re-inspected
      the WSDL and everything looked fine - until I hit the WSDL document in the browser
      using SSL. Again imports and endpoint addresses were pointing to the machine name.
      What’s going on here?
   </p>
        <p>
      After some googling I found articles about something I totally forgot about: SSL host
      headers. Since IIS 6 you can also set host headers for SSL site bindings. Since this
      option is not available via the GUI I kind of “missed” it. These two articles show
      the necessary steps for <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/596b9108-b1a7-494d-885d-f8941b07554c.mspx?mfr=true">IIS6</a> and <a href="http://blogs.iis.net/thomad/archive/2008/01/25/ssl-certificates-on-sites-with-host-headers.aspx">IIS7</a>.
   </p>
        <p>
      My applicationHost.config now looks like this for my site:
   </p>
        <span style="line-height: 115%; font-family: consolas; color: blue; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">&lt;</span>
        <span style="line-height: 115%; font-family: consolas; color: #a31515; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">bindings</span>
        <span style="line-height: 115%; font-family: consolas; color: blue; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">&gt;<br /><span style="mso-spacerun: yes">  </span>&lt;</span>
        <span style="line-height: 115%; font-family: consolas; color: #a31515; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">binding</span>
        <span style="line-height: 115%; font-family: consolas; color: blue; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">
        </span>
        <span style="line-height: 115%; font-family: consolas; color: red; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">protocol</span>
        <span style="line-height: 115%; font-family: consolas; color: blue; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">=</span>
        <span style="line-height: 115%; font-family: consolas; font-size: 11pt; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes">"<span style="color: blue">http</span>"<span style="color: blue"><br /><span style="mso-spacerun: yes">           </span></span><span style="color: red">bindingInformation</span><span style="color: blue">=</span>"<span style="color: blue">*:80:www.mypublicname.com</span>"<span style="color: blue"> /&gt;<br /><span style="mso-spacerun: yes">  </span>&lt;</span><span style="color: #a31515">binding</span><span style="color: blue"></span><span style="color: red">protocol</span><span style="color: blue">=</span>"<span style="color: blue">https</span>"<span style="color: blue"><br /><span style="mso-spacerun: yes">           </span></span><span style="color: red">bindingInformation</span><span style="color: blue">=</span>"<span style="color: blue">*:443:www.mypublicname.com</span>"<span style="color: blue"> /&gt;<br />
   &lt;/</span><span style="color: #a31515">bindings</span><span style="color: blue">&gt;</span></span>
        <p>
      HTH
   </p>
        <p>
      (Rich: marked as answer)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=67a856e5-a198-4df0-8335-e8dfe00b3040" />
      </div>
    </content>
  </entry>
  <entry>
    <title>UAC flawed in Win7?</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UACFlawedInWin7.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=b0a8a298-7a33-4b89-af02-df722a0dddea</id>
    <published>2009-02-04T20:53:17.0313709+01:00</published>
    <updated>2009-02-04T20:54:16.2184921+01:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I really, really hope this is a beta only issue…
   </p>
        <p>
          <a href="http://www.istartedsomething.com/20090204/second-windows-7-uac-flaw-malware-self-elevate/">http://www.istartedsomething.com/20090204/second-windows-7-uac-flaw-malware-self-elevate/</a>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=b0a8a298-7a33-4b89-af02-df722a0dddea" />
      </div>
    </content>
  </entry>
  <entry>
    <title>SQL Data Services Query Injection</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SQLDataServicesQueryInjection.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=81c0a3db-372b-4055-9bc0-668431211386</id>
    <published>2009-01-20T12:34:31.6321655+01:00</published>
    <updated>2009-01-20T12:34:31.6321655+01:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <category term="Work in Progress" label="Work in Progress" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The “query language” of SQL Data Services is basically a LINQ statement as a string,
      e.g.:
   </p>
        <blockquote>
          <p>
            <font face="Courier">from e in entities where e["username"] == "{0}" &amp;&amp; e["password"]
      == "{1}" select e</font>
          </p>
        </blockquote>
        <p>
      Do you see a problem here?
   </p>
        <p>
      Of course string concatenation combined with "no-schema” flex entities allows all
      kinds of injections. <a href="http://www.heege.net/blog/default.aspx">Marcus</a> and
      I did some tests, e.g. try entering the following username for the above statement:
   </p>
        <blockquote>
          <p>
            <font face="Courier New">foo" || "" == "</font>
          </p>
        </blockquote>
        <p>
      This will select all users. I am sure there are other tricks, too.
   </p>
        <p>
      So again – be aware that you have to validate all of your input! Some things you can
      do here include:
   </p>
        <ol>
          <li>
         run a regular expression over your inputs to make sure it only contains legal characters</li>
          <li>
         escape character like quotation marks and back slashes</li>
          <li>
         use e.g. the Single() LINQ operator on the returned entity list when you know that
         only one entity should be returned (otherwise something must be wrong).</li>
        </ol>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=81c0a3db-372b-4055-9bc0-668431211386" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Get help running a partial SSL website in ASP.NET</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GetHelpRunningAPartialSSLWebsiteInASPNET.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=04d0bf7f-48af-4fc1-98d5-8f93597cddaf</id>
    <published>2009-01-19T07:55:56.5999265+01:00</published>
    <updated>2009-01-19T07:55:56.5999265+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      A while ago I wrote <a href="http://www.leastprivilege.com/PartiallySSLSecuredWebAppsWithASPNET.aspx">this</a> article
      about some of the things to watch out for when securing parts of an application with
      SSL. Keith used the attached code as part of his work and extended it. Even better
      he made his extensions available for download – I recommend to have a look. Thanks
      for sharing, Keith!
   </p>
        <p>
      Read his post <a href="http://www.pluralsight.com/community/blogs/keith/archive/2009/01/17/sslhelper-get-help-running-a-partial-ssl-website-in-asp-net.aspx">here</a>.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=04d0bf7f-48af-4fc1-98d5-8f93597cddaf" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Welcome Richard Blewett</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/WelcomeRichardBlewett.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=0e8a2f7c-543b-457a-90cd-cc9726b8ca33</id>
    <published>2009-01-10T20:33:41.7870588+01:00</published>
    <updated>2009-01-10T20:33:41.7870588+01:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I am thrilled to announce that <a href="http://www.dotnetconsult.co.uk/weblog2/">Rich</a> has
      joined <a href="http://www.thinktecture.com">thinktecture</a> this week. That’s great
      news.
   </p>
        <p>
      I’ve been working with Rich since 2004 (in fact – he was part of that scary initiation
      ritual at DevelopMentor called “Test Teach”). He’s a great guy and knows hell of a
      lot about .NET and distributed systems (and I am not going into some of his other
      skills which usually end in a terrible headache next day – and I am not talking about
      World of Warcraft ;). <strong>Welcome Rich!</strong></p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=0e8a2f7c-543b-457a-90cd-cc9726b8ca33" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Live ID and Information Cards</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/LiveIDAndInformationCards.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=1439d65e-9e90-4d3b-93c9-9b3eabba177e</id>
    <published>2009-01-07T06:30:19.651+01:00</published>
    <updated>2009-01-07T06:38:37.723558+01:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I while ago I <a href="http://www.leastprivilege.com/LiveIDAndInformationCardsJustGoodFriends.aspx">wrote</a> that
      there is an experimental version of the Live ID login page that makes use of Information
      Cards linked to your Live ID account. Unfortunately this login form was only used
      for very specific services (hotmail only at that time IIRC).
   </p>
        <p>
      I am happy to see that more and more sites these days use the InfoCard enabled sign
      in page – and more importantly - sites I actually use (e.g. MSDN, Live Mesh, Connect…).
      Way to go!
   </p>
        <img src="http://www.leastprivilege.com/content/binary/Capture1.PNG" border="0" />
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=1439d65e-9e90-4d3b-93c9-9b3eabba177e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Federating with Live ID (using the Access Control Service)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/FederatingWithLiveIDUsingTheAccessControlService.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=0fc01cc6-c15a-4b82-af84-82e3021f2555</id>
    <published>2008-12-28T17:25:49.625+01:00</published>
    <updated>2008-12-28T17:27:10.6405372+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   There are already a number of ways today how you can federate with the Live ID service
   (e.g. using the &lt;a href="http://msdn.microsoft.com/en-us/library/bb404787.aspx"&gt;Live
   ID SDK&lt;/a&gt;, &lt;a href="http://dev.live.com/blogs/devlive/archive/2008/10/27/421.aspx"&gt;OpenID&lt;/a&gt; or &lt;a href="https://msm.live.com"&gt;WS-Federation&lt;/a&gt;).
   Another option would be to use the Access Control Service. I can see a bunch of reasons
   why this may be compelling:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      Live ID is pre-configured in the ACS. You don’t need any extra configuration steps
      to register your site with Live ID. It just works. 
   &lt;li&gt;
      You can use the ACS rules engine to transform the Live ID claims to your application
      claims. 
   &lt;li&gt;
      A Live ID is a low barrier entry for customers and partners to the ACS. In case they
      can’t federate “properly” (e.g. using Geneva or the &lt;a href="http://dev.live.com/blogs/devlive/archive/2008/10/27/420.aspx"&gt;Services
      Connector&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   Generally, this is a good example of how the ACS can simplify security management
   and configuration in your application endpoints. You can simply add another authentication
   method to your application without needing to change anything substantial. All the
   heavy lifting like crypto, trust and claims configuration is done in the ACS.
&lt;/p&gt;
&lt;p&gt;
   This walkthrough uses the PDC bits of the ACS and Geneva framework to access Live
   ID logins in an ASP.NET app. This is all beta software and details are subject to
   change!
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Step 1: Setting up ASP.NET to use the ACS&lt;br&gt;
   &lt;/strong&gt;First you have to enable Geneva in ASP.NET. This involves adding the WS-Federation
   authentication module as well as the session authentication module. You also have
   to setup the service certificate and allowed audience URI. Nothing special here.
&lt;/p&gt;
&lt;p&gt;
   Very similar to the WCF scenario I described &lt;a href="http://www.leastprivilege.com/UsingTheNETAccessControlServiceWithGeneva.aspx"&gt;here&lt;/a&gt;,
   you also have to check the token and SAML issuer. For the issuer check you use the
   regular issuer name registry as described in my post. For the SAML issuer check you
   can use an extensibility point in the FAM – simply add this code to global.asax:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;void&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; WSFederationAuthenticationModule_SecurityTokenValidated(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: #2b91af"&gt;SecurityTokenValidatedEventArgs&lt;/span&gt; e)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;e.ClaimsPrincipal.DemandClaim(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Microsoft.IdentityModel.Claims.&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.SamlIssuerName,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;"http://accesscontrol.windows.net/solutionName"&lt;/span&gt;);&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   These two customizations establish a trust relationship with your ACS. You can now
   start receiving tokens.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Step 2: Registering the application with the ACS&lt;br&gt;
   &lt;/strong&gt;Again nothing special here. You have to create a scope for the application
   in your ACS as well as configure the the encrypting certificate to match the certificate
   you configured in step 1.
&lt;/p&gt;
&lt;p&gt;
   The interesting part is the rule definition. When you add a new rule, you can now
   select the Live ID as an input claim and map it to whatever output claim you want.
   Examples would be to map it to a group (which in turn can map to permissions) or to
   tunnel the ID to the relying party (either as-is or as a different claim). The following
   screenshot shows a rule that transforms the Live ID to a standard name claim:
&lt;/p&gt;
&lt;p&gt;
   &lt;img src="http://www.leastprivilege.com/content/binary/rule_550.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Step 3: Triggering Live ID login&lt;br&gt;
   &lt;/strong&gt;The last step is to trigger the Live ID handshake in your app. The ACS’ endpoint
   for federation with Live ID is
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
   &lt;em&gt;https://accesscontrol.windows.net/passivests/{solutionName}/LiveFederation.aspx&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
   In the query string for this endpoint you have to provide the scope and the identity
   provider name (plus an optional reply-to address), like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
   &lt;em&gt;wa=wsignin1.0&amp;amp;wtrealm={scope}&amp;amp;wreply={replyTo}&amp;amp;whr={identityProvider}&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
   Unfortunately Geneva framework currently does not support the &lt;em&gt;whr&lt;/em&gt; parameter
   directly, which means you have to construct the URL manually. Geneva’s &lt;em&gt;SignInRequest&lt;/em&gt; class
   can help here. The following code does the redirect to the ACS and Live ID:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;protected&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; _lnkLiveLogin_Click(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: #2b91af"&gt;EventArgs&lt;/span&gt; e)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; homeRealm
   = &lt;span style="COLOR: #a31515"&gt;"http://login.live.com"&lt;/span&gt;;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; scope
   = &lt;span style="COLOR: #a31515"&gt;"http://myrp/default.aspx"&lt;/span&gt;;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; acs
   = &lt;span style="COLOR: #a31515"&gt;"https://accesscontrol.windows.net/passivests/{solutionName}/LiveFederation.aspx"&lt;/span&gt;;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; request
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SignInRequestMessage&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Uri&lt;/span&gt;(acs),
   scope);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.Parameters.Add(&lt;span style="COLOR: #a31515"&gt;"whr"&lt;/span&gt;,
   homeRealm);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Response.Redirect(request.RequestUrl);&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   After all redirects have occurred you end up back in your application with a populated &lt;em&gt;IClaimsPrincipal&lt;/em&gt; that
   contains the claims that you configured in your ACS scope. Adding new identity providers
   would be a matter of registering them with your ACS and changing the value of the
   home realm parameter.
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=0fc01cc6-c15a-4b82-af84-82e3021f2555" /&gt;</content>
  </entry>
  <entry>
    <title>Display Tokens &amp;amp; Geneva</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/DisplayTokensAmpGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=172e13c3-8011-48fd-b209-895e2e545247</id>
    <published>2008-12-26T11:44:36.3365946+01:00</published>
    <updated>2008-12-26T11:44:36.3365946+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   What are display tokens? In short: They allow an STS to pass some or all claims back
   to the client in a way that the client can read them. This differs from the “real”
   claims which are part of the security token and are encrypted for the relying party.
   A popular example of an application that consumes display claims is the CardSpace
   identity selector that allows you to preview the claims before they get send to the
   RP.
&lt;/p&gt;
&lt;p&gt;
   Look &lt;a href="http://www.identityblog.com/wp-content/resources/profile/InfoCard-Profile-v1-TechRef.pdf"&gt;here&lt;/a&gt; in
   section 4.3.6 for the technical specification and &lt;a href="http://blogs.msdn.com/vbertocci/archive/2007/10/31/on-displaytoken.aspx"&gt;here&lt;/a&gt; for
   a good discussion of use and abuse of display tokens.
&lt;/p&gt;
&lt;p&gt;
   In Geneva, display tokens are represented by the &lt;em&gt;DisplayToken&lt;/em&gt; class (which
   is a container for &lt;em&gt;DisplayClaim&lt;/em&gt;s). The &lt;em&gt;SecurityTokenService&lt;/em&gt; class
   has an overridable method called &lt;em&gt;GetDisplayToken&lt;/em&gt; in which the &lt;em&gt;DisplayToken&lt;/em&gt; gets
   constructed to be put into the RSTR (see also &lt;a href="http://www.leastprivilege.com/SAMLTokenCreationInAGenevaSTS.aspx"&gt;here&lt;/a&gt;).
   This method internally calls &lt;em&gt;GetDisplayClaimsForSubject&lt;/em&gt; on the default &lt;em&gt;ClaimsMapper&lt;/em&gt; that
   is configured on the &lt;em&gt;SecurityTokenServiceConfiguration &lt;/em&gt;of your STS&lt;em&gt;. &lt;/em&gt;This
   default claims mapper simply takes all claims found in the subject and emits them
   as display claims. For some standard claims the mapper already knows the display name
   and description – the others are emitted without further descriptions. 
&lt;/p&gt;
&lt;p&gt;
   It seems that in the future you want to extend the &lt;em&gt;ClaimsMapper&lt;/em&gt; class for
   your own display token work – for now the class does not seem to be ready for that.
   Another behavior of the &lt;strong&gt;current&lt;/strong&gt; Geneva bits is, that display claims
   are enabled by default – that means if your user requests them (more on that later)
   all claims will be emitted in clear to the user. This may or may not be what you want.
   In &lt;strong&gt;future&lt;/strong&gt; builds of Geneva, the display token feature will be opt-in.
&lt;/p&gt;
&lt;p&gt;
   But if you are building an STS with the current bits – you almost certainly want to
   take control over display token generation, because e.g.
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      maybe you emit claims that the user should not be able to see. 
   &lt;li&gt;
      if you want to emit a display token and you use non-standard claims, you want to provide
      display names and descriptions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Generating a display token&lt;br&gt;
   &lt;/strong&gt;Currently the easiest way to do this is to override the above mentioned &lt;em&gt;GetDisplayToken&lt;/em&gt; method
   in your STS, e.g.:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; DisplayToken
   GetDisplayToken(&lt;br&gt;
   &amp;nbsp; &lt;span style="color: blue"&gt;string&lt;/span&gt; requestedDisplayTokenLanguage, IClaimsIdentity
   subject)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt; displayClaims
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;DisplayClaim&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; DisplayClaim(WSIdentityConstants.ClaimTypes.GivenName, &lt;span style="color: #a31515"&gt;"FirstName"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"First
   Name"&lt;/span&gt;, 
   &lt;br&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;subject.GetClaimValue(WSIdentityConstants.ClaimTypes.GivenName)),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; DisplayClaim(WSIdentityConstants.ClaimTypes.Surname, &lt;span style="color: #a31515"&gt;"LastName"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Last
   Name"&lt;/span&gt;, 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;subject.GetClaimValue(WSIdentityConstants.ClaimTypes.Surname)),&lt;br&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; DisplayClaim(WSIdentityConstants.ClaimTypes.Name, &lt;span style="color: #a31515"&gt;"Name"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Name"&lt;/span&gt;, 
   &lt;br&gt;
   &lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;subject.GetClaimValue(WSIdentityConstants.ClaimTypes.Email)),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;};&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; DisplayToken(requestedDisplayTokenLanguage,
   displayClaims);&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   (of course – if you want to localize the claims – you should honor the &lt;em&gt;requestDisplayTokenLanguage&lt;/em&gt; parameter)
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Requesting and consuming a display token&lt;br&gt;
   &lt;/strong&gt;The above &lt;em&gt;GetDisplayToken&lt;/em&gt; method gets only called if a display token
   is requested. This is done by adding a &lt;em&gt;&amp;lt;RequestDisplayToken /&amp;gt;&lt;/em&gt; element
   to the RST – either by adding this element to the additional request parameters collection
   on the binding or by explicitly setting the &lt;em&gt;DisplayTokenLanguage&lt;/em&gt; property
   on the &lt;em&gt;RequestSecurityToken&lt;/em&gt; class (e.g. when requesting a token using &lt;em&gt;WSTrustClient&lt;/em&gt;).
&lt;/p&gt;
&lt;p&gt;
   The returned display token can be found in the RSTR on the &lt;em&gt;RequestedDisplayToken&lt;/em&gt; property.
   The following code snippet shows both the request and the consumption (some details
   omitted):
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: #2b91af; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;WSTrustClient&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; client
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;WSTrustClient&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GetStsBinding(),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GetStsEndpoint(),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TrustVersion&lt;/span&gt;.WSTrust13,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GetStsCredentials());&lt;br&gt;
   &lt;br&gt;
   &lt;span style="color: #2b91af"&gt;RequestSecurityToken&lt;/span&gt; rst = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;RequestSecurityToken&lt;/span&gt;();&lt;br&gt;
   rst.RequestType = &lt;span style="color: #2b91af"&gt;WSTrust13Constants&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;RequestTypes&lt;/span&gt;.Issue;&lt;br&gt;
   rst.AppliesTo = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;EndpointAddress&lt;/span&gt;(rp);&lt;br&gt;
   rst.TokenType = &lt;span style="color: #2b91af"&gt;Saml11SecurityTokenHandler&lt;/span&gt;.OasisWssSamlTokenProfile11;&lt;br&gt;
   rst.DisplayTokenLanguage = &lt;span style="color: #a31515"&gt;"en"&lt;/span&gt;;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="color: #2b91af"&gt;RequestSecurityTokenResponse&lt;/span&gt; rstr;&lt;br&gt;
   client.Issue(rst, &lt;span style="color: blue"&gt;out&lt;/span&gt; rstr);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: blue"&gt;var&lt;/span&gt; displayClaim &lt;span style="color: blue"&gt;in&lt;/span&gt; rstr.RequestedDisplayToken.DisplayClaims)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"{0}:
   {1} ({2})"&lt;/span&gt;,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;displayClaim.DisplayTag,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;displayClaim.Description,&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;displayClaim.DisplayValue));&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;}&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
HTH &lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=172e13c3-8011-48fd-b209-895e2e545247" /&gt;</content>
  </entry>
  <entry>
    <title>LeastPrivilege.IdentityModel2 Preview</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/LeastPrivilegeIdentityModel2Preview.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=58828c96-5682-4263-88ae-f5a7cc4ce062</id>
    <published>2008-12-25T08:34:17.023+01:00</published>
    <updated>2008-12-25T08:35:28.4435112+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I thought as a little X-Mas present – I just zip up the current version of my IdentityModel2
      solution and make it available for download <a href="http://www.leastprivilege.com/content/binary/LeastPrivilege.IdentityModel2.zip">here</a>.
      It is barely tested (besides my own use cases which were the reason why I wrote most
      of the code in the first place) so I thought I’d call it CTP1 and would appreciate
      your feedback ;)
   </p>
        <p>
      What’s inside?
   </p>
        <ul>
          <li>
         a bunch of extension methods (for IPrincipal, IClaimsPrincipal, IClaimsIdentity, RSACryptoServiceProvider…) 
      </li>
          <li>
         a custom configuration section for easy certificate loading 
      </li>
          <li>
         a simple claims viewer for console, WinForms and ASP.NET 
      </li>
          <li>
         helpers for federating with the Access Control Service</li>
        </ul>
        <p>
      Merry Xmas!
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=58828c96-5682-4263-88ae-f5a7cc4ce062" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Final Release of InfoCardSelector on Codeplex</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/FinalReleaseOfInfoCardSelectorOnCodeplex.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=b5ecc9a4-4487-42fa-b7ef-da6f25cd9cbf</id>
    <published>2008-12-16T08:14:11.3498258+01:00</published>
    <updated>2008-12-16T08:14:11.3498258+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      For a while I had some updates to the InfoCardSelector ASP.NET control sitting here
      – thanks to <a href="http://www.codeplex.com/site/users/view/altair">altair</a> we
      made some minor modifications, nothing critical. I finally <a href="http://www.codeplex.com/InfoCardSelector">uploaded</a> them
      to Codeplex.
   </p>
        <p>
      However – this will be the last release of the control. It works as expected and will
      be soon superseded by the InfoCard control in <a href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=642">Geneva</a>.
   </p>
        <p>
      Have fun!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=b5ecc9a4-4487-42fa-b7ef-da6f25cd9cbf" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ASP.NET Security Goodness</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ASPNETSecurityGoodness.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=c40dc8ee-d95c-433f-88eb-3aaba8356349</id>
    <published>2008-12-15T10:53:52.2834635+01:00</published>
    <updated>2008-12-15T10:53:52.2834635+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      A bunch of (ASP.NET) security tools got released over the weekend – highly recommended!
   </p>
        <p>
      Get more info from <a href="http://securitybuddha.com/2008/12/15/catnet-and-anti-xss-30-released-for-free/">Mark</a> and <a href="http://idunno.org/archive/2008/12/14/announcing-anticsrf-for-asp.net.aspx">Barry</a>.
   </p>
        <p>
          <strong>CAT.NET V1 CTP</strong>
        </p>
        <blockquote>
          <p>
      “CAT.NET is a snap-in to the Visual Studio IDE that helps you identify security flaws
      within a managed code (C#, Visual Basic .NET, J#) application you are developing.
      It does so by scanning the binary and/or assembly of the application, and tracing
      the data flow among its statements, methods, and assemblies. This includes indirect
      data types such as property assignments and instance tainting operations. The engine
      works by reading the target assembly and all reference assemblies used in the application
      -- module-by-module -- and then analyzing all of the methods contained within each.
      It finally displays the issues its finds in a list that you can use to jump directly
      to the places in your application's source code where those issues were found. The
      following rules are currently support by this version of the tool. - Cross Site Scripting
      - SQL Injection - Process Command Injection - File Canonicalization - Exception Information
      - LDAP Injection - XPATH Injection - Redirection to User Controlled Site.”
   </p>
        </blockquote>
        <p>
          <a href="http://www.microsoft.com/downloads/details.aspx?familyid=0178e2ef-9da8-445e-9348-c93f24cc9f9d&amp;displaylang=en&amp;tm">32
      Bit</a> / <a href="http://www.microsoft.com/downloads/details.aspx?familyid=e0052bba-2d50-4214-b65b-37e5ef44f146&amp;displaylang=en&amp;tm">64
      Bit</a></p>
        <p>
       
   </p>
        <p>
          <strong>AntiXSS 3.0 Beta</strong>
        </p>
        <blockquote>
          <p>
      “The Microsoft Anti-Cross Site Scripting Library V3.0 (Anti-XSS V3.0) is an encoding
      library designed to help developers protect their ASP.NET web-based applications from
      XSS attacks. It differs from most encoding libraries in that it uses the white-listing
      technique -- sometimes referred to as the principle of inclusions -- to provide protection
      against XSS attacks. This approach works by first defining a valid or allowable set
      of characters, and encodes anything outside this set (invalid characters or potential
      attacks). The white-listing approach provides several advantages over other encoding
      schemes. New features in this version of the Microsoft Anti-Cross Site Scripting Library
      include: - An expanded white list that supports more languages - Performance improvements
      - Performance data sheets (in the online help) - Support for Shift_JIS encoding for
      mobile browsers - A sample application - Security Runtime Engine (SRE) HTTP module.”
   </p>
        </blockquote>
        <p>
          <a href="http://www.microsoft.com/downloads/details.aspx?familyid=051ee83c-5ccf-48ed-8463-02f56a6bfc09&amp;displaylang=en&amp;tm">download</a>
        </p>
        <p>
       
   </p>
        <p>
          <strong>AntiCSRF</strong>
        </p>
        <blockquote>
          <p>
      “AntiCSRF makes it easier for ASP.NET developers to guard themselves against Cross
      Site Request Forgery. You'll no longer have to manually add and check protection tokens
      to protected yourself against CSRF attacks.”
   </p>
        </blockquote>
        <p>
          <a href="http://www.codeplex.com/AntiCSRF">Codeplex</a>
        </p>
        <p>
       
   </p>
        <p>
      Have fun!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=c40dc8ee-d95c-433f-88eb-3aaba8356349" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Federating with the .NET Access Control Service</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/FederatingWithTheNETAccessControlService.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=1fc51a8d-447c-4b06-9494-0636954bd4f5</id>
    <published>2008-12-11T20:46:34.601+01:00</published>
    <updated>2008-12-12T07:54:53.0548333+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      In my <a href="http://www.leastprivilege.com/UsingTheNETAccessControlServiceWithGeneva.aspx">previous</a> post
      I showed how to migrate the .NET Access Control Service SDK “CardSpaceCalculator”
      sample to Geneva Framework. The way this sample is structured, it allows to authenticate
      with the InfoCard that is associated with your solution account to access the service
      via the ACS.
   </p>
        <p>
      While this is nice for learning purposes – it limits you to this single account. In
      reality you want that your customers/partners federate with your ACS so you can give
      them access to your services. The ACS will then broker the trust and act as a rules-based
      claims generation engine.
   </p>
        <p>
      It turns out that when you have the sample up and running, you are already very close
      to this scenario. How could this work in practice? This walkthrough basically documents
      the steps I did to integrate a custom STS written with the Geneva framework. This
      assumes you already have a working version of the SDK sample as well as a STS.
   </p>
        <p>
          <strong>
          </strong> 
   </p>
        <p>
          <strong>Step 1: Registering the partner’s STS at your Access Control Service<br /></strong>First you have to register the STS. This is done via the .NET Services portal.
      Go to your scope in advanced mode and click the <em>Identity Issuers</em> link. You
      need to specify three things:
   </p>
        <ul>
          <li>
         A display name for the STS. This name is also used for defining rules later on 
      </li>
          <li>
         The STS URI 
      </li>
          <li>
         The STS token signing certificate</li>
        </ul>
        <p>
          <img src="http://www.leastprivilege.com/content/binary/pic11.JPG" border="0" />
        </p>
        <p>
          <strong>Step 2: Adding your Access Control Service to the partner’s STS known list
      of relying parties<br /></strong>The partner’s STS now has to be configured to issue tokens for the ACS. For
      this purpose the partner needs to know the value of the AppliesTo header field (the
      RP identitfier) and the public key of the ACS.
   </p>
        <p>
      The AppliesTo header will be: “http://accesscontrol.windows.net/sts/&lt;yoursolution&gt;/issued_for_certificate”.
   </p>
        <p>
      The encrypting certificate is not so obvious. It is basically the certificate that
      you can pull from https://accesscontrol.windows.net – but automatic browser redirects
      make that kinda hard (I forked mine from the custom IssuerNameRegistry I showed in
      my last post). You can also use <a href="http://www.leastprivilege.com/DownloadingTheCertificateFromAnSSLSite.aspx">this</a> code
      here to download the cert.
   </p>
        <p>
          <strong>Step 3: Updating client configuration</strong>
          <br />
      The next step is to update the client’s configuration to request a token from the
      STS before requesting the token from the ACS. This is very simple – when you use the
      SDK sample you will see a WCF custom binding with the name http://accesscontrol.windows.net/sts/&lt;solutionname&gt;/issued_for_certificate.
      Since this binding is configured for issued tokens but no STS is specified the CardSpace
      identity selector will pop up. When the partner STS issues cards, the user now only
      has to select the right card.
   </p>
        <p>
      To configure a specific STS you have to add an &lt;issuer&gt; and &lt;issuerMetadata&gt;
      element to the binding that points to the partner’s STS WS-Trust endpoint (along with
      the right binding to authenticate with the STS). That’s it.
   </p>
        <p>
          <strong>Step 4: Defining rules for the partner in the ACS<br /></strong>Now technically everything is set up. The last step would be to define rules
      in your ACS for the partner accounts. Let’s say the partner STS includes a “department”
      claim in the token. Now everybody in the department “Research” should have access
      to the “Add” operation of the calculator. The corresponding rule would look like this
      in the portal:
   </p>
        <p>
          <img src="http://www.leastprivilege.com/content/binary/pic21.JPG" border="0" />
        </p>
        <p>
      Another cool feature of the ACS rules engine is to copy input to output claims. This
      allows to tunnel claims from the partner’s STS to your service. You accomplish this
      by setting the “copy input value” option in the rules dialog.
   </p>
        <p>
          <img src="http://www.leastprivilege.com/content/binary/pic31.JPG" border="0" />
        </p>
        <p>
      I’d also recommend checking out Justin’s drill down talk from PDC to learn about the
      forward chaining capabilities of the rules engine.
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=1fc51a8d-447c-4b06-9494-0636954bd4f5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Downloading the Certificate from an SSL Site</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/DownloadingTheCertificateFromAnSSLSite.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=889453ef-2c4f-45ac-80bd-c0c593026c54</id>
    <published>2008-12-11T20:30:47.6541588+01:00</published>
    <updated>2008-12-11T20:30:47.6541588+01:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   Sometimes this is very useful– you point the below code to a server and get the configured
   SSL certificate in return. After that you could import the cert into the local store
   or save it as a file (via the &lt;em&gt;RawData&lt;/em&gt; property).
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;X509Certificate2&lt;/span&gt; DownloadSslCertificate(&lt;span style="color: blue"&gt;string&lt;/span&gt; machinename, &lt;span style="color: blue"&gt;int&lt;/span&gt; port)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;TcpClient&lt;/span&gt; client
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;TcpClient&lt;/span&gt;())&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;client.Connect(machinename,
   port);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SslStream&lt;/span&gt; ssl
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SslStream&lt;/span&gt;(client.GetStream());&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;ssl.AuthenticateAsClient(machinename);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;X509Certificate2&lt;/span&gt;(ssl.RemoteCertificate);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=889453ef-2c4f-45ac-80bd-c0c593026c54" /&gt;</content>
  </entry>
  <entry>
    <title>Using the .NET Access Control Service with Geneva</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsingTheNETAccessControlServiceWithGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=d0b99d26-1cd5-467c-937c-f765efc3319d</id>
    <published>2008-12-11T10:20:45.937+01:00</published>
    <updated>2008-12-11T10:24:59.8890196+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   If you haven’t checked out the .NET Access Control Service yet – I can highly recommend
   it!
&lt;/p&gt;
&lt;p&gt;
   Justin did two talks about it at PDC:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      &lt;a href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/BB55.wmv"&gt;Access Control Service
      in .NET Services&lt;/a&gt;&amp;nbsp; 
   &lt;li&gt;
      &lt;a href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/BB28.wmv"&gt;Access Control Service
      Drilldown&lt;/a&gt;
   &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   In the 2nd talk Justin showed how to use and process claims coming from the ACS rules
   engine in your own services. You can find this code in the “CardSpace Calculator”
   sample in the ACS SDK.
&lt;/p&gt;
&lt;p&gt;
   The sample uses the “old” WCF plumbing to process tokens and create claims based on
   that. I wanted to find out what has to be done to migrate the sample to use Geneva. 
&lt;/p&gt;
&lt;p&gt;
   First let’s have a look at what you want to accomplish with such a scenario:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      your clients live in a different trust domain as your service 
   &lt;li&gt;
      to federate these two domains, you do the following 
      &lt;ul&gt;
         &lt;li&gt;
            register your client’s identity provider (Live ID, Geneva Server/Framework, other
            WS-Trust 1.3 compat STS) at the ACS 
         &lt;li&gt;
            your client obtains a token from the ACS (by sending their identity token) 
         &lt;li&gt;
            this token is used to authenticate with your service 
         &lt;li&gt;
            your service accepts tokens from the ACS and uses their claims for identity related
            work&lt;/li&gt;
      &lt;/ul&gt;
   &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   For your service this means the following:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      accept tokens that are signed by the ACS 
   &lt;li&gt;
      make sure the issuer of that token is your personal instance of the ACS (http://accesscontrol.windows.net/yoursolution)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   In Geneva terms this boils down to the following pieces of plumbing:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      issuer name registry that knows about the ACS issuer certificate 
   &lt;li&gt;
      security token handler that check the SAML issuer name&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   &lt;strong&gt;Issuer Registry&lt;br&gt;
   &lt;/strong&gt;There are two ways to accomplish this. Either you use the standard ConfigurationBasedIssuerNameRegistry
   and add the ACS issuer thumbprint to it:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang=EN-US style="COLOR: #a31515; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;microsoft.identityModel&lt;/span&gt;&lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang=EN-US style="COLOR: #a31515; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;issuerNameRegistry&lt;/span&gt;&lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang=EN-US style="COLOR: red; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;type&lt;/span&gt;&lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;"…&lt;span style="COLOR: blue"&gt;ConfigurationBasedIssuerNameRegistry&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;trustedIssuers&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=http://accesscontrol.windows.net&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: red"&gt;thumbprint&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;416E6FA5D982B096931FBF42C4A3DCD608856C95&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;trustedIssuers&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;issuerNameRegistry&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;microsoft.identityModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&lt;?xml:namespace prefix = o /&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   Or you write a custom registry that has the ACS issuer baked in:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;class&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="COLOR: #2b91af"&gt;AccessControlServiceIssuerRegistry&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;IssuerNameRegistry&lt;br&gt;
   &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; GetIssuerName(&lt;span style="COLOR: #2b91af"&gt;SecurityToken&lt;/span&gt; securityToken)&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;X509SecurityToken&lt;/span&gt; token
   = securityToken &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;X509SecurityToken&lt;/span&gt;;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (token
   == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityTokenException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Token
   is not a X509 Security Token"&lt;/span&gt;);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; cert
   = token.Certificate;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (cert.Thumbprint.Equals(&lt;span style="COLOR: #a31515"&gt;"416E6FA5D982B096931FBF42C4A3DCD608856C95"&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;StringComparison&lt;/span&gt;.OrdinalIgnoreCase))&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #a31515"&gt;"http://accesscontrol.windows.net"&lt;/span&gt;;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityTokenException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Token
   not issued by access control service"&lt;/span&gt;);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Security Token Handler&lt;/strong&gt;
   &lt;br&gt;
   Once you trust the issuer, you also have to make sure that the token got issued by
   your personal instance of the ACS. This is done by checking the SAML issuer name information
   in the token. This is the job of a custom security token handler – you can simply
   derive from the existing &lt;em&gt;Saml11SecurityTokenHandler&lt;/em&gt; and inject this logic
   in the &lt;em&gt;ValidateToken&lt;/em&gt; method.
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;class&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="COLOR: #2b91af"&gt;AccessControlServiceSaml11SecurityTokenHandler&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Saml11SecurityTokenHandler&lt;br&gt;
   &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; _solution;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; AccessControlServiceSaml11SecurityTokenHandler(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; solution) 
   &lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;()&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_solution
   = solution;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ClaimsIdentityCollection&lt;/span&gt; ValidateToken(&lt;span style="COLOR: #2b91af"&gt;SecurityToken&lt;/span&gt; token)&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; identities
   = &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.ValidateToken(token);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;identities[0].DemandClaim(&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ClaimTypes&lt;/span&gt;.SamlIssuerName,&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;"http://accesscontrol.windows.net/"&lt;/span&gt; +
   _solution);&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; identities;&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="COLOR: #2b91af"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Bringing the pieces together&lt;br&gt;
   &lt;/strong&gt;You can now wire up the two custom components using the &lt;em&gt;FederatedServiceCredentials&lt;/em&gt; class
   like this:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: #2b91af; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;ServiceHost&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; host
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ServiceHost&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;CalculatorService&lt;/span&gt;));&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; handlers = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SecurityTokenHandlerCollection&lt;/span&gt;();&lt;br&gt;
   handlers.Add(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;AccessControlServiceSaml11SecurityTokenHandler&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"leastprivilege"&lt;/span&gt;));&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: #2b91af"&gt;FederatedServiceCredentials&lt;/span&gt;.ConfigureServiceHost(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;host,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;handlers,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;AccessControlServiceIssuerRegistry&lt;/span&gt;(),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;TimeSpan&lt;/span&gt;.FromMinutes(5));&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: #2b91af"&gt;FederatedServiceCredentials&lt;/span&gt;.ConfigureServiceHost(host);&lt;br&gt;
   host.Open();&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   Another option would be to use the configuration file – but in this case we somehow
   have to transfer the solution name to the security token handler. Geneva security
   token handlers have a standard configuration extensibility hook that we can use to
   accomplish this (not very obvious at the beginning – but makes sense ;).
&lt;/p&gt;
&lt;p&gt;
   Let’s say our configuration should look like this:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang=EN-US style="COLOR: #a31515; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;microsoft.identityModel&lt;/span&gt;&lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang=EN-US style="COLOR: #a31515; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;issuerNameRegistry &lt;/span&gt;&lt;span lang=EN-US style="COLOR: red; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;type&lt;/span&gt;&lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;"&lt;span style="COLOR: blue"&gt;LeastPrivilege.AccessControlServiceIssuerRegistry,
   Service&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;securityTokenHandlers&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;clear&lt;/span&gt;&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;type&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;LeastPrivilege.AccessControlServiceSaml11SecurityTokenHandler,
   Service&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;accessControlServiceTokenRequirement&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;solutionName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;leastprivilege&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;securityTokenHandlers&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;microsoft.identityModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   To make the token handler aware of this sub config element, you have to add a new
   constructor to the token handler like this:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; AccessControlServiceSaml11SecurityTokenHandler(&lt;span style="COLOR: #2b91af"&gt;XmlElement&lt;/span&gt; customConfigElement)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;()&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (customConfigElement.LocalName
   != &lt;span style="COLOR: #a31515"&gt;"accessControlServiceTokenRequirement"&lt;/span&gt;)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"accessControlServiceTokenRequirement
   expected"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; solutionAttr
   = customConfigElement.Attributes[&lt;span style="COLOR: #a31515"&gt;"solutionName"&lt;/span&gt;];&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (solutionAttr
   == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"solution
   name expected"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_solution = solutionAttr.Value;&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   (if you also need support for the &lt;em&gt;samlSecurityTokenRequirement&lt;/em&gt; element, you
   can manually call &lt;em&gt;LoadSamlTokenAuthenticatorRequirement&lt;/em&gt; on the &lt;em&gt;SecurityTokenHandlerElement&lt;/em&gt; class).
&lt;/p&gt;
&lt;p&gt;
   &lt;a href="http://www.leastprivilege.com/content/binary/CardSpaceCalculatorGeneva.zip"&gt;Here&lt;/a&gt; you
   can find the complete code – to get it working I’d suggest you first get the original
   SDK sample up and running. After that you have to make the necessary adjustments in
   my code (solution name, certificates and URIs).
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=d0b99d26-1cd5-467c-937c-f765efc3319d" /&gt;</content>
  </entry>
  <entry>
    <title>LeastPrivilege.IdentityModel v2</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/LeastPrivilegeIdentityModelV2.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=601698a7-d034-454d-8557-ed97fe31a01e</id>
    <published>2008-12-07T17:49:10.599+01:00</published>
    <updated>2008-12-07T18:45:58.4433114+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   Looking at the download numbers, my &lt;a href="http://www.leastprivilege.com/identityModel"&gt;add-on
   library&lt;/a&gt; for System.IdentityModel was quite popular. Some days ago I started looking
   the code to see what could be still useful in the face of Geneva.
&lt;/p&gt;
&lt;p&gt;
   The good news is, that a lot of my helper classes are not necessary anymore thanks
   to the easier claims model in Geneva. Still I think that most of the time you have
   to wrap the raw &lt;em&gt;IClaimsPrincipal&lt;/em&gt; with more domain specific functionality.
   Since my current project makes heavy use of Geneva I began compiling a set of classes
   that made my life easier while working with the Geneva framework.
&lt;/p&gt;
&lt;p&gt;
   Like in the first release, I added a bunch of extensions methods that make finding
   and demanding claims easier. This is mostly syntactic sugar because the new model
   is very LINQ friendly and you can easily write the queries yourself – but it makes
   the code easier to read IMO. At the heart of all functionality is this extension method:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt;
   FindClaims(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IClaimsIdentity&lt;/span&gt; identity, &lt;span style="COLOR: #2b91af"&gt;Predicate&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt;
   predicate)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; claim &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; identity.Claims&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;where&lt;/span&gt; predicate(claim)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;select&lt;/span&gt; claim;&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   This allows layering all kinds of higher level functionality on top of both &lt;em&gt;IClaimsIdentity&lt;/em&gt; and &lt;em&gt;IClaimsPrincipal, &lt;/em&gt;e.g:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      &lt;strong&gt;&lt;em&gt;FindClaims(commonly used parameters)&lt;br&gt;
      &lt;/em&gt;&lt;/strong&gt;Returns a (possibly empty) list of claims. 
   &lt;li&gt;
      &lt;em&gt;&lt;strong&gt;DemandClaim(commonly user parameters)&lt;/strong&gt;&lt;/em&gt;
      &lt;br&gt;
      Throws a SecurityException if a specified claim is not found 
   &lt;li&gt;
      &lt;em&gt;&lt;strong&gt;GetClaimValue / TryGetClaimValue&lt;/strong&gt;&lt;/em&gt;
      &lt;br&gt;
      Returns the value of a specified claim&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   ..and on top of that it is very easy to add business problem centric functionality.
&lt;/p&gt;
&lt;p&gt;
   This allows me to write code like this:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;var&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; principal
   = &lt;span style="COLOR: #2b91af"&gt;Thread&lt;/span&gt;.CurrentPrincipal.AsClaimsPrincipal();&lt;br&gt;
   &lt;br&gt;
   principal.DemandClaim(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;WSAuthorizationConstants&lt;/span&gt;.Action,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;"Logs.Clear"&lt;/span&gt;,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;&lt;a href="http://accesscontrol.windows.net"&gt;http://accesscontrol.windows.net&lt;/a&gt;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   I will release the code once I have done more testing.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=601698a7-d034-454d-8557-ed97fe31a01e" /&gt;</content>
  </entry>
  <entry>
    <title>T-Mobile Web&amp;rsquo;n&amp;rsquo;Walk &amp;amp; Vista 64</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/TMobileWebrsquonrsquoWalkAmpVista64.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=29f18413-5458-4a8a-90be-64c9ef591f1e</id>
    <published>2008-12-05T10:28:54.0986667+01:00</published>
    <updated>2008-12-05T10:28:54.0986667+01:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I just spent two very unpleasant days trying to get the T-Mobile ExpressCard IV to
      work with Vista 64. But for some reasons the T-Mobile drivers for the Huawei E870
      are screwed under 64 bit.
   </p>
        <p>
      Today I got a tip that I should try to install the latest version of Vodafone Mobile
      Connect which also includes drivers for the same hardware. And bingo this works. You
      can isolate the drivers from the Vodafone program files and uninstall Mobile Connect
      afterwards. awesome…
   </p>
        <p>
      So you have to install a Vodafone software package to get T-Mobile hardware to run.
      Is that weird?
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=29f18413-5458-4a8a-90be-64c9ef591f1e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>UserName Supporting Token &amp;amp; WCF revisited (this time with Geneva)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UserNameSupportingTokenAmpWCFRevisitedThisTimeWithGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=a4e8a227-8f41-42f6-9b3e-71355c48f10c</id>
    <published>2008-11-27T07:47:40.99+01:00</published>
    <updated>2008-11-27T07:49:44.3959686+01:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   A while back I &lt;a href="http://www.leastprivilege.com/UserNameSupportingTokenInWCF.aspx"&gt;wrote&lt;/a&gt; about
   UserName supporting tokens in WCF and how they can be handy to create light-weight
   “delegation” scenarios for middle-tiers. I wanted to give the same scenario a try
   with a Geneva enabled relying party.
&lt;/p&gt;
&lt;p&gt;
   First of all – there are no basic configuration changes necessary (specifically the
   SecurityBindingElement – refer to my original &lt;a href="http://www.leastprivilege.com/UserNameSupportingTokenInWCF.aspx"&gt;post&lt;/a&gt; for
   details). All you have to do is to configure the Geneva “runtime” and wire it in your
   service host. This involves:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      Specifying an issuer registry for the client’s certificate. 
   &lt;li&gt;
      Add a &lt;em&gt;UserNameSecurityTokenHandler&lt;/em&gt; that can cope with empty passwords (this
      also gives you the chance to add some custom claims for the user name token).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   Refer to this &lt;a href="http://www.leastprivilege.com/GenevaIsTheNewWCFSecurity.aspx"&gt;post&lt;/a&gt; for
   details about issuer registries, and this &lt;a href="http://www.leastprivilege.com/UsernamePasswordValidationWithGeneva.aspx"&gt;post&lt;/a&gt; for
   UserName security token handlers.
&lt;/p&gt;
&lt;p&gt;
   All you then have to do is, to take all these pieces and configure the service host
   to use Geneva:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="COLOR: #2b91af; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;ServiceHost&lt;/span&gt;&lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; host
   = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ServiceHost&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;Service&lt;/span&gt;));&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: green"&gt;// add the supporting token to the binding&lt;/span&gt;
   &lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   host.Description.Endpoints[0].Binding =&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang=EN-US style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;AddUserNameSupportingTokenToBinding(host.Description.Endpoints[0].Binding);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: green"&gt;// create security token handlers&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; handlers = &lt;span style="COLOR: blue"&gt;new &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;SecurityTokenHandlerCollection&lt;/span&gt;(&lt;br&gt;
   &lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityTokenHandlerCollection&lt;/span&gt;.DefaultHandlers);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: green"&gt;// add handler for supporting token (empty password)&lt;/span&gt;
   &lt;br&gt;
   handlers.AddOrReplace(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SupportingUserNameSecurityTokenHandler&lt;/span&gt;());&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: green"&gt;// add the issuer name registry (simple for demo purposes)&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; registry = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SimpleIssuerNameRegistry&lt;/span&gt;();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="COLOR: green"&gt;// configure host to use Geneva plumbing&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="COLOR: #2b91af"&gt;FederatedServiceCredentials&lt;/span&gt;.ConfigureServiceHost(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;host,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;handlers,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;registry,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TimeSpan&lt;/span&gt;(0,
   5, 0));&lt;br&gt;
   &lt;br&gt;
   host.Open();&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   On incoming requests, Geneva will now create an &lt;em&gt;IClaimsPrincipal&lt;/em&gt; that contains
   two &lt;em&gt;IClaimsIdentity&lt;/em&gt; instances. One for the direct caller (certificate) and
   one for the supporting token (user name). You can now use the standard means to query
   both identities and their claims. Nice.
&lt;/p&gt;
&lt;p&gt;
   &lt;a href="http://www.leastprivilege.com/content/binary/SupportingUserNameToken1.zip"&gt;SupportingUserNameToken1.zip
   (39.91 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=a4e8a227-8f41-42f6-9b3e-71355c48f10c" /&gt;</content>
  </entry>
  <entry>
    <title>(SAML) Token Creation in a Geneva STS</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SAMLTokenCreationInAGenevaSTS.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=40426bb2-d8ef-4ba6-9fd9-e394e68d62e7</id>
    <published>2008-11-22T16:13:18.7199794+01:00</published>
    <updated>2008-11-22T19:01:18.9443545+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      By default, Geneva STS developers are quite shielded from the SAML creation process
      – you simply derive from <em>SecurityTokenService </em>and implement <em>GetScope</em> and <em>GetOutputClaimsIdentity</em>,
      and the rest gets done by the framework. But if you need more control over the generated
      tokens, it’s worthwhile to have a closer look.
   </p>
        <p>
      Internally the <em>SecurityTokenService</em> class drives a “token information gathering”
      pipeline which results in the construction of a <em>SecurityTokenDescriptor </em>(a
      token neutral description) of the token to be issued. After that the descriptor is
      passed on to a <em>SecurityTokenHandler</em> that creates the security token. In the
      last step, the generated token is wrapped in an RSTR and sent back.
   </p>
        <p>
      In the current bits, the STS pipeline looks like this:
   </p>
        <ul>
          <li>
            <em>
              <strong>GetScope</strong>
              <br />
            </em>Must be implemented. Determines scope specific information like signing and encrypting
         credentials – usually based on the AppliesTo header. 
      </li>
          <li>
            <em>
              <strong>CreateSecurityDescriptor</strong>
              <br />
            </em>Creates a default descriptor based on the scope from step 1. This is one option
         to modify the descriptor manually. 
      </li>
          <li>
            <em>
              <strong>GetSecurityTokenHandler</strong>
              <br />
         C</em>reates the security token handler that is later used for creating the token.
         The handler is determined based on the TokenType property of the RST. 
      </li>
          <li>
            <em>
              <strong>GetIssuerName</strong>
              <br />
            </em>Returns the issuer for the token. By default the issuer from the <em>SecurityTokenServiceConfiguration</em> is
         used. 
      </li>
          <li>
            <em>
              <strong>GetTokenLifetime</strong>
            </em>
            <br />
         Returns the life time of the token. By default the default life time from <em>SecurityTokenServiceConfiguration</em> is
         used (which is 10 hours). 
      </li>
          <li>
            <em>
              <strong>GetProofToken</strong>
            </em>
            <br />
         Creates a <em>ProofTokenDescriptor</em> that describes the proof token (asymmetric,
         symmetric or none). By default the information from the RST and the scope are used
         here. 
      </li>
          <li>
            <em>
              <strong>GetOutputClaimsIdentity</strong>
            </em>
            <br />
         Must be implemented. Returns the identity that describes the subject. 
      </li>
          <li>
            <em>
              <strong>SecurityTokenHandler.CreateToken</strong>
            </em>
            <br />
         The token handler creates the token and returns it to the token service (more details
         later) 
      </li>
          <li>
            <strong>
              <em>GetDisplayToken</em>
            </strong>
            <br />
         Returns the claims that should be client visible (e.g. for an identity selector) 
      </li>
          <li>
            <em>
              <strong>GetResponse</strong>
            </em>
            <br />
         Creates the RSTR. This is a popular hook for looking at the generated response before
         sending it back.</li>
        </ul>
        <p>
      You can override any of these methods to modify the shape of the output token. This
      pipeline is always the same regardless of the token type. Token specific processing
      is done in the security token handler. 
   </p>
        <p>
      Security token handlers also have a pipeline that drives token creation. Since they
      are token specific, you have more control here over the output token details. For
      the purpose of this post, I will describe the SAML 1.1 token creation. The details
      differ for other token types.
   </p>
        <ul>
          <li>
            <em>
              <strong>CreateStatements</strong>
            </em>
            <br />
         Creates the SAML subject, attribute and authentication statements. This method calls
         out to: 
         <ul><li><em><strong>CreateSamlSubject</strong></em><br />
               Looks for a name identifier claim and uses this to create the SAML subject. Additionally
               if this claim has properties that describe the name format and qualifier these values
               will be added to the subject. The last step is to set the proof key identifier and
               subject confirmation method (holder of key / bearer) 
            </li><li><em><strong>CreateAttributeStatement</strong></em><br />
               Creates the attribute statement based on the claims from the token service. 
            </li><li><em><strong>CreateAuthenticationStatementFromAuthenticationInformation</strong></em><br />
               Creates the authentication statement based on the authentication information in the
               token descriptor. This method only gets called if such information is present – so
               be sure to populate the <em>AuthenticationInformation</em> collection on the descriptor
               at some earlier point.</li></ul></li>
          <li>
            <strong>
              <em>CreateConditions</em>
            </strong>
            <br />
         Sets the token lifetime and audience URIs restrictions. 
      </li>
          <li>
            <em>
              <strong>CreateAdvice</strong>
              <br />
            </em>Creates the SAML advice. By default no advice is created. 
      </li>
          <li>
            <em>
              <strong>CreateAssertion</strong>
            </em>
            <br />
         Creates the SAML assertion based on the statements, the conditions and the advice. 
      </li>
          <li>
            <em>
              <strong>GetSigningCredentials </strong>
            </em>
            <br />
         Returns the credential used to sign the token. 
      </li>
          <li>
            <em>
              <strong>GetEncryptingCredentials</strong>
            </em>
            <br />
         Returns the credential used to encrypt the token. If this method returns null, the
         token will not be encrypted.</li>
        </ul>
        <p>
      Again you can override any of these methods.
   </p>
        <p>
      OK – that was a lot of information. Where would you now plug in when you want to modify
      token creation? You basically have two options. Either you override the methods in <em>SecurityTokenService</em> to
      shape the token descriptor that gets passed to the handler. Of, if you need more control,
      you derive from one of the token handlers (e.g. <em>Saml11SecurityTokenHandler</em>)
      and override some of the methods that create the token details.
   </p>
        <p>
      If you choose to write a custom handler, you can wire up the handler to the token
      service by overriding the <em>SecurityTokenService.GetSecurityTokenHandler</em> method.
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=40426bb2-d8ef-4ba6-9fd9-e394e68d62e7" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Geneva HTTP Modules: ClaimsPrincipalHttpModule</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaHTTPModulesClaimsPrincipalHttpModule.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=af477ca9-5955-4f71-a59d-084dbea055bf</id>
    <published>2008-11-17T12:07:10.369+01:00</published>
    <updated>2008-11-17T12:09:37.3530345+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Geneva ships with three HTTP modules to use with ASP.NET: <em>ClaimsPrincipalHttpModule</em>, <em>SessionAuthenticationModule</em> and <em>WSFederationAuthenticationModule</em>.
      What are they for – and when to chose which?
   </p>
        <p>
      In this post I will focus on the simplest one of the three: <em>ClaimsPrincipalHttpModule</em> –
      in following post we will have a close look at the remaining two.
   </p>
        <p>
      The claims principal module is your easiest entry into the claims-based world. It
      simply takes whatever identity is on <em>HttpContext.User</em> and turns that into
      an <em>IClaimsPrincipal</em>. No STS or issued tokens required. There are three main
      decisions made:
   </p>
        <ul>
          <li>
         If client is using Windows authentication, create a <em>WindowsClaimsPrincipal</em>.
         This principal allows downcasting to <em>WindowsPrincipal</em> and <em>WindowsIdentity</em> (to
         access things like impersonation and other Windows security specific features). Furthermore
         it contains the Windows token details as claims (primary SID, group SIDs, SAM account
         name…). 
      </li>
          <li>
         If the client is a FormsAuth client, a claims principal holding the user name, authentication
         method and instant is created. 
      </li>
          <li>
         If RoleManager is enabled, <em>Roles.GetRolesForUser()</em> is called to retrieve
         the user’s role. These roles are transformed into claims of the “<a title="http://schemas.microsoft.com/ws/2008/06/identity/claims/role" href="http://schemas.microsoft.com/ws/2008/06/identity/claims/role">http://schemas.microsoft.com/ws/2008/06/identity/claims/role</a>”
         type. Lovely.</li>
        </ul>
        <p>
      In all cases this means, that traditional <em>IsInRole</em> based security (imperative
      or via <em>UrlAuthorizationModule</em>) as well <em>IIdentity.Name </em>continues
      to work while you get the benefits of claims.
   </p>
        <p>
      The next step would be to wire up a <a href="http://www.leastprivilege.com/ClaimsAuthenticationManagerInGeneva.aspx">ClaimsAuthenticationManager</a> to
      add your own custom claims to the principal. This gives you a smooth migration path
      and co-existence between roles and claims. Nice.
   </p>
        <p>
      One thing that’s missing IMO is the conversion of client certificates to claims. I’ll
      file that as a feature request.
   </p>
        <p>
      Sample: <a href="http://www.leastprivilege.com/content/binary/ClaimsHttpModule.zip">ClaimsHttpModule.zip
      (8.5 KB)</a></p>
        <p>
      (btw – this all reminds me so much of my <a href="http://www.leastprivilege.com/UsingIdentityModelAddingASPNETSupportPart2ClaimsManager.aspx">ClaimsManagerModule</a> I
      have posted in March’08 ;))
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=af477ca9-5955-4f71-a59d-084dbea055bf" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ClaimsAuthenticationManager in Geneva</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ClaimsAuthenticationManagerInGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=2fe780fe-0771-4e0b-ada2-f4360b80916b</id>
    <published>2008-11-14T08:51:53.5635154+01:00</published>
    <updated>2008-11-14T08:51:53.5635154+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   One of the things that Zermatt was lacking was a uniform way to look at incoming claims
   (either from an STS or from auto-converted authentication information).
&lt;/p&gt;
&lt;p&gt;
   In Geneva we now have a piece of plumbing called the &lt;em&gt;ClaimsAuthenticationManager&lt;/em&gt; which
   gets called on the &lt;strong&gt;first&lt;/strong&gt; request when a token comes into your application.
   This gives you a chance to reject or add claims as well as create a completely different
   claims principal (aka claims transformation). These new claims go into the session
   token and subsequent requests will bypass that logic.
&lt;/p&gt;
&lt;p&gt;
   A simple claims authentication manager could look like this:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;class&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: #2b91af"&gt;ClaimsTransformer&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ClaimsAuthenticationManager&lt;br&gt;
   &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; Authenticate(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; endpointUri, &lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; incomingPrincipal)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; GetClaims(incomingPrincipal.Identity.Name,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;incomingPrincipal.Identity.AuthenticationType);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IClaimsPrincipal&lt;/span&gt; GetClaims(&lt;span style="color: blue"&gt;string&lt;/span&gt; name, &lt;span style="color: blue"&gt;string&lt;/span&gt; authenticationType)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimsIdentity&lt;/span&gt; id
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsIdentity&lt;/span&gt;(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;WSIdentityConstants&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Name, &lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;name, &lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimValueTypes&lt;/span&gt;.String, &lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #a31515"&gt;"LeastPrivilege"&lt;/span&gt;),&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"http://leastprivilege/claims/customClaim"&lt;/span&gt;, &lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #a31515"&gt;"customValue"&lt;/span&gt;, &lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimValueTypes&lt;/span&gt;.String, &lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #a31515"&gt;"LeastPrivilege"&lt;/span&gt;)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;},
   authenticationType);&lt;br&gt;
   &lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsPrincipal&lt;/span&gt;(id);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   You register the claims auth manager e.g. in config:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;microsoft.identityModel&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;claimsAuthenticationManager&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="color: red; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;type&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;"&lt;span style="color: blue"&gt;LeastPrivilege.ClaimsTransformer,
   AutoClaims&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;microsoft.identityModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=2fe780fe-0771-4e0b-ada2-f4360b80916b" /&gt;</content>
  </entry>
  <entry>
    <title>Username/Password Validation with Geneva</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsernamePasswordValidationWithGeneva.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=49f9875a-18f0-4a5e-8f06-6ac516669640</id>
    <published>2008-11-13T19:43:34.0378256+01:00</published>
    <updated>2008-11-13T19:43:57.0062816+01:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   In my &lt;a href="http://www.leastprivilege.com/GenevaIsTheNewWCFSecurity.aspx"&gt;previous&lt;/a&gt; post
   I mentioned that Geneva takes over parts of the WCF security system - I used the example
   of certificate validation. This is also true for username/password authentication.
&lt;/p&gt;
&lt;p&gt;
   In the case you have an existing service with a &lt;em&gt;UserNamePasswordValidator&lt;/em&gt; -
   as soon as you opt-into Geneva, the validator will stop to work. This is because Geneva
   takes over parts of the WCF processing pipeline and injects its own token parsing
   and validation system. 
&lt;/p&gt;
&lt;p&gt;
   In Geneva, so-called &lt;em&gt;SecurityTokenHandlers&lt;/em&gt; read and validate incoming tokens.
   As part of the validation process, claims based on that token are created and put
   into the &lt;em&gt;IClaimsPrincipal&lt;/em&gt;, which will abe vailable from your operations.
   There are two handlers that register for UserName tokens: &lt;em&gt;WindowsUserNameSecurityTokenHandler&lt;/em&gt; and &lt;em&gt;MembershipUserNameSecurityTokenHandler &lt;/em&gt;(I
   guess it is clear which account stores they use). 
&lt;/p&gt;
&lt;p&gt;
   By default the Windows handler is registered and unless you have a used a username/password
   pair that incidentally matches a Windows account on your system, username authentication
   will fail.
&lt;/p&gt;
&lt;p&gt;
   You now have two options: using the membership handler (if you have an existing membership
   provider) or write your own handler, which is pretty straightforward. The following
   handler code makes sure that username and password are identical - nothing you should
   do in your production systems - but you get the idea ;)
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;class&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: #2b91af"&gt;SimpleUserNameSecurityTokenHandler&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;UserNameSecurityTokenHandler&lt;br&gt;
   &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsIdentityCollection&lt;/span&gt; ValidateToken(&lt;span style="color: #2b91af"&gt;SecurityToken&lt;/span&gt; token)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;UserNameSecurityToken&lt;/span&gt; unToken
   = token &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;UserNameSecurityToken&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (unToken
   == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"token"&lt;/span&gt;);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   replace with proper password validation!&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (unToken.UserName
   != unToken.Password)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SecurityTokenValidationException&lt;/span&gt;();&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimsIdentity&lt;/span&gt; id
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsIdentity&lt;/span&gt;(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;WSIdentityConstants&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Name,
   unToken.UserName)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}, &lt;span style="color: #a31515"&gt;"UserName"&lt;/span&gt;);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsIdentityCollection&lt;/span&gt;(id);&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;bool&lt;/span&gt; CanValidateToken&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;get&lt;/span&gt;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;true&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="color: #2b91af"&gt;&lt;?xml:namespace prefix = o /&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal"&gt;
   &lt;span lang="EN-US" style="mso-ansi-language: en-us"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   You have to setup the handler in config - this is currently a little cumbersome but
   will hopefully get easier in the future. You first have to remove the windows handler
   - or clear the handler collection and add your own handler to it:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;microsoft.identityModel&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;securityTokenHandlers&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;clear&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;add&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="color: red; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;type&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;"&lt;span style="color: blue"&gt;LeastPrivilege.SimpleUserNameSecurityTokenHandler,
   AutoClaims&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;securityTokenHandlers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;microsoft.identityModel&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   There is also a &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/Geneva/thread/ddd45b84-f0d4-48b2-9ce0-1042bea06193"&gt;thread&lt;/a&gt; on
   MSDN where Pedro shows how to do that programmatically.
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=49f9875a-18f0-4a5e-8f06-6ac516669640" /&gt;</content>
  </entry>
  <entry>
    <title>Code Contracts in .NET 4</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/CodeContractsInNET4.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=c97e09f5-a5aa-4f2b-bd80-182fc38264a2</id>
    <published>2008-11-12T08:02:03.4717378+01:00</published>
    <updated>2008-11-12T08:02:03.4717378+01:00</updated>
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      A really interesting feature in .NET 4 will be Code Contracts. They allow defining
      pre- and post-conditions in code along with some other more advanced options.
   </p>
        <p>
      See the PDC video <a href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/TL51.wmv">here</a> -
      and  more <a href="http://blogs.msdn.com/bclteam/archive/2008/11/11/introduction-to-code-contracts-melitta-andersen.aspx">here</a>.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=c97e09f5-a5aa-4f2b-bd80-182fc38264a2" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Geneva is the new WCF Security</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaIsTheNewWCFSecurity.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=fa57670f-f0b7-46fc-85e5-6c6983b86188</id>
    <published>2008-10-31T07:35:55.6723006+01:00</published>
    <updated>2008-10-31T07:35:55.6723006+01:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   Geneva has evolved to not only a an extension to WCF/ASP.NET for STS/token related
   things - it also changes how base WCF security works - to the better IMO. Let me give
   you an example:
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Trusted certificate issuers&lt;br&gt;
   &lt;/strong&gt;When doing client certificate based authentication you always had three choices
   for validating those certs: PeerTrust, ChainTrust and Custom. I wrote about these
   options in detail (&lt;a href="http://www.leastprivilege.com/CertificateBasedAuthenticationAndWCF.aspx"&gt;here&lt;/a&gt;).
   Typically you ended up writing some custom validation because both Peer- and ChainTrust
   is often&amp;nbsp; not what you want (and there are also some differences when it comes
   to message vs transport based security - see &lt;a href="http://www.leastprivilege.com/CertificateBasedAuthenticationAndWCFMessageSecurity.aspx"&gt;here&lt;/a&gt;, &lt;a href="http://www.leastprivilege.com/CertificateBasedAuthenticationAndWCFTransportSecurity.aspx"&gt;here&lt;/a&gt; and &lt;a href="http://www.leastprivilege.com/CertificateBasedAuthenticationAndWCFModeIndependent.aspx"&gt;here&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
   Once you opt-in to the Geneva model - you will realize that client certificates start
   to break. This is because Geneva has a built-in way to restrict allowed CAs to a specified
   list, and by default this list is enforced - and empty. The background here is, that
   Geneva has this concept of an "issuer registry" - basically a mechanism how to map
   issuers (usually certificate issuers) to a name - the name is then placed on the Issuer
   property of claims. There are two built-in registry classes: the &lt;em&gt;SimpleIssuerNameRegistry&lt;/em&gt; (which
   simply uses the CA's subject name and has no restrictions) and the &lt;em&gt;ConfigurationBasedIssuerNameRegistry&lt;/em&gt; (which
   enforces the list I mentioned above).
&lt;/p&gt;
&lt;p&gt;
   To specify a list of allowed issuers, you have to put something like this in config:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;microsoft.identityModel&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;issuerNameRegistry&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="color: red; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;type&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;"&lt;span style="color: blue"&gt;Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry,
   …&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;trustedIssuers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;LeastPrivilege
   CA&lt;/span&gt;"&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: red"&gt;thumbprint&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"…"&lt;span style="color: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;trustedIssuers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;issuerNameRegistry&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;microsoft.identityModel&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;?xml:namespace prefix = o /&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   This has the effect that only certificates issued by a CA in the &lt;em&gt;trustedIssuers&lt;/em&gt; list
   will be allowed "in". If you don't want that restriction - or already have other validation
   code down the line - you can use the simple name registry. Another option is of course
   to write your own registry class.
&lt;/p&gt;
&lt;p&gt;
   Another big simplification with Geneva comes to custom token/credential types (ever
   tried adding a new credential type of WCF? Even really simple things require you to
   write 10+ classes and a good understanding how they relate to each other). With Geneva's
   concept of SecurityTokenHandlers this gets much easier.
&lt;/p&gt;
&lt;p&gt;
   So in summary - Geneva replaces parts of the WCF security system, simplifies it and
   makes it easier to extend - even if you are not using a security token service. I
   like that.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=fa57670f-f0b7-46fc-85e5-6c6983b86188" /&gt;</content>
  </entry>
  <entry>
    <title>Geneva is the new Zermatt (and much more)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GenevaIsTheNewZermattAndMuchMore.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=b57d38b5-8d8c-4394-a75a-c56f904aed91</id>
    <published>2008-10-27T22:45:34.1432065+01:00</published>
    <updated>2008-10-27T22:45:34.1432065+01:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="CardSpace" label="CardSpace" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Starting with the PDC release, Microsoft's identity framework is now code-named "Geneva
      Framework". Based on that framework, there is also a product called "Geneva Server"
      that brings the ADFS 1.x type of functionality (and more) to the web services/WS-Trust/CardSpace
      world. Furthermore there is also a release called "Geneva CardSpace" which seems to
      be CardSpace v.Next.
   </p>
        <p>
      You can download all the new bits <a href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=642">here</a>.
   </p>
        <p>
      I already had the chance to test-drive some of the new bits and made some interesting
      observations - stay tuned ;)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=b57d38b5-8d8c-4394-a75a-c56f904aed91" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Token Kidnapping (revisited)</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/TokenKidnappingRevisited.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=d998aeec-6862-42e2-a2fb-98a749abf401</id>
    <published>2008-10-16T07:10:04.5467974+02:00</published>
    <updated>2008-10-16T07:10:04.5467974+02:00</updated>
    <category term="Work in Progress" label="Work in Progress" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      It's been a <a href="http://www.leastprivilege.com/TokenKidnapping.aspx">while</a> since
      I linked to Cesar Cerrudo's slide <a href="http://www.argeniss.com/research/TokenKidnapping.pdf">deck</a> about
      token kidnapping. Now there is also a <a href="http://nomoreroot.blogspot.com/2008/10/windows-2003-poc-exploit-for-token.html">POC</a> available
      (with samples how to use it from SQL Server and IIS).
   </p>
        <p>
      There is also some movement at MS now...(<a href="http://blogs.iis.net/nazim/archive/2008/10/14/token-kidnapping-in-windows.aspx">here</a>, <a href="http://www.microsoft.com/technet/security/advisory/951306.mspx">here</a>)
   </p>
        <p>
      Quoting from the <strong>recommendations</strong> page of the original slide deck:
   </p>
        <ul>
          <li>
         Windows XP and 2003</li>
          <ul>
            <li>
            On IIS 6 don't run ASP .NET in full trust and if classic ASP is enabled don't allow
            users to execute binaries</li>
          </ul>
          <li>
         On Windows Vista and 2008</li>
          <ul>
            <li>
            On IIS 7 don't run ASP .NET in full trust or don't run web sites under NetworkServer
            or LocalService accounts</li>
            <li>
            Don't run services under NetworkService or LocalService accounts</li>
            <ul>
              <li>
               Use regular user accounts to run services</li>
            </ul>
          </ul>
        </ul>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=d998aeec-6862-42e2-a2fb-98a749abf401" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Getting rid of the .svc Extension in IIS</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/GettingRidOfTheSvcExtensionInIIS.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=a811cfc2-01a6-4391-83f0-ce79594a2e37</id>
    <published>2008-10-15T21:30:44.8529853+02:00</published>
    <updated>2008-10-15T21:30:44.8529853+02:00</updated>
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   &lt;a href="http://www.masteringbiztalk.com/blogs/jon/"&gt;Jon&lt;/a&gt; posted a &lt;a href="http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,9e0d8d1e-ac7c-49b5-8072-bde42609f5db.aspx"&gt;module&lt;/a&gt; that
   does this.
&lt;/p&gt;
&lt;p&gt;
   I recently tried to use the URL rewriting &lt;a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;amp;g=6&amp;amp;i=1691"&gt;module&lt;/a&gt; for
   IIS 7 to achieve the same - this rule worked for me:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;system.webServer&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;rewrite&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;rules&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;rule&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;/span&gt;&lt;span lang="EN-US" style="color: red; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;name&lt;/span&gt;&lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;=&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;"&lt;span style="color: blue"&gt;Remove
   .svc&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;match&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;url&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;^([0-9a-zA-Z\-]+)/([0-9a-zA-Z\-\.\/\(\)]*)&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;action&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Rewrite&lt;/span&gt;"&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: red"&gt;url&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;{R:1}.svc/{R:2}&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;rule&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;rules&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;rewrite&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.webServer&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;?xml:namespace prefix = o /&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=a811cfc2-01a6-4391-83f0-ce79594a2e37" /&gt;</content>
  </entry>
  <entry>
    <title>CardSpace is&amp;hellip;</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/CardSpaceIshellip.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=9ad2490a-4daa-4aad-b66a-010082d6efae</id>
    <published>2008-10-10T00:21:57.308+02:00</published>
    <updated>2008-10-11T12:15:09.4541145+02:00</updated>
    <category term="CardSpace" label="CardSpace" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I often get the Question: “<strong>What is CardSpace?</strong>”
   </p>
        <p>
      While there is a whole <a href="http://www.identityblog.com/?p=354">philosophical</a> side
      to CardSpace (or similar products) – the technical and pragmatic answer is:
   </p>
        <blockquote>
          <p>
      “CardSpace is a graphical client for security token services built into Windows”
   </p>
        </blockquote>
        <p>
      (or as <a href="http://www.pluralsight.com/community/blogs/keith/default.aspx">Keith</a> recently
      said: “home realm discovery the nice way")
   </p>
        <p>
      Related questions are:
   </p>
        <p>
          <strong>What is a card?</strong>
        </p>
        <blockquote>
          <p>
      “A card is a graphical representation of the configuration details how to talk to
      that security token service (address, required claims, credentials and more…)”
   </p>
        </blockquote>
        <p>
          <strong>Then what’s the difference between personal and managed cards?</strong>
        </p>
        <blockquote>
          <p>
      “Personal cards use a local (aka personal) STS. Managed cards a third-party/remote
      STS”
   </p>
        </blockquote>
        <p>
      That’s it.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=9ad2490a-4daa-4aad-b66a-010082d6efae" />
      </div>
    </content>
  </entry>
  <entry>
    <title>MSDN Article about WCF Service Authorization</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/MSDNArticleAboutWCFServiceAuthorization.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=7043a1c0-533f-46ab-be03-8bd53fe4f2f1</id>
    <published>2008-09-20T11:59:05.038+02:00</published>
    <updated>2008-10-02T08:48:05.1838797+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Christian and I have written an article about the authorization infrastructure in
      WCF. It covers roles- and claims-based authorization and how to customize both. Enjoy.
   </p>
        <p>
          <a title="http://msdn.microsoft.com/en-us/magazine/cc948343.aspx" href="http://msdn.microsoft.com/en-us/magazine/cc948343.aspx">http://msdn.microsoft.com/en-us/magazine/cc948343.aspx</a>
          <br />
      (back online now - sorry for the confusion)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=7043a1c0-533f-46ab-be03-8bd53fe4f2f1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Certificate-backed InfoCards and Service Credential Negotiation</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/CertificatebackedInfoCardsAndServiceCredentialNegotiation.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=8ca6947e-32d7-4503-8a28-de6b6c586b8c</id>
    <published>2008-09-14T14:16:45.956725+02:00</published>
    <updated>2008-09-14T14:16:45.956725+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      When trying to implement certificate backed managed InfoCards you might run into this
      slightly misleading error message:
   </p>
        <blockquote>
          <p>
      "There was a failure making a WS-Trust exchange with an external application. Could
      not retrieve token from identity provider. 
   </p>
          <p>
      Inner Exception: SOAP security negotiation failed. See inner exception for more details.<br />
      Inner Exception: The certificate 'CN=xy' must have a private key. The process must
      have access rights for the private key."
   </p>
        </blockquote>
        <p>
      The real cause for this error is a bug in Windows CardSpace. You can workaround that
      by disabling service credential negotiation on your STS binding by setting <em>negotiateServiceCredential</em> to <em>false</em>.
   </p>
        <p>
      Thanks to the Zermatt forum people for pointing me into the right direction!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=8ca6947e-32d7-4503-8a28-de6b6c586b8c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ASP.NET Controls and Output Encoding</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ASPNETControlsAndOutputEncoding.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=69d1ccde-51e2-48bc-9393-7a2b69fedae5</id>
    <published>2008-09-10T07:28:27.8032154+02:00</published>
    <updated>2008-09-10T07:28:27.8032154+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The last two days I did an ASP.NET security training for a customer. One discussion
      was how ASP.NET control handle (or don't) output encoding - especially how inconsistent
      their behavior is.
   </p>
        <p>
      Five minutes ago I found this <a href="http://keepitlocked.net/archive/2008/09/09/giving-the-owasp-net-esapi-a-second-look.aspx">post</a> by <a href="http://keepitlocked.net/">Alex</a> -
      and he links to this <a href="http://blogs.msdn.com/sfaust/attachment/8918996.ashx">table</a>.
      Wow.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=69d1ccde-51e2-48bc-9393-7a2b69fedae5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Zermatt: Source Code for FormsAuth STS</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ZermattSourceCodeForFormsAuthSTS.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=08c3ee9a-5bd6-46cb-8b36-f11e6671051d</id>
    <published>2008-09-04T00:55:48.554+02:00</published>
    <updated>2008-09-04T00:57:18.0234825+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I got several requests to publish the full source of the FormsAuth STS I described <a href="http://www.leastprivilege.com/ZermattUsingFormsAuthenticationInAPassiveSTS.aspx">here</a>.
      Find it <a href="http://www.leastprivilege.com/content/binary/FormsAuthZermattSTS.zip">here</a>.
      The setup is just like the passive STS/RP samples in the SDK.
   </p>
        <p>
      HTH
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=08c3ee9a-5bd6-46cb-8b36-f11e6671051d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>P2P and WCF: Some Troubleshooting Resources</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/P2PAndWCFSomeTroubleshootingResources.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=7655f511-6106-4ae0-83ac-df2da64207d5</id>
    <published>2008-08-17T07:47:17.0587933+02:00</published>
    <updated>2008-08-17T07:48:32.0744183+02:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      These are helpful resource when troubleshooting P2P:
   </p>
        <p>
          <strong>Checking cloud status:</strong>
          <br />
      netsh p2p pnrp cloud show list
   </p>
        <p>
          <strong>Checking Teredo status:</strong>
          <br />
      netsh int teredo show state
   </p>
        <p>
          <a href="http://blogs.msdn.com/p2p/archive/2007/07/03/ping.aspx">Enabling ping over
      P2P</a>
        </p>
        <p>
          <a href="http://blogs.msdn.com/p2p/archive/2007/11/07/making-sense-of-traceroute.aspx">P2P
      Traceroute</a>
        </p>
        <p>
          <a href="http://blogs.msdn.com/p2p/archive/2007/07/24/pnrp-debugging-guide-part-1.aspx">PNRP
      Debugging Guide</a>
        </p>
        <p>
          <a href="http://blogs.msdn.com/p2p/archive/2008/06/23/pnrp-and-windows-internet-computer-names-on-ws08.aspx">PNRP
      and WICN on Server 2008</a>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=7655f511-6106-4ae0-83ac-df2da64207d5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Zermatt: Using Forms Authentication in a Passive STS</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ZermattUsingFormsAuthenticationInAPassiveSTS.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=9fd0650f-6875-4726-8c1c-fd9cb606f303</id>
    <published>2008-08-15T08:58:18.4863502+02:00</published>
    <updated>2008-08-15T08:58:18.4863502+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   Since all Zermatt samples use Windows authentication to auth against an STS - the
   question how to use forms authentication instead popped up several times. It is easy
   to do that.
&lt;/p&gt;
&lt;p&gt;
   Basically a passive STS endpoint is an ASP.NET handler - could be a plain IHttpHandler,
   an .ashx or a page. All samples simply hook the Page_PreRender event to render the
   redirect logic. But you could also show a UI before doing that. This means you can
   put e.g. a login control on your issuing page and manually verify username/password
   credentials before issuing the token.
&lt;/p&gt;
&lt;p&gt;
   My sample issuing page looks like this:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span lang="EN-US" style="color: #a31515; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;html&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br&gt;
   &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;head&lt;/span&gt; &lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server"&amp;gt;&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;title&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;Forms
   Authentication Sign In&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;title&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;head&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;body&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;form&lt;/span&gt; &lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;="form1"&lt;/span&gt; &lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server"&amp;gt;&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Login&lt;/span&gt; &lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;="server"&lt;/span&gt; &lt;span style="color: red"&gt;ID&lt;/span&gt;&lt;span style="color: blue"&gt;="_login"&lt;/span&gt; &lt;span style="color: red"&gt;OnAuthenticate&lt;/span&gt;&lt;span style="color: blue"&gt;="_login_Authenticate"&lt;/span&gt; &lt;span style="color: blue"&gt;/&amp;gt;&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;form&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;body&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br&gt;
   &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;html&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;?xml:namespace prefix = o /&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   In the Authenticate event you verify credentials somehow, and if successful, create
   a ClaimsIdentity and&amp;nbsp; issue the token. In my sample I additionally issue a forms
   auth ticket for the STS domain so that returning users don't have to re-authenticate
   using the form. 
&lt;/p&gt;
&lt;p&gt;
   Another approach to make the federation token apply to more than one RP is to modify
   the cookie domain (if the RPs are in the same domain).
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;protected&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; _login_Authenticate(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;AuthenticateEventArgs&lt;/span&gt; e)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (ValidateUser(_login.UserName,
   _login.Password))&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;FormsAuthentication&lt;/span&gt;.SetAuthCookie(_login.UserName, &lt;span style="color: blue"&gt;false&lt;/span&gt;);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimsIdentity&lt;/span&gt; identity
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsIdentity&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;(System.IdentityModel.Claims.&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Name,
   _login.UserName), 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #a31515"&gt;"UserName"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimsPrincipal&lt;/span&gt; principal
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsPrincipal&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimsIdentityCollection&lt;/span&gt;(identity));&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ProcessFederationMessage(principal);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=9fd0650f-6875-4726-8c1c-fd9cb606f303" /&gt;</content>
  </entry>
  <entry>
    <title>How to build a Development/Test/Demo CA</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/HowToBuildADevelopmentTestDemoCA.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=e26e1cca-43a8-4b4b-b6dc-ba48b97cd93e</id>
    <published>2008-08-14T16:05:12.6246601+02:00</published>
    <updated>2008-08-14T16:05:12.6246601+02:00</updated>
    <category term="Work in Progress" label="Work in Progress" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I often need X509 certificates - but I never really became friendly with <em>makecert</em>.
      So I ended up running Windows Cerificate Services which proved to be an easy to use,
      robust solution. You can have one at home or carry it around in a VM. Perfect.
   </p>
        <p>
      There are some gotchas you can run into and I refined my configuration over the years.
      I just had to rebuild my Test CA (on Hyper-V) so I thought I'll document the important
      steps (for self-reference and whoever might be interested)
   </p>
        <p>
          <strong>
          </strong> 
   </p>
        <p>
          <strong>Basic Installation</strong>
        </p>
        <ol>
          <li>
         Install Windows Server (2003 or 2008) - either phyiscally or virtually.</li>
          <li>
         Install Certificate Services.</li>
          <li>
         Select Stand-alone CA.</li>
          <li>
         Choose a reasonable lifetime for the CA cert (like 10 years)</li>
          <li>
         Backup the CA cert. You need this when rebuilding the machine or having several installations
         act like the same CA.</li>
        </ol>
        <p>
       
   </p>
        <p>
          <strong>Certificate Lifetimes<br /></strong>By default certificates issued with the CA have a lifetime of one year. They
      usually expire on the very day where you have to do an important demo. You can configure
      the lifetime in the registry. See <a href="http://support.microsoft.com/kb/254632">here</a> for
      details.
   </p>
        <p>
       
   </p>
        <p>
          <strong>Revocation Lists</strong>
          <br />
      Another common reason why you run into problems with certificates are revocation lists.
      The location of the revocation list(s) is embedded in certificates in the CDP (CRL
      Distribution Point) extension. Now by default there is an entry pointing to the CA's
      Netbios name. Accessing that network location works while you are in your home network
      and the CA is up and running. If this network location cannot be accessed, many applications
      and frameworks will fail certificate validation (the default WCF binding security
      settings e.g.).
   </p>
        <p>
      Simply removing the complete CDP extension would be one workaround - but some apps
      don't like that at all. So I wouldn't recommend doing that. A better solution is to
      create a revocation list once, and store that at a publicly available location. You
      can also set the lifetime of that revocation list to some high value (like 5 years),
      so Windows will cache the list. This way you have access to your CRL while on the
      road and due to the high lifetime value, this will even work when having no network
      access at all.
   </p>
        <p>
      To change the CDP settings, open the Certificate Services MMC snap in. Right click
      on your CA and then select properties. On the extensions tab you can see the list
      of CRL locations. The first entry specifies the CA local location where CRLs are published.
      The last three locations get embedded in the certificate. You can delete them and
      add you publicly available location. Make sure you check the "Include in the CDP extensions
      of issued certificates" box for your new location.
   </p>
        <p>
      Next you have to publish a CRL. First you have to set the CRL lifetime. This is configured
      in the properties of the 'Revoked Certificates' folder in the snap in. Set it to e.g.
      five years. Next you publish via right-Click -&gt; All Tasks -&gt; Publish. You can
      find the CRL at the previously configured local location.
   </p>
        <p>
      The last step is to copy the CRL to your public location and that's it.
   </p>
        <p>
      Now you can browse to the CA's web interface (http://server/certsrv) and request certificates.
      After requesting a certificate you have to go to the CA's MMC console and issue the
      cert (in 'Pending Requests'). Then you can download the certificate by returning to
      the web interface.
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=e26e1cca-43a8-4b4b-b6dc-ba48b97cd93e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Most important bug fix in 3.5 SP1</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/MostImportantBugFixIn35SP1.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=94a33094-941b-4ed9-83ab-d9f7c2d2cc7a</id>
    <published>2008-08-14T11:06:21.7184086+02:00</published>
    <updated>2008-08-15T08:59:51.7808368+02:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blogs.msdn.com/brada/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-code-to-be-launched-from-a-network-share.aspx">BradA</a> says:
   </p>
        <blockquote>
          <p>
      "We have brought managed executables in line with native code executables in how they
      behave when run off a network share.  Yea!"
   </p>
        </blockquote>
        <p>
          <a href="http://blogs.msdn.com/vancem/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-code-to-be-launched-from-a-network-share.aspx">VanceN</a> says:
   </p>
        <blockquote>
          <p>
      "Hurray, its finally fixed!  manage code 'just works' from network file share!"
   </p>
        </blockquote>
        <p>
      Grats for fixing this <em>bug</em>!
   </p>
        <p>
       
   </p>
        <p>
      (hint: some sarcasm is hidden in this post ;)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=94a33094-941b-4ed9-83ab-d9f7c2d2cc7a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>WCF Claims to &amp;quot;Zermatt&amp;quot; Claims Migration Story</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/WCFClaimsToQuotZermattquotClaimsMigrationStory.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=7291b07f-f2da-4f79-9c42-b2b4e1388cef</id>
    <published>2008-07-24T12:06:31.7849282+02:00</published>
    <updated>2008-07-24T12:06:31.7849282+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Hey - that's a short post - there is none. thanks. bye...
   </p>
        <p>
      OK hold on - some background info.
   </p>
        <p>
      Microsoft introduced their new claims API with .NET 3.0 as part of the System.IdentityModel
      assembly (with super tight integration into WCF). Needless to say that I really like
      the claims approach - and I have written quite a lot about it <a href="http://www.leastprivilege.com/CategoryView.aspx?category=IdentityModel">here</a>.
   </p>
        <p>
      Also since that day we were all waiting for that super secret identity framework that
      was supposed to extend the claims API and which will finally give us easier support
      for security token services and Information Card related technologies. Now it is in
      beta and is called "Zermatt". Cool. Life is good.
   </p>
        <p>
      After some experiments and proof of concepts - it turns out life is not so good.
   </p>
        <p>
      To enable the "Zermatt" model in WCF you basically have to call the <em>ConfigureServiceHost</em> method
      on the <em>ExtensibleServiceCredentials </em>class<em></em>(at least that's how it
      works with the current bits). As soon as you enable Zermatt the usual places where
      security happens in WCF don't work anymore - namely <em>ServiceSecurityContext </em>and <em>AuthorizationContext</em>.
      Interested readers of my blog know that these classes are the entry point into the
      claims based world in WCF. Also if you have made any investments already into the
      claims model, your code relies on these classes. If they are "gone", your code is
      broken.
   </p>
        <p>
      All the claims functionality found in WCF is now replaced by the Zermatt model and
      there is no connection whatsoever between them. You'll also find that Zermatt has
      its own version of a Claim class (and other structural classes too). This basically
      means that if you have already invested in the WCF claims model but wanna move on
      to Zermatt, you have to throw away all your code and start from scratch. There is
      no migration or co-existence story between WCF claims and Zermatt claims.
   </p>
        <p>
      OK - the next thing I tried is how existing WCF authorization policies work together
      with Zermatt. The results are quite mixed. First of all external policies only work
      with certain credential types - and <em>Right.Idenity</em> claims are not supported
      at all.
   </p>
        <p>
      Fortunately, there is a <a href="https://connect.microsoft.com/community/discussion/richui/default.aspx?SiteID=642">forum</a> for
      Zermatt so I can ask some MSFT people about their take on that. Here's what I got
      back (I'd love to provide links to the forum posts - but unfortunately this forum
      is sooo cool and ajaxy that one of the most important features of the web - called
      URLs - don't work):
   </p>
        <blockquote>
          <p>
      "Hi Dominick,<br />
      Deeper investigation on my part into what I suspected was a bug turned<br />
      out to be by design. The scenario you are attempting (upgrading a<br />
      legacy app that depends on the WCF claims model) is not supported in<br />
      Zermatt. 
   </p>
        </blockquote>
        <blockquote>
          <p>
      Once you opt into Zermatt's claims model, the WCF claims API does not<br />
      work anymore. The reason for this behavior is the new claims model in<br />
      Zermatt is not backwards compatible with the WCF claims API and it is<br />
      not feasible to support both the old and new models at the same time<br />
      for WCF applications. 
   </p>
        </blockquote>
        <blockquote>
          <p>
      As you have called out earlier in a separate discussion, you have to<br />
      choose between staying with the WCF API and not use Zermatt, or move<br />
      your application to Zermatt. If you do choose to migrate, any code<br />
      that depends on the WCF claims API will need to be rewritten."
   </p>
        </blockquote>
        <p>
          <strong>Have you also spotted the word "legacy" wrt to WCF??? They must be kidding
      me!</strong>
        </p>
        <p>
      Here's my answer:
   </p>
        <blockquote>
          <p>
      "I don't understand the problem - why can't you take existing authZ<br />
      policies and transform them into a ClaimsIdentity - this would be an<br />
      easy solution for the migration problem. 
   </p>
        </blockquote>
        <blockquote>
          <p>
      Frankly - this sucks. 
   </p>
        </blockquote>
        <blockquote>
          <p>
      What do I tell my customers? Sorry for leading you into the<br />
      System.IdentityModel direction? Your code will not move forward? 
   </p>
        </blockquote>
        <blockquote>
          <p>
      You have a brand new communication framework with a brand new claims<br />
      based authZ model - now you are releasing a brand new identity<br />
      framework that just disables the technologies used before???? This is<br />
      not right. 
   </p>
        </blockquote>
        <blockquote>
          <p>
      I don't ask for a full compatibility story between S.IM and Zermat -<br />
      but i don't want to throw away all my code (or my customers code)."
   </p>
        </blockquote>
        <p>
      Am I asking for too much? Is this a non-issue? I filed a bug for that <a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=357568&amp;SiteID=642">here</a>.
      If this is also important for you - feel free to vote.
   </p>
        <p>
       
   </p>
        <p>
          <strong>Disclaimer:</strong> Don't get me wrong. I don't want to bash Microsoft or
      the Zermatt team, nor the people on the forum which are really helpful. I just think
      this is a wrong design decision. And I read somewhere that Microsoft is looking for
      feedback. So here it is.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=7291b07f-f2da-4f79-9c42-b2b4e1388cef" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Try &amp;quot;Zermatt&amp;quot; and give Feedback</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/TryQuotZermattquotAndGiveFeedback.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=13037998-9cc3-412f-876e-cc7d9fa3fe86</id>
    <published>2008-07-18T09:35:37.530245+02:00</published>
    <updated>2008-07-18T09:35:37.530245+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The last week I spent some time exploring parts of the "Zermatt" framework - some
      things are really cool - some I have mixed feelings about.
   </p>
        <p>
      The team is still in a quite early stage where design decisions and directions are
      (re-) considered. Since "Zermatt" is the main Microsoft identity framework we have
      to live (and work) with for the next years, take you chance to shape it!
   </p>
        <ul>
          <li>
            <a href="https://connect.microsoft.com/Downloads/Downloads.aspx?SiteID=642">Download</a>
          </li>
          <li>
            <a href="https://connect.microsoft.com/community/discussion/richui/default.aspx?SiteID=642">Forum</a>
          </li>
          <li>
            <a href="https://connect.microsoft.com/feedback/default.aspx?SiteID=642">Feedback</a>
          </li>
        </ul>
        <p>
      I have already started some discussions, so feel free to contribute.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=13037998-9cc3-412f-876e-cc7d9fa3fe86" />
      </div>
    </content>
  </entry>
  <entry>
    <title>CLR Security Site on Codeplex</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/CLRSecuritySiteOnCodeplex.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=460f7d00-af38-447c-a2f6-3d7a3ee025dd</id>
    <published>2008-07-11T08:15:18.6557134+02:00</published>
    <updated>2008-07-11T08:15:18.6557134+02:00</updated>
    <category term="For Your Favourites" label="For Your Favourites" scheme="dasBlog" />
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The CLR security team has a <a href="http://www.codeplex.com/clrsecurity">site</a> now
      on Codeplex - Shawn has all the details <a href="http://blogs.msdn.com/shawnfa/">here</a>.
   </p>
        <p>
      Good stuff!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=460f7d00-af38-447c-a2f6-3d7a3ee025dd" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Skiing in &amp;quot;Zermatt&amp;quot;</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SkiingInQuotZermattquot.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=11ded872-4a52-410b-9c14-13b745448889</id>
    <published>2008-07-10T00:38:23.3233248+02:00</published>
    <updated>2008-07-10T00:38:23.3233248+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Today, Microsoft finally announced the first public version of their .NET identity
      framework code named "Zermatt". The most important things you get from this framework
      are:
   </p>
        <ul>
          <li>
         APIs for the token/claims related heavy crypto lifting 
      </li>
          <li>
         Supporting classes for claims aware applications (including an IIdentity/IPrincipal
         implementation to give you a common programming model and smooth migration path) 
      </li>
          <li>
         ASP.NET plumbing for accepting tokens in web applications 
      </li>
          <li>
         ASP.NET controls for adding Information Card support to web applications 
      </li>
          <li>
         OM for creating Information Cards 
      </li>
          <li>
         Framework and base classes to write security token services (for active and passive
         scenarios)</li>
        </ul>
        <p>
      If you have already started looking into claims based security, this framework extends
      the concepts found in <em>System.IdentityModel</em> and makes it much easier to exploit
      the full power of token/claims based security systems. See <a href="http://blogs.msdn.com/vbertocci/archive/2008/07/09/announcing-the-beta-release-of-zermatt-developer-identity-framework.aspx">here</a> for
      the official announcement.
   </p>
        <p>
      You can download the bits and a good whitepaper (written by Keith) here:
   </p>
        <p>
          <a title="https://connect.microsoft.com/site/sitehome.aspx?SiteID=642" href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=642">https://connect.microsoft.com/site/sitehome.aspx?SiteID=642</a>
        </p>
        <p>
      Stay tuned ;)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=11ded872-4a52-410b-9c14-13b745448889" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Using IdentityModel: Useful Extension Methods for Serializing Claim Sets</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsingIdentityModelUsefulExtensionMethodsForSerializingClaimSets.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=b550b5f7-d5f6-47de-a5e0-4def7c663f20</id>
    <published>2008-07-02T23:13:54.9181449+02:00</published>
    <updated>2008-07-02T23:13:54.9181449+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   As a follow up to my last post - the following extension methods make it easy to manually
   serialize claim sets:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt; Serialize(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt; set, &lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;&amp;gt;
   knownTypes)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;DataContractSerializer&lt;/span&gt; dcs
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DataContractSerializer&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;set.GetType(),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;knownTypes,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt;.MaxValue,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;false&lt;/span&gt;,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;true&lt;/span&gt;,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt; ms
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;();&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;dcs.WriteObject(ms, set);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ms.Seek(0, &lt;span style="color: #2b91af"&gt;SeekOrigin&lt;/span&gt;.Begin);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;.Load(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;XmlTextReader&lt;/span&gt;(ms));&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;
   &lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: en-us; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt; Serialize(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt;&amp;gt;
   claimSets, &lt;span style="color: blue"&gt;string&lt;/span&gt; rootName, 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; rootNamespace, &lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;&amp;gt;
   knownTypes)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XNamespace&lt;/span&gt; ns
   = &lt;span style="color: #2b91af"&gt;XNamespace&lt;/span&gt;.Get(rootNamespace);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;XElement&lt;/span&gt;(ns
   + rootName,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;from&lt;/span&gt; cs &lt;span style="color: blue"&gt;in&lt;/span&gt; claimSets&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;select&lt;/span&gt; cs.Serialize(knownTypes));&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=b550b5f7-d5f6-47de-a5e0-4def7c663f20" /&gt;</content>
  </entry>
  <entry>
    <title>Re:MVP</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ReMVP.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=05e9088f-0faf-4485-94e2-3fb1e1ada472</id>
    <published>2008-07-02T22:53:58.2958268+02:00</published>
    <updated>2008-07-02T22:53:58.2958268+02:00</updated>
    <category term="Misc" label="Misc" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Quoting <a href="http://www.pluralsight.com/community/blogs/brian/archive/2008/07/01/a-new-year-starts.aspx">Brian</a>:
   </p>
        <p>
      "Microsoft has decided I didn't cause too much trouble over the last 12 months so
      I get to continue being a <font color="#0000ff">{0}</font> MVP. Thanks!", <font color="#0000ff">"Developer
      Security"</font></p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=05e9088f-0faf-4485-94e2-3fb1e1ada472" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Using IdentityModel: Serializing Claim Sets</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsingIdentityModelSerializingClaimSets.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=bdbba2ce-c51e-4a2a-b223-b18a5cb5c9ae</id>
    <published>2008-07-02T10:00:28.9816999+02:00</published>
    <updated>2008-07-02T10:19:33.2160749+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   Both &lt;em&gt;Claim&lt;/em&gt; and &lt;em&gt;ClaimSet&lt;/em&gt; are decorated with &lt;em&gt;DataContract/DataMember&lt;/em&gt; attributes.
   This means they are made for serialization. And this makes sense - maybe you want
   to forward a claim set (server to server) or send a claim set from server to client
   (UI authorization).
&lt;/p&gt;
&lt;p&gt;
   But you will most likely run into problems when trying to serialize a claim set using
   the &lt;em&gt;DataContractSerializer&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Known Types&lt;br&gt;
   &lt;/strong&gt;DCS needs to 'know' all types that are involved in the serialization process.
   This involves every type in the inheritance chain down to ClaimSet (e.g. &lt;em&gt;DefaultClaimSet&lt;/em&gt; or
   my &lt;em&gt;DeferredLoadClaimSet&lt;/em&gt;) as well as all possible resource types. You either
   supply the known types via attributes/config (&lt;em&gt;KnownType&lt;/em&gt; and &lt;em&gt;ServiceKnownType&lt;/em&gt;).
&lt;/p&gt;
&lt;p&gt;
   Or you supply the types when newing up the DCS manually:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: #2b91af; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-ansi-language: en-us"&gt;DataContractSerializer&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-ansi-language: en-us"&gt; dcs
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DataContractSerializer&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt;),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;&amp;gt;
   { &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;DefaultClaimSet&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;UIClaimResource&lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;)
   });&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Circular References&lt;br&gt;
   &lt;/strong&gt;Typical claim sets will have circular references - e.g. when the last issuer
   in the chain points to himself. DCS is not made for cyclic reference - but rather
   object trees (at least with the default settings). When you are trying to serialize
   objects with cyclic references you will get the following exception : "type contains
   cycles and cannot be serialized if reference tracking is disabled.". In WCF traces
   you will see something like "message not logged because its size exceeds configured
   quota".
&lt;/p&gt;
&lt;p&gt;
   When newing up a DCS you can opt for "preserving object references". This will create
   ID/IDREF pairs in the serialized XML and allows for type references and thus cycles.
   (Aaron has an &lt;a href="http://www.pluralsight.com/community/blogs/aaron/archive/2008/05/14/50943.aspx"&gt;explanation&lt;/a&gt; of
   how that works).
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span lang="EN-US" style="color: #2b91af; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-ansi-language: en-us"&gt;DataContractSerializer&lt;/span&gt;&lt;span lang="EN-US" style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-ansi-language: en-us"&gt; dcs
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DataContractSerializer&lt;/span&gt;(&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt;),&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;&amp;gt;
   { &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;DefaultClaimSet&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;UIClaimResource&lt;/span&gt;)
   },&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt;.MaxValue,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;true&lt;/span&gt;,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;true&lt;/span&gt;,&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: green"&gt;//
   preserveObjectReferences&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   This is fine when you can control the DCS parameters. But you can't easily do that
   in WCF. Sowmy has a &lt;a href="http://blogs.msdn.com/sowmy/archive/2006/03/26/561188.aspx"&gt;sample&lt;/a&gt; on
   how to enable reference preserving in WCF. This will solve the problem!
&lt;/p&gt;
&lt;span style="font-size: 11pt; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: de; mso-fareast-language: en-us; mso-bidi-language: ar-sa"&gt;[&lt;span style="color: #2b91af"&gt;OperationContract&lt;/span&gt;]&lt;br&gt;
[&lt;span style="color: #2b91af"&gt;ReferencePreservingDataContractFormat&lt;/span&gt;]&lt;br&gt;
&lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt; GetClaims();&lt;/span&gt; 
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;3.5 SP1 to the Rescue!?&lt;/strong&gt;
   &lt;br&gt;
   Starting with 3.5 SP1 you can enable reference preserving on a &lt;em&gt;DataContract&lt;/em&gt; like
   this:
&lt;/p&gt;
&lt;span lang="EN-US" style="font-size: 11pt; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa"&gt;[&lt;span style="color: #2b91af"&gt;DataContract&lt;/span&gt;(Namespace
= &lt;span style="color: #a31515"&gt;"..."&lt;/span&gt;, &lt;b style="mso-bidi-font-weight: normal"&gt;IsReference
= &lt;span style="color: blue"&gt;true&lt;/span&gt;&lt;/b&gt;)]&lt;br&gt;
&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;abstract&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DeferredLoadClaimSet&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   But there are two problems with this approach:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      You actually need access to the DataContract to change the attribute. In the claims
      case - you would need to change the framework's &lt;em&gt;DefaultClaimSet&lt;/em&gt; or your own &lt;em&gt;ClaimSet&lt;/em&gt;-derived
      class.&lt;/li&gt;
   &lt;li&gt;
      Every &lt;em&gt;DataContract&lt;/em&gt; in the inheritance chain needs the &lt;em&gt;IsReference&lt;/em&gt; attribute
      - otherwise you will get the following error: "Derived types must have the same value
      for IsReference as the base type". Since all custom claim sets ultimately derive from &lt;em&gt;ClaimSet&lt;/em&gt; -
      but this &lt;em&gt;DataContract&lt;/em&gt; has no &lt;em&gt;IsReference&lt;/em&gt; set, we are back to square
      one.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;Conclusion&lt;/strong&gt;
   &lt;br&gt;
   Keep these things in mind when serializing claim sets:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      supply all involved types as known types&lt;/li&gt;
   &lt;li&gt;
      Set &lt;em&gt;preserveObjectReferences&lt;/em&gt; to true on the DCS. The new attribute on &lt;em&gt;DataContract&lt;/em&gt; in
      3.5 SP1 is nice - but does not help with claim sets. Use the [ReferencePreservingDataContractFormat]
      attribute instead (find the code &lt;a href="http://blogs.msdn.com/sowmy/attachment/561188.ashx"&gt;here&lt;/a&gt;).&lt;/li&gt;
   &lt;li&gt;
      Reference preserving adds ID/IDREF attributes to the resulting XML. These attributes
      come from a Microsoft namespace. This may be a problem for interop scenarios. If you
      need full control over the XML, either use the DCS extensibility points for manual
      serialization, or don't use the DCS at all (and use one of the alternative message
      generation mechanisms). Another option would be to use a more standardized serialization
      format for claims like a SAML token.&lt;/li&gt;
   &lt;li&gt;
      &lt;em&gt;WindowsClaimSet&lt;/em&gt; and &lt;em&gt;X509CertificateClaimSet&lt;/em&gt; are not marked with
      [DataContract] at all - they are not intended for serialization.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   HTH
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=bdbba2ce-c51e-4a2a-b223-b18a5cb5c9ae" /&gt;</content>
  </entry>
  <entry>
    <title>PowerShell Profile</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/PowerShellProfile.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=01ad0c4b-2601-4ac6-b4dd-83809f43115f</id>
    <published>2008-06-15T16:44:38.5208473+02:00</published>
    <updated>2008-06-15T16:52:27.9865927+02:00</updated>
    <category term="Work in Progress" label="Work in Progress" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Putting <a href="http://www.tavaresstudios.com/Blog/post/The-last-vsvars32ps1-Ill-ever-need.aspx">these</a><a href="http://www.leastprivilege.com/MyMonadCommandPrompt.aspx">three</a><a href="http://www.leastprivilege.com/AdminTitleBarForPowerShell.aspx">things</a> (and
      a little bit of <a href="http://www.interact-sw.co.uk/iangblog/2007/02/09/pshdetectelevation">this</a>)
      together - you can build a very nice profile script for PowerShell ;)
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=01ad0c4b-2601-4ac6-b4dd-83809f43115f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Advanced Extensions to IIS 7 Configuration</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/AdvancedExtensionsToIIS7Configuration.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=bf0ddd2a-8712-4777-90a1-3a7492511bd9</id>
    <published>2008-06-13T00:55:59.4171334+02:00</published>
    <updated>2008-06-13T00:55:59.4171334+02:00</updated>
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Great article about IIS 7 configuration extensibility:
   </p>
        <p>
          <a title="http://learn.iis.net/page.aspx/241/configuration-extensibility/" href="http://learn.iis.net/page.aspx/241/configuration-extensibility/">http://learn.iis.net/page.aspx/241/configuration-extensibility/</a>
        </p>
        <p>
      Especially infos about the COM backed extensions are hard to find elsewhere...
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=bf0ddd2a-8712-4777-90a1-3a7492511bd9" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Software Architect 2008</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SoftwareArchitect2008.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=c0ebf17c-d5ac-423a-9d49-27200a5d99fc</id>
    <published>2008-06-07T06:44:43.2469319+02:00</published>
    <updated>2008-06-07T06:44:43.2469319+02:00</updated>
    <category term="Conferences" label="Conferences" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Thanks to everyone who attended my IdentityModel talk at <a href="http://www.software-architect.co.uk/">Software
      Architect</a>.
   </p>
        <p>
      You can have all the code I showed you during my talk - just send me a private message
      or leave a comment. Most of the demos are online anyways - have a look at my IdentityModel <a href="http://www.leastprivilege.com/IdentityModel">micro-site</a>.
   </p>
        <p>
      Questions and feedback are more than welcome. Happy identity-ing.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=c0ebf17c-d5ac-423a-9d49-27200a5d99fc" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Writing IIS 7 Manager Extensions</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/WritingIIS7ManagerExtensions.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=d7d81925-ba58-4281-95dd-c53d9ea98533</id>
    <published>2008-06-05T11:16:30.1827905+02:00</published>
    <updated>2008-06-05T11:16:30.1827905+02:00</updated>
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Good walkthrough here:
   </p>
        <p>
          <a title="http://learn.iis.net/page.aspx/441/understanding-ui-extension-authoring/" href="http://learn.iis.net/page.aspx/441/understanding-ui-extension-authoring/">http://learn.iis.net/page.aspx/441/understanding-ui-extension-authoring/</a>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=d7d81925-ba58-4281-95dd-c53d9ea98533" />
      </div>
    </content>
  </entry>
  <entry>
    <title>SQL Server Security Best Practices</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SQLServerSecurityBestPractices.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=9c9d4ab6-c1d9-45b8-b6ef-bbb4f4f56c9a</id>
    <published>2008-05-28T10:39:37.2060185+02:00</published>
    <updated>2008-05-28T10:39:37.2060185+02:00</updated>
    <category term="For Your Favourites" label="For Your Favourites" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.sqlskills.com/blogs/bobb">Bob</a> wrote me an email as a response
      to <a href="http://www.leastprivilege.com/SystemAccountsAndSQLServer2005.aspx">this</a> post.
      He also directed me to this <a href="http://download.microsoft.com/download/8/5/e/85eea4fa-b3bb-4426-97d0-7f7151b2011c/SQL2005SecBestPract.doc">whitepaper</a> he
      wrote about SQL Server Security. Interesting read!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=9c9d4ab6-c1d9-45b8-b6ef-bbb4f4f56c9a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>OpenID Phishing Demo</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/OpenIDPhishingDemo.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=fcf019b2-11fb-4c61-a58a-88efdb06056b</id>
    <published>2008-05-26T22:02:32.5873635+02:00</published>
    <updated>2008-05-26T22:02:32.5873635+02:00</updated>
    <category term="For Your Favourites" label="For Your Favourites" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Funny and educational:
   </p>
        <p>
          <a title="http://idtheft.fun.de/" href="http://idtheft.fun.de/">http://idtheft.fun.de/</a>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=fcf019b2-11fb-4c61-a58a-88efdb06056b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>System Accounts and SQL Server 2005</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/SystemAccountsAndSQLServer2005.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=50d609a8-e4e9-4a68-846e-fd40dfc41bf6</id>
    <published>2008-05-26T13:26:37.9644917+02:00</published>
    <updated>2008-05-26T13:27:17.0418664+02:00</updated>
    <category term="Work in Progress" label="Work in Progress" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I recently ran into a strange situation - I was expecting an "access denied" but it
      didn't happen (yes - security guys are strange people ;). Here's the long story:
   </p>
        <p>
      I was writing some test code for LINQ to SQL (see <a href="http://www.leastprivilege.com/LINQToSQLAndSecurity.aspx">here</a>)
      in ASP.NET. Since this was on a freshly installed box I was expecting an access denied
      since I hadn't created a SQL login for <em>Network Service</em> yet. But it worked
      - I could successfully query (and update) data in all databases. Shock.
   </p>
        <p>
      After some investigation I found the reason for this behavior. Since I was using SQL
      Express, the SQL instance was running as <em>Network Service</em> (the default). Furthermore
      setup creates a Windows group for SQL Server service accounts (e.g. MACHINE\SQLServer2005MSSQLUser$...)
      and puts <em>Network Service</em> in there. It turns out that this Windows group is
      mapped to a SQL login with a server role of <em>sysadmin...</em></p>
        <p>
      This means (on my machine) that all SQL clients running as <em>Network Service</em> (or
      can get an impersonation token for that account) have <em>sysadmin</em> privileges
      in the SQL Server installation. Or more generally - when a client can use the same
      Windows account as SQL Server itself - it will get sysadmin privileges
   </p>
        <p>
      I thought I might point this out, since running SQL Server and ASP.NET as <em>Network
      Service</em> seems to be a pretty common configuration.
   </p>
        <p>
          <strong>The moral of the story: Always create dedicated service accounts for SQL Server
      (or every service you install). </strong>
        </p>
        <p>
      btw - the full blown SQL Server installation specifically asks you for the account
      to use (but also gives <em>Network Service</em> as a choice).
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=50d609a8-e4e9-4a68-846e-fd40dfc41bf6" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Avoid unhandled Exceptions in WCF Error Handlers</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/AvoidUnhandledExceptionsInWCFErrorHandlers.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=5ec86ca3-e719-464a-b5be-220aa31102ce</id>
    <published>2008-05-23T10:26:30.189201+02:00</published>
    <updated>2008-05-23T10:26:30.189201+02:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The <em>IErrorHandler</em> interface in WCF allows to write some central error handling
      code that gets invoked whenever an unhandled exception bubbles up from your service.
      There are two methods to implement:
   </p>
        <ul>
          <li>
            <em>ProvideFault</em> - called on the request thread to turn the exception into a
         fault message</li>
          <li>
            <em>HandleError</em> - called on a separate thread for error logging and the like</li>
        </ul>
        <p>
      While WCF tries its best to shield the service host from all kinds of error conditions,
      there are some situations where unhandled exceptions can hurt your hosting process.
      One of them is the <em>HandleError</em> method on <em>IErrorHandler</em>.
   </p>
        <p>
          <em>HandleError</em> is called on a background thread to allow doing (kind of) lenghty
      operations without impacting the request where the error originally occurred. If you
      have an unhandled exception in <em>HandleError</em> the normal CLR rules for excpetions
      in background threads apply - which means shutting down the process. Be careful here.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=5ec86ca3-e719-464a-b5be-220aa31102ce" />
      </div>
    </content>
  </entry>
  <entry>
    <title>How to change validity period of issued certificates in Windows Certificate Services</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/HowToChangeValidityPeriodOfIssuedCertificatesInWindowsCertificateServices.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=da9f58c3-5442-4f68-a2c4-ea93d4c9cbc7</id>
    <published>2008-05-18T17:22:24.7057592+02:00</published>
    <updated>2008-05-18T17:22:24.7057592+02:00</updated>
    <category term="For Your Favourites" label="For Your Favourites" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://support.microsoft.com/kb/254632">http://support.microsoft.com/kb/254632</a>
        </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=da9f58c3-5442-4f68-a2c4-ea93d4c9cbc7" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Two important Security changes in .NET 3.5 SP1</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/TwoImportantSecurityChangesInNET35SP1.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=24ee543d-a836-4b35-b00d-1366cb1733a5</id>
    <published>2008-05-15T08:53:45.2456668+02:00</published>
    <updated>2008-05-15T08:53:45.2456668+02:00</updated>
    <category term="FX Security" label="FX Security" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Shawn details the two big security changes in .NET 3.5 SP1 on his blog:
   </p>
        <ul>
          <li>
            <a href="http://blogs.msdn.com/shawnfa/archive/2008/05/14/strong-name-bypass.aspx">Strong
         Name Bypass</a>
          </li>
          <li>
            <a href="http://blogs.msdn.com/shawnfa/archive/2008/05/12/fulltrust-on-the-localintranet.aspx">Full
         Trust on the Local Intranet</a>
          </li>
        </ul>
        <p>
      We have discussed both changes internally - and I have mixed feelings about them.
      I guess the most important thing to be aware of is, that they are not opt-in changes.
      By installing SP1 - the behavior will change automatically - if you like it or not.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=24ee543d-a836-4b35-b00d-1366cb1733a5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Improved IisRegMgmt</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/ImprovedIisRegMgmt.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=2f7d30da-b7b1-4d28-9b89-6bef02ad15cc</id>
    <published>2008-05-14T08:34:10.3648344+02:00</published>
    <updated>2008-05-14T08:34:10.3648344+02:00</updated>
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Thanks to <a href="http://blogs.msdn.com/carlosag/">CarlosAg</a> from the IIS team,
      I was able to improve my tool for registering IIS 7 management modules.
   </p>
        <p>
          <a href="http://www.leastprivilege.com/content/binary/IisRegMgmt01.zip">IisRegMgmt01.zip</a>
        </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=2f7d30da-b7b1-4d28-9b89-6bef02ad15cc" />
      </div>
    </content>
  </entry>
  <entry>
    <title>P2P and WCF: The PeerName Tool</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/P2PAndWCFThePeerNameTool.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=6e1dbade-12c5-44f7-98c4-6b90d4cd9963</id>
    <published>2008-05-14T08:03:31.624+02:00</published>
    <updated>2008-05-14T08:06:29.0761302+02:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      To play around with peer name registration and resolution, I wrote a little tool that
      makes this easy (yes - I know all this functionality is also available via netsh -
      but I wanted something more specialized).
   </p>
        <p>
          <strong>Registering</strong>
        </p>
        <p>
          <img src="http://www.leastprivilege.com/content/binary/PeerNameReg.png" border="0" />
        </p>
        <p>
          <strong>Resolving</strong>
        </p>
        <p>
          <img src="http://www.leastprivilege.com/content/binary/PeerNameResolve.png" border="0" />
        </p>
        <p>
          <a href="http://www.leastprivilege.com/content/binary/PeerName.zip">PeerName.zip (27.31
      KB)</a>
        </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=6e1dbade-12c5-44f7-98c4-6b90d4cd9963" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Using IdentityModel: Tracing</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsingIdentityModelTracing.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=85567584-e6c1-4a35-86fb-78a447e27a77</id>
    <published>2008-05-12T19:28:09.084661+02:00</published>
    <updated>2008-05-12T19:28:09.084661+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      While reading through some of the code of <em>System.IdentityModel</em>, I noticed
      that there is some diagnostics tracing going on. Just add a trace listener for the
      source 'System.IdentityModel' to your config file.
   </p>
        <p>
      HTH
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=85567584-e6c1-4a35-86fb-78a447e27a77" />
      </div>
    </content>
  </entry>
  <entry>
    <title>P2P and WCF: Some Resources</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/P2PAndWCFSomeResources.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=a38f39cb-900c-4bf7-9cb6-5cb17639ad53</id>
    <published>2008-05-02T06:09:01.4524206+02:00</published>
    <updated>2008-05-02T06:09:01.4524206+02:00</updated>
    <category term="For Your Favourites" label="For Your Favourites" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      If you want to know more about P2P and its related protocols and components, here's
      a list of online resource I found useful while researching:
   </p>
        <ul>
          <li>
            <a href="http://blogs.msdn.com/p2p/">P2P team blog</a>
          </li>
          <li>
            <a href="http://blogs.msdn.com/peerchan/">Peer Channel blog</a>
          </li>
          <li>
            <a href="http://msdn.microsoft.com/en-us/library/cc219453.aspx">Peer Channel protocol
         specification</a>
          </li>
          <li>
            <a href="http://technet.microsoft.com/en-us/network/bb545868.aspx">P2P on TechNet</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/technet/network/ipv6/teredo.mspx">Teredo</a>
          </li>
          <li>
         "The Teredo Protocol: Tunneling Past Network Security and other Security Implications" <a href="http://www.symantec.com/avcenter/reference/Teredo_Security.pdf">whitepaper</a></li>
          <li>
         "Get Connected with .NET 3.5" MSDN <a href="http://msdn.microsoft.com/msdnmag/issues/07/09/Networking/default.aspx">article</a></li>
          <li>
         "Peer-to-Peer Programming with WCF and .NET Framework 3.5" MSDN <a href="http://msdn.microsoft.com/en-us/library/cc297274.aspx">article</a></li>
        </ul>
        <p>
      Have fun!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=a38f39cb-900c-4bf7-9cb6-5cb17639ad53" />
      </div>
    </content>
  </entry>
  <entry>
    <title>P2P and WCF: Exposing a Service</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/P2PAndWCFExposingAService.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=98a3b225-8111-4650-ba32-ae97ef0ac435</id>
    <published>2008-05-01T11:26:52.057+02:00</published>
    <updated>2008-05-01T12:13:45.5240125+02:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The <a href="http://www.leastprivilege.com/P2PAndWCFFindingAService.aspx">last</a> post
      explained how to find a PNRP registered service. What else do you have to do for e.g.
      exposing a WCF service over the P2P infrastructure?
   </p>
        <p>
      Code-wise nothing. If the WCF service listens on all NICs (the default), a client
      can do a resolution via the peer DNS name and connect to it. Easy.
   </p>
        <p>
      Well - hold on - does that mean that arbitrary clients can now traverse my NAT and
      connect to my intranet machine? Kind of - yes...
   </p>
        <p>
      For the service to be accessible you also have to adjust firewall rules:
   </p>
        <ul>
          <li>
         the port the service is listening on must be openend (this will allow <em>normal</em> TCP/IP
         traffic to the endpoint) 
      </li>
          <li>
         to allow Teredo traffic to the service, additionally the "allow edge traversal" option
         must be checked. This option is only available via the advanced firewall (available
         via <em>Administrative Tools</em> or <em>MMC</em>). See screenshot:</li>
        </ul>
        <p>
          <img src="http://www.leastprivilege.com/content/binary/EdgeTraversal_Firewall.png" border="0" />
        </p>
        <p>
      So to recap - these are the prereqs for a globally reachable service:
   </p>
        <ul>
          <li>
         P2P (PNRP and Teredo) must work properly 
      </li>
          <li>
         the service must be registered 
      </li>
          <li>
         the client (or peer) must know the peer name 
      </li>
          <li>
         the endpoint port must be opened in the firewall 
      </li>
          <li>
         Teredo traffic must be allowed for this port</li>
        </ul>
        <p>
      But one thing is very true, you now allow (internet) inbound traffic to an intranet
      hosted service, which has some implications:
   </p>
        <ul>
          <li>
         there is probably no security around that intranet machine (like a DMZ). 
      </li>
          <li>
         intranet machines are typically not hardened for exposing internet services. 
      </li>
          <li>
         this means that if the service has some security problem (e.g. directory traversal
         etc), there are no safe-nets that will stop an attacker e.g. accessing other machines
         or system resources. 
      </li>
          <li>
         your administrators may not like this!</li>
        </ul>
        <p>
      Typical P2P scenarios don't necessarily involve publicly known peer names, so you
      maybe only have a limited exposure. But still - the traffic bypasses perimeter security
      and goes directly into the intranet. So be careful.
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=98a3b225-8111-4650-ba32-ae97ef0ac435" />
      </div>
    </content>
  </entry>
  <entry>
    <title>P2P and WCF: Finding a Service</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/P2PAndWCFFindingAService.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=d5154265-efff-4252-84a1-e67658abeb87</id>
    <published>2008-05-01T08:43:10.3885721+02:00</published>
    <updated>2008-05-01T08:43:10.3885721+02:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   After you have &lt;a href="http://www.leastprivilege.com/P2PAndWCFRegisteringAService.aspx"&gt;registered&lt;/a&gt; a
   service, the next step is to find it again. The &lt;em&gt;System.Net.PeerToPeer&lt;/em&gt; API
   includes a &lt;em&gt;PeerNameResolver&lt;/em&gt; class which does that.
&lt;/p&gt;
&lt;p&gt;
   You input the peer name and get back the registration details (IP addresses, port,
   comment and data):
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;static&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Resolve(&lt;span style="color: blue"&gt;string&lt;/span&gt; name)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PeerNameResolver&lt;/span&gt; resolver
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;PeerNameResolver&lt;/span&gt;();&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PeerName&lt;/span&gt; peerName
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;PeerName&lt;/span&gt;(name);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Resolving
   {0}..."&lt;/span&gt;, peerName);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PeerNameRecordCollection&lt;/span&gt; results
   = resolver.Resolve(peerName);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (results.Count
   == 0)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"No
   records found."&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt;;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt; count
   = 1;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;PeerNameRecord&lt;/span&gt; record &lt;span style="color: blue"&gt;in&lt;/span&gt; results)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Record
   #{0}\n"&lt;/span&gt;, count);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"DNS
   Name: {0}"&lt;/span&gt;, record.PeerName.PeerHostName);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Endpoints:"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;IPEndPoint&lt;/span&gt; endpoint &lt;span style="color: blue"&gt;in&lt;/span&gt; record.EndPointCollection)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"\t
   Endpoint:{0}"&lt;/span&gt;, endpoint);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;count++;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   The way you will resolve peer names more commonly is via the DNS format (the &lt;em&gt;PeerHostName&lt;/em&gt; property
   in the above code). A peer name also has DNS name representation (e.g. &lt;em&gt;foo.pnrp.net&lt;/em&gt; for
   an unsecured service named &lt;em&gt;foo&lt;/em&gt;). Whenever you use this format (e.g. with
   ping or any other application that does DNS name resolution), Windows will use the
   P2P APIs internally to return the corresponding IP address). See &lt;a href="http://blogs.msdn.com/p2p/archive/2007/06/15/pnrp-and-pnrp-net.aspx"&gt;here&lt;/a&gt; for
   the details.
&lt;/p&gt;
&lt;p&gt;
   This e.g. means that you could make a registration on a web server for port 80 and
   can use the browser to directly connect to the web server using the DNS format name.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=d5154265-efff-4252-84a1-e67658abeb87" /&gt;</content>
  </entry>
  <entry>
    <title>P2P and WCF: Registering a Service</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/P2PAndWCFRegisteringAService.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=69ceff74-e10a-4bfe-b1b4-87a76af1e738</id>
    <published>2008-05-01T07:42:58.0869436+02:00</published>
    <updated>2008-05-01T07:42:58.0869436+02:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   To make a service discoverable using the P2P infrastructure, you first have to do
   a so called peer name registration.
&lt;/p&gt;
&lt;p&gt;
   A peer name registration has the following properties:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      a name (there are two different flavours: secured and unsecured - more on that later) 
   &lt;li&gt;
      one or more IP addresses and scope 
   &lt;li&gt;
      a port number 
   &lt;li&gt;
      a comment (optional) 
   &lt;li&gt;
      up to 4KB of binary data (optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   &lt;strong&gt;Peer Name&lt;/strong&gt;
   &lt;br&gt;
   The name of the service you want to register. Names have the following format: 'authorityId.Name'.
   Unsecured Names use a '0' as the authorityId and are easy to spoof/squat. When using
   a secured name, a key/pair is generated on the fly (the first time only) to sign the
   registration request. The public key hash becomes the authorityId in this case.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;IP addresses and scope&lt;/strong&gt;
   &lt;br&gt;
   That's the most fascinating (and complicated) part. The peer name registration can
   have local and/or a global scope. A global scope means that the service can be discovered
   and contacted - well - globally. How can that work, given the service is behind a
   NAT device? IPv6 is the answer.
&lt;/p&gt;
&lt;p&gt;
   Now you may ask yourself: "but my network/router hardware is not IPv6 enabled, can
   this still work?". Yes it does - making the transition between IPv4 and IPv6 is the
   job of so called transition or tunneling protocols. Teredo is the name of the protocol
   that is typically used here. Teredo has several jobs - one is to provide a globally
   unique IPv6 address, the other is to enable NAT traversal. I won't go into the Teredo
   details here, but this &lt;a href="http://technet.microsoft.com/en-us/library/bb457011.aspx"&gt;document&lt;/a&gt; describes
   how it works.
&lt;/p&gt;
&lt;p&gt;
   When you do a &lt;em&gt;'ipconfig'&lt;/em&gt; on the command line you may already see a bunch
   of IPv6 addresses. The one that is directly associated with your NIC is the local
   address. You may also see a "Tunnel Adapter" interface - that would be the global
   Teredo provided address.
&lt;/p&gt;
&lt;p&gt;
   You can check the status/health of the Teredo protocol by using this command: &lt;em&gt;'netsh
   int teredo show state'&lt;/em&gt;. This &lt;a href="http://blogs.msdn.com/p2p/archive/2007/03/22/teredo-and-the-pnrp-global-cloud.aspx"&gt;article&lt;/a&gt; helps
   you with troubleshooting if Teredo should not be enabled on your machine.
&lt;/p&gt;
&lt;p&gt;
   You can also have a look at the scope of your registration by checking the &lt;em&gt;clouds&lt;/em&gt; to
   which your machine has access. This is done by doing a &lt;em&gt;'netsh p2p pnrp cloud show
   list'&lt;/em&gt;. You should see one or more &lt;em&gt;LinkLocal_&lt;/em&gt; clouds and a &lt;em&gt;Global_&lt;/em&gt; cloud.
&lt;/p&gt;
&lt;p&gt;
   Again this &lt;a href="http://blogs.msdn.com/p2p/archive/2007/06/12/understanding-pnrp-clouds.aspx"&gt;article&lt;/a&gt; has
   all the details on clouds and their background.
&lt;/p&gt;
&lt;p&gt;
   So to wrap it up - by default a peer name registration will use all available NICs/IP
   addresses. If you have a global IPv6 address (which means that Teredo is working properly
   and you can 'see' the global cloud) this one is used also. This in turn means that
   the service can be used by every client that also has a global address.
&lt;/p&gt;
&lt;p&gt;
   The remaining properties are self explaining I think.
&lt;/p&gt;
&lt;p&gt;
   The following code snippet would register a secured peer name in all available clouds
   (you can find the APIs in the System.Net assembly (v3.5):
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;private&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Register(&lt;span style="color: blue"&gt;string&lt;/span&gt; name, &lt;span style="color: blue"&gt;int&lt;/span&gt; port, &lt;span style="color: blue"&gt;string&lt;/span&gt; comment)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PeerName&lt;/span&gt; peerName
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;PeerName&lt;/span&gt;(name, &lt;span style="color: #2b91af"&gt;PeerNameType&lt;/span&gt;.Secured);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PeerNameRegistration&lt;/span&gt; reg
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;PeerNameRegistration&lt;/span&gt;();&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;reg.PeerName = peerName;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;reg.Port = port;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;reg.Cloud = &lt;span style="color: #2b91af"&gt;Cloud&lt;/span&gt;.Available;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;reg.Comment = _cl.Comment;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;reg.Start();&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   The next posts will deal with peer name resolution and how to host a WCF service over
   this infrastructure.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=69ceff74-e10a-4bfe-b1b4-87a76af1e738" /&gt;</content>
  </entry>
  <entry>
    <title>P2P, PNRP, Teredo...the Motivation</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/P2PPNRPTeredotheMotivation.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=2b264cfe-9822-4054-aa51-37e27524f81b</id>
    <published>2008-04-30T08:18:56.0807164+02:00</published>
    <updated>2008-04-30T08:18:56.0807164+02:00</updated>
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Since I started playing around with computers, communication of machines over a "wire"
      has been fascinating to me. This is probably why I ended up in the distributed applications
      space.
   </p>
        <p>
      Typically clients talk to servers and servers to servers - but less common clients
      directly to clients. But applications like MSN Messenger or Skype show useful use
      cases of client to client communication. With Vista and Server 2008 (and XP SP2 +
      some components) peer to peer networking has become part of the operating system.
      There is also a peer channel in WCF that sits on top of these core components. Time
      to have a closer look.
   </p>
        <p>
      So what features is the P2P infrastructure supposed to give you?
   </p>
        <ul>
          <li>
         Global/local registration of services</li>
          <li>
         Global/local connectivity between peers which includes the capability to traverse
         NAT devices</li>
          <li>
         Global/local virtual broadcasting networks</li>
          <li>
         Peer/Service Discovery</li>
          <li>
         Invitation/activation of P2P enabled applications</li>
        </ul>
        <p>
      All of these capabilities are as fascinating as they are scary. More importantly I
      really think that P2P communication patterns will be a "big" thing and will also change
      the way we have to think about network/perimeter security.
   </p>
        <p>
      In the next posts I will write about some of my findings. Stay tuned.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=2b264cfe-9822-4054-aa51-37e27524f81b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Using IdentityModel: Converting ADFS Security Properties to Claims</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsingIdentityModelConvertingADFSSecurityPropertiesToClaims.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=54620546-a29b-479f-af68-c530aabcf70f</id>
    <published>2008-04-28T07:39:21.381632+02:00</published>
    <updated>2008-04-28T08:33:33.9858152+02:00</updated>
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   This little helper might be useful when you are working with ADFS, but want to use
   the IdentityModel types in your app:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt; ToClaimSet(&lt;span style="color: blue"&gt;this&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SingleSignOnIdentity&lt;/span&gt; identity)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt;
   claims = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;&amp;gt;();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;claims.Add(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;(identity.NameType,
   identity.Name, &lt;span style="color: #2b91af"&gt;Rights&lt;/span&gt;.Identity));&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;SecurityProperty&lt;/span&gt; property &lt;span style="color: blue"&gt;in&lt;/span&gt; identity.SecurityPropertyCollection)&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; claimType
   = property.Uri;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (claimType.EndsWith(&lt;span style="color: #a31515"&gt;"NameValue"&lt;/span&gt;))&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;claimType
   = property.Name;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;claims.Add(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Claim&lt;/span&gt;(claimType,
   property.Value, &lt;span style="color: #2b91af"&gt;Rights&lt;/span&gt;.PossessProperty));&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DefaultClaimSet&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;ClaimSet&lt;/span&gt;.System,
   claims);&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=54620546-a29b-479f-af68-c530aabcf70f" /&gt;</content>
  </entry>
  <entry>
    <title>Ein Session Abstract ganz genau nach meinem Geschmack</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/EinSessionAbstractGanzGenauNachMeinemGeschmack.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=f920f63b-8f39-44ed-aac3-c994f1604a12</id>
    <published>2008-04-22T13:49:20.414+02:00</published>
    <updated>2008-04-22T13:50:43.2402056+02:00</updated>
    <category term="Microsoft Deutschland Security Portal" label="Microsoft Deutschland Security Portal" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Gesehen auf der JAX2008 Webseite:
   </p>
        <blockquote>
          <p>
            <strong>Security Last – Sicherheitsentscheidungen spät treffen</strong>
            <br />
      Sicherheitsanforderungen wie Logins und Berechtigung sind wichtig – aber müssen diese
      wirklich gleich am Anfang umgesetzt werden? Das nachträgliche Hinzufügen dieser Anforderungen
      mit reinem Java und OOP ist sehr schwierig, weshalb dies meistens mit „Ja“ beantwortet
      wird. Erfahren Sie hier, wie mithilfe von Tools wie Spring Security, AspectJ und CAS
      auch spät in Anwendungen integriert werden kann.
   </p>
        </blockquote>
        <p>
      Ohne Worte... 
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=f920f63b-8f39-44ed-aac3-c994f1604a12" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Token Kidnapping</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/TokenKidnapping.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=a00be432-76a0-4078-b890-2143af32a68f</id>
    <published>2008-04-20T09:15:28.789+02:00</published>
    <updated>2008-04-20T10:03:32.2237359+02:00</updated>
    <category term="For Your Favourites" label="For Your Favourites" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Interesting...and shocking.
   </p>
        <p>
      Read more here: 
      <br /><a href="http://www.argeniss.com/research/TokenKidnapping.pdf">http://www.argeniss.com/research/TokenKidnapping.pdf</a></p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=a00be432-76a0-4078-b890-2143af32a68f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Installing an IIS 7 Extension</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/InstallingAnIIS7Extension.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=e14c9126-4dcb-42c7-9bac-7855c2b3f81b</id>
    <published>2008-04-20T08:50:57.209+02:00</published>
    <updated>2008-04-22T07:41:27.1780428+02:00</updated>
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   Related to cleaning up my authentication module for &lt;a href="http://www.codeplex.com/CustomBasicAuth"&gt;Codeplex&lt;/a&gt;,
   I needed a way to (semi) automatically install a complete IIS extension (including
   schema, config sections and management extensions). I came up with a batch file that
   does the necessary steps (anybody out there that wants to write a real installer?).
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;1. Register all assemblies in the GAC&lt;br&gt;
   &lt;/strong&gt;Usually an IIS 7 extension consists of at least three assemblies (module/handler,
   server extensions, client extensions). Gacutil.exe is your friend here (use the /if
   option). Also take into account, that IIS loads GACed assemblies domain neutral. That
   means that you have to recycle the worker process when you update e.g. your GACed
   module.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;2. Register schema and config section&lt;/strong&gt;
   &lt;br&gt;
   This involves copying your schema to the IIS' schema directory and add a &amp;lt;configSection&amp;gt;
   registration to applicationHost.config. &lt;a href="http://mvolo.com/blogs/serverside"&gt;Mike
   Volodarsky&lt;/a&gt; from the IIS team has written a nice tool call &lt;a href="http://mvolo.com/blogs/serverside/archive/2007/08/04/IISSCHEMA.EXE-_2D00_-A-tool-to-register-IIS7-configuration-sections.aspx"&gt;IisSchema&lt;/a&gt; that
   automates this step.
&lt;/p&gt;
&lt;p&gt;
   &lt;strong&gt;3. Registering the management extension&lt;/strong&gt;
   &lt;br&gt;
   This involves adding the module to administration.config (in two different places).
   I haven't found an automated way of doing this, so I wrote a little tool to accomplish
   this task.
&lt;/p&gt;
&lt;p&gt;
   IisRegMgmt [install/uninstall] [assembly_to_register]
&lt;/p&gt;
&lt;p&gt;
   This will find all &lt;em&gt;Microsoft.Web.Management.Server.ConfigurationModuleProvider&lt;/em&gt; derived
   classes in the specified assembly and register them in administration.config.
&lt;/p&gt;
&lt;p&gt;
   The code to do the registration is as follows:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;private&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RegisterAdministration(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; name, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; type, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; assembly)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   get access to administration.config&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;Configuration&lt;/span&gt; administration
   = _manager.GetAdministrationConfiguration();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   get access to &amp;lt;moduleProviders&amp;gt;&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ConfigurationSection&lt;/span&gt; moduleProvidersSection
   = 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;administration.GetSection(&lt;span style="COLOR: #a31515"&gt;"moduleProviders"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ConfigurationElementCollection&lt;/span&gt; moduleProviders
   =&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;moduleProvidersSection.GetCollection();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   check for existing elements first&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Clean(name, moduleProviders);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   create new element&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ConfigurationElement&lt;/span&gt; newModuleProvider
   =&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;moduleProviders.CreateElement();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   set attributes&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;newModuleProvider.SetAttributeValue(&lt;span style="COLOR: #a31515"&gt;"name"&lt;/span&gt;,
   name);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;newModuleProvider.SetAttributeValue(&lt;span style="COLOR: #a31515"&gt;"type"&lt;/span&gt;,
   type + &lt;span style="COLOR: #a31515"&gt;", "&lt;/span&gt; + assembly);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   add element&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;moduleProviders.Add(newModuleProvider);&lt;br&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   get access to &amp;lt;modules&amp;gt;&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ConfigurationSection&lt;/span&gt; modulesSection
   = 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;administration.GetSection(&lt;span style="COLOR: #a31515"&gt;"modules"&lt;/span&gt;);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ConfigurationElementCollection&lt;/span&gt; modules
   = modulesSection.GetCollection();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   check for existing element first&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Clean(name, modules);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   create new element&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;ConfigurationElement&lt;/span&gt; newModule
   = modules.CreateElement();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   set attributes&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;newModule.SetAttributeValue(&lt;span style="COLOR: #a31515"&gt;"name"&lt;/span&gt;,
   name);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   add element&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;modules.Add(newModule);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//
   save changes&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;_manager.CommitChanges();&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   Don't forget to clean up the sections before you add the new module, otherwise you
   might end up with double entries:
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;private&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Clean(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; name, &lt;span style="COLOR: #2b91af"&gt;ConfigurationElementCollection&lt;/span&gt; elements)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; hits
   = &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; e &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; elements&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;where&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;)e.GetAttributeValue(&lt;span style="COLOR: #a31515"&gt;"name"&lt;/span&gt;)
   == name&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;select&lt;/span&gt; e;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hits.ToList().ForEach(e
   =&amp;gt; elements.Remove(e));&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   For completeness sake, here's how you can find the right management classes in the
   assembly (and because I was amused about 'Linq to Reflection' ;)
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="COLOR: blue; FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;private&lt;/span&gt;&lt;span style="FONT-FAMILY: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&amp;gt;
   GetManagementTypes(&lt;span style="COLOR: #2b91af"&gt;Assembly&lt;/span&gt; a)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; baseType
   = &lt;span style="COLOR: #a31515"&gt;"Microsoft.Web.Management.Server.ConfigurationModuleProvider"&lt;/span&gt;;&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; types
   = &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; t &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; a.GetExportedTypes()&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;where&lt;/span&gt; t.BaseType.FullName
   == baseType&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;select&lt;/span&gt; t.FullName;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; types;&lt;br&gt;
   }&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   &lt;a href="http://www.leastprivilege.com/content/binary/IisRegMgmt01.zip"&gt;IisRegMgmt01.zip
   (18.66 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=e14c9126-4dcb-42c7-9bac-7855c2b3f81b" /&gt;</content>
  </entry>
  <entry>
    <title>Custom Basic Authentication is now on Codeplex</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/CustomBasicAuthenticationIsNowOnCodeplex.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=f9453fb0-6e2a-4faf-8cf9-62162dc7531e</id>
    <published>2008-04-19T09:44:05.453+02:00</published>
    <updated>2008-04-19T15:19:13.3821266+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I also moved my "Basic Authentication against non-Windows accounts for IIS" (phew)
      project to Codeplex
   </p>
        <p>
          <a href="http://www.codeplex.com/CustomBasicAuth">http://www.codeplex.com/CustomBasicAuth</a>
        </p>
        <p>
      Again, if you have feature ideas or want to contribute, contact me.
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=f9453fb0-6e2a-4faf-8cf9-62162dc7531e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>InfoCardSelector is now on Codeplex</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/InfoCardSelectorIsNowOnCodeplex.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=735b42bd-85e2-4345-9acc-7e0a14899f5d</id>
    <published>2008-04-16T18:02:36.155617+02:00</published>
    <updated>2008-04-16T18:02:36.155617+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="CardSpace" label="CardSpace" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I finally found a new home for my ASP.NET InfoCard control:
   </p>
        <p>
          <a href="http://www.codeplex.com/InfoCardSelector">http://www.codeplex.com/InfoCardSelector</a>
        </p>
        <p>
      If you feel like contributing or suggesting new features, you can contact me via this
      page.
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=735b42bd-85e2-4345-9acc-7e0a14899f5d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Developing ASP.NET Applications in Medium Trust</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/DevelopingASPNETApplicationsInMediumTrust.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=170f8682-d133-4e8c-982b-d3d45db15cbf</id>
    <published>2008-04-12T07:56:02.7015012+02:00</published>
    <updated>2008-04-12T07:56:02.7015012+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://keepitlocked.net/">Alex Smolen</a> did a good <a href="http://keepitlocked.net/archive/2008/04/11/developing-asp-net-in-partial-trust.aspx">write
      up</a> of the various approaches for sandboxing ASP.NET applications. Recommended!
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=170f8682-d133-4e8c-982b-d3d45db15cbf" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Beware of Whitespaces in WAS Configuration</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/BewareOfWhitespacesInWASConfiguration.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=7a332526-ab1c-4697-9eba-9dd8ecb40e88</id>
    <published>2008-04-03T10:04:24.5512034+02:00</published>
    <updated>2008-04-03T10:04:24.5512034+02:00</updated>
    <category term="IIS" label="IIS" scheme="dasBlog" />
    <category term="WCF" label="WCF" scheme="dasBlog" />
    <category term="Work in Progress" label="Work in Progress" scheme="dasBlog" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
      This took me a while to solve...
   </p>
        <p>
      In the WAS configuration dialog there must be NO whitespaces in the enabled protocols
      configuration. Otherwise you will get this error:
   </p>
        <p>
      "Could not find a base address that matches scheme net.tcp for the endpoint with binding
      NetTcpBinding."
   </p>
        <p>
       
   </p>
        <p>
          <img src="http://www.leastprivilege.com/content/binary/WasSettings.jpg" border="0" />
        </p>
        <p>
      HTH
   </p>
        <p>
       
   </p>
        <img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=7a332526-ab1c-4697-9eba-9dd8ecb40e88" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Using Information Cards in ASMX Web Services</title>
    <link rel="alternate" type="text/html" href="http://www.leastprivilege.com/UsingInformationCardsInASMXWebServices.aspx" />
    <id>http://www.leastprivilege.com/PermaLink.aspx?guid=46671e74-ded6-4432-be78-cd0b394e4346</id>
    <published>2008-03-30T10:49:07.0081464+02:00</published>
    <updated>2008-03-30T10:50:43.3050214+02:00</updated>
    <category term="ASP.NET" label="ASP.NET" scheme="dasBlog" />
    <category term="CardSpace" label="CardSpace" scheme="dasBlog" />
    <category term="IdentityModel" label="IdentityModel" scheme="dasBlog" />
    <content type="html">&lt;p&gt;
   As I wrote &lt;a href="http://www.leastprivilege.com/GettingCardSpaceTokensProgrammatically.aspx"&gt;here&lt;/a&gt; -
   an Information Card token is just a string. This means that (with the help of some
   extra plumbing) you can seamlessly integrate cards into "legacy" technologies. Here's
   a sample walkthrough for ASMX web services.
&lt;/p&gt;
&lt;p&gt;
   To transmit the token to the service, I will use a SOAP header. So the first step
   is to define the header:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;XmlRoot&lt;/span&gt;(ElementName
   = &lt;span style="color: #a31515"&gt;"InformationCard"&lt;/span&gt;,&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Namespace = &lt;span style="color: #a31515"&gt;"http://schemas.xmlsoap.org/ws/2005/05/identity"&lt;/span&gt;)]&lt;br&gt;
   &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;InfoCardTokenHeader&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;SoapHeader&lt;/span&gt;
   &lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; Token;&lt;br&gt;&lt;?xml:namespace prefix = o /&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   For metadata support, we can now annotate a web method with this header information:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;[&lt;span style="color: #2b91af"&gt;WebService&lt;/span&gt;(Namespace
   = &lt;span style="color: #a31515"&gt;"urn:leastprivilege"&lt;/span&gt;)]&lt;br&gt;
   [&lt;span style="color: #2b91af"&gt;WebServiceBinding&lt;/span&gt;(ConformsTo = &lt;span style="color: #2b91af"&gt;WsiProfiles&lt;/span&gt;.BasicProfile1_1)]&lt;br&gt;
   &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;AsmxService&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;WebService&lt;/span&gt;
   &lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af"&gt;InfoCardTokenHeader&lt;/span&gt; InfoCardToken;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="color: #2b91af"&gt;WebMethod&lt;/span&gt;]&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="color: #2b91af"&gt;SoapHeader&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"InfoCardToken"&lt;/span&gt;,
   Direction = &lt;span style="color: #2b91af"&gt;SoapHeaderDirection&lt;/span&gt;.In)]&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; Ping()&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;…&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   The client can now use the &lt;em&gt;CardSpaceSelector &lt;/em&gt;API (or my &lt;a href="http://www.leastprivilege.com/IdentityModel"&gt;wrapper&lt;/a&gt;)
   to get a token manually. Afterwards the token gets transmitted using the header:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;static&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Main(&lt;span style="color: blue"&gt;string&lt;/span&gt;[]
   args)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AsmxService&lt;/span&gt; proxy
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;AsmxService&lt;/span&gt;();&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;InfoCardTokenHeader&lt;/span&gt; token
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;InfoCardTokenHeader&lt;/span&gt;();&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;token.Token = GetInfoCardToken(proxy.Url);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;proxy.InformationCard =
   token;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(proxy.Ping());&lt;br&gt;
   }&lt;br&gt;
   &lt;br&gt;
   &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; GetInfoCardToken(&lt;span style="color: blue"&gt;string&lt;/span&gt; targetUri)&lt;br&gt;
   {&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IdentitySelector&lt;/span&gt; selector
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IdentitySelector&lt;/span&gt;();&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;selector.TargetUri = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;(targetUri);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;selector.SetTargetCertificate(targetUri);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;selector.RequiredClaims.Add(&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.GivenName);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;selector.RequiredClaims.Add(&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Surname);&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;selector.RequiredClaims.Add(&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.Email);&lt;br&gt;
   &lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;GenericXmlSecurityToken&lt;/span&gt; token
   = selector.GetToken();&lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; token.TokenXml.OuterXml;&lt;br&gt;
   }&lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   On the server side you could now retrieve the token from the header and use your favourite
   token decryption class to extract the claims. If you want to put in a little bit more
   work, you can improve the integration of that information using a &lt;em&gt;SoapExtension&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
   The extension will check the incoming headers, extract the token and set &lt;em&gt;Thread.CurrentPrincipal&lt;/em&gt; and &lt;em&gt;Context.User&lt;/em&gt; to
   an instance of &lt;a href="http://www.leastprivilege.com/IdentityModel"&gt;IdentityPrincipal&lt;/a&gt; that
   wraps the token generated authorization context. A corresponding extension attribute
   connects this logic with the web method:
&lt;/p&gt;
&lt;span style="font-size: 11pt; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa"&gt;[&lt;span style="color: #2b91af"&gt;WebMethod&lt;/span&gt;]&lt;br&gt;
[&lt;span style="color: #2b91af"&gt;InfoCardSoapExtension&lt;/span&gt;(TokenRequired = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;br&gt;
[&lt;span style="color: #2b91af"&gt;SoapHeader&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"InfoCardToken"&lt;/span&gt;,
Direction = &lt;span style="color: #2b91af"&gt;SoapHeaderDirection&lt;/span&gt;.In)]&lt;br&gt;
&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; Ping()&lt;br&gt;
{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IdentityPrincipal&lt;/span&gt;.Current.ClaimSets.FindClaim(&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClaimTypes&lt;/span&gt;.GivenName).Get&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt;();&lt;br&gt;
}&lt;/span&gt; 
&lt;p&gt;
   This gives the web service method seamless access to incoming claims.
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   The code for the SOAP extension is quite simple (the configuration code is omitted):
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="color: blue; font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;public&lt;/span&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;InfoCardSoapExtension&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;SoapExtension&lt;br&gt;
   &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; ProcessMessage(&lt;span style="color: #2b91af"&gt;SoapMessage&lt;/span&gt; message)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (message.Stage
   == &lt;span style="color: #2b91af"&gt;SoapMessageStage&lt;/span&gt;.AfterDeserialize)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;SoapHeader&lt;/span&gt; header &lt;span style="color: blue"&gt;in&lt;/span&gt; message.Headers)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;InfoCardTokenHeader&lt;/span&gt; tokenHeader
   = 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;header &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;InfoCardTokenHeader&lt;/span&gt;;&lt;span style="color: #2b91af"&gt;
   &lt;br style="mso-special-character: line-break"&gt;
   &lt;br style="mso-special-character: line-break"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (tokenHeader
   != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: #2b91af"&gt;
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IdentityPrincipal&lt;/span&gt; principal;&lt;span style="color: #2b91af"&gt;
   &lt;br style="mso-special-character: line-break"&gt;
   &lt;br style="mso-special-character: line-break"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;
   &lt;span style="font-family: consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;try&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt; token
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Token&lt;/span&gt;(tokenHeader.Token, &lt;span style="color: blue"&gt;true&lt;/span&gt;);&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;principal
   = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IdentityPrincipal&lt;/span&gt;(token.AuthorizationContext);&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;catch&lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;HttpException&lt;/span&gt;(500, &lt;span style="color: #a31515"&gt;"Token
   validation failed"&lt;/span&gt;); 
   &lt;br&gt;
   &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HttpContext&lt;/span&gt;.Current.User
   = &lt;span style="color: #2b91af"&gt;Thread&lt;/span&gt;.CurrentPrincipal = principal;&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;return&lt;/span&gt;;&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (_tokenRequired)&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;HttpException&lt;/span&gt;(401, &lt;span style="color: #a31515"&gt;"Authentication
   required"&lt;/span&gt;);&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;br&gt;
   &lt;/span&gt;}&lt;span style="color: blue"&gt;
   &lt;o:p&gt;&lt;/o:p&gt;
   &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   Disclaimer: I know that this code could be written far more generic. Consider this
   as a proof of concept.
&lt;/p&gt;
&lt;p&gt;
   &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   The &lt;a href="http://www.leastprivilege.com/IdentityModel"&gt;LeastPrivilege.IdentityModel&lt;/a&gt; download
   contains the complete sample. Have fun.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leastprivilege.com/aggbug.ashx?id=46671e74-ded6-4432-be78-cd0b394e4346" /&gt;</content>
  </entry>
</feed>