Sergey Shishkin

on agile software development

Archive for April 2007

CardSpace SDK: Creating Managed Cards, Part 1

A managed information card is simply an XML document, which can be written to a file, downloaded from Internet, copied between devices and finally installed into the Windows CardSpace system, or into some other card selector. Information cards files have ‘.crd’ extension; MIME content type for information cards is ‘application/x-informationcard’.

A format of an information card XML document is described in Section 4.1 of a ‘Technical Reference for the Information Card Profile’ (http://identityblog.com/wp-content/resources/profile/InfoCard-Profile-v1-TechRef.pdf). The format is quite simple and straightforward; therefore this article will focus on designing an API for creating managed information cards and working with them.

The main class of the API is the InformationCard class. Since the information card is an XML document, it will be a logical step to provide the user of the API with the same coding experience as using the XmlDocument class of the System.Xml namespace. Similar to the XmlDocument, the InformationCard class has a default constructor and a set of overloads of Save and Load methods. InformationCard also explicitly implements IXmlSerializable interface in order to support advanced serialization scenarios.

To create a managed information card user needs to: create an instance of the InformationCard class calling its default constructor; set the required properties; and call the Save method on that instance providing a filename, a Stream or an XmlWriter.

InformationCard card = new InformationCard();

card.CardId = new Uri("http://cardspace.newtelligence.com/cards/1");

card.Save("card.crd");

// or

card.Save(Response.OutputStream);

In the next post I’ll write more about how to deal with the required and optional properties of the InformationCard class. Part 3 will cover creation of managed cards based on the templates predefined in the configuration file.

Your comments with ideas, feature requests and so on are always welcome!

Advertisements

Written by Sergey Shishkin

06.04.2007 at 14:59

Posted in Uncategorized