Package org.apache.directory.server.ldap

Examples of org.apache.directory.server.ldap.LdapServer


        {
            LOG.info( "server: using default settings ..." );
            DirectoryService directoryService = new DefaultDirectoryService();
            directoryService.startup();
            SocketAcceptor socketAcceptor = new SocketAcceptor( null );
            LdapServer ldapServer = new LdapServer();
            ldapServer.setSocketAcceptor( socketAcceptor );
            ldapServer.setDirectoryService( directoryService );
            ldapServer.start();
            LdapServer ldapsServer = new LdapServer();
            ldapsServer.setEnableLdaps( true );
            ldapsServer.setSocketAcceptor( socketAcceptor );
            ldapsServer.setDirectoryService( directoryService );
            ldapsServer.start();
            apacheDS = new ApacheDS( directoryService, ldapServer, ldapsServer );
        }

        if ( install != null )
        {
View Full Code Here


            service.setExitVmOnShutdown(false);
            service.setShutdownHookEnabled(false);
            service.getChangeLog().setEnabled(false);
            service.startup();

            server = new LdapServer();
            server.setTransports(new TcpTransport("localhost", serverPort));
            server.setDirectoryService(service);
            server.start();

            createRoot(partition);
View Full Code Here

        return partition;
    }

    public void configureLdapServer(final int port) throws Exception
    {
        ldapService = new LdapServer();
        ldapService.setTransports(new TcpTransport(port));
        ldapService.setDirectoryService(service);

        apacheDs = new ApacheDS(ldapService);
    }
View Full Code Here

          entryExo.add( "dc", "exoplatform" );
          service.getAdminSession().add( entryExo );
      }

      port = AvailablePortFinder.getNextAvailable(1024);
      server = new LdapServer();
      server.setTransports( new TcpTransport(port));
      server.setDirectoryService(service);
      server.start();

      // server launched and configured
View Full Code Here

            partition.setSuffixDn(new Dn(service.getSchemaManager(),
                    getRoot()));
            partition.initialize();
            service.addPartition(partition);

            server = new LdapServer();
            server.setTransports(new TcpTransport("localhost", getServerPort()));
            server.setDirectoryService(service);

            service.startup();
            server.start();
View Full Code Here

        processLdif(schemaManager, adminSession, "partition.ldif", mappings);
        processLdif(schemaManager, adminSession, "krbtgt.ldif", mappings);
        processLdif(schemaManager, adminSession, "user.ldif", mappings);
        processLdif(schemaManager, adminSession, "server.ldif", mappings);

        ldapServer = new LdapServer();
        ldapServer.setServiceName("DefaultLDAP");
        Transport ldap = new TcpTransport( "0.0.0.0", LDAP_PORT, 3, 5 );
        ldapServer.addTransports(ldap);
        ldapServer.setDirectoryService(directoryService);
        ldapServer.start();
View Full Code Here

        Entry result;
        try {
            initDirectoryService(sce.getServletContext(), workDir, loadDefaultContent);

            server = new LdapServer();
            server.setTransports(
                    new TcpTransport(Integer.valueOf(sce.getServletContext().getInitParameter("testds.port"))));
            server.setDirectoryService(service);

            server.start();
View Full Code Here

            is.close();

        }

        // service LDAP :
        server = new LdapServer();
        // int serverPort = 10389;
        int serverPort = 389;
        server.setTransports(new TcpTransport(serverPort));
        server.setDirectoryService(service);
View Full Code Here

        }
       
        assertTrue( service.getAdminSession().exists( new Dn( "dc=example,dc=com" ) ) );

        // Now, get the server
        LdapServer ldapServer = ServerAnnotationProcessor.createLdapServer( service, AvailablePortFinder
            .getNextAvailable( 1024 ) );

        // Check that the server is running
        assertTrue( ldapServer.isStarted() );
       
        // Try to read an entry in the server
        LdapContext ctx = ( LdapContext ) getWiredContext( ldapServer, null ).lookup( "dc=example,dc=com" );
        SearchControls controls = new SearchControls();
        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
        controls.setReturningAttributes( new String[]{"*"} );
       
        NamingEnumeration<SearchResult> enumeration = ctx.search( "", "(objectClass=*)", controls );
       
        // collect all results
        HashSet<String> results = new HashSet<String>();
       
        while ( enumeration.hasMore() )
        {
            SearchResult result = enumeration.next();
            results.add( result.getNameInNamespace() );
        }
       
        assertEquals( 1, results.size() );
        assertTrue( results.contains( "dc=example,dc=com" ) );

        enumeration.close();
        ctx.close();
        ldapServer.stop();
        service.shutdown();
       
        FileUtils.deleteDirectory( service.getInstanceLayout().getInstanceDirectory() );
    }
View Full Code Here

     */
    public static LdapServer instantiateLdapServer( CreateLdapServer createLdapServer, DirectoryService directoryService, int startPort )
    {
        if ( createLdapServer != null )
        {
            LdapServer ldapServer = new LdapServer();
           
            ldapServer.setServiceName( createLdapServer.name() );
           
            // Read the transports
            createTransports( ldapServer, createLdapServer.transports(), startPort );
           
            // Associate the DS to this LdapServer
            ldapServer.setDirectoryService( directoryService );
           
            ldapServer.setSaslHost( createLdapServer.saslHost() );
           
            ldapServer.setSaslPrincipal( createLdapServer.saslPrincipal() );
           
            if( !Strings.isEmpty( createLdapServer.keyStore() ) )
            {
                ldapServer.setKeystoreFile( createLdapServer.keyStore() );
                ldapServer.setCertificatePassword( createLdapServer.certificatePassword() );
            }
           
            for( Class<?> extOpClass : createLdapServer.extendedOpHandlers() )
            {
                try
                {
                    ExtendedOperationHandler extOpHandler = ( ExtendedOperationHandler ) extOpClass.newInstance();
                    ldapServer.addExtendedOperationHandler( extOpHandler );
                }
                catch( Exception e )
                {
                    throw new RuntimeException( I18n.err( I18n.ERR_690, extOpClass.getName() ), e );
                }
            }
           
            for( SaslMechanism saslMech : createLdapServer.saslMechanisms() )
            {
                try
                {
                    MechanismHandler handler = ( MechanismHandler ) saslMech.implClass().newInstance();
                    ldapServer.addSaslMechanismHandler( saslMech.name(), handler );
                }
                catch( Exception e )
                {
                    throw new RuntimeException( I18n.err( I18n.ERR_691, saslMech.name(), saslMech.implClass().getName() ), e );
                }
            }
           
            NtlmMechanismHandler ntlmHandler = ( NtlmMechanismHandler ) ldapServer.getSaslMechanismHandlers().get( SupportedSaslMechanisms.NTLM );
            if( ntlmHandler != null )
            {
                Class<?> ntlmProviderClass = createLdapServer.ntlmProvider();
                // default value is a invalid Object.class
                if( ( ntlmProviderClass != null ) && ( ntlmProviderClass != Object.class ) )
View Full Code Here

TOP

Related Classes of org.apache.directory.server.ldap.LdapServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.