Package org.apache.directory.server.core

Examples of org.apache.directory.server.core.DirectoryService



    public void testDoubleBypass() throws Exception
    {
        LdapDN dn = new LdapDN( "ou=system" );
        DirectoryService ds = new MockDirectoryService();
        DefaultCoreSession session = new DefaultCoreSession(
            new LdapPrincipal( new LdapDN(), AuthenticationLevel.STRONG ), ds );
        LookupOperationContext opContext = new LookupOperationContext( session, dn );
        Set<String> bypass = new HashSet<String>();
        bypass.add( "1" );
View Full Code Here



    public void testCompleteBypass() throws Exception
    {
        LdapDN dn = new LdapDN( "ou=system" );
        DirectoryService ds = new MockDirectoryService();
        DefaultCoreSession session = new DefaultCoreSession(
            new LdapPrincipal( new LdapDN(), AuthenticationLevel.STRONG ), ds );
        LookupOperationContext opContext = new LookupOperationContext( session, dn );
        opContext.setByPassed( ByPassConstants.BYPASS_ALL_COLLECTION );
        InvocationStack.getInstance().push( opContext );
View Full Code Here

        LdapDN principalDn = new LdapDN( getPrincipal( env ) );
        byte[] credential = getCredential( env );
        String authentication = getAuthentication( env );
        String providerUrl = getProviderUrl( env );

        DirectoryService service = ( DirectoryService ) env.get( DirectoryService.JNDI_KEY );

        if ( service == null )
        {
            throw new ConfigurationException( "Cannot find directory service in environment: " + env );
        }

        if ( ! service.isStarted() )
        {
            return new DeadContext();
        }

        ServerLdapContext ctx = null;
        try
        {
            CoreSession session = service.getSession( principalDn, credential );
            ctx = new ServerLdapContext( service, session, new LdapDN( providerUrl ) );
        }
        catch ( Exception e )
        {
            JndiUtils.wrap( e );
View Full Code Here

     */
    public static class Factory implements DirectoryServiceFactory
    {
        public DirectoryService newInstance() throws Exception
        {
            DirectoryService service = new DefaultDirectoryService();
            service.getChangeLog().setEnabled( true );
           
            Partition foo = new JdbmPartition();
            foo.setId( "foo" );
            foo.setSuffix( "dc=foo,dc=com" );
            service.addPartition( foo );
           
            Partition bar = new JdbmPartition();
            bar.setId( "bar" );
            bar.setSuffix( "dc=bar,dc=com" );
            service.addPartition( bar );
           
            return service;
        }
View Full Code Here

        ClonedServerEntry dsEntry = configPartition.lookup( forwardEntry.getId() );

        LOG.debug( "directory service entry {}", dsEntry );

        DirectoryService dirService = new DefaultDirectoryService();
        // MUST attributes
        dirService.setInstanceId( getString( "ads-directoryServiceId", dsEntry ) );
        dirService.setReplicaId( getInt( "ads-dsReplicaId", dsEntry ) );

        DN interceptorsDN = new DN( dsEntry.get( "ads-dsInterceptors" ).getString() );
        interceptorsDN.normalize( configPartition.getSchemaManager().getNormalizerMapping() );
        List<Interceptor> interceptors = getInterceptors( interceptorsDN );
        dirService.setInterceptors( interceptors );

        DN partitionsDN = new DN( dsEntry.get( "ads-dsPartitions" ).getString() );
        partitionsDN.normalize( configPartition.getSchemaManager().getNormalizerMapping() );

        Map<String, Partition> partitions = getPartitions( partitionsDN );

        Partition systemPartition = partitions.remove( "system" );

        if ( systemPartition == null )
        {
            throw new Exception( I18n.err( I18n.ERR_505 ) );
        }

        dirService.setSystemPartition( systemPartition );
        dirService.setPartitions( new HashSet<Partition>( partitions.values() ) );

        // MAY attributes
        EntryAttribute acEnabledAttr = dsEntry.get( "ads-dsAccessControlEnabled" );

        if ( acEnabledAttr != null )
        {
            dirService.setAccessControlEnabled( Boolean.parseBoolean( acEnabledAttr.getString() ) );
        }

        EntryAttribute anonAccessAttr = dsEntry.get( "ads-dsAllowAnonymousAccess" );

        if ( anonAccessAttr != null )
        {
            dirService.setAllowAnonymousAccess( Boolean.parseBoolean( anonAccessAttr.getString() ) );
        }

        EntryAttribute changeLogAttr = dsEntry.get( "ads-dsChangeLog" );

        if ( changeLogAttr != null )
        {
            DN clDN = new DN( changeLogAttr.getString() );
            clDN.normalize( schemaManager.getNormalizerMapping() );
            ChangeLog cl = getChangeLog( clDN );
            dirService.setChangeLog( cl );
        }

        EntryAttribute denormAttr = dsEntry.get( "ads-dsDenormalizeOpAttrsEnabled" );

        if ( denormAttr != null )
        {
            dirService.setDenormalizeOpAttrsEnabled( Boolean.parseBoolean( denormAttr.getString() ) );
        }

        EntryAttribute journalAttr = dsEntry.get( "ads-dsJournal" );

        if ( journalAttr != null )
        {
            DN journalDN = new DN( journalAttr.getString() );
            journalDN.normalize( schemaManager.getNormalizerMapping() );
            dirService.setJournal( getJournal( journalDN ) );
        }

        EntryAttribute maxPduAttr = dsEntry.get( "ads-dsMaxPDUSize" );

        if ( maxPduAttr != null )
        {
            dirService.setMaxPDUSize( Integer.parseInt( maxPduAttr.getString() ) );
        }

        EntryAttribute passwordHidAttr = dsEntry.get( "ads-dsPasswordHidden" );

        if ( passwordHidAttr != null )
        {
            dirService.setPasswordHidden( Boolean.parseBoolean( passwordHidAttr.getString() ) );
        }

        EntryAttribute replAttr = dsEntry.get( "ads-dsReplication" );

        if ( replAttr != null )
        {
            // configure replication
        }

        EntryAttribute syncPeriodAttr = dsEntry.get( "ads-dsSyncPeriodMillis" );

        if ( syncPeriodAttr != null )
        {
            // FIXME the DirectoryService interface doesn't have this setter
            //dirService.setSyncPeriodMillis( Long.parseLong( syncPeriodAttr.getString() ) );
        }

        EntryAttribute testEntryAttr = dsEntry.get( "ads-dsTestEntries" );

        if ( testEntryAttr != null )
        {
            String entryFilePath = testEntryAttr.getString();
            dirService.setTestEntries( getTestEntries( entryFilePath ) );
        }

        if ( !isEnabled( dsEntry ) )
        {
            // will only be useful if we ever allow more than one DS to be configured and
View Full Code Here

            apacheDS = ( ApacheDS ) factory.getBean( "apacheDS" ); //$NON-NLS-1$
        }
        else
        {
            LOG.info( "server: using default settings ..." ); //$NON-NLS-1$
            DirectoryService directoryService = new DefaultDirectoryService();
            directoryService.startup();
            ldapServer = new LdapServer();
            ldapServer.setDirectoryService( directoryService );
            TcpTransport tcpTransportSsl = new TcpTransport( 10636 );
            tcpTransportSsl.enableSSL( true );
            ldapServer.setTransports( new TcpTransport( 10389 ), tcpTransportSsl );
View Full Code Here

        DN principalDn = new DN( getPrincipal( env ) );
        byte[] credential = getCredential( env );
        String authentication = getAuthentication( env );
        String providerUrl = getProviderUrl( env );

        DirectoryService service = ( DirectoryService ) env.get( DirectoryService.JNDI_KEY );

        if ( service == null )
        {
            throw new ConfigurationException( I18n.err( I18n.ERR_477, env ) );
        }

        if ( ! service.isStarted() )
        {
            return new DeadContext();
        }

        ServerLdapContext ctx = null;
        try
        {
            CoreSession session = service.getSession( principalDn, credential );
            ctx = new ServerLdapContext( service, session, new DN( providerUrl ) );
        }
        catch ( Exception e )
        {
            JndiUtils.wrap( e );
View Full Code Here

     */
    Thread.sleep( 65000 );
  }

  private static void shutdownRunningServers() throws NamingException {
    DirectoryService ds = DirectoryService.getInstance();
    ds.shutdown();
  }
View Full Code Here

        { @CreateTransport( port=16000, protocol = "LDAP") })
    private static void startProvider() throws Exception
    {
        Method createProviderMethod = ClientServerReplicationIT.class.getDeclaredMethod( "startProvider" );
        CreateDS dsAnnotation = createProviderMethod.getAnnotation( CreateDS.class );
        DirectoryService provDirService = DSAnnotationProcessor.createDS( dsAnnotation );

        CreateLdapServer serverAnnotation = createProviderMethod.getAnnotation( CreateLdapServer.class );

        providerServer = ServerAnnotationProcessor.instantiateLdapServer( serverAnnotation, provDirService, 0 );
       
View Full Code Here

        { @CreateTransport( port=17000, protocol = "LDAP") })
    private static void startConsumer() throws Exception
    {
        Method createProviderMethod = ClientServerReplicationIT.class.getDeclaredMethod( "startConsumer" );
        CreateDS dsAnnotation = createProviderMethod.getAnnotation( CreateDS.class );
        DirectoryService provDirService = DSAnnotationProcessor.createDS( dsAnnotation );

        CreateLdapServer serverAnnotation = createProviderMethod.getAnnotation( CreateLdapServer.class );

        consumerServer = ServerAnnotationProcessor.instantiateLdapServer( serverAnnotation, provDirService, 0 );
       
        SyncReplConsumer syncreplClient = new SyncReplConsumer();
        final SyncreplConfiguration config = new SyncreplConfiguration();
        config.setProviderHost( "localhost" );
        config.setPort( 16000 );
        config.setReplUserDn( "uid=admin,ou=system" );
        config.setReplUserPassword( "secret".getBytes() );
        config.setUseTls( false );
        config.setBaseDn( "dc=example,dc=com" );
        config.setRefreshInterval( 1000 );
       
        syncreplClient.setConfig( config );
       
        List<ReplicationConsumer> replConsumers = new ArrayList<ReplicationConsumer>();
        replConsumers.add( syncreplClient );
       
        consumerServer.setReplConsumers( replConsumers );
       
        Runnable r = new Runnable()
        {
            public void run()
            {
                try
                {
                    consumerServer.start();
                   
                    DirectoryService ds = consumerServer.getDirectoryService();
                   
                    Dn configDn = new Dn( ds.getSchemaManager(), "ads-replProviderId=localhost,ou=system" );
                    config.setConfigEntryDn( configDn );
                   
                    Entry provConfigEntry = new DefaultEntry( ds.getSchemaManager(), configDn );
                    provConfigEntry.add( "objectClass", "ads-replConsumer" );
                    provConfigEntry.add( "ads-replConsumerId", "localhost" );
                    provConfigEntry.add( "ads-searchBaseDN", config.getBaseDn() );
                    provConfigEntry.add( "ads-replProvHostName", config.getProviderHost() );
                    provConfigEntry.add( "ads-replProvPort", String.valueOf( config.getPort() ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.server.core.DirectoryService

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.