org.ops4j.pax.wicket.util
Class UserAdminAuthenticator

java.lang.Object
  extended by org.ops4j.pax.wicket.util.UserAdminAuthenticator
All Implemented Interfaces:
PaxWicketAuthenticator

public class UserAdminAuthenticator
extends java.lang.Object
implements PaxWicketAuthenticator

This is a PaxWicketAuthenticator that uses the User Admin Service as specified in the OSGi R4 specification.

The ApplicationName must be provided in the constructor, and it will be used as the name space of the users and credentials in the User Admin service.

The user will be obtained thru the call;

     User user = userAdmin.getUser( m_applicationName + ".userid", username );
 

and the credentials are checked with;

   boolean authenticated = user.hasCredential( m_applicationName + ".password", password ) );
 

The Roles returned lacks any name space or prefixing.

All authentication will fail if no UserAdmin service is registered in the OSGi framework.


Constructor Summary
UserAdminAuthenticator(org.osgi.framework.BundleContext bundleContext, java.lang.String applicationName)
          Constructor for the UserAdminAuthenticator.
 
Method Summary
 org.apache.wicket.authorization.strategies.role.Roles authenticate(java.lang.String username, java.lang.String password)
          Authenticate the specified userName with the specified password.
 void dispose()
          Releases all the resources used by this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserAdminAuthenticator

public UserAdminAuthenticator(org.osgi.framework.BundleContext bundleContext,
                              java.lang.String applicationName)
                       throws java.lang.IllegalArgumentException
Constructor for the UserAdminAuthenticator.

Parameters:
bundleContext - The bundleContext of the Bundle where this class is used.
applicationName - The name of the Pax Wicket application. This is the same as the name registered in the PaxWicketApplicationFactory and used in all ContentAggregators and ContentSources.
Throws:
java.lang.IllegalArgumentException - if the bundleContext or the applicationName arguments are null.
Method Detail

dispose

public void dispose()
Releases all the resources used by this class.


authenticate

public org.apache.wicket.authorization.strategies.role.Roles authenticate(java.lang.String username,
                                                                          java.lang.String password)
Authenticate the specified userName with the specified password. Returns null if the specified userName is not authenticate.

Specified by:
authenticate in interface PaxWicketAuthenticator
Parameters:
username - The username to authenticate.
password - The password to authenticate.
Returns:
An instance of Roles if the arguments can be authenticated, null otherwise.
Since:
1.0.0


Copyright © 2008. All Rights Reserved.