Overview

README:

What is this?

This is an example cross-product Atlassian plugin for Confluence & JIRA that demonstrates a trivial example of using the Spring LDAP framework to connect to a remote LDAP server from within a "plugins-2" plugin.

Currently it does not work in JIRA due to some missing OSGI exports (see JRA-29896).

NOTE: This is an example plugin for demonstration purposes only. It is not suitable for installation on a production server - use at your own risk!

How do I use it?

Run the plugin using the Atlassian Plugin SDK and then access the test LDAP servlet @ ${BASE_URL}/plugins/servlet/ldaptest.

In the current version of JIRA, accessing this servlet will cause an exception to be thrown when the Servlet plugin module is initialised, generating a stacktrace like this and showing a 404 Page to the user.

[INFO] [talledLocalContainer] 2012-10-11 17:42:25,359 http-2990-3 ERROR anonymous 1062x501x1 - 172.22.1.237 /plugins/servlet/ldaptest [atlassian.plugin.module.PrefixDelegatingModuleFactory] Detected an error (NoClassDefFoundError) instantiating the module for plugin 'com.example.ldap.example-ldap-plugin' for module 'ldap-servlet': org/springframework/ldap/core/ContextSource.  This error is usually caused by your plugin using a imported component class that itself relies on other packages in the product. You can probably fix this by adding the missing class's package to your <Import-Package> instructions; for more details on how to fix this, see http://confluence.atlassian.com/x/QRS-Cg .
[INFO] [talledLocalContainer] 2012-10-11 17:42:25,361 http-2990-3 ERROR anonymous 1062x501x1 - 172.22.1.237 /plugins/servlet/ldaptest [atlassian.plugin.servlet.DefaultServletModuleManager] Unable to create servlet
[INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.NoClassDefFoundError: org/springframework/ldap/core/ContextSource
[INFO] [talledLocalContainer]   at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:152)
[INFO] [talledLocalContainer]   at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:115)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:344)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:147)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:41)
[INFO] [talledLocalContainer]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
...
[INFO] [talledLocalContainer] Caused by: java.lang.NoClassDefFoundError: org/springframework/ldap/core/ContextSource
[INFO] [talledLocalContainer]   at java.lang.Class.getDeclaredConstructors0(Native Method)
[INFO] [talledLocalContainer]   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
[INFO] [talledLocalContainer]   at java.lang.Class.getConstructors(Class.java:1459)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractBeanDefinition.getResolvedAutowireMode(AbstractBeanDefinition.java:520)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:832)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
...
[INFO] [talledLocalContainer] Caused by: java.lang.ClassNotFoundException: org.springframework.ldap.core.ContextSource
[INFO] [talledLocalContainer]   at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
[INFO] [talledLocalContainer]   at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
...

In Confluence (and JIRA if JRA-29896 is fixed) you'll see an HTML form where you can input connection details for an LDAP server. Atlassians can use their EAC-Crowd credentials to connect to extranet-ldap.private.atlassian.com. Hitting submit will invoke Spring LDAP to connect to the specified LDAP server and list and the Person objects identified within the Base DN.