<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Govind's WebLog : SAML</title><link>http://blogs.msdn.com/govindr/archive/tags/SAML/default.aspx</link><description>Tags: SAML</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Updated Re-Serialize SAML token</title><link>http://blogs.msdn.com/govindr/archive/2007/05/03/updated-re-serialize-saml-token.aspx</link><pubDate>Thu, 03 May 2007 20:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2397574</guid><dc:creator>govindr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/govindr/comments/2397574.aspx</comments><wfw:commentRss>http://blogs.msdn.com/govindr/commentrss.aspx?PostID=2397574</wfw:commentRss><description>There has been a lot of interest around this and hence I have attached some code listing to this post. &lt;A class="" href="http://blogs.msdn.com/govindr/archive/2006/10/24/re-serialize-saml-token.aspx" target=_blank mce_href="http://blogs.msdn.com/govindr/archive/2006/10/24/re-serialize-saml-token.aspx"&gt;Check it out!&lt;/A&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2397574" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/govindr/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/govindr/archive/tags/SAML/default.aspx">SAML</category></item><item><title>Federation and Bearer Tokens</title><link>http://blogs.msdn.com/govindr/archive/2006/11/22/federation-and-bearer-tokens.aspx</link><pubDate>Wed, 22 Nov 2006 14:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1121881</guid><dc:creator>govindr</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/govindr/comments/1121881.aspx</comments><wfw:commentRss>http://blogs.msdn.com/govindr/commentrss.aspx?PostID=1121881</wfw:commentRss><description>&lt;P&gt;The latest &lt;A class="" href="http://docs.oasis-open.org/ws-sx/ws-trust/200512/ws-trust-1.3-spec-cd-01.pdf" target=_blank mce_href="http://docs.oasis-open.org/ws-sx/ws-trust/200512/ws-trust-1.3-spec-cd-01.pdf"&gt;WS-Trust spec&lt;/A&gt; (yet to be ratified by OASIS) introduces a concept called Bearer Tokens. This basically is a keyless token that a client requests from an STS (Security Token Service). The only purpose this token serves is to provide more information about the client to the service while the client already has a way to secure its conversation with the service. (Read my other post on &lt;a href="http://blogs.msdn.com/govindr/archive/2006/10/18/federation.aspx"&gt;Federation&lt;/a&gt; for more details on how client uses that key obtained from a STS token.) &lt;/P&gt;
&lt;P&gt;This introduces some qurikiness. The obtained issued token can now be added only as a supporting token. In case of transport secured messages this can just be a signed supporting tokens.&amp;nbsp;In messages level security scenarios, this token should be added as a signed encrypted supporting token.&amp;nbsp;Note, the client doesn't have a key so there is no need for the client to prove to the service that it did obtain the token for the STS and it does know some secret information of the token. So just adding the token as signed token in message level security will expose the token for a third party, who can just snoop the token and replay it to the service as if it is the client.&lt;/P&gt;
&lt;P&gt;Bearer tokens issued by a STS should be some how verifiale by the service. For this purpose the Bearer token should be signed by the STS. A SAML 1.1, SAML 2.0 or a custom token fits well for this purpose. WCF will require a wsu:Id to be on the issued token to be able to sign it (In message level security case). A SAML 1.1 does not have a wsu:Id on it and its attribute list is&amp;nbsp;not extendable&amp;nbsp;by the schema and hence it is not possible to use SAML 1.1 as bearer tokens in WCF with message level security. The only choices are SAML 2.0 or a custom token that contains a wsu:Id on it.&lt;/P&gt;
&lt;P&gt;The cool feature of Bearer tokens in my opinion is that it enables the client to get multiple such tokens from different STS and present all of it to the service. The service might need information from multiple sources to allow or deny permissions for a client and instead of doing multiple round trips the client can present all information to the service at once.&lt;/P&gt;
&lt;P&gt;WCF v1 does not support this token type and we might be adding support for this in the future. The idea behind this post is to explain the issues involved in using such tokens and how it plays with message level and transport level security. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1121881" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/govindr/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Message+Security/default.aspx">Message Security</category><category domain="http://blogs.msdn.com/govindr/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/govindr/archive/tags/transport+security/default.aspx">transport security</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Security+Tokens/default.aspx">Security Tokens</category><category domain="http://blogs.msdn.com/govindr/archive/tags/SAML/default.aspx">SAML</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Federation/default.aspx">Federation</category><category domain="http://blogs.msdn.com/govindr/archive/tags/webservices/default.aspx">webservices</category></item><item><title>Re-Serialize SAML token</title><link>http://blogs.msdn.com/govindr/archive/2006/10/24/re-serialize-saml-token.aspx</link><pubDate>Wed, 25 Oct 2006 03:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:870770</guid><dc:creator>govindr</dc:creator><slash:comments>19</slash:comments><comments>http://blogs.msdn.com/govindr/comments/870770.aspx</comments><wfw:commentRss>http://blogs.msdn.com/govindr/commentrss.aspx?PostID=870770</wfw:commentRss><description>&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a &lt;a href="http://blogs.msdn.com/govindr/archive/2006/10/18/federation.aspx"&gt;Federation&lt;/a&gt; Scenario a client might want to access the services by using a SAML token that was issued to it by a STS. The service in turn might have to call other services (like a intermediary) to fulfill the request. When calling the backend service the service might want to use the SAML token that was presented to it by the client. This is a very common enterprise scenario. WCF currently does not&amp;nbsp;enable this scenario. You can get around this by writing some custom code on the service side. Basically you need to write a custom SAML assertion that will remember the stream and will write it out when it has to. This also involves registering your own serializer and so on. Below is some code samples,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Write a Custom SAML Assertion&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=590&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class CustomSamlAssertion : SamlAssertion &lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MemoryStream ms;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ms = new MemoryStream(Encoding.UTF8.GetBytes(reader.ReadOuterXml()));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ms.Position = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlDictionaryReader dicReader = XmlDictionaryReader.CreateTextReader(ms, XmlDictionaryReaderQuotas.Max);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;base.ReadXml(dicReader, samlSerializer, keyInfoSerializer, outOfBandTokenResolver);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override void WriteXml(XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ms != null)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/P&gt;
&lt;P&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; ms.Position = 0;&lt;/P&gt;
&lt;P&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;XmlDocument dom = new XmlDocument();&lt;/P&gt;
&lt;P&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;dom.Load(ms);&lt;/P&gt;
&lt;P&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; dom.DocumentElement.WriteTo(writer);&lt;/P&gt;
&lt;P&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;return;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.WriteXml(writer, samlSerializer, keyInfoSerializer);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above assertion just stores the incoming SAML Assertion in a memory stream and writes out the stream when you try to re-send the assertion. Note, if you want to create a new SAML assertion you will have to new up the built in SAML Assertion. The way signature processing is handled on the send side will prevent from writing out the signature if the CustomSamlAssertion is new'ed up to build a new assertion. The next step would be to provide a custom SAML serializer,&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Write a Custom SAML Serializer&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=590&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class CustomSamlSerializer : SamlSerializer&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override SamlAssertion LoadAssertion(XmlDictionaryReader reader, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustomSamlAssertion assertion = new CustomSamlAssertion();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assertion.ReadXml(reader, this, keyInfoSerializer, outOfBandTokenResolver);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return assertion;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now we need to plug the Custom Serializer with the way Token Serialization is handled in WCF. So we need to write a &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Write a Custom Token Serializer&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=590&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class CustomTokenSerializer : WSSecurityTokenSerializer&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;protected override void WriteTokenCore(XmlWriter writer, SecurityToken token)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (token is SamlSecurityToken)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&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; SamlAssertion assertion = ((SamlSecurityToken)token).Assertion;&lt;/P&gt;
&lt;P&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;if (assertion is CustomSamlAssertion)&lt;/P&gt;
&lt;P&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; {&lt;/P&gt;
&lt;P&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; XmlDictionaryWriter dicWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer);&lt;/P&gt;
&lt;P&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; ((CustomSamlAssertion)assertion).WriteXml(dicWriter, new SamlSerializer(), WSSecurityTokenSerializer.DefaultInstance);&lt;/P&gt;
&lt;P&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; return;&lt;/P&gt;
&lt;P&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; }&lt;/P&gt;
&lt;P&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;/P&gt;
&lt;P&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; base.WriteTokenCore(writer, token);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above code delegates all token serialization to the base class except for SAML. &lt;/P&gt;
&lt;P&gt;Next, we need to provide a TokenManager that gives out our Custom Serializer instead of the default serializer.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Write a Custom Token Manager&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=590&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class CustomTokenManager : ClientCredentialsSecurityTokenManager&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public CustomTokenManager(CustomClientCredentials clientCredentials)&lt;/P&gt;
&lt;P&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; : base(clientCredentials)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/P&gt;
&lt;P&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; this.tokenProvider = new SamlTokenProvider(token as SamlSecurityToken);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public override SecurityTokenSerializer CreateSecurityTokenSerializer(SecurityTokenVersion version)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&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; return new CustomTokenSerializer();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All Credentials related stuff should end up in ClientCredentials or ServiceCredentials in object in WCF. So let's implement a Custom Client Credentials that wraps the Token Manager.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Write Custom Client Credentials&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=590&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class CustomClientCredentials : ClientCredentials&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityToken securityToken;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override SecurityTokenManager CreateSecurityTokenManager()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new CustomTokenManager(this);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected override ClientCredentials CloneCore()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;When you are receiving the SAML token (you are the service) all that you need is the custom SAML Serializer. Below is how you would configure this,&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=590&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService));&lt;/P&gt;
&lt;P&gt;serviceHost.Credentials.IssuedTokenAuthentication.SamlSerializer = new CustomSamlSerializer();&lt;/P&gt;
&lt;P&gt;serviceHost.Open();&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now any SAML token received via this serviceHost will be loaded into the Custom SAML Assertion we have created.&lt;/P&gt;
&lt;P&gt;When you want to re-serialize the SAML token, you have to register your Custom Client Credentials with the Channel Factory (Note: you will be acting as a client in this case). Below is how you would configure this,&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=590&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EndpointAddress er = new EndpointAddress(new Uri(backEndServiceUri), EndpointIdentity.CreateDnsIdentity("Server-Cert"));&lt;/P&gt;
&lt;P&gt;ChannelFactory&amp;lt;ICalculator&amp;gt; factory = new ChannelFactory&amp;lt;ICalculator&amp;gt;(GetCustomBinding(), er);&lt;/P&gt;
&lt;P&gt;CustomClientCredentials clientCredentials = new CustomClientCredentials();&lt;/P&gt;
&lt;P&gt;factory.Endpoint.Behaviors.Remove&amp;lt;ClientCredentials&amp;gt;();&lt;/P&gt;
&lt;P&gt;factory.Endpoint.Behaviors.Add(clientCredentials);&lt;/P&gt;
&lt;P&gt;ICalculator client = factory.CreateChannel();&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;That's it, you can now receive SAML tokens and re-serialize the token to a backend service.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The attached project has code for this scenario.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=870770" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/govindr/attachment/870770.ashx" length="44572" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/govindr/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Message+Security/default.aspx">Message Security</category><category domain="http://blogs.msdn.com/govindr/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/govindr/archive/tags/SAML/default.aspx">SAML</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Federation/default.aspx">Federation</category><category domain="http://blogs.msdn.com/govindr/archive/tags/dotnet/default.aspx">dotnet</category><category domain="http://blogs.msdn.com/govindr/archive/tags/webservices/default.aspx">webservices</category></item><item><title>Federation </title><link>http://blogs.msdn.com/govindr/archive/2006/10/18/federation.aspx</link><pubDate>Thu, 19 Oct 2006 01:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:841104</guid><dc:creator>govindr</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/govindr/comments/841104.aspx</comments><wfw:commentRss>http://blogs.msdn.com/govindr/commentrss.aspx?PostID=841104</wfw:commentRss><description>&lt;P&gt;As you are moving to Web Services world one of the buzz words that you will hear time and again is "Federation". This is simply a security scenario that involves 3 parties to secure a Message. The 3 parties in the scenario are,&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Client&lt;/LI&gt;
&lt;LI&gt;Security Token Service (STS)&lt;/LI&gt;
&lt;LI&gt;Target Service&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;This is very similar to Kerberos authentication. In a typical Federation Scenario, a client that wants to talk to a Target Service will first go to the STS and present its credentials and will ask the STS to issue it a token with which it can talk to the Service. The STS then issues a token to the Client which the client presents to the Service to gain access to the Service's functionality. &lt;/P&gt;
&lt;P&gt;What the Client has effectively done here is to transfer its one set of credentials to another that the Target Service will understand.&lt;/P&gt;
&lt;P&gt;One simple scenario is Microsoft Passport. Once you login to passport with your username/password then you can access other sites which accepts the passport credentials. All the other sites now don't have to know your username and password to authenticate you. They know you have a Passport ticket and that is good enough for them. &lt;/P&gt;
&lt;P&gt;So, is Federation all about Single Sign On (SSO)? Not really. SSO is just one feature of Federation. Let's consider&amp;nbsp;another scenario. Company A and Company B might come to agreement that all of Company A's employees can access certain resources inside Company B. Now, let's say both Company A and B has an Active Directory (AD)&amp;nbsp;which contains credentials for all their own employees. Now to allow access to Company A's employees, Company B can create accounts for all of Company A's employees in its AD.&amp;nbsp;As you would realize this is not a viable/scalable solution. Instead, Company B can ask Company A to setup a STS on its end that will authenticate its employees based on their credentials in AD and issue a new token that the Service at Company B will understand and also contains the permission set associated with that employee. Now there is a implicit understanding between Company A's STS and Company B's Serivce on how this token should look like and how to verify the authenticity of this token and so on. SAML (Security Assertion Markup Language) is a great option for the token that gets passed between the STS and the Service. &lt;/P&gt;
&lt;P&gt;WCF has good support for Federation and SAML 1.1. The latest specification of SAML is SAML 2.0 which WCF does not support out of the box. You can create SAML 2.0 as a custom token using the extensibility points available in WCF. I will post more information about Federation and SAML later.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=841104" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/govindr/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Message+Security/default.aspx">Message Security</category><category domain="http://blogs.msdn.com/govindr/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Security+Tokens/default.aspx">Security Tokens</category><category domain="http://blogs.msdn.com/govindr/archive/tags/SAML/default.aspx">SAML</category><category domain="http://blogs.msdn.com/govindr/archive/tags/Federation/default.aspx">Federation</category><category domain="http://blogs.msdn.com/govindr/archive/tags/dotnet/default.aspx">dotnet</category><category domain="http://blogs.msdn.com/govindr/archive/tags/webservices/default.aspx">webservices</category></item></channel></rss>