You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/10 11:49:57 UTC
svn commit: r376623 [36/38] - in /directory/sandbox/akarasulu/rc1/apacheds:
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/src/main/java/org/...
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java Fri Feb 10 02:48:07 2006
@@ -92,8 +92,8 @@
{
this.directoryService = service;
}
-
-
+
+
protected ServiceRegistry getMinaRegistry()
{
return minaRegistry;
@@ -151,8 +151,8 @@
public void afterStartup( DirectoryService service ) throws NamingException
{
- ServerStartupConfiguration cfg =
- ( ServerStartupConfiguration ) service.getConfiguration().getStartupConfiguration();
+ ServerStartupConfiguration cfg = ( ServerStartupConfiguration ) service.getConfiguration()
+ .getStartupConfiguration();
Hashtable env = service.getConfiguration().getEnvironment();
loadLdifs( service );
@@ -162,9 +162,9 @@
setupRegistry( cfg );
startLDAP( cfg, env );
startLDAPS( cfg, env );
- startKerberos(cfg, env);
- startChangePassword(cfg, env);
- startNTP(cfg, env);
+ startKerberos( cfg, env );
+ startChangePassword( cfg, env );
+ startNTP( cfg, env );
}
}
@@ -179,14 +179,18 @@
root.createSubcontext( LDIF_FILES_DN, entry );
log.info( "Creating " + LDIF_FILES_DN );
}
- catch( NamingException e ) { log.info( LDIF_FILES_DN + " exists" );}
+ catch ( NamingException e )
+ {
+ log.info( LDIF_FILES_DN + " exists" );
+ }
}
-
private final static String WINDOWSFILE_ATTR = "windowsFilePath";
private final static String UNIXFILE_ATTR = "unixFilePath";
private final static String WINDOWSFILE_OC = "windowsFile";
private final static String UNIXFILE_OC = "unixFile";
+
+
private void addFileEntry( DirContext root, File ldif ) throws NamingException
{
String rdnAttr = File.separatorChar == '\\' ? WINDOWSFILE_ATTR : UNIXFILE_ATTR;
@@ -217,7 +221,8 @@
try
{
- return root.getAttributes( buf.toString(), new String[]{ "createTimestamp" });
+ return root.getAttributes( buf.toString(), new String[]
+ { "createTimestamp" } );
}
catch ( NamingException e )
{
@@ -233,20 +238,20 @@
{
canonical = file.getCanonicalPath();
}
- catch (IOException e)
+ catch ( IOException e )
{
log.error( "could not get canonical path", e );
return null;
}
-
+
return StringUtils.replace( canonical, "\\", "\\\\" );
}
private void loadLdifs( DirectoryService service ) throws NamingException
{
- ServerStartupConfiguration cfg =
- ( ServerStartupConfiguration ) service.getConfiguration().getStartupConfiguration();
+ ServerStartupConfiguration cfg = ( ServerStartupConfiguration ) service.getConfiguration()
+ .getStartupConfiguration();
// log and bail if property not set
if ( cfg.getLdifDirectory() == null )
@@ -259,7 +264,7 @@
if ( !cfg.getLdifDirectory().exists() )
{
log.warn( "LDIF load directory '" + getCanonical( cfg.getLdifDirectory() )
- + "' does not exist. No LDIF files will be loaded.");
+ + "' does not exist. No LDIF files will be loaded." );
return;
}
@@ -275,13 +280,13 @@
if ( !cfg.getLdifDirectory().isDirectory() )
{
log.info( "LDIF load directory '" + getCanonical( cfg.getLdifDirectory() )
- + "' is a file. Will attempt to load as LDIF." );
+ + "' 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 + "." );
+ + "' skipped. It has already been loaded on " + time + "." );
return;
}
LdifFileLoader loader = new LdifFileLoader( root, cfg.getLdifDirectory(), cfg.getLdifFilters() );
@@ -299,13 +304,13 @@
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.");
+ + "' does not contain any LDIF files. No LDIF files will be loaded." );
return;
}
@@ -317,7 +322,7 @@
{
String time = ( String ) fileEntry.get( "createTimestamp" ).get();
log.info( "Load of LDIF file '" + getCanonical( ldifFiles[ii] )
- + "' skipped. It has already been loaded on " + time + "." );
+ + "' skipped. It has already been loaded on " + time + "." );
continue;
}
LdifFileLoader loader = new LdifFileLoader( root, ldifFiles[ii], cfg.getLdifFilters() );
@@ -349,15 +354,16 @@
{
// Skip if disabled
int port = cfg.getLdapPort();
- if( port < 0 )
+ if ( port < 0 )
{
return;
}
-
+
Service service = new Service( "LDAP", TransportType.SOCKET, new InetSocketAddress( port ) );
startLDAP0( cfg, env, service, new DefaultIoFilterChainBuilder() );
}
+
/**
* Starts up the LDAPS protocol provider to service LDAPS requests
*
@@ -366,7 +372,7 @@
private void startLDAPS( ServerStartupConfiguration cfg, Hashtable env ) throws NamingException
{
// Skip if disabled
- if( !cfg.isEnableLdaps() )
+ if ( !cfg.isEnableLdaps() )
{
return;
}
@@ -375,42 +381,40 @@
IoFilterChainBuilder chain;
try
{
- chain = ( IoFilterChainBuilder ) Class.forName(
- "org.apache.directory.server.ssl.LdapsInitializer",
- true,
- ServerContextFactory.class.getClassLoader() ).getMethod(
- "init", new Class[] { ServerStartupConfiguration.class } ).invoke(
- null, new Object[] { cfg } );
+ chain = ( IoFilterChainBuilder ) Class.forName( "org.apache.directory.server.ssl.LdapsInitializer", true,
+ ServerContextFactory.class.getClassLoader() ).getMethod( "init", new Class[]
+ { ServerStartupConfiguration.class } ).invoke( null, new Object[]
+ { cfg } );
}
- catch( InvocationTargetException e )
+ catch ( InvocationTargetException e )
{
- if( e.getCause() instanceof NamingException )
+ if ( e.getCause() instanceof NamingException )
{
throw ( NamingException ) e.getCause();
}
else
{
- throw ( NamingException ) new NamingException(
- "Failed to load LDAPS initializer." ).initCause( e.getCause() );
+ throw ( NamingException ) new NamingException( "Failed to load LDAPS initializer." ).initCause( e
+ .getCause() );
}
}
- catch( Exception e )
+ catch ( Exception e )
{
- throw ( NamingException ) new NamingException(
- "Failed to load LDAPS initializer." ).initCause( e );
+ throw ( NamingException ) new NamingException( "Failed to load LDAPS initializer." ).initCause( e );
}
Service service = new Service( "LDAPS", TransportType.SOCKET, new InetSocketAddress( cfg.getLdapsPort() ) );
startLDAP0( cfg, env, service, chain );
}
- private void startLDAP0( ServerStartupConfiguration cfg, Hashtable env, Service service, IoFilterChainBuilder chainBuilder )
- throws LdapNamingException, LdapConfigurationException
+
+ private void startLDAP0( ServerStartupConfiguration cfg, Hashtable env, Service service,
+ IoFilterChainBuilder chainBuilder ) throws LdapNamingException, LdapConfigurationException
{
// Register all extended operation handlers.
LdapProtocolProvider protocolProvider = new LdapProtocolProvider( ( Hashtable ) env.clone() );
-
- for( Iterator i = cfg.getExtendedOperationHandlers().iterator(); i.hasNext(); )
+
+ for ( Iterator i = cfg.getExtendedOperationHandlers().iterator(); i.hasNext(); )
{
ExtendedOperationHandler h = ( ExtendedOperationHandler ) i.next();
protocolProvider.addExtendedOperationHandler( h );
@@ -421,17 +425,17 @@
DirectoryPartitionNexus nexus = directoryService.getConfiguration().getPartitionNexus();
nexus.registerSupportedExtensions( h.getExtensionOids() );
}
-
+
try
{
// Disable the disconnection of the clients on unbind
IoAcceptor acceptor = minaRegistry.getAcceptor( service.getTransportType() );
acceptor.setDisconnectClientsOnUnbind( false );
( ( SocketAcceptor ) acceptor ).setReuseAddress( true );
-
+
minaRegistry.bind( service, protocolProvider.getHandler(), chainBuilder );
ldapService = service;
-
+
if ( log.isInfoEnabled() )
{
log.info( "Successful bind of " + service.getName() + " Service completed: " + ldapService );
@@ -439,15 +443,18 @@
}
catch ( IOException e )
{
- String msg = "Failed to bind the " + service.getName() + " protocol service to the service registry: " + service;
+ String msg = "Failed to bind the " + service.getName() + " protocol service to the service registry: "
+ + service;
LdapConfigurationException lce = new LdapConfigurationException( msg );
lce.setRootCause( e );
log.error( msg, e );
throw lce;
}
}
-
- private void startKerberos(ServerStartupConfiguration cfg, Hashtable env) {
+
+
+ private void startKerberos( ServerStartupConfiguration cfg, Hashtable env )
+ {
if ( cfg.isEnableKerberos() )
{
try
@@ -464,12 +471,14 @@
}
- private void startChangePassword(ServerStartupConfiguration cfg, Hashtable env) {
+ private void startChangePassword( ServerStartupConfiguration cfg, Hashtable env )
+ {
if ( cfg.isEnableChangePassword() )
{
try
{
- ChangePasswordConfiguration changePasswordConfiguration = new ChangePasswordConfiguration( env, LoadStrategy.PROPS );
+ ChangePasswordConfiguration changePasswordConfiguration = new ChangePasswordConfiguration( env,
+ LoadStrategy.PROPS );
PrincipalStore store = new JndiPrincipalStoreImpl( changePasswordConfiguration, this );
changePasswordServer = new ChangePasswordServer( changePasswordConfiguration, minaRegistry, store );
}
@@ -481,7 +490,8 @@
}
- private void startNTP(ServerStartupConfiguration cfg, Hashtable env) {
+ private void startNTP( ServerStartupConfiguration cfg, Hashtable env )
+ {
if ( cfg.isEnableNtp() )
{
try
@@ -495,19 +505,20 @@
}
}
}
-
+
+
private void stopLDAP0( Service service )
{
if ( ldapService != null )
{
-
+
try
{
// we should unbind the service before we begin sending the notice
// of disconnect so new connections are not formed while we process
List writeFutures = new ArrayList();
IoAcceptor acceptor = minaRegistry.getAcceptor( service.getTransportType() );
-
+
// If the socket has already been unbound as with a successful
// GracefulShutdownRequest then this will complain that the service
// is not bound - this is ok because the GracefulShutdown has already
@@ -517,23 +528,23 @@
{
sessions = new ArrayList( acceptor.getManagedSessions( service.getAddress() ) );
}
- catch( IllegalArgumentException e )
+ catch ( IllegalArgumentException e )
{
log.warn( "Seems like the LDAP service " + service + " has already been unbound." );
return;
}
-
+
minaRegistry.unbind( service );
if ( log.isInfoEnabled() )
{
log.info( "Unbind of " + service.getName() + " Service complete: " + ldapService );
log.info( "Sending notice of disconnect to existing clients sessions." );
}
-
+
// Send Notification of Disconnection messages to all connected clients.
- if( sessions != null )
+ if ( sessions != null )
{
- for( Iterator i = sessions.iterator(); i.hasNext(); )
+ for ( Iterator i = sessions.iterator(); i.hasNext(); )
{
IoSession session = ( IoSession ) i.next();
writeFutures.add( session.write( NoticeOfDisconnect.UNAVAILABLE ) );
@@ -542,14 +553,14 @@
// And close the connections when the NoDs are sent.
Iterator sessionIt = sessions.iterator();
- for( Iterator i = writeFutures.iterator(); i.hasNext(); )
+ for ( Iterator i = writeFutures.iterator(); i.hasNext(); )
{
WriteFuture future = ( WriteFuture ) i.next();
future.join( 1000 );
( ( IoSession ) sessionIt.next() ).close();
}
}
- catch( Exception e )
+ catch ( Exception e )
{
log.warn( "Failed to sent NoD.", e );
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-main/src/main/java/org/apache/directory/server/Service.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-main/src/main/java/org/apache/directory/server/Service.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-main/src/main/java/org/apache/directory/server/Service.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-main/src/main/java/org/apache/directory/server/Service.java Fri Feb 10 02:48:07 2006
@@ -43,7 +43,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class Service implements DaemonApplication
+public class Service implements DaemonApplication
{
private static final Logger log = LoggerFactory.getLogger( Service.class );
private Properties env;
@@ -66,14 +66,14 @@
cfg = ( MutableServerStartupConfiguration ) factory.getBean( "configuration" );
env = ( Properties ) factory.getBean( "environment" );
}
- else if ( args.length > 0 && new File( args[0] ).exists() ) // hack that takes server.xml file argument
+ else if ( args.length > 0 && new File( args[0] ).exists() ) // hack that takes server.xml file argument
{
log.info( "server: loading settings from ", args[0] );
ApplicationContext factory = null;
factory = new FileSystemXmlApplicationContext( new File( args[0] ).toURL().toString() );
cfg = ( MutableServerStartupConfiguration ) factory.getBean( "configuration" );
env = ( Properties ) factory.getBean( "environment" );
- }
+ }
else
{
log.info( "server: using default settings ..." );
@@ -83,37 +83,37 @@
env.setProperty( Context.PROVIDER_URL, "ou=system" );
env.setProperty( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
-
+
if ( install != null )
{
cfg.setWorkingDirectory( install.getPartitionsDirectory() );
}
-
+
env.putAll( cfg.toJndiEnvironment() );
new InitialDirContext( env );
workerThread = new Thread( worker, "SynchWorkerThread" );
- if (log.isInfoEnabled())
+ if ( log.isInfoEnabled() )
{
- log.info( "server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "");
+ log.info( "server: started in {} milliseconds", ( System.currentTimeMillis() - startTime ) + "" );
}
}
-
-
+
+
public void synch() throws Exception
{
env.putAll( new SyncConfiguration().toJndiEnvironment() );
new InitialDirContext( env );
}
-
+
public void start()
{
workerThread.start();
return;
}
-
+
public void stop( String[] args ) throws Exception
{
@@ -122,33 +122,33 @@
{
worker.lock.notify();
}
-
+
while ( startNoWait && workerThread.isAlive() )
{
log.info( "Waiting for SynchWorkerThread to die." );
workerThread.join( 500 );
}
-
+
env.putAll( new ShutdownConfiguration().toJndiEnvironment() );
new InitialDirContext( env );
}
- public void destroy()
+ public void destroy()
{
}
-
class SynchWorker implements Runnable
{
Object lock = new Object();
boolean stop = false;
-
+
+
public void run()
{
- while ( ! stop )
+ while ( !stop )
{
- synchronized( lock )
+ synchronized ( lock )
{
try
{
@@ -159,7 +159,7 @@
log.warn( "SynchWorker failed to wait on lock.", e );
}
}
-
+
try
{
synch();
@@ -171,15 +171,14 @@
}
}
}
-
-
- public static final String BANNER =
- " _ _ ____ ____ \n" +
- " / \\ _ __ __ _ ___| |__ ___| _ \\/ ___| \n" +
- " / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ | | \\___ \\ \n" +
- " / ___ \\| |_) | (_| | (__| | | | __/ |_| |___) | \n" +
- " /_/ \\_\\ .__/ \\__,_|\\___|_| |_|\\___|____/|____/ \n" +
- " |_| \n";
+
+ public static final String BANNER = " _ _ ____ ____ \n"
+ + " / \\ _ __ __ _ ___| |__ ___| _ \\/ ___| \n"
+ + " / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ | | \\___ \\ \n"
+ + " / ___ \\| |_) | (_| | (__| | | | __/ |_| |___) | \n"
+ + " /_/ \\_\\ .__/ \\__,_|\\___|_| |_|\\___|____/|____/ \n"
+ + " |_| \n";
+
public static void printBanner()
{
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-sar/src/main/java/org/apache/directory/server/sar/DirectoryServiceMBean.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-sar/src/main/java/org/apache/directory/server/sar/DirectoryServiceMBean.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-sar/src/main/java/org/apache/directory/server/sar/DirectoryServiceMBean.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-sar/src/main/java/org/apache/directory/server/sar/DirectoryServiceMBean.java Fri Feb 10 02:48:07 2006
@@ -17,6 +17,7 @@
*/
package org.apache.directory.server.sar;
+
import org.w3c.dom.Element;
import javax.naming.NamingException;
@@ -39,7 +40,8 @@
*
* @return The root DOM element
*/
- public Element getEmbeddedLDIFFilters( );
+ public Element getEmbeddedLDIFFilters();
+
/**
* Sets the root element of the XML properties list of defined LDIF filters
@@ -48,13 +50,15 @@
*/
public void setEmbeddedLDIFFilters( Element fil );
+
/**
* Gets the root element of the XML properties list of additional
* environment properties
*
* @return The root DOM element
*/
- public Element getEmbeddedAdditionalEnvProperties( );
+ public Element getEmbeddedAdditionalEnvProperties();
+
/**
* Sets the root element of the XML properties list of additional
@@ -64,13 +68,15 @@
*/
public void setEmbeddedAdditionalEnvProperties( Element env );
+
/**
* Gets the root element of the XML properties list of custom bootstrap
* schema properties
*
* @return The root DOM element
*/
- public Element getEmbeddedCustomBootstrapSchema( );
+ public Element getEmbeddedCustomBootstrapSchema();
+
/**
* Sets the root element of the XML properties list of custom bootstrap
@@ -80,12 +86,14 @@
*/
public void setEmbeddedCustomBootstrapSchema( Element cfg );
+
/**
* Test to see if the directory service to use is embedded in this VM
*
* @return True if embedded else false
*/
- public boolean isEmbeddedServerEnabled( );
+ public boolean isEmbeddedServerEnabled();
+
/**
* Set if the directory service to use is embedded in this VM
@@ -94,12 +102,14 @@
*/
public void setEmbeddedServerEnabled( boolean enabled );
+
/**
* Gets the name-to-object binding for Context INITIAL_CONTEXT_FACTORY
*
* @return Context.INITIAL_CONTEXT_FACTORY
*/
- public String getContextFactory( );
+ public String getContextFactory();
+
/**
* Sets the name-to-object binding for Context INITIAL_CONTEXT_FACTORY
@@ -108,12 +118,14 @@
*/
public void setContextFactory( String factoryClass );
+
/**
* Gets the name-to-object binding for Context PROVIDER_URL
*
* @return Context.PROVIDER_URL
*/
- public String getContextProviderURL( );
+ public String getContextProviderURL();
+
/**
* Sets the name-to-object binding for Context PROVIDER_URL
@@ -122,12 +134,14 @@
*/
public void setContextProviderURL( String providerURL );
+
/**
* Gets the name-to-object binding for Context SECURITY_AUTHENTICATION
*
* @return Context.SECURITY_AUTHENTICATION
*/
- public String getContextSecurityAuthentication( );
+ public String getContextSecurityAuthentication();
+
/**
* Sets the name-to-object binding for Context SECURITY_AUTHENTICATION
@@ -136,12 +150,14 @@
*/
public void setContextSecurityAuthentication( String securityAuthentication );
+
/**
* Gets the name-to-object binding for Context SECURITY_PRINCIPAL
*
* @return Context.SECURITY_PRINCIPAL
*/
- public String getContextSecurityPrincipal( );
+ public String getContextSecurityPrincipal();
+
/**
* Sets the name-to-object binding for Context SECURITY_PRINCIPAL
@@ -150,12 +166,14 @@
*/
public void setContextSecurityPrincipal( String securityPrincipal );
+
/**
* Gets the name-to-object binding for Context SECURITY_CREDENTIALS
*
* @return Context.SECURITY_CREDENTIALS
*/
- public String getContextSecurityCredentials( );
+ public String getContextSecurityCredentials();
+
/**
* Sets the name-to-object binding for Context SECURITY_CREDENTIALS
@@ -164,20 +182,23 @@
*/
public void setContextSecurityCredentials( String securityCredentials );
+
/**
* Opens a directory context based on the currently assigned name-to-object
* bindings
*
* @return A valid directory context or null on error
*/
- public DirContext openDirContext( ) throws NamingException;
+ public DirContext openDirContext() throws NamingException;
+
/**
* Embedded server only - Flushes out any I/O buffer or write cache
*
* @return True if flush succeeded else false
*/
- public boolean flushEmbeddedServerData( );
+ public boolean flushEmbeddedServerData();
+
/**
* Embedded server only - Changes the current password of the uid=admin
@@ -188,15 +209,16 @@
*
* @return Confirmation message for UI display
*/
- public String changedEmbeddedAdminPassword( String oldPassword,
- String newPassword );
+ public String changedEmbeddedAdminPassword( String oldPassword, String newPassword );
+
/**
* Embedded server only - tests if anonymous access is permitted
*
* @return True if permitted else false
*/
- public boolean isEmbeddedAnonymousAccess( );
+ public boolean isEmbeddedAnonymousAccess();
+
/**
* Embedded server only - sests if anonymous access is permitted
@@ -205,13 +227,15 @@
*/
public void setEmbeddedAnonymousAccess( boolean anonymousAccess );
+
/**
* Embedded server only - tests if LDAP wire protocol handler is to be
* started
*
* @return True if LDAP wire protocol in use else false
*/
- public boolean isEmbeddedLDAPNetworkingSupport( );
+ public boolean isEmbeddedLDAPNetworkingSupport();
+
/**
* Embedded server only - sests if LDAP wire protocol handler is to be
@@ -221,12 +245,14 @@
*/
public void setEmbeddedLDAPNetworkingSupport( boolean ldapNetworkingSupport );
+
/**
* Embedded server only - gets the LDAP listen port
*
* @return LDAP listen port
*/
- public int getEmbeddedLDAPPort( );
+ public int getEmbeddedLDAPPort();
+
/**
* Embedded server only - sets the LDAP listen port
@@ -235,13 +261,15 @@
*/
public void setEmbeddedLDAPPort( int ldapPort );
+
/**
* Embedded server only - gets the LDAPSSL) listen port (!NOT YET
* SUPPORTED!)
*
* @return LDAPS listen port
*/
- public int getEmbeddedLDAPSPort( );
+ public int getEmbeddedLDAPSPort();
+
/**
* Embedded server only - sets the LDAPS (SSL) listen port (!NOT YET
@@ -251,6 +279,7 @@
*/
public void setEmbeddedLDAPSPort( int ldapsPort );
+
/**
* Embedded server only - Gets the name of the root partion which was
* automatically created on server startup
@@ -258,7 +287,8 @@
* @return The name of the custom root partition (null for no custom
* partition)
*/
- public String getEmbeddedCustomRootPartitionName( );
+ public String getEmbeddedCustomRootPartitionName();
+
/**
* Embedded server only - Sets the name of the root partion which is
@@ -269,13 +299,15 @@
*/
public void setEmbeddedCustomRootPartitionName( String rootPartitianName );
+
/**
* Embedded server only - Gets the name of the workfile folder used by the
* server
*
* @return Folder name
*/
- public String getEmbeddedWkdir( );
+ public String getEmbeddedWkdir();
+
/**
* Embedded server only - Sets the name of the workfile folder used by the
@@ -285,13 +317,15 @@
*/
public void setEmbeddedWkdir( String wkdir );
+
/**
* Embedded server only - Gets the name of the LDIF import folder used by
* the server
*
* @return LDIF import folder
*/
- public String getEmbeddedLDIFdir( );
+ public String getEmbeddedLDIFdir();
+
/**
* Embedded server only - Sets the name of the LDIF import folder used by
@@ -301,12 +335,14 @@
*/
public void setEmbeddedLDIFdir( String LDIFdir );
+
/**
* Embedded server only - test if access control is enabled
*
* @return True is enabled else false
*/
- public boolean isEmbeddedAccessControlEnabled( );
+ public boolean isEmbeddedAccessControlEnabled();
+
/**
* Embedded server only - Set if access control is enabled
@@ -315,12 +351,14 @@
*/
public void setEmbeddedAccessControlEnabled( boolean enabled );
+
/**
* Embedded server only - test if NTP wire protocol is enabled
*
* @return True is enabled else false
*/
- public boolean isEmbeddedEnableNtp( );
+ public boolean isEmbeddedEnableNtp();
+
/**
* Embedded server only - set if NTP wire protocol is enabled
@@ -329,12 +367,14 @@
*/
public void setEmbeddedEnableNtp( boolean enabled );
+
/**
* Embedded server only - test if Kerberos wire protocol is enabled
*
* @return True is enabled else false
*/
- public boolean isEmbeddedEnableKerberos( );
+ public boolean isEmbeddedEnableKerberos();
+
/**
* Embedded server only - set if Kerberos wire protocol is enabled
@@ -343,12 +383,14 @@
*/
public void setEmbeddedEnableKerberos( boolean enabled );
+
/**
* Embedded server only - test if Change Password wire protocol is enabled
*
* @return True is enabled else false
*/
- public boolean isEmbeddedEnableChangePassword( );
+ public boolean isEmbeddedEnableChangePassword();
+
/**
* Embedded server only - set if Change Password wire protocol is enabled
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/LdapsInitializer.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/LdapsInitializer.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/LdapsInitializer.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/LdapsInitializer.java Fri Feb 10 02:48:07 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.ssl;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyStore;
@@ -35,6 +36,7 @@
import org.apache.mina.common.IoFilterChainBuilder;
import org.apache.mina.filter.SSLFilter;
+
/**
* Loads the certificate file for LDAPS support and creates the appropriate
* MINA filter chain.
@@ -50,21 +52,22 @@
// Load the certificate
char[] certPasswdChars = cfg.getLdapsCertificatePassword().toCharArray();
String storePath = cfg.getLdapsCertificateFile().getPath();
-
+
KeyStore ks = null;
try
{
ks = loadKeyStore( storePath, "PKCS12" );
}
- catch( Exception e )
+ catch ( Exception e )
{
try
{
ks = loadKeyStore( storePath, "JKS" );
}
- catch( Exception e2 )
+ catch ( Exception e2 )
{
- throw ( NamingException ) new NamingException( "Failed to load a certificate: " + storePath ).initCause( e );
+ throw ( NamingException ) new NamingException( "Failed to load a certificate: " + storePath )
+ .initCause( e );
}
}
@@ -74,23 +77,25 @@
// Set up key manager factory to use our key store
KeyManagerFactory kmf = KeyManagerFactory.getInstance( "SunX509" );
kmf.init( ks, certPasswdChars );
-
+
// Initialize the SSLContext to work with our key managers.
sslCtx = SSLContext.getInstance( "TLS" );
- sslCtx.init( kmf.getKeyManagers(),
- new TrustManager[] { new ServerX509TrustManager() }, new SecureRandom() );
+ sslCtx.init( kmf.getKeyManagers(), new TrustManager[]
+ { new ServerX509TrustManager() }, new SecureRandom() );
}
- catch( Exception e )
+ catch ( Exception e )
{
throw ( NamingException ) new NamingException( "Failed to create a SSL context." ).initCause( e );
}
-
+
DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
chain.addLast( "SSL", new SSLFilter( sslCtx ) );
return chain;
}
-
- private static KeyStore loadKeyStore( String storePath, String storeType ) throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException
+
+
+ private static KeyStore loadKeyStore( String storePath, String storeType ) throws KeyStoreException, IOException,
+ CertificateException, NoSuchAlgorithmException
{
FileInputStream in = null;
// Create keystore
@@ -103,13 +108,13 @@
}
finally
{
- if( in != null )
+ if ( in != null )
{
try
{
in.close();
}
- catch( IOException ignored )
+ catch ( IOException ignored )
{
}
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/support/ServerX509TrustManager.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/support/ServerX509TrustManager.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/support/ServerX509TrustManager.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/main/java/org/apache/directory/server/ssl/support/ServerX509TrustManager.java Fri Feb 10 02:48:07 2006
@@ -16,11 +16,13 @@
*/
package org.apache.directory.server.ssl.support;
+
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509TrustManager;
+
/**
* An {@link X509TrustManager} for LDAP server.
*
@@ -33,16 +35,19 @@
{
}
+
public void checkClientTrusted( X509Certificate[] arg0, String arg1 ) throws CertificateException
{
// We don't check clients at all right now.
// XXX: Do we need a client-side certificates?
}
+
public void checkServerTrusted( X509Certificate[] arg0, String arg1 ) throws CertificateException
{
// It is server-side trust manager, so we don't need to check the server itself.
}
+
public X509Certificate[] getAcceptedIssuers()
{
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/LdapsTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/LdapsTest.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/LdapsTest.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/LdapsTest.java Fri Feb 10 02:48:07 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.ssl;
+
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Hashtable;
@@ -54,7 +55,7 @@
public void setUp() throws Exception
{
doDelete( configuration.getWorkingDirectory() );
-
+
int ldapsPort = AvailablePortFinder.getNextAvailable( 8192 );
configuration.setEnableLdaps( true );
configuration.setLdapsCertificatePassword( "boguspw" );
@@ -64,13 +65,12 @@
InputStream in = getClass().getResourceAsStream( "/bogus.cert" );
configuration.getLdapsCertificateFile().getParentFile().mkdirs();
- FileOutputStream out = new FileOutputStream(
- configuration.getLdapsCertificateFile() );
+ FileOutputStream out = new FileOutputStream( configuration.getLdapsCertificateFile() );
- for( ;; )
+ for ( ;; )
{
int c = in.read();
- if( c < 0 )
+ if ( c < 0 )
{
break;
}
@@ -79,7 +79,7 @@
in.close();
out.close();
-
+
doDelete = false;
super.setUp();
doDelete = true;
@@ -100,7 +100,7 @@
*/
public void tearDown() throws Exception
{
- ctx.unbind(RDN);
+ ctx.unbind( RDN );
ctx.close();
ctx = null;
super.tearDown();
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusSSLContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusSSLContextFactory.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusSSLContextFactory.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusSSLContextFactory.java Fri Feb 10 02:48:07 2006
@@ -18,6 +18,7 @@
*/
package org.apache.directory.server.ssl.support;
+
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
@@ -26,6 +27,7 @@
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
+
/**
* Factory to create a bougus SSLContext.
*
@@ -54,13 +56,14 @@
/**
* Bougus keystore password.
*/
- private static final char[] BOGUS_PW = { 'b', 'o', 'g', 'u', 's', 'p',
- 'w' };
+ private static final char[] BOGUS_PW =
+ { 'b', 'o', 'g', 'u', 's', 'p', 'w' };
private static SSLContext serverInstance = null;
private static SSLContext clientInstance = null;
+
/**
* Get SSLContext singleton.
*
@@ -68,26 +71,24 @@
* @throws java.security.GeneralSecurityException
*
*/
- public static SSLContext getInstance( boolean server )
- throws GeneralSecurityException
+ public static SSLContext getInstance( boolean server ) throws GeneralSecurityException
{
SSLContext retInstance = null;
- if( server )
+ if ( server )
{
- if( serverInstance == null )
+ if ( serverInstance == null )
{
- synchronized( BogusSSLContextFactory.class )
+ synchronized ( BogusSSLContextFactory.class )
{
- if( serverInstance == null )
+ if ( serverInstance == null )
{
try
{
serverInstance = createBougusServerSSLContext();
}
- catch( Exception ioe )
+ catch ( Exception ioe )
{
- throw new GeneralSecurityException(
- "Can't create Server SSLContext:" + ioe );
+ throw new GeneralSecurityException( "Can't create Server SSLContext:" + ioe );
}
}
}
@@ -96,11 +97,11 @@
}
else
{
- if( clientInstance == null )
+ if ( clientInstance == null )
{
- synchronized( BogusSSLContextFactory.class )
+ synchronized ( BogusSSLContextFactory.class )
{
- if( clientInstance == null )
+ if ( clientInstance == null )
{
clientInstance = createBougusClientSSLContext();
}
@@ -111,27 +112,26 @@
return retInstance;
}
- private static SSLContext createBougusServerSSLContext()
- throws GeneralSecurityException, IOException
+
+ private static SSLContext createBougusServerSSLContext() throws GeneralSecurityException, IOException
{
// Create keystore
KeyStore ks = KeyStore.getInstance( "JKS" );
InputStream in = null;
try
{
- in = BogusSSLContextFactory.class
- .getResourceAsStream( BOGUS_KEYSTORE );
+ in = BogusSSLContextFactory.class.getResourceAsStream( BOGUS_KEYSTORE );
ks.load( in, BOGUS_PW );
}
finally
{
- if( in != null )
+ if ( in != null )
{
try
{
in.close();
}
- catch( IOException ignored )
+ catch ( IOException ignored )
{
}
}
@@ -143,14 +143,13 @@
// Initialize the SSLContext to work with our key managers.
SSLContext sslContext = SSLContext.getInstance( PROTOCOL );
- sslContext.init( kmf.getKeyManagers(),
- BogusTrustManagerFactory.X509_MANAGERS, null );
+ sslContext.init( kmf.getKeyManagers(), BogusTrustManagerFactory.X509_MANAGERS, null );
return sslContext;
}
- private static SSLContext createBougusClientSSLContext()
- throws GeneralSecurityException
+
+ private static SSLContext createBougusClientSSLContext() throws GeneralSecurityException
{
SSLContext context = SSLContext.getInstance( PROTOCOL );
context.init( null, BogusTrustManagerFactory.X509_MANAGERS, null );
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusTrustManagerFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusTrustManagerFactory.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusTrustManagerFactory.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/BogusTrustManagerFactory.java Fri Feb 10 02:48:07 2006
@@ -18,6 +18,7 @@
*/
package org.apache.directory.server.ssl.support;
+
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -29,6 +30,7 @@
import javax.net.ssl.TrustManagerFactorySpi;
import javax.net.ssl.X509TrustManager;
+
/**
* Bogus trust manager factory. Creates BogusX509TrustManager
*
@@ -40,41 +42,45 @@
static final X509TrustManager X509 = new X509TrustManager()
{
- public void checkClientTrusted( X509Certificate[] x509Certificates,
- String s ) throws CertificateException
+ public void checkClientTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException
{
}
- public void checkServerTrusted( X509Certificate[] x509Certificates,
- String s ) throws CertificateException
+
+ public void checkServerTrusted( X509Certificate[] x509Certificates, String s ) throws CertificateException
{
}
+
public X509Certificate[] getAcceptedIssuers()
{
- return new X509Certificate[ 0 ];
+ return new X509Certificate[0];
}
};
- static final TrustManager[] X509_MANAGERS = new TrustManager[] { X509 };
+ static final TrustManager[] X509_MANAGERS = new TrustManager[]
+ { X509 };
+
public BogusTrustManagerFactory()
{
}
+
protected TrustManager[] engineGetTrustManagers()
{
return X509_MANAGERS;
}
+
protected void engineInit( KeyStore keystore ) throws KeyStoreException
{
// noop
}
- protected void engineInit(
- ManagerFactoryParameters managerFactoryParameters )
- throws InvalidAlgorithmParameterException
+
+ protected void engineInit( ManagerFactoryParameters managerFactoryParameters )
+ throws InvalidAlgorithmParameterException
{
// noop
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/SSLSocketFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/SSLSocketFactory.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/SSLSocketFactory.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-ssl/src/test/java/org/apache/directory/server/ssl/support/SSLSocketFactory.java Fri Feb 10 02:48:07 2006
@@ -18,6 +18,7 @@
*/
package org.apache.directory.server.ssl.support;
+
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
@@ -26,6 +27,7 @@
import javax.net.SocketFactory;
+
/**
* Simple Socket factory to create sockets with or without SSL enabled.
* If SSL enabled a "bougus" SSL Context is used (suitable for test purposes)
@@ -40,20 +42,22 @@
private static javax.net.SocketFactory factory = null;
+
public static SocketFactory getDefault()
{
return new SSLSocketFactory();
}
+
public SSLSocketFactory()
{
super();
}
- public Socket createSocket( String arg1, int arg2 ) throws IOException,
- UnknownHostException
+
+ public Socket createSocket( String arg1, int arg2 ) throws IOException, UnknownHostException
{
- if( isSslEnabled() )
+ if ( isSslEnabled() )
{
return getSSLFactory().createSocket( arg1, arg2 );
}
@@ -63,11 +67,11 @@
}
}
- public Socket createSocket( String arg1, int arg2, InetAddress arg3,
- int arg4 ) throws IOException,
- UnknownHostException
+
+ public Socket createSocket( String arg1, int arg2, InetAddress arg3, int arg4 ) throws IOException,
+ UnknownHostException
{
- if( isSslEnabled() )
+ if ( isSslEnabled() )
{
return getSSLFactory().createSocket( arg1, arg2, arg3, arg4 );
}
@@ -77,10 +81,10 @@
}
}
- public Socket createSocket( InetAddress arg1, int arg2 )
- throws IOException
+
+ public Socket createSocket( InetAddress arg1, int arg2 ) throws IOException
{
- if( isSslEnabled() )
+ if ( isSslEnabled() )
{
return getSSLFactory().createSocket( arg1, arg2 );
}
@@ -90,10 +94,10 @@
}
}
- public Socket createSocket( InetAddress arg1, int arg2, InetAddress arg3,
- int arg4 ) throws IOException
+
+ public Socket createSocket( InetAddress arg1, int arg2, InetAddress arg3, int arg4 ) throws IOException
{
- if( isSslEnabled() )
+ if ( isSslEnabled() )
{
return getSSLFactory().createSocket( arg1, arg2, arg3, arg4 );
}
@@ -103,25 +107,26 @@
}
}
+
public static javax.net.SocketFactory getSocketFactory()
{
- if( factory == null )
+ if ( factory == null )
{
factory = new SSLSocketFactory();
}
return factory;
}
+
private javax.net.ssl.SSLSocketFactory getSSLFactory()
{
- if( sslFactory == null )
+ if ( sslFactory == null )
{
try
{
- sslFactory = BogusSSLContextFactory.getInstance( false )
- .getSocketFactory();
+ sslFactory = BogusSSLContextFactory.getInstance( false ).getSocketFactory();
}
- catch( GeneralSecurityException e )
+ catch ( GeneralSecurityException e )
{
throw new RuntimeException( "could not create SSL socket", e );
}
@@ -129,10 +134,12 @@
return sslFactory;
}
+
public static boolean isSslEnabled()
{
return sslEnabled;
}
+
public static void setSslEnabled( boolean newSslEnabled )
{
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/ApachedsTools.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/ApachedsTools.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/ApachedsTools.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/ApachedsTools.java Fri Feb 10 02:48:07 2006
@@ -48,7 +48,7 @@
private final static Options global = new Options();
private final static Properties props = new Properties();
private final static String version;
-
+
static
{
ToolCommand command;
@@ -75,7 +75,7 @@
global.addOption( op );
op = new Option( "version", false, "print the version information and exit" );
global.addOption( op );
-
+
try
{
props.load( ApachedsTools.class.getResourceAsStream( "ApachedsTools.properties" ) );
@@ -84,27 +84,27 @@
{
e.printStackTrace();
}
-
+
version = props.getProperty( "apacheds.tools.version" );
}
-
-
+
+
private static boolean hasBannerOption( String[] args )
{
for ( int ii = 0; ii < args.length; ii++ )
{
- if ( args[ii].equals( "-b" ) || args[ii].equals( "-banner" ))
+ if ( args[ii].equals( "-b" ) || args[ii].equals( "-banner" ) )
{
return true;
}
}
return false;
}
-
- public static void main( String [] args ) throws Exception
+
+ public static void main( String[] args ) throws Exception
{
- if ( ! hasBannerOption( args ) )
+ if ( !hasBannerOption( args ) )
{
printBanner();
}
@@ -114,7 +114,7 @@
System.err.println( "Type apacheds-tools help for usage." );
System.exit( 1 );
}
-
+
// help is a special command
String command = args[0].toLowerCase();
if ( "help".equals( command ) )
@@ -131,20 +131,20 @@
System.exit( 0 );
}
}
- else if ( command.equals( "-version" ) )
+ else if ( command.equals( "-version" ) )
{
System.out.println( "apacheds-tools version " + version );
System.exit( 0 );
}
-
+
ToolCommand cmd = ( ToolCommand ) commands.get( command );
if ( cmd == null )
{
System.err.println( "Unknown command: " + args[0] );
System.err.println( "Type apacheds-tools help for usage." );
System.exit( 1 );
- }
-
+ }
+
CommandLine cmdline = getCommandLine( command, args );
if ( cmdline.hasOption( 'd' ) )
{
@@ -152,7 +152,7 @@
dumpArgs( "raw command line arguments: ", args );
dumpArgs( "parsed arguments: ", cmdline.getArgs() );
}
-
+
cmd.setQuietEnabled( cmdline.hasOption( 'q' ) );
cmd.setDebugEnabled( cmdline.hasOption( 'd' ) );
cmd.setVerboseEnabled( cmdline.hasOption( 'v' ) );
@@ -160,7 +160,7 @@
if ( cmdline.getOptionValue( 'i' ) != null )
{
cmd.setLayout( cmdline.getOptionValue( 'i' ) );
- if ( ! cmd.isQuietEnabled() )
+ if ( !cmd.isQuietEnabled() )
{
System.out.println( "loading settings from: " + cmd.getLayout().getConfigurationFile() );
}
@@ -174,10 +174,10 @@
System.err.println( "forced configuration load (-c) requires the -i option" );
System.exit( 1 );
}
-
+
cmd.execute( cmdline );
}
-
+
private static CommandLine getCommandLine( String command, String[] args )
{
@@ -188,30 +188,29 @@
{
cmdline = parser.parse( all, args );
}
- catch( ParseException e )
+ catch ( ParseException e )
{
- System.err.println( "Command line parsing failed for " + command
- + ". Reason: " + e.getMessage() );
+ System.err.println( "Command line parsing failed for " + command + ". Reason: " + e.getMessage() );
System.exit( 1 );
}
return cmdline;
}
-
-
+
+
private static Options allOptions( String command )
{
if ( command.equals( "help" ) )
{
return global;
}
-
+
Options all = new Options();
ToolCommand cmd = ( ToolCommand ) commands.get( command );
for ( Iterator ii = global.getOptions().iterator(); ii.hasNext(); )
{
all.addOption( ( Option ) ii.next() );
}
-
+
for ( Iterator ii = cmd.getOptions().getOptions().iterator(); ii.hasNext(); )
{
all.addOption( ( Option ) ii.next() );
@@ -219,7 +218,7 @@
return all;
}
-
+
private static void dumpArgs( String msg, String[] args )
{
if ( args.length == 0 )
@@ -228,7 +227,7 @@
System.out.println( "\t NONE" );
return;
}
-
+
StringBuffer buf = new StringBuffer();
buf.append( msg ).append( "\n" );
for ( int ii = 0; ii < args.length; ii++ )
@@ -237,8 +236,8 @@
}
System.out.println( buf );
}
-
-
+
+
private static void helpOnCommand( String command )
{
if ( command.equals( "help" ) )
@@ -250,7 +249,7 @@
{
ToolCommand cmd = ( ToolCommand ) commands.get( command );
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( "apacheds-tools "+cmd+" [options]", cmd.getOptions() );
+ formatter.printHelp( "apacheds-tools " + cmd + " [options]", cmd.getOptions() );
}
else
{
@@ -263,28 +262,27 @@
private static void printUsage()
{
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( "apacheds-tools <command> [options]",
- "\nGlobal options:", global, "\nType \"apacheds-tools help <command>\" for help on a command." );
+ formatter.printHelp( "apacheds-tools <command> [options]", "\nGlobal options:", global,
+ "\nType \"apacheds-tools help <command>\" for help on a command." );
System.out.println( "\nAvalable commands:" );
Iterator it = commands.values().iterator();
System.out.println( "\thelp" );
- while( it.hasNext() )
+ while ( it.hasNext() )
{
System.out.println( "\t" + it.next() );
}
-
+
System.out.println( "\nThese apacheds-tools are used to manage the Apache Directory Server." );
System.out.println( "For additional information, see http://directory.apache.org/" );
}
-
- public static final String BANNER =
- " _ _ ____ ____ _____ _ \n" +
- " / \\ _ __ __ _ ___| |__ ___| _ \\/ ___| |_ _|__ ___ | |___ \n" +
- " / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ | | \\___ \\ | |/ _ \\ / _ \\| / __| \n" +
- " / ___ \\| |_) | (_| | (__| | | | __/ |_| |___) | | | (_) | (_) | \\__ \\ \n" +
- " /_/ \\_\\ .__/ \\__,_|\\___|_| |_|\\___|____/|____/ |_|\\___/ \\___/|_|___/ \n" +
- " |_| \n";
+ public static final String BANNER = " _ _ ____ ____ _____ _ \n"
+ + " / \\ _ __ __ _ ___| |__ ___| _ \\/ ___| |_ _|__ ___ | |___ \n"
+ + " / _ \\ | '_ \\ / _` |/ __| '_ \\ / _ \\ | | \\___ \\ | |/ _ \\ / _ \\| / __| \n"
+ + " / ___ \\| |_) | (_| | (__| | | | __/ |_| |___) | | | (_) | (_) | \\__ \\ \n"
+ + " /_/ \\_\\ .__/ \\__,_|\\___|_| |_|\\___|____/|____/ |_|\\___/ \\___/|_|___/ \n"
+ + " |_| \n";
+
public static void printBanner()
{
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DiagnosticCommand.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DiagnosticCommand.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DiagnosticCommand.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DiagnosticCommand.java Fri Feb 10 02:48:07 2006
@@ -40,14 +40,14 @@
*/
public class DiagnosticCommand extends ToolCommand
{
- public static final String PORT_RANGE = "(" + AvailablePortFinder.MIN_PORT_NUMBER + ", "
- + AvailablePortFinder.MAX_PORT_NUMBER + ")";
+ public static final String PORT_RANGE = "(" + AvailablePortFinder.MIN_PORT_NUMBER + ", "
+ + AvailablePortFinder.MAX_PORT_NUMBER + ")";
private int port = 10389;
private String host = "localhost";
private String password = "secret";
-
+
protected DiagnosticCommand()
{
super( "diagnostic" );
@@ -57,7 +57,7 @@
public void execute( CommandLine cmd ) throws Exception
{
processOptions( cmd );
-
+
if ( isDebugEnabled() )
{
System.out.println( "Parameters for LaunchDiagnosticUI extended request:" );
@@ -76,8 +76,7 @@
LdapContext ctx = new InitialLdapContext( env, null );
if ( isDebugEnabled() )
{
- System.out.println( "Connection to the server established.\n"+
- "Sending extended request ... " );
+ System.out.println( "Connection to the server established.\n" + "Sending extended request ... " );
}
ctx.extendedOperation( new LaunchDiagnosticUiRequest( 3 ) );
ctx.close();
@@ -90,12 +89,12 @@
{
System.out.println( "Processing options for launching diagnostic UI ..." );
}
-
+
// -------------------------------------------------------------------
// figure out and error check the port value
// -------------------------------------------------------------------
- if ( cmd.hasOption( 'p' ) ) // - user provided port w/ -p takes precedence
+ if ( cmd.hasOption( 'p' ) ) // - user provided port w/ -p takes precedence
{
String val = cmd.getOptionValue( 'p' );
try
@@ -107,20 +106,20 @@
System.err.println( "port value of '" + val + "' is not a number" );
System.exit( 1 );
}
-
+
if ( port > AvailablePortFinder.MAX_PORT_NUMBER )
{
- System.err.println( "port value of '" + val + "' is larger than max port number: "
+ System.err.println( "port value of '" + val + "' is larger than max port number: "
+ AvailablePortFinder.MAX_PORT_NUMBER );
System.exit( 1 );
}
else if ( port < AvailablePortFinder.MIN_PORT_NUMBER )
{
- System.err.println( "port value of '" + val + "' is smaller than the minimum port number: "
+ System.err.println( "port value of '" + val + "' is smaller than the minimum port number: "
+ AvailablePortFinder.MIN_PORT_NUMBER );
System.exit( 1 );
}
-
+
if ( isDebugEnabled() )
{
System.out.println( "port overriden by -p option: " + port );
@@ -129,7 +128,7 @@
else if ( getConfiguration() != null )
{
port = getConfiguration().getLdapPort();
-
+
if ( isDebugEnabled() )
{
System.out.println( "port overriden by server.xml configuration: " + port );
@@ -139,7 +138,7 @@
{
System.out.println( "port set to default: " + port );
}
-
+
// -------------------------------------------------------------------
// figure out the host value
// -------------------------------------------------------------------
@@ -147,7 +146,7 @@
if ( cmd.hasOption( 'h' ) )
{
host = cmd.getOptionValue( 'h' );
-
+
if ( isDebugEnabled() )
{
System.out.println( "host overriden by -h option: " + host );
@@ -157,7 +156,7 @@
{
System.out.println( "host set to default: " + host );
}
-
+
// -------------------------------------------------------------------
// figure out the password value
// -------------------------------------------------------------------
@@ -184,7 +183,7 @@
Option op = new Option( "h", "host", true, "server host: defaults to localhost" );
op.setRequired( false );
opts.addOption( op );
- op = new Option( "p", "port", true, "server port: defaults to 10389 or server.xml specified port" );
+ op = new Option( "p", "port", true, "server port: defaults to 10389 or server.xml specified port" );
op.setRequired( false );
opts.addOption( op );
op = new Option( "w", "password", true, "the apacheds administrator's password: defaults to secret" );
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DisconnectNotificationCommand.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DisconnectNotificationCommand.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DisconnectNotificationCommand.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DisconnectNotificationCommand.java Fri Feb 10 02:48:07 2006
@@ -52,11 +52,12 @@
private int port = 10389;
private String bindDn = "uid=admin,ou=system";
private String password = "secret";
-// private String shutdownCommand = "echo";
-// private String[] shutdownCommandArgs = new String[] {
-// "server $HOST:$PORT will shutdown for $OFFLINE minutes in $DELAY seconds" };
-
+
+ // private String shutdownCommand = "echo";
+ // private String[] shutdownCommandArgs = new String[] {
+ // "server $HOST:$PORT will shutdown for $OFFLINE minutes in $DELAY seconds" };
+
protected DisconnectNotificationCommand()
{
super( "notifications" );
@@ -66,7 +67,7 @@
public void notificationReceived( UnsolicitedNotificationEvent evt )
{
notification = evt.getNotification();
-
+
if ( notification.getID().equals( NoticeOfDisconnect.EXTENSION_OID ) )
{
System.out.println( "\nRecieved NoticeOfDisconnect: " + NoticeOfDisconnect.EXTENSION_OID );
@@ -79,14 +80,14 @@
GracefulDisconnect gd = new GracefulDisconnect( notification.getEncodedValue() );
System.out.println( "LDAP server will shutdown in " + gd.getDelay() + " seconds." );
System.out.println( "LDAP server will be back online in " + gd.getTimeOffline() + " minutes." );
-
+
if ( gd.getDelay() > 0 )
{
Thread t = new Thread( new Counter( gd.getDelay() ) );
t.start();
}
}
- else
+ else
{
System.out.println( "Unknown event recieved with OID: " + evt.getNotification().getID() );
}
@@ -100,29 +101,36 @@
System.out.println( "Process shutting down abruptly." );
System.exit( 1 );
}
-
-
+
class Counter implements Runnable
{
int delay;
-
- Counter( int delay )
+
+
+ Counter(int delay)
{
this.delay = delay;
}
-
+
+
public void run()
{
System.out.println( "Starting countdown until server shutdown:" );
- System.out.print( "[" );
+ System.out.print( "[" );
long delayMillis = delay * 1000 - 1000; // 1000 is for setup costs
long startTime = System.currentTimeMillis();
while ( System.currentTimeMillis() - startTime < delayMillis && !canceled )
{
- try{ Thread.sleep( 1000 ); }catch ( InterruptedException e ){}
+ try
+ {
+ Thread.sleep( 1000 );
+ }
+ catch ( InterruptedException e )
+ {
+ }
System.out.print( "." );
}
-
+
if ( canceled )
{
System.out.println( " -- countdown canceled -- " );
@@ -140,19 +148,19 @@
public void execute( CommandLine cmd ) throws Exception
{
processOptions( cmd );
-
+
Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
- env.put("java.naming.provider.url", "ldap://" + host + ":" + port );
- env.put("java.naming.security.principal", bindDn );
- env.put("java.naming.security.credentials", password );
- env.put("java.naming.security.authentication", "simple" );
+ env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+ env.put( "java.naming.provider.url", "ldap://" + host + ":" + port );
+ env.put( "java.naming.security.principal", bindDn );
+ env.put( "java.naming.security.credentials", password );
+ env.put( "java.naming.security.authentication", "simple" );
LdapContext ctx = new InitialLdapContext( env, null );
ctx = ctx.newInstance( null );
UnsolicitedNotificationListener listener = new DisconnectNotificationCommand();
( ( EventContext ) ctx ).addNamingListener( "", SearchControls.SUBTREE_SCOPE, listener );
-
+
System.out.println( "Listening for notifications." );
System.out.println( "Press any key to terminate." );
System.in.read();
@@ -167,12 +175,12 @@
{
System.out.println( "Processing options for disconnect notifications ..." );
}
-
+
// -------------------------------------------------------------------
// figure out and error check the port value
// -------------------------------------------------------------------
- if ( cmd.hasOption( 'p' ) ) // - user provided port w/ -p takes precedence
+ if ( cmd.hasOption( 'p' ) ) // - user provided port w/ -p takes precedence
{
String val = cmd.getOptionValue( 'p' );
try
@@ -184,20 +192,20 @@
System.err.println( "port value of '" + val + "' is not a number" );
System.exit( 1 );
}
-
+
if ( port > AvailablePortFinder.MAX_PORT_NUMBER )
{
- System.err.println( "port value of '" + val + "' is larger than max port number: "
+ System.err.println( "port value of '" + val + "' is larger than max port number: "
+ AvailablePortFinder.MAX_PORT_NUMBER );
System.exit( 1 );
}
else if ( port < AvailablePortFinder.MIN_PORT_NUMBER )
{
- System.err.println( "port value of '" + val + "' is smaller than the minimum port number: "
+ System.err.println( "port value of '" + val + "' is smaller than the minimum port number: "
+ AvailablePortFinder.MIN_PORT_NUMBER );
System.exit( 1 );
}
-
+
if ( isDebugEnabled() )
{
System.out.println( "port overriden by -p option: " + port );
@@ -206,7 +214,7 @@
else if ( getConfiguration() != null )
{
port = getConfiguration().getLdapPort();
-
+
if ( isDebugEnabled() )
{
System.out.println( "port overriden by server.xml configuration: " + port );
@@ -216,7 +224,7 @@
{
System.out.println( "port set to default: " + port );
}
-
+
// -------------------------------------------------------------------
// figure out the host value
// -------------------------------------------------------------------
@@ -224,7 +232,7 @@
if ( cmd.hasOption( 'h' ) )
{
host = cmd.getOptionValue( 'h' );
-
+
if ( isDebugEnabled() )
{
System.out.println( "host overriden by -h option: " + host );
@@ -234,7 +242,7 @@
{
System.out.println( "host set to default: " + host );
}
-
+
// -------------------------------------------------------------------
// figure out the password value
// -------------------------------------------------------------------
@@ -252,7 +260,7 @@
{
System.out.println( "password set to default: " + password );
}
-
+
// -------------------------------------------------------------------
// figure out the binddn value
// -------------------------------------------------------------------
@@ -279,7 +287,7 @@
Option op = new Option( "h", "host", true, "server host: defaults to localhost" );
op.setRequired( false );
opts.addOption( op );
- op = new Option( "p", "port", true, "server port: defaults to 10389 or server.xml specified port" );
+ op = new Option( "p", "port", true, "server port: defaults to 10389 or server.xml specified port" );
op.setRequired( false );
opts.addOption( op );
op = new Option( "w", "password", true, "the apacheds administrator's password: defaults to secret" );
Modified: directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java Fri Feb 10 02:48:07 2006
@@ -50,7 +50,6 @@
import org.apache.directory.shared.ldap.schema.UsageEnum;
-
/**
* Simple tool used to dump the contents of a jdbm based partition.
*
@@ -63,14 +62,14 @@
private BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
private Set exclusions = new HashSet();
private boolean includeOperational = false;
-
-
+
+
public DumpCommand()
{
super( "dump" );
}
-
-
+
+
public void execute( CommandLine cmdline ) throws Exception
{
getLayout().verifyInstallation();
@@ -80,7 +79,7 @@
String[] partitions = cmdline.getOptionValues( 'p' );
String outputFile = cmdline.getOptionValue( 'f' );
PrintWriter out = null;
-
+
String[] excludedAttributes = cmdline.getOptionValues( 'e' );
if ( excludedAttributes != null )
{
@@ -91,7 +90,7 @@
exclusions.add( type.getName() );
}
}
-
+
if ( outputFile == null )
{
out = new PrintWriter( System.out );
@@ -100,7 +99,7 @@
{
out = new PrintWriter( new FileWriter( outputFile ) );
}
-
+
for ( int ii = 0; ii < partitions.length; ii++ )
{
File partitionDirectory = new File( getLayout().getPartitionsDirectory(), partitions[ii] );
@@ -108,20 +107,20 @@
dump( partitionDirectory, out );
}
}
-
-
+
+
private void dump( File partitionDirectory, PrintWriter out ) throws Exception
{
- if ( ! partitionDirectory.exists() )
+ if ( !partitionDirectory.exists() )
{
System.err.println( "Partition directory " + partitionDirectory + " does not exist!" );
System.exit( 1 );
}
- out.println( "# ========================================================================");
+ out.println( "# ========================================================================" );
out.println( "# ApacheDS Tools Version: " + getVersion() );
out.println( "# Partition Directory: " + partitionDirectory );
- out.println( "# ========================================================================\n\n");
+ out.println( "# ========================================================================\n\n" );
String path = partitionDirectory.getPath() + File.separator + "master";
BaseRecordManager base = new BaseRecordManager( path );
@@ -143,8 +142,8 @@
Attributes entry = ( Attributes ) tuple.getValue();
filterAttributes( dn, entry );
-
- if ( ! ( entry instanceof LockableAttributesImpl ) )
+
+ if ( !( entry instanceof LockableAttributesImpl ) )
{
Attributes tmp = entry;
entry = new LockableAttributesImpl();
@@ -160,7 +159,7 @@
}
}
}
-
+
buf.append( "# Entry: " ).append( id ).append( "\n#---------------------\n\n" );
buf.append( "dn: " ).append( dn ).append( "\n" ).append( entry );
if ( list.hasMore() )
@@ -182,19 +181,19 @@
while ( attrs.hasMore() )
{
Attribute attr = ( Attribute ) attrs.next();
- if ( ! registry.hasAttributeType( attr.getID() ) )
+ if ( !registry.hasAttributeType( attr.getID() ) )
{
- if ( ! isQuietEnabled() )
+ if ( !isQuietEnabled() )
{
- System.out.println( "# Cannot properly filter unrecognized attribute "
- + attr.getID() + " in " + dn );
+ System.out
+ .println( "# Cannot properly filter unrecognized attribute " + attr.getID() + " in " + dn );
}
continue;
}
-
+
AttributeType type = registry.lookup( attr.getID() );
boolean isOperational = type.getUsage() != UsageEnum.USERAPPLICATIONS;
- if ( exclusions.contains( attr.getID() ) || ( isOperational && ( ! includeOperational ) ) )
+ if ( exclusions.contains( attr.getID() ) || ( isOperational && ( !includeOperational ) ) )
{
toRemove.add( attr.getID() );
}
@@ -209,15 +208,15 @@
}
}
}
-
-
+
+
public Options getOptions()
{
Options opts = new Options();
Option op = new Option( "f", "file", true, "file to output the dump to" );
op.setRequired( false );
opts.addOption( op );
- op = new Option( "p", "partitions", true, "the partitions to dump" );
+ op = new Option( "p", "partitions", true, "the partitions to dump" );
op.setRequired( true );
op.setValueSeparator( File.pathSeparatorChar );
opts.addOption( op );