@ Override public void start ( final Logger logger ) { try { logger . logInfo ( "Starting UnboundID server" ) ; final InMemoryListenerConfig listenerConfig = InMemoryListenerConfig . createLDAPConfig ( "default" , getServerPort ( ) ) ; final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig ( new DN ( getRoot ( ) ) ) ; config . setListenerConfigs ( listenerConfig ) ; if ( getAuthDn ( ) != null ) { config . addAdditionalBindCredentials ( getAuthDn ( ) , getPasswd ( ) ) ; } server = new InMemoryDirectoryServer ( config ) ; String [ ] objectClasses = getObjectClasses ( ) ; if ( objectClasses == null ) { objectClasses = DEFAULT_ROOT_OBJECT_CLASSES ; } server . add ( new Entry ( getRoot ( ) , new Attribute ( "objectclass" , objectClasses ) ) ) ; if ( getLdifFile ( ) != null ) { final InputStream in = new FileInputStream ( getLdifFile ( ) ) ; try { final LDIFReader reader = new LDIFReader ( in ) ; server . importFromLDIF ( false , reader ) ; } finally { in . close ( ) ; } } server . startListening ( ) ; logger . logInfo ( "Started UnboundID server" ) ; } catch ( final LDAPException e ) { e . printStackTrace ( ) ; logger . logError ( "Could not launch embedded UnboundID directory server" , e ) ; } catch ( final IOException e ) { e . printStackTrace ( ) ; logger . logError ( "Could not launch embedded UnboundID directory server" , e ) ; } }
Configure and start the embedded UnboundID server creating the root DN and loading the LDIF seed data .