Package org.apache.directory.server.ldap.replication

Examples of org.apache.directory.server.ldap.replication.SyncReplConfiguration


     */
    private static ReplicationConsumer createConsumer( CreateConsumer createConsumer )
    {
        ReplicationConsumer consumer = new ReplicationConsumerImpl();

        SyncreplConfiguration config = new SyncreplConfiguration();
        config.setRemoteHost( createConsumer.remoteHost() );
        config.setRemotePort( createConsumer.remotePort() );
        config.setReplUserDn( createConsumer.replUserDn() );
        config.setReplUserPassword( Strings.getBytesUtf8( createConsumer.replUserPassword() ) );
        config.setUseTls( createConsumer.useTls() );
        config.setBaseDn( createConsumer.baseDn() );
        config.setRefreshInterval( createConsumer.refreshInterval() );

        consumer.setConfig( config );

        return consumer;
    }
View Full Code Here


        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() ) );
                    provConfigEntry.add( "ads-replAliasDerefMode", config.getAliasDerefMode().getJndiValue() );
                    provConfigEntry.add( "ads-replAttributes", config.getAttributes() );
                    provConfigEntry.add( "ads-replRefreshInterval", String.valueOf( config.getRefreshInterval() ) );
                    provConfigEntry.add( "ads-replRefreshNPersist", String.valueOf( config.isRefreshNPersist() ) );
                    provConfigEntry.add( "ads-replSearchScope", config.getSearchScope().getLdapUrlValue() );
                    provConfigEntry.add( "ads-replSearchFilter", config.getFilter() );
                    provConfigEntry.add( "ads-replSearchSizeLimit", String.valueOf( config.getSearchSizeLimit() ) );
                    provConfigEntry.add( "ads-replSearchTimeOut", String.valueOf( config.getSearchTimeout() ) );
                    provConfigEntry.add( "ads-replUserDn", config.getReplUserDn() );
                    provConfigEntry.add( "ads-replUserPassword", config.getReplUserPassword() );
                   
                    consumerSession = consumerServer.getDirectoryService().getAdminSession();
                    consumerSession.add( provConfigEntry );
                }
                catch( Exception e )
View Full Code Here

        {
            String className = replBean.getReplConsumerImpl();
           
            ReplicationConsumer consumer = null;
            Class<?> consumerClass = null;
            SyncreplConfiguration config = null;
           
            try
            {
                if( className == null )
                {
                    consumerClass = SyncReplConsumer.class;
                }
                else
                {
                    consumerClass = Class.forName( className );
                }
               
                consumer = ( ReplicationConsumer ) consumerClass.newInstance();
               
                // we don't support any other configuration impls atm, but this configuration should suffice for many needs
                config = new SyncreplConfiguration();

                config.setBaseDn( replBean.getSearchBaseDn() );
                config.setProviderHost( replBean.getReplProvHostName() );
                config.setPort( replBean.getReplProvPort() );
                config.setAliasDerefMode( AliasDerefMode.getDerefMode( replBean.getReplAliasDerefMode() ) );
                config.setAttributes( replBean.getReplAttributes().toArray( new String[0] ) );
                config.setRefreshInterval( replBean.getReplRefreshInterval() );
                config.setRefreshNPersist( replBean.isReplRefreshNPersist() );
               
                int scope = SearchScope.getSearchScope( replBean.getReplSearchScope() );
                config.setSearchScope( SearchScope.getSearchScope( scope ) );
               
                config.setFilter( replBean.getReplSearchFilter() );
                config.setSearchTimeout( replBean.getReplSearchTimeOut() );
                config.setReplUserDn( replBean.getReplUserDn() );
                config.setReplUserPassword( replBean.getReplUserPassword() );
               
                config.setUseTls( replBean.isReplUseTls() );
                config.setStrictCertVerification( replBean.isReplStrictCertValidation() );
               
                config.setConfigEntryDn( replBean.getDn() );
               
                if ( replBean.getReplPeerCertificate() != null )
                {
                    ReplicationTrustManager.addCertificate( replBean.getReplConsumerId(), replBean.getReplPeerCertificate() );
                }
View Full Code Here

TOP

Related Classes of org.apache.directory.server.ldap.replication.SyncReplConfiguration

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.