<?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>Chris Keyser's WebLog</title><link>http://blogs.msdn.com/chriskeyser/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Input on customization scenarios for the next release of SharePoint guidance</title><link>http://blogs.msdn.com/chriskeyser/archive/2009/09/18/input-on-customization-scenarios-for-the-next-release-of-sharepoint-guidance.aspx</link><pubDate>Fri, 18 Sep 2009 17:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9896798</guid><dc:creator>chriskeyser</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/9896798.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=9896798</wfw:commentRss><description>&lt;P&gt;We are rolling right into scoping the next release of patterns and practices SharePoint guidance for SharePoint 2010.&amp;nbsp; Now this is a little different than how pattners and practices typically works since we working in advance of a product release.&amp;nbsp; There will be many great features coming in 2010 that you'll hear about over the coming months, but the reality is that many of the fundamental business problems and required customizations remain the same.&amp;nbsp; We are looking for input on what customization scenarios are most important to our customers as we plan for this release.&amp;nbsp; Please give us feedback on new areas you'd like to see covered, or areas you'd like to see extended from our current release, &lt;A title="Developing SharePoint Applications" href="http://www.microsoft.com/spg" mce_href="http://www.microsoft.com/spg"&gt;Developing SharePoint Applications&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;To provide your customization scenario feedback please go to our &lt;A title=CodePlex href="http://www.codeplex.com/spg" mce_href="http://www.codeplex.com/spg"&gt;codeplex site&lt;/A&gt; where I have added a &lt;A title="discussion forum" href="http://spg.codeplex.com/Thread/View.aspx?ThreadId=69385" mce_href="http://spg.codeplex.com/Thread/View.aspx?ThreadId=69385"&gt;discussion forum&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9896798" width="1" height="1"&gt;</description></item><item><title>Released Developing SharePoint Applications!</title><link>http://blogs.msdn.com/chriskeyser/archive/2009/09/04/released-developing-sharepoint-applications.aspx</link><pubDate>Fri, 04 Sep 2009 22:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9891584</guid><dc:creator>chriskeyser</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/9891584.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=9891584</wfw:commentRss><description>&lt;P&gt;We've just released &lt;A href="http://www.microsoft.com/spg" mce_href="http://www.microsoft.com/spg"&gt;Developing SharePoint Applications&lt;/A&gt;!&amp;nbsp; Thanks to all of our advisors and a dedicated team for helping put together a packed release.&amp;nbsp; The release contains some reusable bits, a new Partner Portal reference implementation, and a bunch of written content.&amp;nbsp; While the referennce implementation represents a pretty complicated application that demonstrates advanced principles, we worked hard to make the content accessible incrementally, and to make sure you can get something out of the guidance without having to understand the reference implementation in depth.&amp;nbsp; We also packed in a few reusable tidbits like a simple logging framework, a service locator, some classes to help you with buidling list based repositories, a configuration manager, and a small but helpful nugget for registering AJAX scripts in your web part without worrying about conflicting with other parts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Please send on your feedback!&amp;nbsp;&amp;nbsp; We are also collecting scenarios for our next release, so I'd love to hear about any new areas you'd like to have us explore that are challenging as a developer.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9891584" width="1" height="1"&gt;</description></item><item><title>Terminology and SharePoint ALM</title><link>http://blogs.msdn.com/chriskeyser/archive/2009/03/09/terminology-and-sharepoint-alm.aspx</link><pubDate>Mon, 09 Mar 2009 17:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9467797</guid><dc:creator>chriskeyser</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/9467797.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=9467797</wfw:commentRss><description>&lt;P&gt;Thanks for the feedback on my last &lt;A class="" title=post href="http://blogs.msdn.com/chriskeyser/archive/2009/03/06/sharepoint-and-alm-application-types-classification.aspx" mce_href="http://blogs.msdn.com/chriskeyser/archive/2009/03/06/sharepoint-and-alm-application-types-classification.aspx"&gt;post&lt;/A&gt;.&amp;nbsp; I figured I'd write another post since this is an area we've thought about a lot.&amp;nbsp; Sorry for the delayed response,&amp;nbsp;I was out watching my nephews wrestle in their final championships all weekend....both did great.&amp;nbsp; One placed in New Jersey high school states (Robert Pletcher, he took 8th at 215 lbs) and one in college eastern regionals, EIWA (Matthew Pletcher, he took fourth at 165 lbs).&lt;/P&gt;
&lt;P&gt;In terms of the use of assembling an application, I thought of both assembling and composing .&amp;nbsp; Composing has a number of other meanings, so I chose assembling.&amp;nbsp; I'm open to better suggestions, given the context, I thought it was clearly talking at a higher level than .NET assemblies but I'm open to other suggestions.&amp;nbsp; We are frequently struggling with appropriate and precise language that doesn't conflict with other terms it seems&amp;nbsp;with&amp;nbsp;our SharePoint guidance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe it makes sense to keep the activity I am calling assembly (constructing the application in the browser and&amp;nbsp;with SharePoint Designer)&amp;nbsp;as&amp;nbsp;separate activity from developing code.&amp;nbsp; At the end of the day both activities lead to a delivered business application, but how those applications are packaged, deployed, managed, maintained, as well as the&amp;nbsp;scope of impact, depends upon whether the applications are developed using a coding methodology and delivered to production via a wsp, vs. put together in pieces&amp;nbsp;that are retained in the content database.&amp;nbsp; I am shying away from calling both activities development, since I think to many development implies writing code.&amp;nbsp; I do think both activities are about building business applications.&amp;nbsp; I'd like to hear other thoughts&amp;nbsp;on this area.&lt;/P&gt;
&lt;P&gt;We've strugged with the word application, and I differentiate here between something that is intended to be a complete solution (an application) from something that is intended to be incorporated (assembled) as a capability within an application.&amp;nbsp; I use application and&amp;nbsp;components to try and draw that out.&amp;nbsp; By an application I mean that the entire project will be treated as a single monolithic conceptual grouping.&amp;nbsp;&amp;nbsp;A component is intended to be used in application development or assembled into an application.&amp;nbsp; Honestly, my preferred term would be solution, but that then gets confused with a SharePoint Solution (wsp).&amp;nbsp; We have been careful in guidance to not overload the terms feature and solution.&amp;nbsp;&amp;nbsp;We could use more feedback to help refine these terms.&lt;/P&gt;
&lt;P&gt;Please keep feedback coming, we'd like to get this discussion to a point where it is easier and more concise to understand.&amp;nbsp; Also I'd like to hear more about if there are obvious holes in the scenarios listed below - what are the cases that are missing, and where do we need more granularity?&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9467797" width="1" height="1"&gt;</description></item><item><title>SharePoint and ALM – application types/classification</title><link>http://blogs.msdn.com/chriskeyser/archive/2009/03/06/sharepoint-and-alm-application-types-classification.aspx</link><pubDate>Fri, 06 Mar 2009 19:12:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9462965</guid><dc:creator>chriskeyser</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/9462965.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=9462965</wfw:commentRss><description>&lt;p&gt;I’ve been doing some work on aspects of application lifecycle management with our &lt;a href="http://www.codeplex.com/spg"&gt;version 2&lt;/a&gt; SharePoint guidance currently in development.&amp;nbsp; In &lt;a href="http://www.microsoft.com/spg"&gt;version 1&lt;/a&gt; of our published guidance, we looked at some ALM aspects with managing code developed for SharePoint, in particular we looked at team development, packaging, factoring, environment setup, and process considerations.&amp;nbsp; We also covered upgrade, which has a set of challenges in SharePoint due to the power of the framework, in particular the ability to customize the application after developed assets are deployed.&lt;/p&gt; &lt;p&gt;We’re now starting to dig deeper into this arena with different types of SharePoint applications – taking a look beyond the development and management of a packaged application into what we are calling content driven applications.&amp;nbsp; Really what we mean by this is moving into applications which are less structured from a development perspective, that mix developed assets, assembled applications, and generated content.&lt;/p&gt; &lt;p&gt;We are defining application assembly as the process of building an application by composing parts using the browser and SharePoint designer.&amp;nbsp; SharePoint has a powerful model for assembling applications, a key reason for its huge popularity with information workers.&amp;nbsp; But once we move into this arena we introduce new complexities into ALM:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;How do I manage the lifecycle now of these assembled applications?  &lt;ul&gt; &lt;li&gt;How do I deploy the applications  &lt;li&gt;How do I maintain the applications  &lt;li&gt;How do I upgrade the applications  &lt;li&gt;How do I preserve customizations&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Where do I build these sort of applications?  &lt;ul&gt; &lt;li&gt;In production?  &lt;li&gt;In authoring?  &lt;li&gt;In staging?&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;How do I test these applications  &lt;ul&gt; &lt;li&gt;When do I need to test the applications?  &lt;li&gt;Where do I test developed components vs. assembled components?  &lt;li&gt;How do I make sure that the dependences of my developed components are explicitly managed (not dependent upon authored definitions?)  &lt;li&gt;How do I manage differences in scope between developed components (farm or web application level) vs. assembled application logic (site collection/site level)?&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I came up with this table to try and get some shape around the different types of scenarios to frame the different demands from an ALM viewpoint based upon the intent of the application.&amp;nbsp; I’m looking for feedback – does this make sense, or is it hogwash?&amp;nbsp; If it makes sense, does it seem complete enough, or are there missing aspects?&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="1088" border="1"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p dir="ltr" style="margin-right: 0px"&gt;&lt;strong&gt;Title&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Unmanaged assembled application&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;Assembled using browser and SPD  &lt;li&gt;Built and maintained in production environment  &lt;li&gt;Single instance site  &lt;li&gt;Never packaged and reused&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Non-upgradable assembled application (managed)&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;Assembled using browser and SPD  &lt;li&gt;Multiple site instances  &lt;li&gt;Does not support upgrade on change – new versions only apply to new sites  &lt;li&gt;May be assembled in a staging/authoring environment, or directly in production  &lt;li&gt;Packaged and reused with a site template&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Upgradable assembled application (managed)&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;Assembled using browser and SPD  &lt;li&gt;Multiple site instances  &lt;li&gt;Supports upgrade on change – new versions can be applied to existing sites  &lt;li&gt;Assembled in a staging/authoring environment  &lt;li&gt;Packaged and reused with a site template&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Upgradeable assembled published application (managed)&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;Assembled using browser and SPD  &lt;li&gt;One or more site instances  &lt;li&gt;Typically read only functionality for end users  &lt;li&gt;Supports upgrade on change from authoring to production.  &lt;li&gt;Production changes and data not preserved.  &lt;li&gt;May be assembled in a staging/authoring environment, or directly in production  &lt;li&gt;Packaged and deployed to sites using content deployment&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Non-upgradeable developed application&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;An application that is developed and fully encapsulated in one or more WSPs.  &lt;li&gt;Supports multiple instances  &lt;li&gt;Does not upgrade deployed instances on change&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Upgradeable developed application&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;An application that is developed and fully encapsulated in one or more WSPs.  &lt;li&gt;Supports multiple instances  &lt;li&gt;Upgrades deployed instances on change&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Non-upgradable developed component&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;A component that is developed and fully encapsulated in one or more WSPs.  &lt;li&gt;A component is capability used within a constructed application  &lt;li&gt;New versions of the component will not upgrade existing instances.&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="314"&gt; &lt;p&gt;Upgradeable developed component&lt;/p&gt;&lt;/td&gt; &lt;td valign="top" width="772"&gt; &lt;ul&gt; &lt;li&gt;A component that is developed and fully encapsulated in one or more WSPs.  &lt;li&gt;A component is capability used within a constructed application  &lt;li&gt;New versions of the component will upgrade existing instances.&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9462965" width="1" height="1"&gt;</description></item><item><title>I'm back...</title><link>http://blogs.msdn.com/chriskeyser/archive/2008/12/11/i-m-back.aspx</link><pubDate>Fri, 12 Dec 2008 02:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9199126</guid><dc:creator>chriskeyser</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/9199126.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=9199126</wfw:commentRss><description>&lt;P&gt;I think I must have set a record for the longest period of blog inactivity.&amp;nbsp; Boy, could not believe its been since 2004, time sure does fly.&amp;nbsp; I've been "meaning to" get back to blogging for a few years now, but you know what they say about good intentions...&lt;/P&gt;
&lt;P&gt;I've moved over recently to patterns and practices after spending 18 months in Office as the Group Program Manager for Duet.&amp;nbsp; I made the move for personal reasons as I'm going to eventually end back up on the east coast if the real estate market decides to cooperate.&amp;nbsp; Fortunately patterns and practices doesn't mind distribute development, and we do it on a number of our projects - our dev manager, Ade Miller, even recently delivered a white paper on &lt;A class="" title="distributed agile practices in p&amp;amp;p" href="http://download.microsoft.com/download/4/4/a/44a2cebd-63fb-4379-898d-9cf24822c6cc/distributed_agile_development_at_microsoft_patterns_and_practices.pdf" mce_href="http://download.microsoft.com/download/4/4/a/44a2cebd-63fb-4379-898d-9cf24822c6cc/distributed_agile_development_at_microsoft_patterns_and_practices.pdf"&gt;distributed agile practices in p&amp;amp;p&lt;/A&gt;.&amp;nbsp;We&amp;nbsp;are doing a lot of great stuff in Duet and I learned a lot in my role - pretty awe inspiring&amp;nbsp;to see how the machinery of a huge development organization like Office works effectively.&amp;nbsp; But now that I've&amp;nbsp;moved to p&amp;amp;p, I've really enjoyed the change back to a small agile team and to start getting my hands dirty again.&amp;nbsp; I had a chance to work as an IC on the first release of SharePoint guidance, and will be the program manager for the 2nd release.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I will blog&amp;nbsp;regularly about our experiences and architecture issues as we move into the next release.&amp;nbsp; We'll be kicking off development on that release in January.&amp;nbsp; You can find the V1 release at &lt;A href="http://www.microsoft.com/spg"&gt;http://www.microsoft.com/spg&lt;/A&gt;.&amp;nbsp; We'll be focusing on three major areas: building enterprise class sharepoint applications (focusing on scale and supportability), content oriented SharePoint application (publishing, authoring, and composition), and integrating line of business data with SharePoint.&amp;nbsp; Our codeplex project is at &lt;A href="http://www.codeplex.com/spg"&gt;www.codeplex.com/spg&lt;/A&gt;, and we'll be doing bi-weekly drops for review and input once we get moving as is typical for a p&amp;amp;p project.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;Talk to you soon!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9199126" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/chriskeyser/archive/tags/patterns+and+practices/default.aspx">patterns and practices</category><category domain="http://blogs.msdn.com/chriskeyser/archive/tags/sharepoint/default.aspx">sharepoint</category></item><item><title>Source code for SCT tokens in a Farm source code</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/11/30/272678.aspx</link><pubDate>Wed, 01 Dec 2004 01:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:272678</guid><dc:creator>chriskeyser</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/272678.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=272678</wfw:commentRss><description>&lt;p&gt;I had a question on the source code for this sample.&amp;nbsp; The link is in the article tucked near the top.&amp;nbsp; Here it is too:&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;a href="http://download.microsoft.com/download/3/c/2/3c2c3aee-d3de-4b9f-94db-a1580cd51da8/Code-TokenCache.msi"&gt;http://download.microsoft.com/download/3/c/2/3c2c3aee-d3de-4b9f-94db-a1580cd51da8/Code-TokenCache.msi&lt;/a&gt;&lt;/p&gt; &lt;p&gt;This particular sample needs to be installed to the same directory as the WSE samples.&amp;nbsp; There should be an updated version soon that removes this dependency, and a readme file describes the necessary setup steps that is installed with sample.&amp;nbsp; Note that you will also need to install the sample WSE certs for this to run.&amp;nbsp; Instructions can be found in the WSE documentation (default location is: Program Files\Microsoft WSE\v2.0\Samples\CS\QuickStart)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=272678" width="1" height="1"&gt;</description></item><item><title>Article is live on MSDN</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/11/23/268778.aspx</link><pubDate>Tue, 23 Nov 2004 23:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:268778</guid><dc:creator>chriskeyser</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/268778.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=268778</wfw:commentRss><description>&lt;p&gt;I finally got an article on SCTs in a web farm live on MSDN.&amp;nbsp; The sample code needs to be installed the the same directory as the WSE samples (default C:\Program Files\Microsoft WSE\v2.0\Samples\CS\QuickStart).&amp;nbsp; There is an update that should be posted soon that removes this dependency.&amp;nbsp; You can find the article here:&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnwebsrv/html/sctinfarm.asp"&gt;http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnwebsrv/html/sctinfarm.asp&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=268778" width="1" height="1"&gt;</description></item><item><title>Code for SCT implementation in a farm</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/09/29/235825.aspx</link><pubDate>Wed, 29 Sep 2004 18:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:235825</guid><dc:creator>chriskeyser</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/235825.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=235825</wfw:commentRss><description>&lt;p&gt;Sorry I've been dark for a few weeks - I've been in the process of trying to get my blogs and sample code on SCT's in a web farm packaged up and released to MSDN.&amp;nbsp; I hope to have it out there in a couple of weeks.&amp;nbsp; I will be getting back into my blog next week on something new.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=235825" width="1" height="1"&gt;</description></item><item><title>SCT Options - Using a cookie approach with SCT's in a farm</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/09/05/225981.aspx</link><pubDate>Mon, 06 Sep 2004 06:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:225981</guid><dc:creator>chriskeyser</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/225981.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=225981</wfw:commentRss><description>&lt;p&gt;So far I've discussed using two techniques for using SCT's in a web farm, pinning and using a database as a caching mechanism.&amp;nbsp; The third and final technique I'm going to cover is using a cookie-like approach of embedding the information in the extended area of the SCT.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Advantages of this technique:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Resilent to server failure&lt;/li&gt; &lt;li&gt;Does not require any state to be maintained on the farm - operationally simple&lt;/li&gt; &lt;li&gt;Cost - lower cost when compared to database cache as it doesn't require a redundant database to be in place to maintian state.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Disadvantages&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Increased network bandwidth costs&lt;/li&gt; &lt;li&gt;Increased processing - due to processing extended data in payload (this needs to be parsed, even if it isn't decrypted/deserialized).&amp;nbsp; I did not measure the cost of doing the database retrieval vs. the cost of processing the cookie for cases where the SCT needs to be re-hydrated if its not in cache - my gut feel is that its probably close to a wash..&lt;/li&gt; &lt;li&gt;Requires key management on the server side (key used to encrypt/decrypt the serialized infomration in the cookie)&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;One of the advantages of using an SCT is that it is singificantly lighter weight than other token types because it relies upon client and server maintaining state.&amp;nbsp; The schema for the SCT can be viewed here: &lt;a href="http://schemas.xmlsoap.org/ws/2004/04/sc/"&gt;http://schemas.xmlsoap.org/ws/2004/04/sc/&lt;/a&gt;&amp;nbsp; where one can see that the contents of the SCT is simply an identifier, followed by any content.&amp;nbsp; Using a cookie technique we put the necessary information to reconstitute the token here.&amp;nbsp; This approach definitely compromises one of the advantages of an SCT over other token times since we bloat the SCT somewhat.&amp;nbsp; However we can still achieve significantly better performance, and reduce most of the processing overhead (other than managing the network traffic and parsing the additional area in the DOM) to a one time hit that is still sigificantly less costly than processing the equivalent tokens.&amp;nbsp; A big part of the cost of processing an XML token is xml signatures and encryption.&amp;nbsp; In order to perform these operations, a process of cononicalization needs to occur (&lt;a href="http://www.w3.org/TR/xml-exc-c14n/"&gt;http://www.w3.org/TR/xml-exc-c14n/&lt;/a&gt;) that is very expensive to perform.&amp;nbsp; We'll avoid this cost and be able to more compactly represent the token by using binary encryption and signing.&amp;nbsp; While I won't do it here, compression can also be used to reduce this payload.&amp;nbsp; Finally, while I've implemented a generic technique of getting the XML representation of the base token since that's the only generic approach currently available to serialize/deserialize a token, it would be much better to perform custom serialization&amp;nbsp; to a more compact representation if you always know your base token type.&lt;/p&gt; &lt;p&gt;Serialization I've described in previous blogs and that remains the same process as when serializing the token for persistence to a database.&amp;nbsp; I did re-factor my sample to move the serialization logic into its own class out of the token cache class so it was re-usable by the cookie logic.&amp;nbsp; &lt;/p&gt; &lt;p&gt;I had to make a few additional changes to existing DistributedSCTTokenManager .&amp;nbsp; First I added a mode to my&amp;nbsp; with three enumerated values - database, cookie, and none.&amp;nbsp; I then modified the PersistSecurityToken to add the cookie to the SCT if in cookie mode - this amounts to adding a single additional element to the extensibility section of the SCT, and putting the binary serialized, encrypted, and signed SCT information base64 encoded within that element.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;font size="2"&gt;&amp;nbsp;public void PersistSecurityToken(string identifier, SecurityContextToken token)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(_cacheMode == CacheMode.database)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((DistributedTokenCache)_tokenCache).PersistSecurityToken(identifier, token);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if(_cacheMode == CacheMode.cookie)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddCookieToSCT(token);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font size="2"&gt;private void AddCookieToSCT(SecurityContextToken token)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte []data = _serializer.SerializeToBytes(token);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte []encryptedData = _encryptor.SignAndEncrypt(data);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string serializedAndEncryptedData = Convert.ToBase64String(encryptedData);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;XmlDocument doc = new XmlDocument();&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlElement extendedSCT = doc.CreateElement(TokenNames.Prefix, &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; TokenNames.SCT.ExtensionElement, TokenNames.Namespace);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;extendedSCT.InnerText = serializedAndEncryptedData;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; token.AnyElements.Add(extendedSCT);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;Finally I overrode the LoadTokenFromXml method.&amp;nbsp; In this method, I first just do the base method LoadTokenFromXml, try to retrieve the SCT from the local cache, and if I fail to find it, I then decrypt, validate, and load the SCT from the cookie information, and add the SCT to the local cache.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;public override SecurityToken LoadTokenFromXml(System.Xml.XmlElement element)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityContextToken sct = base.LoadTokenFromXml(element) as SecurityContextToken;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityContextToken tokenToReturn = TokenCache[sct.Identifier] as SecurityContextToken;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do this in two stages for performance if token contains state- only load if not in cache&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(tokenToReturn == null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(_cacheMode == CacheMode.cookie)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&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; tokenToReturn = LoadSctFromCookie(element, sct.Identifier);&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;TokenCache.Add(sct.Identifier, tokenToReturn);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return tokenToReturn;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;font size="2"&gt;private SecurityContextToken LoadSctFromCookie(System.Xml.XmlElement element, string identifier)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string serializedAndEncryptedData = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityContextToken sct = null;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach(XmlElement childNode in element.ChildNodes)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (childNode.LocalName == TokenNames.SCT.ExtensionElement &amp;amp;&amp;amp; &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; childNode.NamespaceURI == TokenNames.Namespace)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&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; serializedAndEncryptedData = childNode.InnerText;&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; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(serializedAndEncryptedData != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte []encryptedData = Convert.FromBase64String(serializedAndEncryptedData);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte []serializedData = _encryptor.DecryptAndValidate(encryptedData);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sct = _serializer.DeserializeSCT(identifier, serializedData);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//Should not happenl.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new System.Web.Services.Protocols.SoapException("Server does not support distributed cache for SCTs", &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; System.Web.Services.Protocols.SoapException.ServerFaultCode);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return sct;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;This one I had tried before, so it came up and running pretty quickly.&amp;nbsp; Well that's it for SCT's.&amp;nbsp; I think I'll try something a little more abstract next blog...maybe service factoring, which is something I've struggled with over the last year.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=225981" width="1" height="1"&gt;</description></item><item><title>SCT Options - Using a database to cache SCT's in a farm, final chapter</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/08/31/223797.aspx</link><pubDate>Wed, 01 Sep 2004 05:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:223797</guid><dc:creator>chriskeyser</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/223797.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=223797</wfw:commentRss><description>&lt;div class="Section1"&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;OK, so here I am in my hotel room ready to rip off a really long blog entry to close out caching SCT’s in a database, and I can’t get to the internet.&amp;nbsp; Go figure.&amp;nbsp; I’ll have to wing where I left off from memory.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Last discussion I reviewed serializing a token, and left off with my first assumption proven wrong – that the token was complete when added to the cache, so I could just use this event to go ahead and also persist the token to the database.&amp;nbsp;&amp;nbsp;Unfortunately there is no event to&amp;nbsp;hook that would key me into when the token is complete and can be persisted.&amp;nbsp; An interchange with an excellent dev on the WSE team suggested overriding the security context token service to achieve the desired behavior.&amp;nbsp; So while the SecurityContextTokenManager generally handles all token handling items of interest once a token is created, the SecurityContextTokenService is actually responsible for creating, populating, and issuing the SecurityContextToken.&amp;nbsp; A simple override does the trick in this case:&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;public class DistributedCacheSCTService: SecurityContextTokenService &lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;protected override RequestSecurityTokenResponse IssueSecurityToken(SecurityTokenMessage request) &lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // invoke the base implementation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RequestSecurityTokenResponse response = base.IssueSecurityToken(request);&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // now filled up the SCT's properties&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.SetupIssuedToken(request, response);&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // now cache the fully-fledged SCT again&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ISecurityTokenManager mgr = SecurityTokenManager.GetSecurityTokenManagerByTokenType(WSTrust.TokenTypes.SecurityContextToken);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SecurityContextToken token = response.RequestedSecurityToken.SecurityToken as SecurityContextToken;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DistributedCacheSCTManager sctMgr = (DistributedCacheSCTManager)mgr;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sctMgr.PersistSecurityToken(token.Identifier, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;response.RequestedSecurityToken.SecurityToken);&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return response;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;}&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Essentially I’m doing the same functionality as the default implementation, only I’m also telling the manager I derived from SecurityContextTokenManager previously to persist the token once its been setup, rather then persisting when its been added to the cache.&amp;nbsp; WSE also needs to be configured to use the DistributedCacheSCTService for issuing SCTs, which is achieved through configuration:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;autoIssueSecurityContextToken enabled="true" type="SecureConvCodeService.DistributedCacheSCTService, SecureConvCodeService" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The good news is that now I did get a complete token serialized to the cache.&amp;nbsp; Bad news is when I deserialized the token, I got a new security fault.&amp;nbsp; As it turns out the base token was a UsernameToken, which has a nonce value.&amp;nbsp; WSE tracks the nonce values and detects reuse of a nonce, which indicates a highly probable replay attack.&amp;nbsp; While I am “rehydrating” the token with the LoadTokenFromXml method on the token manager, the manager actually thinks its loading the token from a message.&amp;nbsp; Since the nonce has been used before, it throws a security fault.&amp;nbsp; The problem here is that I was using an artificial means to test my caching logic by not putting the token in my local in-memory cache.&amp;nbsp; Typically what would have occurred is that if the manager had seen it before, the token would already&amp;nbsp;be cached in memory.&amp;nbsp; Otherwise it would load it back from the database, and since the replay detection also relies upon an in-memory cache of nonces, it will not cause a problem on the second service instance in the farm.&amp;nbsp; In any case, I was able to circumvent this issue by one more configuration setting, this one for the UsernameTokenManager&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Courier New" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;securityTokenManager type="SecureConvCodeService.CustomUsernameTokenManager,SecureConvCodeService"&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp; xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" &lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;qname="wsse:UsernameToken" &amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;replayDetection enabled="false"/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/securityTokenManager&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This did enable me to deserialize the SCT and base token.&amp;nbsp; I figured I was out of the woods with my fully re-constituted token.&amp;nbsp; Not so lucky.&amp;nbsp; WSE ended up throwing one more exception indicating that it could not locate the security token.&amp;nbsp; Now what?&amp;nbsp; Well this one had me stumped, but I was fortunate enough to corner the same excellent WSE developer who helped me work through the best approach for getting around the incomplete token issue.&amp;nbsp; As it ends up we discovered that there is a "feature" with the current SCT implementation that requires the token Id (which is different than the identifier) to be consistent across messages.&amp;nbsp; Typically the token id should only need to be consistent within a particular message, while the SCT identifier is consistent across all messages.&amp;nbsp; The simple work around was to add Id to the serialized SCT information, and to set the original value when the token is re-hydrated.&amp;nbsp; Once I did this, the sample worked.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;I was so excited about actually writing some code that I neglected to discuss the advantages and disadvantages of this approach.&amp;nbsp; The advantages of the database cache approach are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;1)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Minimizes network transport overhead (when compared to the ‘cookie’ method to be discussed next)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;2)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Resilient to service instance failures in the farm&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo2"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;3)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Low performance overhead – slightly higher than using pinning, but only since local caching of tokens is still used, it’s only once per token per service instance maximum.&amp;nbsp; This is a slight performance hit over the session pinning approach.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The disadvantages are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;1)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Operational complexity is highest of all approaches.&amp;nbsp; Database has to be maintained for caching.&amp;nbsp; If a session database is already being maintained, then this could piggy back off of the existing session database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;2)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Security – if the data written to the database is not encrypted, it could be compromised by someone who can sniff the network&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;3)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Cost – database needs to be available for caching.&amp;nbsp; For high availability systems, this would need to be a clustered database since an outage would take out all services that rely on SCT’s in your farm for security.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Next blog I’ll start covering the approach I prefer because it gives operational simplicity with resiliency at the cost of network and processing overhead.&amp;nbsp; This uses a conceptual model near and dear to all web developers – using cookies as a means to manage session state rather than relying upon you backend services using stateful sessions.&amp;nbsp; In this case though the state information is embedded within the extensibility area of the SCT itself.&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=223797" width="1" height="1"&gt;</description></item><item><title>SCT Options - Using a database to cache SCT's in a farm, Volume 2</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/08/29/222515.aspx</link><pubDate>Mon, 30 Aug 2004 04:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:222515</guid><dc:creator>chriskeyser</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/222515.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=222515</wfw:commentRss><description>&lt;p&gt;Last entry I discussed how to extend the SCT manager, and MRUSecurityTokenCache to use a database to persist tokens to share SCT's across service instances within a web farm.&amp;nbsp; I left the details of token serialization not implemented however.&amp;nbsp; This blog I'll dig into that with a generic method of serializing and deserializing tokens.&amp;nbsp; I'd like to note that it would be more efficient generally if you have control over the base token to use a more efficient mechanism to serialize the token.&lt;/p&gt; &lt;p&gt;Tokens are unfortunately not serializable.&amp;nbsp; There are a few reasons this design choice was made -&amp;nbsp;the downer is that efficient token serialization is not as simple as it could be.&amp;nbsp; There are two tokens we need to be concerned with - the first is the SCT itself, and the second is the "base token" of the SCT.&amp;nbsp; I discussed the base token in a previous blog but realized that I wasn't particularly clear about where it came from.&amp;nbsp; When estabilshing an SCT, a token is provided by the client to prove its authenticity and estabilish identity before the SCT will be issued.&amp;nbsp;&amp;nbsp;In the case of the secure conversation example, a UsernameToken is used for client credentials for the SCT request.&amp;nbsp; If the credentials are accepted, then this token becomes the "base" token of the SCT.&amp;nbsp; The SCT itself is generally very lightwieght, while the base token typically contains identity and perhaps authorization related information for the authenticated client.&lt;/p&gt; &lt;p&gt;So the bottom line is that we need to serialize both of these.&amp;nbsp; The approach I took assumes that generally tokens that are not SCT's are stateless - i.e., they can be reconstituted based upon the information contained within the token xml, and perhaps a secret know on each service - for instance, the private key of a public cert installed on all servers in the farm, or a symmetric key shared in the configuraiton accross all servers in the farm.&amp;nbsp; The method we are going to work on is one added to the DistributedTokenCache described in my last entry:&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;pre&gt;&lt;font size="2"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt; provtected virtual void SaveToStore(SecurityToken token)&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;… persist the token&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;I'm going to describe how I implemented this for SCT's. One could generalize this for other tokens, but I haven't yet figured&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;out a valid use case for this need. For the base tokens, I'm going to use a method every token must implement to &lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;serialize itself to xml, GetXml, and to deserialize the token on reload using the appropriate token manager's &lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;LoadTokenFromXml method.&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;For the SCT, define a simple class to contain the relevant information from the SCT. For my purposes, I defined the&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;following as sufficient, altthough there are additional items you could push off - for instance, if you were using the&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;"AppliesTo" value for some of your validation, you would want to add that information to this class:&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Times New Roman" size="3"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&lt;p&gt;[Serializable] &lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;private&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;class&lt;/font&gt;&lt;font size="2"&gt; SCTData&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; public&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;byte&lt;/font&gt;&lt;font size="2"&gt;[] KeyBytes;&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; public&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; TokenIssuer;&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; public&lt;/font&gt;&lt;font size="2"&gt; DateTime Created;&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; public&lt;/font&gt;&lt;font size="2"&gt; DateTime Expires;&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; public&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; BaseTokenType;&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; public&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt; SerializedBaseToken;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;I set the relevant data values from the SCT being seriailzed, (Created and Expired come from Lifetime which is not&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;serializable). SerializedBaseToken is a string containing the XML retrieved from the base token using GetXml. I then&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;serialize this class into a byte stream and store it to the database along with the associated identifier (used to retrieve the&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;entry on deserialization). I also added a column where I put the current datetime so I can clean up the store later.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;My first thought was to use Expires, but unfortunately Expires is a few thousand years in the future by default.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;I created a somewhat artficial test case to see if this logic worked by skipping placing the token in the cache when first&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;added and expected to see everything run beautifully.. Well it didn't. I got a SecurityFault and a decryption error. I &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;started digging, and I found out that the SCT wasn't in fact complete when it was added to the cache, so I was serializing &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;an incomplete token to the cache database, which was then of course incomplete when de-serialized on the next&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;request. The base token &lt;/font&gt;&lt;font size="3"&gt;wasn't set, nor the TokenIssuer (as well as a few other properties). Next entry I'll discuss &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;how I fixed this particular &lt;/font&gt;&lt;font size="3"&gt;issue (and two others) to get the cache running.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=222515" width="1" height="1"&gt;</description></item><item><title>Using a database cache to share SCTs in a farm, volume 1</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/08/26/220985.aspx</link><pubDate>Thu, 26 Aug 2004 17:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:220985</guid><dc:creator>chriskeyser</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/220985.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=220985</wfw:commentRss><description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Sorry I’ve gone dark for the last few days just as things were getting interesting and I had promised some code snippets.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I decided to actually implement a solution using a distributed cache for SCT’s –&amp;nbsp;I had implemented a proof-of-concept embedding state in the SCT already, so I assumed that doing a distributed cache approach would be even easier extrapolation of this work…well you know what the say about assumptions.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In any case, it’s made this an interesting enough problem that I think I’ll write it up for MSDN in the future.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;OK, well on to how to do a distributed approach.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Last time I talked about the approach of using some sort of session affinity mechanism to ensure the client was always routed to the same service instance.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This was the simplest approach, but had a number of drawbacks.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The second approach we’ll examine is using a database cache.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: center" align="center"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id=_x0000_t75 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt;&lt;/v:path&gt;&lt;o:lock v:ext="edit" aspectratio="t"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Now to how we achieve this approach?&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;My first theory was to override the token cache in the security token manager for the SCT to handle this situation, and write a new type of cache class for handling SCT's.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In WSE, for each type of token handled there is an associated specialized security token manager that knows how to handle pretty much all aspects of managing that token type that is registered via the config file with the WSE runtime.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The only requirement for a security token manager is that they implement the ISecurityTokenManager interface, however there is also a base SecurityTokenManager implementation that would more commonly be used if you are implementing your own custom tokens.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In this case we don’t even need to do that – we really just need to derive from the SecurityContextTokenManager class, and override the TokenCache property.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This part of the implementation is pretty trivial:&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;font face="Courier New" size="1"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;public class DistfibutedCacheSCTManager: SecurityContextTokenManager&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;{&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DistributedTokenCache _cache;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public DistributedCacheSCTManager(): base()&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Arial" size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&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; _cache&amp;nbsp;= new DistributedTokenCache();&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Arial" size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Arial" size="1"&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Arial" size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected override ISecurityTokenCache TokenCache&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Arial" size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font face="Arial" size="1"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font face="Arial" size="1"&gt;{&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font face="Arial" size="1"&gt;return _cache;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font face="Arial" size="1"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Arial" size="1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font face="Arial" size="1"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Then we&amp;nbsp;define a distributed cache.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In order to do this, I just derived from the WSE MRUSecurityTokenCache class (MRU == Most Recently Used).&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;We still want to cache the token locally in addition to persisting it to a central database cache.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This way we only have one database hit per SCT per service instance in the web farm maximum for each SCT that is established with a client (this assumes the token is never flushed from a local cache).&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;public class DistributedTokenCache: MRUSecurityTokenCache&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p&lt;/span&gt;ublic DistributedTokenCache(int capacity): base(capacity)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p&lt;/span&gt;ublic override void Add(string identifier, SecurityToken token)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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; i&lt;/span&gt;f(base.Contains(identifier) == false)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; b&lt;/span&gt;ase.Add(identifier, token);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; &lt;/span&gt;SaveToStore(token);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p&lt;/span&gt;ublic override SecurityToken this[string identifier]&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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; g&lt;/span&gt;et&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; &lt;/span&gt;SecurityToken token = base[identifier];&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; &lt;/span&gt;If(token == null)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 4"&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; t&lt;/span&gt;oken = ReadFromStore(identifier);&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&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; if(token != null)&lt;o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 4"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b&lt;/span&gt;ase.Add(token);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; r&lt;/span&gt;eturn token;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;|&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p&lt;/span&gt;ublic override bool Contains(string identifier)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&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; bool&amp;nbsp;containsToken = false;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;o: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; containsToken = base.Contains(identifier) ;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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; i&lt;/span&gt;f(containsToken == false)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; &lt;/span&gt;SecurityToken token = ReadFromStore(identifier);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 3"&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; i&lt;/span&gt;f(token != null)&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;o: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; {&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;o: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;&amp;nbsp;&amp;nbsp;&amp;nbsp; containsToken = true;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 4"&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; b&lt;/span&gt;ase.Add(identifier, token);&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&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; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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; r&lt;/span&gt;eturn containsToken;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;|&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p&lt;/span&gt;rovtected virtual void SaveToStore(SecurityToken token)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;… persist the token&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p&lt;/span&gt;rotected virtual SecurityToken ReadFromStore(identifier string)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 2"&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;… load the token&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"&gt;&lt;font size="1"&gt;&lt;font face="Arial"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;In order to use the derived security context token manager, you need to register the manager with WSE.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This is a simple config file entry:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Arial"&gt;&amp;lt;securityTokenManager type="SecureConvCodeService.DistributedCacheSCTManager, SecureConvCodeService" xmlns:wssc="http://schemas.xmlsoap.org/ws/2004/04/sc" qname="wssc:SecurityContextToken"/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Next entry I’ll go into detail about saving and loading the token back from the database cache, and cover the first unanticipated issues I encountered with the implementation.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=220985" width="1" height="1"&gt;</description></item><item><title>SCT Options - Pinning a client session to a service instance</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/08/19/217525.aspx</link><pubDate>Fri, 20 Aug 2004 02:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217525</guid><dc:creator>chriskeyser</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/217525.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=217525</wfw:commentRss><description>&lt;p&gt;Most web developers are familiar with one way with maintaining state within a web farm from their ASP days...server affinity.&amp;nbsp; This was really the only optional available before .NET other than writing your own distributed session management solution for web applications if you wanted to maintain server side session state.&amp;nbsp; This approach can also be used in the case of SCTs.&amp;nbsp; Since most web services today are typically accessed via http, this logic is already built into load balancing hardware, and often these balancers will setup affinity for a particular service instance based on such values as client IP address or a cookie value, such as session ID.&amp;nbsp;&amp;nbsp;A common term used to describe this is "pinning" the session to a server instance.&amp;nbsp; This may be a perfectly adequate solution for your service, and this is certainly the easiest option to implement.&amp;nbsp; There is no additional development work required to implement this approach - typically just flip a switch in your load balancer, and your off to the races.&amp;nbsp; The advantages of this approach are:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Easiest to implement - no code required&lt;/li&gt; &lt;li&gt;The most performant solution (assuming that it doesn't introduce significant load imbalance issues that are possible when pinning occurs)&lt;/li&gt; &lt;li&gt;Simplest solution to support operationally&lt;/li&gt; &lt;li&gt;Supports all base token types efficiently (more on this below)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The disadvantages of this solution are:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Not resielent to server failures.&amp;nbsp; Since the client is pinned to a particular instance, if the server goes down, the SCT is no longer valid.&amp;nbsp; If the message subsequently gets rerouted to an available server, it will be rejected.&amp;nbsp; This could be compensated for by logic in a smart client side proxy.&lt;/li&gt; &lt;li&gt;Can introduce imbalances in loading - this is a typical problem with pinning a session to a particular instance&lt;/li&gt; &lt;li&gt;Reliant upon some type of session affinity management.&amp;nbsp; This is typical&amp;nbsp;available&amp;nbsp;with&amp;nbsp;http load balancers, but may not be as likely of a feature for other load balancing solutions.&lt;/li&gt; &lt;li&gt;This is a point-to-point approach.&amp;nbsp; Messages transiting multiple hops won't have an http connection directly between the client and service.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;One of the advantages mentioned above is supports all types of base tokens efficiently.&amp;nbsp; The limitiation with the other two approaches mentioned that I will cover in the future is that they require the base token information to be serialized.&amp;nbsp; Since the WSE SecurityToken class is not serialable, no derived class can not be serializable.&amp;nbsp;&amp;nbsp;There is an out...you should typically at least be able to retrieve the XML representation of a token with GetXml and LoadXml, but this adds significant additional memory and processing costs over binary serialization for the cached token.&amp;nbsp; A technique to mitigate this cost that will be covered later is to cache the token locally.&amp;nbsp; Therefore the deserialization only needs to occur if the token is not in the local cache - which means only once per token per service instance (assuming that the token doesn't get flushed from a full cache).&lt;/p&gt; &lt;p&gt;For a high reliability system, this approach would not be the best choice.&amp;nbsp; While choosing the simplest solution that meets your needs is almost always the best choice, I am bothered by the fact that this relies on out-of-band information for session affinity and requires point to point communications that seesms to violate the spirit of messaging within SOA.&amp;nbsp; But then I think maybe I'm being too much of a purist...&lt;/p&gt; &lt;p&gt;Tomorrow I'll start covering the distributed cache approach, where I'll start digging into some code samples.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=217525" width="1" height="1"&gt;</description></item><item><title>Why do we need to manage state when using a Security Context Token, and what are the implications?</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/08/18/216640.aspx</link><pubDate>Wed, 18 Aug 2004 17:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:216640</guid><dc:creator>chriskeyser</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/216640.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=216640</wfw:commentRss><description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;A security context token is a lightweight token that can be established for multiple message exchanges between two endpoints.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;It only makes sense to establish an SCT if it is anticipated that multiple messages will be exchanged.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The specification for this feature can be found here and builds on both ws-security and ws-trust.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You’ll notice that the defined payload of the token is very light – in fact, only one element mandatory element is defined, Identifier, for an SCT.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;While a third party approach to issuing SCT’s is not prohibited, the model that WSE supports out of the box and we anticipate will be predominantly used is based on a conversation between two endpoints.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In fact, WSE has a really cool feature, auto issuing (configured with &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;b&gt;&lt;span style="FONT-WEIGHT: bold"&gt; autoIssueSecurityContextToken&amp;gt;)&lt;/span&gt;&lt;/b&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; where the framework picks up an incoming SCT request issued directly to the service endpoint and handles it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;If you’ve seen what various security token looks like, you know that they can be pretty large, and the associated transport and parsing logic can add measurable overhead – for instance, a Kerberos based token can be well over 1K in size.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;SCT avoids this overhead by relying on the client and service retaining the key information as well as BaseToken used in originally establishing the secure context.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;An exchange has already occurred to authenticate and establish identity when an SCT is requested that has established the identity and credentials of the client.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Once established, the client and service use the identifier in the SCT to pull the key and base token information back out of a cache for validating the message information and establishing the identity.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The implication here of course is that state is saved on both the client and service side that allows the parties to more efficiently manage security.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;However when your service is deployed to a web farm, this assumption on the server side needs to be addressed.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Several ways to deal with this issue are:&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;1)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Pin the client session to a particular server instance hosting the service in the farm.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Most load balancers have an ability to route incoming requests to the same server instance based upon some form of session affinity.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;2)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Support a distributed cache on the server side for sharing the SCT information across the farm.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Arial"&gt;&lt;span style="mso-list: Ignore"&gt;3)&lt;font face="Times New Roman" size="1"&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Put the state information for the SCT into the extensibility area of the SCT.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;I will examine all three options over the next few blog entries.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=216640" width="1" height="1"&gt;</description></item><item><title>Kickoff for a procrastinator - are you a top down, middle out, or bottoms up kind of person?</title><link>http://blogs.msdn.com/chriskeyser/archive/2004/08/16/215444.aspx</link><pubDate>Tue, 17 Aug 2004 01:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:215444</guid><dc:creator>chriskeyser</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/chriskeyser/comments/215444.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chriskeyser/commentrss.aspx?PostID=215444</wfw:commentRss><description>&lt;p&gt;I'm a software architect with the Archtecture Strategy group at Microsoft.&amp;nbsp; I've been working up to starting a blog for some time now, and have finally run out of excuses to put it off any longer.&amp;nbsp; Mind you I like blogs and gets lots of value out of what they have to say...just been waiting for that ultimate nugget of wisdom I could impart on everyone that would convince them that despite my lousy spelling, I really do have something worthwhile to say.&amp;nbsp; Well I've given up on discovering that one and decided to just plow ahead.&lt;/p&gt; &lt;p&gt;I'm fairly new at Microsoft - I just crossed over my one year boundary.&amp;nbsp; Its been a tremendous learning experience for me.&amp;nbsp; I have a varied background - having worked in embedded systems, consulting and a string of startups in the last 15 years in software development.&amp;nbsp; I spent five years out of college in the Navy as an officer in the nuclear power program.&amp;nbsp; I'm always looking for new challenges, and working at Microsoft definitely fits into that category - I am most fortunate to be associated with a great team of non-egotistical really&amp;nbsp;smart people.&amp;nbsp; Boy, how often does that happen?&amp;nbsp;&lt;/p&gt; &lt;p&gt;One of the challenges that I've encountered here in this group is thinking in the abstract.&amp;nbsp; I always thought I was good at abstract thinking until I came here.&amp;nbsp; .&amp;nbsp; Now I think I'm still pretty good at drawing abstractions out of one or more concrete problems, refactoring those abstractions as the system&amp;nbsp;evolves&amp;nbsp;- that I've done all my career - but taking it to the next level just isn't the way my brain works.&amp;nbsp; I need that concrete problem or set of problems to start with.&amp;nbsp; If I can't draw the line from the abstraction to some vague implementation approaches in my mind, then it just doesn't work for me.&amp;nbsp; I think it's kind of like the difference between an innovator and an inventor.&amp;nbsp; Someone like Pat Hellend who can generalize in the abstract and come up with an elegant model of how it ought to be referring back to a&amp;nbsp;very general problem space is amazing to work with - and it all makes sense to me when he presents it and applies it against specific instances - although elements of his thinking in some cases is beyond what technology can&amp;nbsp;effectively deliver today, pointing to what we need to plan and strive to accomplish tomorrow (I'm sure anyone reading my lowly blog has perused Pat's long ago).&amp;nbsp;&amp;nbsp;After the last year of working within this group, if I hadn't had prior experience working with bottom's up person I would think that I must be one of those.&amp;nbsp; But I have definitely been there working with a few&amp;nbsp;bottoms up people.&amp;nbsp; That's the person that when I arrive at some moderately elegant system architecture diagram with some pretty pictures in PowerPoint and Visio&amp;nbsp;catches the few key leaps of faith I made when I doing my hand waving around my vague idea of implementation, and has saved my rear-end more than once.&amp;nbsp; Now that I interface with lots of top down thinkers, I seem to be feeling that bottom-up thinker's pain as I struggle to draw the lines, but I'm definitely getting there as I'm being stretched.&amp;nbsp; Thus I decided I must be a middle out kind of architect.&amp;nbsp; If you ask me how I would realize my ideas, I'll have some semblence of how that may be translated to actual&amp;nbsp;implementation.&amp;nbsp; I'd like to think I've brought some value to the group as a result by being the pestering guy always asking the questions - kind of like my bottom's up compadre always did to me - and helping keep everyone honest.&amp;nbsp; The most effective organizations have characters with each of these skills IMHO.&amp;nbsp; Those that can traverse all of these levels effectively are few and far between.&amp;nbsp;&amp;nbsp;I had a chance to interact recently with Jack Greenfield, and I really like the thinking going on with domain specific langauages and software factories.&amp;nbsp; This&amp;nbsp;will give us a more formal and effective mechanisms for transcending these levels of abstractions and help reduce this friction.&lt;/p&gt; &lt;p&gt;Anyway, that was my soft, non-controversial touch-feely kind of introduction to convince you I'm a nice guy.&amp;nbsp; From now on I'll try to get down to the really interesting (and more concrete) issues and avoid any further speculation about abstract issues ;-).&amp;nbsp; To start with, in the tradition of being middle out, I'm going to do my first series of blogs starting this week based on managing Security Context Token's in a load balanced web farm with WSE2, discussing first&amp;nbsp;the options within a farm for&amp;nbsp;this problem, pluses and minuses of each approch, then dive into some code snippets.&amp;nbsp; Since I hate to take credit for work someone else has done, I want to acknoweldge up front that the thought leadership for this work came out of a collaboration I had with Fred Chong, an excellent architect also in the Architecture Strategy group, and is based primarily on elements of a proposal that Fred generated.&amp;nbsp; Stay tuned if you are interested...&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=215444" width="1" height="1"&gt;</description></item></channel></rss>