Published on WSO2 Oxygen Tank (http://wso2.org)

Adding InfoCard Log In to a J2EE Web Application

By dimuthul
Created 2007-12-19 17:34

This article by Dimuthu Leelarathne describes how to introduce CardSpace authentication to J2EE Web applications using WSO2's Identity Solution.

Introduction

WSO2 Identity Solution [0] provides a set of components to enable CardSpace authentication for Web applications. It enables Windows CardSpace [1] authentication for J2EE applications using a servlet filter.

The servlet filter that introduces CardSpace is called "RelyingPartyFilter".  See Configuration manual of the RelyingPartyFilter [1] for details. This manual will be referenced in the rest of the rest of this document as "Java Servlet Filter Developer Guide".

Applies To

WSO2 Identity Solution version 1.0
J2SE version: jdk1.5

The article is organized into following sections.

RelyingPartyFilter - A Servlet Filter

RelyingPartyFilter must be deployed in your application to enable CardSpace login. You can deploy the servlet filter in your application in the same way you deploy any other servlet filter. Then it must be configured with the set of parameters in web.xml. For step by step information on how to install the RelyingPartyFilter and the complete list of parameters with sample possible values, please refer  "Java Servlet Fileter Developer Guide [1]".

CardSpace authentication can be enabled only on SSL protocol. Therefore, your Web application login must be secured using SSL. Private key of the SSL certificate will be used to encrypt SAML token sent to your Web application. Therefore, when giving configuration parameters required by RelyingPartyFilter in the web.xml, including values of Keystore, StorePass, KeyAlias, KeyPass, StoreType parameters must point to the keystore containing private key of the SSL certificate. If the keystore details are not given properly, the application will not startup.

What Happens Behind the Scene?

When a user submits an InforCard as a part of logging into the Web site, an encrypted SAML token will be generated as the login credentials. When RelyingPartyFilter is deployed in your Web application it will intercept this request. If the request contains "InfoCardSignin" parameter, then it will be processed.

Following list of actions will be performed by the RelyingPartyFilter:

After RelyingPartyFilter processes the request, it is then handed over to your application. Here is how you should read the values from the request.

 

String auth = (String)request.getAttribute(TokenVerifierConstants.SERVLET_ATTR_STATE);
String welcomeString = "";

if(auth != null && TokenVerifierConstants.STATE_SUCCESS.equals(auth)) {
welcomeString = "Welcome "
String issuerInfo = request.getAttribute("issuerInfo");
//retrieving claims made by the user
String givenName = (String)request.getAttribute(IdentityConstants.CLAIM_GIVEN_NAME);
String surname = (String)request.getAttribute(IdentityConstants.CLAIM_SURNAME);
String email = (String)request.getAttribute(IdentityConstants.CLAIM_EMAIL_ADDRESS);
welcomeString = welcomeString + givenName + " " + surname + " "+email;
}else{
welcomeString = "Login Failure!!"
}

 

Deploying the Sample Web Application

This article contains a couple of sample applications - one  that demonstrates CardSpace login [1] and the other demonstrating Card Registration [1]. Steps to run these samples are:

  1. Install maven2 [2]
  2. Build the project by typing "mvn clean install" inside the unzipped folder.
  3. Enable SSL in your servlet container using the keystore available here [2]. The store password is "wso2is".
  4. Drop the card-login-SNAPSHOT.war file to the webapps folder. Check whether SSL is working properly.
  5. Point your browser to https://localhost:port/card-login-SNAPSHOT/index.jsp

Managed Information Card Login or Self Issued Information Card Login

You can enable Windows CardSpace authentication using - personal InforCards (also known as self-issued) and/or managed InfoCards, but there are several implications to consider before making a decision:

Personal Cards can be created by anybody with an Identity enabled Web browser. If the Web application is in a public site, where everyone is allowed to login then it should support personal cards. For example, Yahoo and Google, allow anyone to register without limiting it to a group of trusted users. A similar policy can be enforced using InfoCard Technology if the login supports personal cards.

If the Web application should be limited to a set of trusted users, with a set of certified claims, then managed InfoCard is the way to go. An example would be a bank account balance inquiry service that only allows account holders to login. Another example scenario is an enterprise wide intranet login. In this situation only staff should be able to login and an Identity Provider must be always present. Identity Provider (IdP) is a third party service that provides trust brokerage. WSO2 Identity Solution provides a configurable, easily manageable Identity Provider that can connect to standard set of enterprise user stores. It can be configured as a commercial IdP or an enterprise IdP - much more like a ticketing service in Keberos. If your Web application is in a public site with a set of users with tokens then you have to register you site with a commercial IdP.

As mentioned above InfoCard login will work only in the SSL transport protocol. Therefore your Web application must have a X509 certificate. For testing purpose you can create a self signed certificate using the Java key tool.

You can also support both managed and personal InfoCard authentication.

Different parameters must be present in different modes. The following table illustrates which parameters must be present in different modes:

Parameters Required for Managed Card Authentication Required for Info Card Authentication Usage
Keystore, StorePass, KeyAlias, KeyPass, StoreType Yes Yes Details about the private key store
TrustedIdP.KeyStore, TrustedIdP.StorePass, TrustedIdP.StoreType Yes No This keystore must contain all the certificates of trusted IdPs
IssuerPolicy Yes Yes Indicates InfoCard type - "Self", "Managed", "SelfAndManaged"
TokenValidationPolicy, WhiteList, BlackList Yes No SAML tokens will be signature validated and then checked against BlackList OR WhiteList.
MultiValueClaimsPolicy Optional Optional Optional

Implementing Self Issued Information Card Login

Let me provide some background information that will help you make decisions when implementing self issued information card authentication.

Implementing Managed Card Logins

You have to find solutions to several practical problems when implementing managed information card authentication.

Summary

You can add CardSpace authentication to J2EE web application using RelyingPartyFilter provided by WSO2 Identity Solution. It must be configured giving values in the web.xml. We also discussed several important design aspects when implementing InfoCard logins.

Author

Dimuthu Leelarathne, Senior Software Engineer, dimuthul@wso2.com


Source URL:
http://wso2.org/library/2994