views:

846

answers:

4

Hi,

I want to authenticate users against our AD so I understand that I need spring security and spring ldap.

Here is what is in my POM:

<groupId>org.springframework.security</groupId>
<artifactId>org.springframework.security.core</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
...
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.3.0.RELEASE</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>

Here are the respective entries from my secruity-context:

<ldap-authentication-provider user-dn-pattern="CN=0},OU=CAN,OU=NOT,OU=TELL,OU=YOU"/>
    ..  
<!-- LDAP Security Configuration -->
<ldap-server url="ldap://10.9.1.1:389/DC=TELL,DC=YOU"/>

However when I run my application using:

mvn jetty:run

I get following error:

If you are using LDAP with Spring Security, please ensure that you include the spring-ldap jar file in your application; nested exception is java.lang.ClassNotFoundException: org.springframework.ldap.core.support.BaseLdapPathContextSource:
java.lang.ClassNotFoundException: org.springframework.ldap.core.support.BaseLdapPathContextSource
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
    at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:375)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
    at org.springframework.security.config.ldap.ContextSourceSettingPostProcessor.postProcessBeanFactory(ContextSourceSettingPostProcessor.java:33)
+2  A: 

A dependency of type pom won't provide any classes. Use this dependency instead:

<dependency>
  <groupId>org.springframework.ldap</groupId>
  <artifactId>spring-ldap-core</artifactId>
  <version>1.3.0.RELEASE</version>
</dependency>

This artifact contains the o.s.l.c.s.BaseLdapPathContextSource class which is currently missing.

Pascal Thivent
+1  A: 

<type>pom</type> looks fishy to me. Try changing the type to jar

Vinnie
A: 

Thanks, Pascal! I figured that out just a few secs ago. Now I have a new Problem:

mvn clean package
Listening for transport dt_socket at address: 8000
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building sc
[INFO]    task-segment: [clean, package]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
Downloading: http://repository.springsource.com/maven/bundles/release/org/springframework/ldap/spring-ldap/1.3.0.RELEASE/spring-ldap-1.3.0.RELEASE.jar
Downloading: http://repository.springsource.com/maven/bundles/external/org/springframework/ldap/spring-ldap/1.3.0.RELEASE/spring-ldap-1.3.0.RELEASE.jar
Downloading: http://repository.springsource.com/maven/bundles/milestone/org/springframework/ldap/spring-ldap/1.3.0.RELEASE/spring-ldap-1.3.0.RELEASE.jar
Downloading: http://repository.springsource.com/maven/bundles/snapshot/org/springframework/ldap/spring-ldap/1.3.0.RELEASE/spring-ldap-1.3.0.RELEASE.jar
Downloading: http://repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.0.RELEASE/spring-ldap-1.3.0.RELEASE.jar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
er4z0r
Please, add this kind of details to the initial question (and drop a comment or people don't get notified). Anyway, the problem is that you didn't apply my answer accurately, you are still trying to download `spring-ldap` while I explicitly wrote to use `spring-ldap-core`.
Pascal Thivent
Ummm. Yes. Just reread the docs at spring-ldap. Good old RTFM in combination with a great forum made the day. Again ;-)
er4z0r
+1  A: 

Just for the sake of completeness. Here is a list of dependencies that works for me:

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>org.springframework.security.core</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>org.springframework.security.config</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>org.springframework.security.web</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>org.springframework.security.taglibs</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core-tiger</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
        <version>3.0.1.RELEASE</version>
    </dependency>
er4z0r