##### WSO2 Identity Solution

- Content
- Home

##### Downloads

- Releases

##### Documentation

- Adminstrator Guide
- Installation Guide
- Identity Provider in Production Environment
- mod_cspace Configuration Guide
- Relying Party Developer Guide
- Idp User Guide

##### Samples

- Identity Provider
- PHP Relying Party
- Java Relying Party

##### API Documentation

- Java Docs

##### Get Involved

- Mailing Lists

##### Project Information

- Project Team
- Issue Tracking
- License

# WSO2 Identity Solution, v1.0-beta : Java Servlet Filter Developer Guide

## Introduction

This servlet filter org.wso2.solutions.identity.relyingparty.servletfilter.RelyingPartyFilter can be used with a servlet based web application to provide information card login to that application. The developer should follow the steps described below in intgrating this servlet filter:

## Configuration Steps

- Step 1 : Add the servlet filter to you application
Include the following entry in the web.xml file of the application:

        <filter>
            <filter-name>TokenValidator</filter-name>
            <filter-class>org.wso2.solutions.identity.relyingparty.servletfilter.RelyingPartyFilter</filter-class>
            <init-param>
    	    	<param-name>config-file</param-name>
    		    <param-value>/path/to/config.xml</param-value>
      		</init-param>
        </filter>

        <filter-mapping>
            <filter-name>TokenValidator</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

- Step 2 : Servler filter configuration file

    <RPConfig>
    	<ServiceKey>
    		<Keystore>/path/to/keystore</Keystore>
    		<StorePass>your_keystore_password</StorePass>
    		<KeyAlias>alias_of_private_key</KeyAlias>
    		<KeyPass>password_of_private_key</KeyPass>
    		<StoreType>keystore_type_(JKS_or_PKCS12)</StoreType>
    	</ServiceKey>
        <VerifierService>http://localhost:12080/wsas/services/RelyingPartyService</VerifierService>
    </RPConfig>

In the above configuration there are two main configuration elements :

1. Private key of the web application
2. Token verifier service endpoint address
The token verifier service is available with the identity provider of identity solution. Endpoint address can be found here.

- Step 3 : Add the information card login page
The user loing page must contain a form with an object tag as shown below:

       <form name="frm" id="frm" method="post" action="InfoCardLogin.action">
    		<input type="hidden" name="InfoCardSignin" value="Log in" /><br/>
    		<OBJECT type="application/x-informationCard" name="xmlToken">
    			<PARAM  Name="tokenType"
    					Value="urn:oasis:names:tc:SAML:1.0:assertion">
    			<PARAM  Name="requiredClaims"
    					Value="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier">
    			<PARAM Name="issuer" value="http://schemas.xmlsoap.org/ws/2005/05/identity/issuer/self">
    		</OBJECT>
      </form>

The object tag here is the standard information card object as defined here. It is important that you include the hidden field called "InfoCardSignin" with the value "Log in". The filter will process the HTTP POST request to extract the token sent when this request parameter is available.
- Step 4 : Obtain the information in the verified token and process
The results of token processing will be available as attributes in the ServletRequest object. To indicate whether token verification was successful or not there will be an attribute by the name "org.wso2.solutions.identity.rp.State". On successful verification value of this attribute will be "success". Otherwise it will be "failure". The ServletRequest will also contain a set of attrbites by the names of the claims (the part of claim URI after the final "/") with their values.

These values can be used by the developer to initiate a user session in a web application.