Spring Security 3.1和正确的罐子

Ste*_*eve 3 spring-security

我正在使用Spring 3.1,而且我是第一次使用LDAP.

这是我的*-security.xml:

<beans:beans xmlns="http://www.springframework.org/schema/security"
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.1.xsd">

  <http auto-config="true">
    <intercept-url pattern="/welcome*" access="ROLE_USER" />
    <form-login login-page="/login" default-target-url="/welcome"
      authentication-failure-url="/loginfailed" />
    <logout logout-success-url="/logout" />
  </http>

  <ldap-server url = "ldap://ldap-east.abc.acme.org:636/o=acme.org" />

    <authentication-manager>
      <ldap-authentication-provider user-dn-pattern="uid={0},ou=people"/>
    </authentication-manager>

</beans:beans>
Run Code Online (Sandbox Code Playgroud)

我在我的lib中开始使用这些与安全相关的jar:

spring-security-ldap-3.1.0.RELEASE.jar
spring-security-config-3.1.0.RELEASE.jar
spring-security-core-3.1.0.RELEASE.jar
spring-security-taglibs-3.1.0.RELEASE.jar
spring-security-web-3.1.0.RELEASE.jar
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息:

org.springframework.context.ApplicationContextException:找不到:org.springframework.ldap.core.support.BaseLdapPathContextSource.
如果您正在使用带有Spring Security的LDAP,请确保在您的应用程序中包含spring-ldap jar文件; 嵌套异常是java.lang.ClassNotFoundException:org.springframework.ldap.core.support.BaseLdapPathContextSource

所以,我在lib中添加了更多jar作为这组安全文件:

spring-ldap-core-1.3.1.RELEASE.jar
spring-ldap-core-tiger-1.3.1.RELEASE.jar
spring-security-ldap-3.1.0.RELEASE.jar
spring-security-config-3.1.0.RELEASE.jar
spring-security-core-3.1.0.RELEASE.jar
spring-security-taglibs-3.1.0.RELEASE.jar
spring-security-web-3.1.0.RELEASE.jar
Run Code Online (Sandbox Code Playgroud)

这让我更深入了解更多错误消息:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.filterChains': 
Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' 
while setting bean property 'sourceList' with key [0]; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': 
Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' 
while setting constructor argument with key [2]; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0':
Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' w
hile setting bean property 'authenticationManager'; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': 
Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' 
while setting constructor argument; nested exception is 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': 
FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.authenticationManager': 
Cannot resolve reference to bean 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0' 
while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0': 
Cannot create inner bean '(inner bean)' of type [org.springframework.security.ldap.authentication.BindAuthenticator] 
while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name '(inner bean)#17': Cannot resolve reference to bean 'org.springframework.security.securityContextSource' 
while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.securityContextSource': 
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Could not instantiate bean class [org.springframework.security.ldap.DefaultSpringSecurityContextSource]: 
Constructor threw exception; nested exception is java.lang.NoClassDefFoundE
Run Code Online (Sandbox Code Playgroud)

我正在赶上很多东西,学习Maven就在我的名单上,但我还没有.有关使用Spring 3.1进行基本LDAP身份验证的正确混合罐的任何提示?

我尝试加载整个Spring 3.1.1 dist,整个Spring LDAP 1.3.1 dist和整个Spring Security 3.1.0 dist.我有一切.所以我很遗憾看到这是一个依赖性问题,FWIW.

fmu*_*car 7

spring-security-config
spring-security-taglibs
spring-security-ldap
Run Code Online (Sandbox Code Playgroud)

那些3应该足够了,如果你使用maven或类似的工具他们将拉他们的dependendies.

如果没有,您需要遍历所有3个库并在类路径中复制所有依赖项.

依赖图