mirror of
				https://github.com/spring-projects/spring-security.git
				synced 2025-10-30 22:28:46 +00:00 
			
		
		
		
	Added code to set the manager username and password if supplied.
This commit is contained in:
		
							parent
							
								
									3d0f3302dc
								
							
						
					
					
						commit
						0b54eece28
					
				| @ -6,6 +6,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; | |||||||
| import org.springframework.beans.factory.support.RootBeanDefinition; | import org.springframework.beans.factory.support.RootBeanDefinition; | ||||||
| import org.springframework.beans.factory.BeanDefinitionStoreException; | import org.springframework.beans.factory.BeanDefinitionStoreException; | ||||||
| import org.springframework.util.StringUtils; | import org.springframework.util.StringUtils; | ||||||
|  | import org.springframework.util.Assert; | ||||||
| import org.springframework.security.ldap.DefaultInitialDirContextFactory; | import org.springframework.security.ldap.DefaultInitialDirContextFactory; | ||||||
| import org.springframework.security.providers.ldap.LdapAuthenticationProvider; | import org.springframework.security.providers.ldap.LdapAuthenticationProvider; | ||||||
| import org.springframework.security.providers.ldap.populator.DefaultLdapAuthoritiesPopulator; | import org.springframework.security.providers.ldap.populator.DefaultLdapAuthoritiesPopulator; | ||||||
| @ -34,7 +35,6 @@ public class LdapBeanDefinitionParser extends AbstractBeanDefinitionParser { | |||||||
|     /** Defines the Url of the ldap server to use. If not specified, an embedded apache DS instance will be created */ |     /** Defines the Url of the ldap server to use. If not specified, an embedded apache DS instance will be created */ | ||||||
|     private static final String URL_ATTRIBUTE = "url"; |     private static final String URL_ATTRIBUTE = "url"; | ||||||
|     private static final String AUTH_TYPE_ATTRIBUTE = "auth"; |     private static final String AUTH_TYPE_ATTRIBUTE = "auth"; | ||||||
|     // TODO: Setting login/passwords for non embedded server. |  | ||||||
|     private static final String PRINCIPAL_ATTRIBUTE = "managerDn"; |     private static final String PRINCIPAL_ATTRIBUTE = "managerDn"; | ||||||
|     private static final String PASSWORD_ATTRIBUTE = "managerPassword"; |     private static final String PASSWORD_ATTRIBUTE = "managerPassword"; | ||||||
| 
 | 
 | ||||||
| @ -68,6 +68,18 @@ public class LdapBeanDefinitionParser extends AbstractBeanDefinitionParser { | |||||||
|             initialDirContextFactory.getConstructorArgumentValues().addIndexedArgumentValue(0, url); |             initialDirContextFactory.getConstructorArgumentValues().addIndexedArgumentValue(0, url); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         String managerDn = elt.getAttribute(PRINCIPAL_ATTRIBUTE); | ||||||
|  |         String managerPassword = elt.getAttribute(PASSWORD_ATTRIBUTE); | ||||||
|  | 
 | ||||||
|  |         if (StringUtils.hasText(managerDn)) { | ||||||
|  |             Assert.hasText(managerPassword, "You must specify the " + PASSWORD_ATTRIBUTE + | ||||||
|  |                     " if you supply a " + managerDn); | ||||||
|  | 
 | ||||||
|  |             initialDirContextFactory.getPropertyValues().addPropertyValue("managerDn", managerDn); | ||||||
|  |             initialDirContextFactory.getPropertyValues().addPropertyValue("managerPassword", managerPassword); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|         // TODO: Make these default values for 2.0 |         // TODO: Make these default values for 2.0 | ||||||
|         initialDirContextFactory.getPropertyValues().addPropertyValue("useLdapContext", Boolean.TRUE); |         initialDirContextFactory.getPropertyValues().addPropertyValue("useLdapContext", Boolean.TRUE); | ||||||
|         initialDirContextFactory.getPropertyValues().addPropertyValue("dirObjectFactory", "org.springframework.ldap.core.support.DefaultDirObjectFactory"); |         initialDirContextFactory.getPropertyValues().addPropertyValue("dirObjectFactory", "org.springframework.ldap.core.support.DefaultDirObjectFactory"); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user