Sergey Shishkin

on agile software development

CardSpace SDK: Creating Managed Cards, Part 3

One more sample from the upcoming SDK:


Using the Configuration

To simplify the process of the creation of information cards and to increase the maintenance capabilities of applications the Information Card API provides support for the .NET Configuration. The <cardSpace> configuration section and the <newCard> configuration element can be used to predefine the information card’s properties in the application configuration file. The call to the static InformationCard.Create method will return then a new information card based on the predefined values.

Source Code

App.config

    <cardSpace>

        <newCard

            language ="en-US"

            cardId ="http://cardspace.newtelligence.com/cards/"

            cardVersion ="2"

            cardName ="newtelligence"

            cardImage ="card.png"

            issuer ="http://cardspace.newtelligence.com/ip"

            timeExpires ="2008-01-01"

            requireAppliesTo ="false"

            >

            <tokenServices>

                <add

                    uri ="http://cardspace.newtelligence.com/sts"

                    mex ="https://cardspace.newtelligence.com/sts/mex"

                    >

                    <identity

                        storeLocation ="LocalMachine"

                        storeName ="My"

                        findType ="FindBySubjectName"

                        findValue ="http://www.fabrikam.com"

                        />

                    <usernamePasswordCredential />

                </add>

            </tokenServices>

            <claimTypes>

                <add

                    id ="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname"

                    displayTag ="Last Name"

                    description ="Surname or family name of a subject"

                    />

                <add

                    id ="http://cardspace.newtelligence.com/claims/custom"

                    displayTag ="Custom Claim"

                    description ="This is a custom claim"

                    />

            </claimTypes>

            <tokenTypes>

                <add type ="urn:oasis:names:tc:SAML:1.0:assertion" />

            </tokenTypes>

            <privacyNotice

                location ="http://cardspace.newtelligence.com/ip/privacy"

                version ="3"

                />

            <signingCertificate

                storeLocation ="LocalMachine"

                storeName ="My"

                findType ="FindBySubjectName"

                findValue ="http://www.fabrikam.com"

                />

        </newCard>

    </cardSpace>

Program.cs

    // Create a new card using config settings

    InformationCard card = InformationCard.Create();

 

    // Set the actual CardId based on the config settings

    card.CardId = new Uri(card.CardId, "1");

 

    // Set the Username property for the UserCredential object

    TokenServiceReference service = card.TokenServices[0];

    UsernamePasswordCredential credential =

        (UsernamePasswordCredential)service.UserCredential;

    credential.Username = "bob";

 

    card.Save("card.crd");

Advertisements

Written by Sergey Shishkin

08.05.2007 at 09:51

Posted in Uncategorized

%d bloggers like this: