org.acegisecurity.userdetails.ldap
Class LdapUserDetailsMapper

java.lang.Object
  extended by org.acegisecurity.userdetails.ldap.LdapUserDetailsMapper
All Implemented Interfaces:
LdapEntryMapper

public class LdapUserDetailsMapper
extends Object
implements LdapEntryMapper

The entry mapper used by the authenticators to create an ldap user object.

Version:
$Id$
Author:
Luke Taylor

Constructor Summary
LdapUserDetailsMapper()
           
 
Method Summary
protected  GrantedAuthority createAuthority(Object role)
          Creates a GrantedAuthority from a role attribute.
 Object mapAttributes(String dn, Attributes attributes)
           
protected  String mapPassword(Attribute passwordAttribute)
          Extension point to allow customized creation of the user's password from the attribute stored in the directory.
 void setConvertToUpperCase(boolean convertToUpperCase)
          Determines whether role field values will be converted to upper case when loaded.
 void setPasswordAttributeName(String passwordAttributeName)
          The name of the attribute which contains the user's password.
 void setRoleAttributes(String[] roleAttributes)
          The names of any attributes in the user's entry which represent application roles.
 void setRolePrefix(String rolePrefix)
          The prefix that should be applied to the role names
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LdapUserDetailsMapper

public LdapUserDetailsMapper()
Method Detail

mapAttributes

public Object mapAttributes(String dn,
                            Attributes attributes)
                     throws NamingException
Specified by:
mapAttributes in interface LdapEntryMapper
Throws:
NamingException

mapPassword

protected String mapPassword(Attribute passwordAttribute)
                      throws NamingException
Extension point to allow customized creation of the user's password from the attribute stored in the directory.

Parameters:
passwordAttribute - the attribute instance containing the password
Returns:
a String representation of the password.
Throws:
NamingException

createAuthority

protected GrantedAuthority createAuthority(Object role)
Creates a GrantedAuthority from a role attribute. Override to customize authority object creation.

The default implementation converts string attributes to roles, making use of the rolePrefix and convertToUpperCase properties. Non-String attributes are ignored.

Parameters:
role - the attribute returned from
Returns:
the authority to be added to the list of authorities for the user, or null if this attribute should be ignored.

setConvertToUpperCase

public void setConvertToUpperCase(boolean convertToUpperCase)
Determines whether role field values will be converted to upper case when loaded. The default is true.

Parameters:
convertToUpperCase - true if the roles should be converted to upper case.

setPasswordAttributeName

public void setPasswordAttributeName(String passwordAttributeName)
The name of the attribute which contains the user's password. Defaults to "userPassword".

Parameters:
passwordAttributeName - the name of the attribute

setRoleAttributes

public void setRoleAttributes(String[] roleAttributes)
The names of any attributes in the user's entry which represent application roles. These will be converted to GrantedAuthoritys and added to the list in the returned LdapUserDetails object.

Parameters:
roleAttributes - the names of the role attributes.

setRolePrefix

public void setRolePrefix(String rolePrefix)
The prefix that should be applied to the role names

Parameters:
rolePrefix - the prefix (defaults to "ROLE_").


Copyright © 2004-2006 Acegi Technology Pty Limited. All Rights Reserved.