Results 1 to 2 of 2

Thread: Configuring spring-ldap to use weblogic ldap context

  1. #1
    Join Date
    Apr 2008
    Posts
    12

    Default Configuring spring-ldap to use weblogic ldap context

    Greetings,

    Most of the examples i've found that show using spring-ldap to authenticate users, show examples using spring xml files to specify the context, such as

    <bean id="contextSource" class="org.springframework.ldap.core.support.LdapC ontextSource">
    <!-- Figure out how to connect to WebLogic's LDAP security realm -->
    <property name="url" value="ldap://url.to.ldap.server:389" />
    <property name="userDn" value="uid=admin,ou=system" />
    <property name="password" value="adminpassword" />
    </bean>

    seen here: http://blog.jayway.com/2009/02/02/si...g-spring-ldap/

    I don't really understand this model, as this configuration means building it into a war file that is only clumsily available by users.

    what i want is for spring-ldap to configure itself with the application server's information, specifically in WebLogic the LDAP server specified in a security realm.

    Are there any samples of how one goes about doing this that i could look at?

    EDIT::

    OK, so here's my attempt at this, I could be completely off base, and probably am but..

    In my Spring.xml file i have

    <bean id="contextSource" class="com.acme.security.WebLogicContextSource">
    </bean>

    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
    <constructor-arg ref="contextSource" />
    </bean>

    <bean id="authenticator" class="com.acme.security.Authenticator" >
    <property name="ldapTemplate" ref="ldapTemplate" />
    </bean>

    Where WebLogicContextSource is

    public class WebLogicContextSource extends LdapContextSource {

    @Override
    public void afterPropertiesSet() throws Exception {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    Set<ObjectName> names = mbs.queryNames(null, null);
    for (ObjectName name : names) {
    System.out.println(name.getCanonicalName());
    }

    super.afterPropertiesSet();
    }

    }

    I was hoping to override LdapContextSource, use JMX to look up the url, credentials, etc of the ldap server in use, and then call setters in the parent to set the values.

    But break points aren't hitting in afterPropertiesSet, and instead i see

    Error creating bean with name 'contextSource' defined in ServletContext resource [/WEB-INF/ldap-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one server url must be set

    Now i would have thought that if i overrode afterPropertiesSet and had a break point there, i wouldn't get this error message (yet).

    Obviously my afterPropertiesSet currently isn't doing anything about setting the serviceUrl and that has to be done, but as i have no idea how all this works i tossed in some debug code to try to figure it out. But I would have assumed that break points would be hit.

    Can anyone point in me in the right direction?



    thanks
    dave
    Last edited by dbrosius; Apr 5th, 2011 at 03:57 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    12

    Default BreakPoints in afterPropertiesSet

    OK, so the exact problem here is that for some reason breakpoints are not being hit in this method, but it is being called. So i guess i can try to continue.

    I am able to pull properties defined in weblogic, and built ldap urls etc. This probably will work, but i realize that perhaps i can just get weblogic to authenticate users through some jmx operation.


    Alas, I don't see anything like this tho... Am i missing something? I guess the question is off topic for a spring forum, tho. oh well.
    Last edited by dbrosius; Apr 6th, 2011 at 08:10 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •