Java Doc for LdapAuthenticationProvider.java in  » Security » acegi-security » org » acegisecurity » providers » ldap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Security » acegi security » org.acegisecurity.providers.ldap 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider
      org.acegisecurity.providers.ldap.LdapAuthenticationProvider

LdapAuthenticationProvider
public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider (Code)
An org.acegisecurity.providers.AuthenticationProvider implementation that provides integration with an LDAP server.

There are many ways in which an LDAP directory can be configured so this class delegates most of its responsibilites to two separate strategy interfaces, LdapAuthenticator and LdapAuthoritiesPopulator .

LdapAuthenticator

This interface is responsible for performing the user authentication and retrieving the user's information from the directory. Example implementations are org.acegisecurity.providers.ldap.authenticator.BindAuthenticator BindAuthenticator which authenticates the user by "binding" as that user, and org.acegisecurity.providers.ldap.authenticator.PasswordComparisonAuthenticatorPasswordComparisonAuthenticator which performs a comparison of the supplied password with the value stored in the directory, either by retrieving the password or performing an LDAP "compare" operation.

The task of retrieving the user attributes is delegated to the authenticator because the permissions on the attributes may depend on the type of authentication being used; for example, if binding as the user, it may be necessary to read them with the user's own permissions (using the same context used for the bind operation).

LdapAuthoritiesPopulator

Once the user has been authenticated, this interface is called to obtain the set of granted authorities for the user. The org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator DefaultLdapAuthoritiesPopulator can be configured to obtain user role information from the user's attributes and/or to perform a search for "groups" that the user is a member of and map these to roles.

A custom implementation could obtain the roles from a completely different source, for example from a database.

Configuration

A simple configuration might be as follows:
 <bean id="initialDirContextFactory" class="org.acegisecurity.providers.ldap.DefaultInitialDirContextFactory">
 <constructor-arg value="ldap://monkeymachine:389/dc=acegisecurity,dc=org"/>
 <property name="managerDn"><value>cn=manager,dc=acegisecurity,dc=org</value></property>
 <property name="managerPassword"><value>password</value></property>
 </bean>
 <bean id="ldapAuthProvider" class="org.acegisecurity.providers.ldap.LdapAuthenticationProvider">
 <constructor-arg>
 <bean class="org.acegisecurity.providers.ldap.authenticator.BindAuthenticator">
 <constructor-arg><ref local="initialDirContextFactory"/></constructor-arg>
 <property name="userDnPatterns"><list><value>uid={0},ou=people</value></list></property>
 </bean>
 </constructor-arg>
 <constructor-arg>
 <bean class="org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator">
 <constructor-arg><ref local="initialDirContextFactory"/></constructor-arg>
 <constructor-arg><value>ou=groups</value></constructor-arg>
 <property name="groupRoleAttribute"><value>ou</value></property>
 </bean>
 </constructor-arg>
 </bean>

This would set up the provider to access an LDAP server with URL ldap://monkeymachine:389/dc=acegisecurity,dc=org. Authentication will be performed by attempting to bind with the DN uid=<user-login-name>,ou=people,dc=acegisecurity,dc=org. After successful authentication, roles will be assigned to the user by searching under the DN ou=groups,dc=acegisecurity,dc=org with the default filter (member=<user's-DN>). The role name will be taken from the "ou" attribute of each match.

The authenticate method will reject empty passwords outright. LDAP servers may allow an anonymous bind operation with an empty password, even if a DN is supplied. In practice this means that if the LDAP directory is configured to allow unauthenitcated access, it might be possible to authenticate as any user just by supplying an empty password. More information on the misuse of unauthenticated access can be found in draft-ietf-ldapbis-authmeth-19.txt.


author:
   Luke Taylor
version:
   $Id: LdapAuthenticationProvider.java 1995 2007-08-30 21:12:16Z luke_t $
See Also:   org.acegisecurity.providers.ldap.authenticator.BindAuthenticator
See Also:   org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator



Constructor Summary
public  LdapAuthenticationProvider(LdapAuthenticator authenticator, LdapAuthoritiesPopulator authoritiesPopulator)
     Create an instance with the supplied authenticator and authorities populator implementations.
