Skip to content
yanaga edited this page Mar 14, 2012 · 10 revisions

The spring-security-janrain project provides spring-security classes for the Janrain (formerly RPXNow!) authentication service.

We also included two JSF2 components for using the embedded and modal Janrain widgets.


Spring Security 3.1.x configuration

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

	<http pattern="/spring/login" security="none" />
	<http>
		<custom-filter position="PRE_AUTH_FILTER" ref="janrainAuthenticationFilter" />
		<logout logout-url="/spring/logout" logout-success-url="/" />
	</http>
	<authentication-manager alias="authenticationManager">
		<authentication-provider ref="janrainAuthenticationProvider" />
	</authentication-manager>

	<beans:bean id="janrainAuthenticationFilter" class="br.com.insula.spring.security.janrain.JanrainAuthenticationFilter">
		<beans:property name="authenticationManager" ref="authenticationManager" />
		<beans:property name="janrainService" ref="janrainService" />
	</beans:bean>

	<beans:bean id="janrainAuthenticationProvider" class="br.com.insula.spring.security.janrain.JanrainAuthenticationProvider">
		<beans:property name="authenticationUserDetailsService" ref="myAuthenticationUserDetailsService" />
	</beans:bean>

	<beans:bean id="janrainService" class="br.com.insula.spring.security.janrain.JanrainService">
		<beans:property name="apiKey" value="youApiKey" />
	</beans:bean>
</beans:beans>

This assumes that you login page will be /spring/login, but of course you are free to choose any other uri.

Your myAuthenticationUserDetailsService should implement AuthenticationUserDetailsService<JanrainAuthenticationToken>, looking for your users based on the property identifier of the JanrainAuthenticationToken and possibly filling up your beans with the email and name information provided.


JSF2 Components

To use Janrain with JSF2, you just have to declare the janrain namespace as http://insula.com.br/janrain and use one of <janrain:embedded> or <janrain:modal>, depending on what you've configured in the Janrain site.

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:janrain="http://insula.com.br/janrain">

	<janrain:embedded applicationName="myapplicationname" language="pt-BR" />
	<janrain:modal applicationName="myapplicationname" language="pt-BR">Sign In</janrain:modal>

</ui:composition>

Other view technologies

Please take a look at the source code, specially at embedded.xhtml and modal.xhtml, located at src/main/resources/META-INF/janrain. These are the JSF2 sources for the components. We're pretty sure it will be a simple task to port these to your preferred view technology.


Maven instructions

Add the following repository into the <repositories> element of your pom.xml:

<repository>
	<id>maven-oss-insula</id>
	<name>Insula Maven OSS Releases Repository</name>
	<url>http://maven-oss.insula.com.br/releases</url>
</repository>

And the following dependency into the <dependencies> element of your pom.xml:

<dependency>
	<groupId>br.com.insula</groupId>
	<artifactId>spring-security-janrain</artifactId>
	<version>1.1.5</version>
</dependency>