Class EmbeddedLdapServerContextSourceFactoryBean

java.lang.Object
org.springframework.security.config.ldap.EmbeddedLdapServerContextSourceFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<DefaultSpringSecurityContextSource>, org.springframework.context.ApplicationContextAware

public class EmbeddedLdapServerContextSourceFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<DefaultSpringSecurityContextSource>, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationContextAware
Creates a DefaultSpringSecurityContextSource used to perform LDAP authentication and starts and in-memory LDAP server.
Since:
5.7
  • Constructor Details

    • EmbeddedLdapServerContextSourceFactoryBean

      public EmbeddedLdapServerContextSourceFactoryBean()
  • Method Details

    • fromEmbeddedLdapServer

      public static EmbeddedLdapServerContextSourceFactoryBean fromEmbeddedLdapServer()
      Create an EmbeddedLdapServerContextSourceFactoryBean that will use an embedded LDAP server to perform LDAP authentication. This requires a dependency on `com.unboundid:unboundid-ldapsdk`.
      Returns:
      the EmbeddedLdapServerContextSourceFactoryBean
    • setLdif

      public void setLdif(String ldif)
      Specifies an LDIF to load at startup for an embedded LDAP server. The default is "classpath*:*.ldif".
      Parameters:
      ldif - the ldif to load at startup for an embedded LDAP server.
    • setPort

      public void setPort(int port)
      The port to connect to LDAP to (the default is 33389 or random available port if unavailable). Supplying 0 as the port indicates that a random available port should be selected.
      Parameters:
      port - the port to connect to
    • setRoot

      public void setRoot(String root)
      Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org".
      Parameters:
      root - root suffix for the embedded LDAP server
    • setManagerDn

      public void setManagerDn(String managerDn)
      Username (DN) of the "manager" user identity (i.e. "uid=admin,ou=system") which will be used to authenticate to an LDAP server. If omitted, anonymous access will be used.
      Parameters:
      managerDn - the username (DN) of the "manager" user identity used to authenticate to a LDAP server.
    • setManagerPassword

      public void setManagerPassword(String managerPassword)
      The password for the manager DN. This is required if the setManagerDn(String) is specified.
      Parameters:
      managerPassword - password for the manager DN
    • getObject

      public DefaultSpringSecurityContextSource getObject() throws Exception
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<DefaultSpringSecurityContextSource>
      Throws:
      Exception
    • getObjectType

      public Class<?> getObjectType()
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<DefaultSpringSecurityContextSource>
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException