The following code fragments illustrate creating an open format cookie:
// Gets an object reference of the interface type IFederationOpenIdentity, bound to a custom
// implementation of the IFederationOpenIdentity interface.
// AES128/CBC/PKCS5Padding is the only supported cryptographic transformation string.
IFederationOpenIdentity openID = IdentityFactory.GetInstance("AES128/CBC/PKCS5Padding", UseHMACFlag);
// Initializes the parameters required to create cookie.
openID.InitCookieInfo(Domain, CookieZone, CookieName, Password);
// Sets a user attribute.
openID.LoginID = txtLoginID.Text;
// Creates an open format cookie and sets it into the response object.
openID.CreateCookie(HttpResponse);
The following code fragments illustrate consuming an open format cookie:
// Gets an object reference of the interface type IFederationOpenIdentity, bound to a custom
// implementation of the IFederationOpenIdentity interface.
// AES128/CBC/PKCS5Padding is the only supported cryptographic transformation string.
IFederationOpenIdentity openID = IdentityFactory.GetInstance("AES128/CBC/PKCS5Padding", UseHMACFlag);
// Initializes parameters needed to extract cookie.
openID.InitCookieInfo(Domain, CookieZone, CookieName, Password);
// Extracts the cookie from the HttpRequest, decrypts it, and saves the attributes in a Hashtable.
openID.ExtractCookie(HttpRequest);
// Retrieves some attributes.
String id = openID.LoginID; String nid = openID.NameID;
| Copyright © 2012 CA. All rights reserved. |
|