Package org.apache.ldap.server.configuration

Examples of org.apache.ldap.server.configuration.ServerStartupConfiguration


     */
    public static void main( String[] args ) throws Exception
    {
        long startTime = System.currentTimeMillis();
        Properties env;
        ServerStartupConfiguration cfg;

        if ( args.length > 0 )
        {
            log.info( "server: loading settings from " + args[0] );
            ApplicationContext factory = new FileSystemXmlApplicationContext( args[0] );
            cfg = ( ServerStartupConfiguration ) factory.getBean( "configuration" );
            env = ( Properties ) factory.getBean( "environment" );
        }
        else
        {
            log.info( "server: using default settings ..." );
            env = new Properties();
            cfg = new MutableServerStartupConfiguration();
        }

        env.setProperty( Context.PROVIDER_URL, "ou=system" );
        env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
        env.putAll( cfg.toJndiEnvironment() );

        new InitialDirContext( env );

        if (log.isInfoEnabled())
        {
View Full Code Here


    }


    public void afterStartup( DirectoryService service ) throws NamingException
    {
        ServerStartupConfiguration cfg =
            ( ServerStartupConfiguration ) service.getConfiguration().getStartupConfiguration();
        Hashtable env = service.getConfiguration().getEnvironment();

        loadLdifs( service );

        if ( cfg.isEnableNetworking() )
        {
            setupRegistry( cfg );
            startLdapProtocol( cfg, env );

            if ( cfg.isEnableKerberos() )
            {
                try
                {
                    KdcConfiguration kdcConfiguration = new KdcConfiguration( env, LoadStrategy.PROPS );
                    PrincipalStore kdcStore = new JndiPrincipalStoreImpl( kdcConfiguration, this );
                    kdcServer = new KerberosServer( kdcConfiguration, minaRegistry, kdcStore );
                }
                catch ( Throwable t )
                {
                    log.error( "Failed to start the Kerberos service", t );
                }
            }

            if ( cfg.isEnableChangePassword() )
            {
                try
                {
                    ChangePasswordConfiguration changePasswordConfiguration = new ChangePasswordConfiguration( env, LoadStrategy.PROPS );
                    PrincipalStore store = new JndiPrincipalStoreImpl( changePasswordConfiguration, this );
                    changePasswordServer = new ChangePasswordServer( changePasswordConfiguration, minaRegistry, store );
                }
                catch ( Throwable t )
                {
                    log.error( "Failed to start the Change Password service", t );
                }
            }

            if ( cfg.isEnableNtp() )
            {
                try
                {
                    NtpConfiguration ntpConfig = new NtpConfiguration( env, LoadStrategy.PROPS );
                    ntpServer = new NtpServer( ntpConfig, minaRegistry );
View Full Code Here

    }


    private void loadLdifs( DirectoryService service ) throws NamingException
    {
        ServerStartupConfiguration cfg =
            ( ServerStartupConfiguration ) service.getConfiguration().getStartupConfiguration();

        // log and bail if property not set
        if ( cfg.getLdifDirectory() == null )
        {
            log.info( "LDIF load directory not specified.  No LDIF files will be loaded." );
            return;
        }

        // log and bail if LDIF directory does not exists
        if ( !cfg.getLdifDirectory().exists() )
        {
            log.warn( "LDIF load directory '" + getCanonical( cfg.getLdifDirectory() )
                    + "' does not exist.  No LDIF files will be loaded.");
            return;
        }

        // get an initial context to the rootDSE for creating the LDIF entries
        Hashtable env = ( Hashtable ) service.getConfiguration().getEnvironment().clone();
        env.put( Context.PROVIDER_URL, "" );
        DirContext root = ( DirContext ) this.getInitialContext( env );

        // make sure the configuration area for loaded ldif files is present
        ensureLdifFileBase( root );

        // if ldif directory is a file try to load it
        if ( !cfg.getLdifDirectory().isDirectory() )
        {
            log.info( "LDIF load directory '" + getCanonical( cfg.getLdifDirectory() )
                    + "' is a file.  Will attempt to load as LDIF." );
            Attributes fileEntry = getLdifFileEntry( root, cfg.getLdifDirectory() );
            if ( fileEntry != null )
            {
                String time = ( String ) fileEntry.get( "createTimestamp" ).get();
                log.info( "Load of LDIF file '" + getCanonical( cfg.getLdifDirectory() )
                        + "' skipped.  It has already been loaded on " + time + "." );
                return;
            }
            LdifFileLoader loader = new LdifFileLoader( root, cfg.getLdifDirectory(), cfg.getLdifFilters() );
            loader.execute();

            addFileEntry( root, cfg.getLdifDirectory() );
            return;
        }

        // get all the ldif files within the directory (should be sorted alphabetically)
        File[] ldifFiles = cfg.getLdifDirectory().listFiles( new FileFilter()
        {
            public boolean accept( File pathname )
            {
                boolean isLdif = pathname.getName().toLowerCase().endsWith( ".ldif" );
                return pathname.isFile() && pathname.canRead() && isLdif;
            }
        });

        // log and bail if we could not find any LDIF files
        if ( ldifFiles == null || ldifFiles.length == 0 )
        {
            log.warn( "LDIF load directory '" + getCanonical( cfg.getLdifDirectory() )
                    + "' does not contain any LDIF files.  No LDIF files will be loaded.");
            return;
        }

        // load all the ldif files and load each one that is loaded
        for ( int ii = 0; ii < ldifFiles.length; ii++ )
        {
            Attributes fileEntry = getLdifFileEntry( root, ldifFiles[ii] );
            if ( fileEntry != null )
            {
                String time = ( String ) fileEntry.get( "createTimestamp" ).get();
                log.info( "Load of LDIF file '" + getCanonical( ldifFiles[ii] )
                        + "' skipped.  It has already been loaded on " + time + "." );
                continue;
            }
            LdifFileLoader loader = new LdifFileLoader( root, ldifFiles[ii], cfg.getLdifFilters() );
            int count = loader.execute();
            log.info( "Loaded " + count + " entries from LDIF file '" + getCanonical( ldifFiles[ii] ) + "'" );
            if ( fileEntry == null )
            {
                addFileEntry( root, ldifFiles[ii] );
View Full Code Here

     */
    public static void main( String[] args ) throws Exception
    {
        long startTime = System.currentTimeMillis();
        Properties env;
        ServerStartupConfiguration cfg;

        if ( args.length > 0 )
        {
            log.info( "server: loading settings from {}", args[0] );
            ApplicationContext factory = new FileSystemXmlApplicationContext( args[0] );
            cfg = ( ServerStartupConfiguration ) factory.getBean( "configuration" );
            env = ( Properties ) factory.getBean( "environment" );
        }
        else
        {
            log.info( "server: using default settings ..." );
            env = new Properties();
            cfg = new MutableServerStartupConfiguration();
        }

        env.setProperty( Context.PROVIDER_URL, "ou=system" );
        env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
        env.putAll( cfg.toJndiEnvironment() );

        new InitialDirContext( env );

        if (log.isInfoEnabled())
        {
View Full Code Here

        }
    }
   
    public void afterStartup( ContextFactoryService service ) throws NamingException
    {
        ServerStartupConfiguration cfg =
            ( ServerStartupConfiguration ) service.getConfiguration().getStartupConfiguration();
        Hashtable env = service.getConfiguration().getEnvironment();

        if ( cfg.isEnableNetworking() )
        {
            setupRegistry( cfg );
            startLdapProtocol( cfg, env );

            if ( cfg.isEnableKerberos() )
            {
                startKerberosProtocol( env );
            }
        }
    }
View Full Code Here

     */
    public static void main( String[] args ) throws Exception
    {
        long startTime = System.currentTimeMillis();
        Properties env;
        ServerStartupConfiguration cfg;

        if ( args.length > 0 )
        {
            log.info( "server: loading settings from {}", args[0] );
            ApplicationContext factory = new FileSystemXmlApplicationContext( args[0] );
            cfg = ( ServerStartupConfiguration ) factory.getBean( "configuration" );
            env = ( Properties ) factory.getBean( "environment" );
        }
        else
        {
            log.info( "server: using default settings ..." );
            env = new Properties();
            cfg = new MutableServerStartupConfiguration();
        }

        env.setProperty( Context.PROVIDER_URL, "ou=system" );
        env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
        env.putAll( cfg.toJndiEnvironment() );

        new InitialDirContext( env );

        if (log.isInfoEnabled())
        {
View Full Code Here

        }
    }
   
    public void afterStartup( ContextFactoryService service ) throws NamingException
    {
        ServerStartupConfiguration cfg =
            ( ServerStartupConfiguration ) service.getConfiguration().getStartupConfiguration();
        Hashtable env = service.getConfiguration().getEnvironment();

        if ( cfg.isEnableNetworking() )
        {
            setupRegistry( cfg );
            startLdapProtocol( cfg, env );

            if ( cfg.isEnableKerberos() )
            {
                startKerberosProtocol( env );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.ldap.server.configuration.ServerStartupConfiguration

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.