{"id":819,"date":"2007-06-25T14:14:02","date_gmt":"2007-06-25T22:14:02","guid":{"rendered":"\/?p=819"},"modified":"2007-06-30T13:24:51","modified_gmt":"2007-06-30T21:24:51","slug":"819","status":"publish","type":"post","link":"https:\/\/www.identityblog.com\/?p=819","title":{"rendered":"CardSpace control for ASP.NET"},"content":{"rendered":"<p>Dominick Baier at <a href=\"http:\/\/www.leastprivilege.com\/\">LeastPrivilege<\/a> has made&nbsp;leaps and bounds in his CardSpace control for the Microsoft ASP.NET environment (though it should work equally well for people using a Higgins identity selector or managed card).&nbsp; It is very cleanly designed.&nbsp; Amazingly, he&#39;s already added support for the new icon (does he ever sleep?).&nbsp; His blog has an <a href=\"http:\/\/www.leastprivilege.com\/FeatureCompleteVersionOfTheASPNETCardSpaceControl.aspx\" class=\"broken_link\">ongoing discussion <\/a>around the control and related issues:<\/p>\n<blockquote><p>After I made some incremental changes and releases of my CardSpace control (found some bugs, got some feedback), I wanted to consolidate all the information along with a new version and some new features here. It now contains all the features <strong>I<\/strong> need and will be the last release for some time i guess.<\/p>\n<p>If you have any feedback or suggestions feel free to write me or leave me a comment. If you want to add support&nbsp;for XHTML, contact me too \ud83d\ude09<\/p>\n<p>Download <a href=\"http:\/\/www.leastprivilege.com\/content\/binary\/CardSpaceSelectorV2.5.zip\" class=\"broken_link\"><font color=\"#993300\">here<\/font><\/a>. Have fun!<\/p>\n<p>PS. This was only possible with a little help of my friends&#8230;thanks Brock and JasonD!<\/p>\n<h3>Features<\/h3>\n<p><strong>Easy to use syntax<\/strong><br \/>\nOne of my main goals was to have an easy to use markup syntax and intellisense support. I don&#39;t want to type in all those namespace URIs&#8230;<\/p>\n<pre style=\"font-family: consolas\"><span style=\"color: blue\">&lt;<\/span><span style=\"color: #a31515\">lp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: #a31515\">CardSpaceSelector<\/span> <span style=\"color: red\">runat<\/span><span style=\"color: blue\">=\"server\"<\/span> <span style=\"color: red\">ID<\/span><span style=\"color: blue\">=\"_selector_sic\"<\/span> <span style=\"color: red\">AutoPostback<\/span><span style=\"color: blue\">=\"true\" \r\n<\/span>    <span style=\"color: red\">IssuerType<\/span><span style=\"color: blue\">=\"SelfIssued\"&gt; \r\n\r\n<\/span>    <span style=\"color: blue\">&lt;<\/span><span style=\"color: #a31515\">lp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: #a31515\">ClaimType<\/span> <span style=\"color: red\">Name<\/span><span style=\"color: blue\">=\"givenname\"<\/span> <span style=\"color: blue\">\/&gt; \r\n<\/span>    <span style=\"color: blue\">&lt;<\/span><span style=\"color: #a31515\">lp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: #a31515\">ClaimType<\/span> <span style=\"color: red\">Name<\/span><span style=\"color: blue\">=\"surname\"<\/span> <span style=\"color: blue\">\/&gt; \r\n<\/span>    <span style=\"color: blue\">&lt;<\/span><span style=\"color: #a31515\">lp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: #a31515\">ClaimType<\/span> <span style=\"color: red\">Name<\/span><span style=\"color: blue\">=\"email\"<\/span> <span style=\"color: blue\">\/&gt; \r\n\r\n&lt;\/<\/span><span style=\"color: #a31515\">lp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: #a31515\">CardSpaceSelector<\/span><span style=\"color: blue\">&gt;<\/span><\/pre>\n<p><strong>Clean markup and independence of the server form<\/strong><br \/>\nThe emitted&nbsp;markup works with Firefox and IE. I also made sure that the &lt;object&gt; tag is placed outside of the postback form. This allows you to have multiple postback controls on the form without triggering the identity selector.<\/p>\n<p><strong>Support for standard InfoCard image<\/strong><br \/>\nYou can choose between all standard sizes of the official InfoCard <a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?FamilyID=ce99e033-39a8-4bc5-9014-60ed0b560d0e&amp;displaylang=en\"><font color=\"#993300\">image<\/font><\/a>. You can also supply your own image and dimensions<\/p>\n<p><img border=\"0\" src=\"http:\/\/www.leastprivilege.com\/content\/binary\/infocard_128x90.png\" \/><\/p>\n<p><strong>Designer integration<\/strong><br \/>\nI&nbsp;never use the designer &#8211; but&nbsp;I acknowledge the fact that some people do \ud83d\ude09 The control&nbsp;renders correctly in the&nbsp;designer and has an editor to setup the required\/optional claims (including intellisense support).<\/p>\n<p><img border=\"0\" src=\"http:\/\/www.leastprivilege.com\/content\/binary\/ClaimsEditorSized.png\" \/><\/p>\n<p><strong>Event driven<\/strong><br \/>\nThe control fires an event when a token is submitted.<\/p>\n<pre style=\"font-family: consolas\"><span style=\"color: blue\">protected<\/span> <span style=\"color: blue\">void<\/span> _selector_sic_TokenSubmitted(<span style=\"color: blue\">object<\/span> sender, <span style=\"color: #2b91af\">TokenSubmittedEventArgs<\/span> e) {     <span style=\"color: blue\">string<\/span> xmlToken = e.Token; }<\/pre>\n<p><strong>Conditional rendering<br \/>\n<\/strong>You can choose to render the control only if the client browser supports InfoCards. You can specify an alternative &lt;div \/&gt; that would render in that case (e.g. to tell the user how to get CardSpace).<\/p>\n<p><strong>Decoupling<\/strong><br \/>\nI intentionally didn&#39;t couple the control with any user management&nbsp;semantics (like membership) or decryption clases (like the TokenProcessor). It is totally up to you how to proceed after you received the encrypted token. This is considered a feature \ud83d\ude09<\/p>\n<h3><\/h3>\n<h3>Properties<\/h3>\n<p><strong>InfoCard setup<\/strong><\/p>\n<p><em>IssuerType<\/em><br \/>\nThis enum has two values \u00e2\u20ac\u02dcSelfIssued\u00e2\u20ac\u2122 and \u00e2\u20ac\u02dcManaged\u00e2\u20ac\u2122. If you select \u00e2\u20ac\u02dcSelfIssued\u00e2\u20ac\u2122 then the issuer URI for self-issued cards will be emitted. If you select \u00e2\u20ac\u02dcManaged\u00e2\u20ac\u2122 you have to set the issuer URI yourself. Defaults to &#8216;SelfIssued&#8217;<\/p>\n<p><em>Issuer and IssuerPolicy<br \/>\n<\/em>Specifies the URIs for the issuer and the issuer policy.<\/p>\n<p><em>TokenType<\/em><br \/>\nSpecifies the token type. Defaults to SAML 1.0.<\/p>\n<p><em>PrivacyUrl and PrivacyVersion<br \/>\n<\/em>Specifies to the URL and version of the associated privacy policy (if any).<\/p>\n<p><strong>Image<\/strong><\/p>\n<p><em>ImageUrl<\/em><br \/>\nSpecifies&nbsp;a custom&nbsp;image to display. Defaults to the official InfoCard icon.&nbsp;<\/p>\n<p><em>StandardImageSize<\/em><br \/>\nSelects one of the standard images sizes for the official InfoCard icon. Defaults to 114&#215;80.<\/p>\n<p><em>Width &amp; Height<\/em><br \/>\nSpecifies the size of the image in pixels. Only relevant when a custom image is used.<\/p>\n<p><strong>Rendering<\/strong><\/p>\n<p><em>RenderOnlyIfSupported<\/em><br \/>\nWhen set to true, the control will only render if the client browser supports CardSpace. You have to embed the control into a &lt;div \/&gt; and specify the name in the <em>DivToRender<\/em> attribute. Defaults to <em>false<\/em>.<\/p>\n<p><em>DivToRender<\/em><br \/>\nSpecifies which &lt;div \/&gt; to render\/make invisible based on client support.<\/p>\n<p>UnsupportedDiv<br \/>\nOptionally specifies a &lt;div \/&gt; to render when CardSpace is not supported on the client.<\/p>\n<p><em>RenderMode<\/em><br \/>\nChoose between static and dynamic rendering. Static&nbsp;preserves the&nbsp;space for the control on the client. Defaults to <em>Static<\/em>.<\/p>\n<p><strong>Misc<\/strong><\/p>\n<p><em>HiddenFieldName<\/em><br \/>\nName of the hidden field used to transmit the token back to the page. Defaults to <em>__XMLTOKEN<\/em>.<\/p>\n<p><em>AutoPostBack<\/em><br \/>\nSpecifies if the control posts back after a card has been selected. Defaults to <em>false<\/em>.<\/p>\n<p><em>TriggerOnLoad<\/em><br \/>\nSpecifies if the identity selector should be invoked directly after the page has finished loading. Defaults to <em>false<\/em>.<\/p>\n<p><em>XmlToken<\/em><br \/>\nHolds the encrypted token after the user has selected a card.<\/p><\/blockquote>\n<p>Dominick also did a set of four videos on CardSpace for UK MSDN that I would recommend:<\/p>\n<blockquote><p><a href=\"http:\/\/www.microsoft.com\/uk\/msdn\/nuggets\/nugget\/232\/CardSpace-Implementation-Strategies.aspx\"><font color=\"#993300\">Implementation Strategies<\/font><\/a><\/p>\n<ul>\n<li><a href=\"http:\/\/www.microsoft.com\/uk\/msdn\/nuggets\/nugget\/231\/Windows-CardSpace-and-Certificates.aspx\"><font color=\"#993300\">The Role of Certificates<\/font><\/a><\/li>\n<li><a href=\"http:\/\/www.microsoft.com\/uk\/msdn\/nuggets\/nugget\/224\/Using-CardSpace-with-ASPNET.aspx\"><font color=\"#993300\">ASP.NET Integration<\/font><\/a><\/li>\n<li><a href=\"http:\/\/www.microsoft.com\/uk\/msdn\/nuggets\/nugget\/230\/Using-Windows-CardSpace-with-WCF.aspx\"><font color=\"#993300\">WCF Integration<\/font><\/a><\/li>\n<\/ul>\n<p>Also find the sample code&nbsp;he used <a href=\"http:\/\/www.leastprivilege.com\/content\/binary\/CardSpaceNuggetDemos.zip\" class=\"broken_link\"><font color=\"#993300\">here<\/font><\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>One of Dominick&#39;s goals was an easy to use markup syntax and intellisense support. He didn&#39;t want us typing in all those namespace URIs&#8230;<\/p>\n","protected":false},"author":68,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,7,9,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/posts\/819"}],"collection":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=819"}],"version-history":[{"count":0,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/posts\/819\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}