Java Doc for DefaultLdapAuthoritiesPopulator.java in  » Security » acegi-security » org » acegisecurity » providers » ldap » populator » 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.populator 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator

DefaultLdapAuthoritiesPopulator
public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator(Code)
The default strategy for obtaining user role information from the directory.

It obtains roles by performing a search for "groups" the user is a member of.

A typical group search scenario would be where each group/role is specified using the groupOfNames (or groupOfUniqueNames) LDAP objectClass and the user's DN is listed in the member (or uniqueMember) attribute to indicate that they should be assigned that role. The following LDIF sample has the groups stored under the DN ou=groups,dc=acegisecurity,dc=org and a group called "developers" with "ben" and "marissa" as members:

 dn: ou=groups,dc=acegisecurity,dc=orgobjectClass: top
 objectClass: organizationalUnitou: groupsdn: cn=developers,ou=groups,dc=acegisecurity,dc=org
 objectClass: groupOfNamesobjectClass: topcn: developersdescription: Acegi Security Developers
 member: uid=ben,ou=people,dc=acegisecurity,dc=orgmember: uid=marissa,ou=people,dc=acegisecurity,dc=orgou: developer
 

The group search is performed within a DN specified by the groupSearchBase property, which should be relative to the root DN of its InitialDirContextFactory. If the search base is null, group searching is disabled. The filter used in the search is defined by the groupSearchFilter property, with the filter argument {0} being the full DN of the user. You can also optionally use the parameter {1}, which will be substituted with the username. You can also specify which attribute defines the role name by setting the groupRoleAttribute property (the default is "cn").

The configuration below shows how the group search might be performed with the above schema.

 <bean id="ldapAuthoritiesPopulator"
 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>
 <!-- the following properties are shown with their default values -->
 <property name="searchSubTree"><value>false</value></property>
 <property name="rolePrefix"><value>ROLE_</value></property>
 <property name="convertToUpperCase"><value>true</value></property>
 </bean>
 
A search for roles for user "uid=ben,ou=people,dc=acegisecurity,dc=org" would return the single granted authority "ROLE_DEVELOPER".

The single-level search is performed by default. Setting the searchSubTree property to true will enable a search of the entire subtree under groupSearchBase.
author:
   Luke Taylor
version:
   $Id: DefaultLdapAuthoritiesPopulator.java 1996 2007-08-30 21:15:14Z luke_t $




Constructor Summary
public  DefaultLdapAuthoritiesPopulator(InitialDirContextFactory initialDirContextFactory, String groupSearchBase)
     Constructor for group search scenarios.

Method Summary
protected  SetgetAdditionalRoles(LdapUserDetails ldapUser)
     This method should be overridden if required to obtain any additional roles for the given user (on top of those obtained from the standard search implemented by this class).
final public  GrantedAuthority[]getGrantedAuthorities(LdapUserDetails userDetails)
     Obtains the authorities for the user who's directory entry is represented by the supplied LdapUserDetails object.
public  SetgetGroupMembershipRoles(String userDn, String username)
    
protected  SetgetGroupMembershipRoles(String userDn, Attributes userAttributes)
     Searches for groups the user is a member of.
Parameters:
  userDn - the user's distinguished name.
Parameters:
  userAttributes - the retrieved user's attributes (unused by default).
protected  StringgetGroupSearchBase()
    
protected  InitialDirContextFactorygetInitialDirContextFactory()
    
public  voidsetConvertToUpperCase(boolean convertToUpperCase)
    
public  voidsetDefaultRole(String defaultRole)
     The default role which will be assigned to all users.
public  voidsetGroupRoleAttribute(String groupRoleAttribute)
    
public  voidsetGroupSearchFilter(String groupSearchFilter)
    
public  voidsetRolePrefix(String rolePrefix)
    
public  voidsetSearchSubtree(boolean searchSubtree)
     If set to true, a subtree scope search will be performed.


Constructor Detail
DefaultLdapAuthoritiesPopulator
public DefaultLdapAuthoritiesPopulator(InitialDirContextFactory initialDirContextFactory, String groupSearchBase)(Code)
Constructor for group search scenarios. userRoleAttributes may still be set as a property.
Parameters:
  initialDirContextFactory - supplies the contexts used to search for user roles.
Parameters:
  groupSearchBase - if this is an empty string the search will be performed from the root DN of thecontext factory.




Method Detail
getAdditionalRoles
protected Set getAdditionalRoles(LdapUserDetails ldapUser)(Code)
This method should be overridden if required to obtain any additional roles for the given user (on top of those obtained from the standard search implemented by this class).
Parameters:
  ldapUser - the user who's roles are required the extra roles which will be merged with those returned by the group search



getGrantedAuthorities
final public GrantedAuthority[] getGrantedAuthorities(LdapUserDetails userDetails)(Code)
Obtains the authorities for the user who's directory entry is represented by the supplied LdapUserDetails object.
Parameters:
  userDetails - the user who's authorities are required the set of roles granted to the user.



getGroupMembershipRoles
public Set getGroupMembershipRoles(String userDn, String username)(Code)



getGroupMembershipRoles
protected Set getGroupMembershipRoles(String userDn, Attributes userAttributes)(Code)
Searches for groups the user is a member of.
Parameters:
  userDn - the user's distinguished name.
Parameters:
  userAttributes - the retrieved user's attributes (unused by default). the set of roles obtained from a group membership search, or null if groupSearchBase has beenset.



getGroupSearchBase
protected String getGroupSearchBase()(Code)



getInitialDirContextFactory
protected InitialDirContextFactory getInitialDirContextFactory()(Code)



setConvertToUpperCase
public void setConvertToUpperCase(boolean convertToUpperCase)(Code)



setDefaultRole
public void setDefaultRole(String defaultRole)(Code)
The default role which will be assigned to all users.
Parameters:
  defaultRole - the role name, including any desired prefix.



setGroupRoleAttribute
public void setGroupRoleAttribute(String groupRoleAttribute)(Code)



setGroupSearchFilter
public void setGroupSearchFilter(String groupSearchFilter)(Code)



setRolePrefix
public void setRolePrefix(String rolePrefix)(Code)



setSearchSubtree
public void setSearchSubtree(boolean searchSubtree)(Code)
If set to true, a subtree scope search will be performed. If false a single-level search is used.
Parameters:
  searchSubtree - set to true to enable searching of the entire tree below the groupSearchBase.



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.