public  LdapAuthenticationProvider(LdapAuthenticator authenticator)
     Creates an instance with the supplied authenticator and a null authorities populator.

Method Summary
protected  voidadditionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication)
    
protected  UserDetailscreateUserDetails(LdapUserDetails ldapUser, String username, String password)
     Creates the final UserDetails object that will be returned by the provider once the user has been authenticated.

The LdapAuthoritiesPopulator will be used to create the granted authorites for the user.

Can be overridden to customize the creation of the final UserDetails instance.

protected  LdapAuthoritiesPopulatorgetAuthoritiesPopulator()
    
public  booleanisIncludeDetailsObject()
    
protected  UserDetailsretrieveUser(String username, UsernamePasswordAuthenticationToken authentication)
    
public  voidsetIncludeDetailsObject(boolean includeDetailsObject)
    


Constructor Detail
LdapAuthenticationProvider
public LdapAuthenticationProvider(LdapAuthenticator authenticator, LdapAuthoritiesPopulator authoritiesPopulator)(Code)
Create an instance with the supplied authenticator and authorities populator implementations.
Parameters:
  authenticator - the authentication strategy (bind, password comparison, etc)to be used by this provider for authenticating users.
Parameters:
  authoritiesPopulator - the strategy for obtaining the authorities for a given user after they've beenauthenticated.



LdapAuthenticationProvider
public LdapAuthenticationProvider(LdapAuthenticator authenticator)(Code)
Creates an instance with the supplied authenticator and a null authorities populator. In this case, the authorities must be mapped from the user context.
Parameters:
  authenticator - the authenticator strategy.




Method Detail
additionalAuthenticationChecks
protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException(Code)



createUserDetails
protected UserDetails createUserDetails(LdapUserDetails ldapUser, String username, String password)(Code)
Creates the final UserDetails object that will be returned by the provider once the user has been authenticated.

The LdapAuthoritiesPopulator will be used to create the granted authorites for the user.

Can be overridden to customize the creation of the final UserDetails instance. The default will merge any additional authorities retrieved from the populator with the propertis of original ldapUser object and set the values of the username and password.


Parameters:
  ldapUser - The intermediate LdapUserDetails instance returned by the authenticator.
Parameters:
  username - the username submitted to the provider
Parameters:
  password - the password submitted to the provider The UserDetails for the successfully authenticated user.



getAuthoritiesPopulator
protected LdapAuthoritiesPopulator getAuthoritiesPopulator()(Code)



isIncludeDetailsObject
public boolean isIncludeDetailsObject()(Code)



retrieveUser
protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException(Code)



setIncludeDetailsObject
public void setIncludeDetailsObject(boolean includeDetailsObject)(Code)



Fields inherited from org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider
protected boolean hideUserNotFoundExceptions(Code)(Java Doc)
protected MessageSourceAccessor messages(Code)(Java Doc)

Methods inherited from org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider
abstract protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException(Code)(Java Doc)
final public void afterPropertiesSet() throws Exception(Code)(Java Doc)
public Authentication authenticate(Authentication authentication) throws AuthenticationException(Code)(Java Doc)
protected Authentication createSuccessAuthentication(Object principal, Authentication authentication, UserDetails user)(Code)(Java Doc)
protected void doAfterPropertiesSet() throws Exception(Code)(Java Doc)
public UserCache getUserCache()(Code)(Java Doc)
public boolean isForcePrincipalAsString()(Code)(Java Doc)
public boolean isHideUserNotFoundExceptions()(Code)(Java Doc)
abstract protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException(Code)(Java Doc)
public void setForcePrincipalAsString(boolean forcePrincipalAsString)(Code)(Java Doc)
public void setHideUserNotFoundExceptions(boolean hideUserNotFoundExceptions)(Code)(Java Doc)
public void setMessageSource(MessageSource messageSource)(Code)(Java Doc)
public void setUserCache(UserCache userCache)(Code)(Java Doc)
public boolean supports(Class authentication)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.