You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/06/14 11:14:34 UTC
svn commit: r784530 [1/5] - in /directory:
apacheds/trunk/core/src/main/java/org/apache/directory/server/core/
apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/
apacheds/trunk/core/src/test/java/org/apache/directory/serv...
Author: elecharny
Date: Sun Jun 14 09:14:31 2009
New Revision: 784530
URL: http://svn.apache.org/viewvc?rev=784530&view=rev
Log:
o Reviewed and changed the configuration
o LdapService has been renamed to LdapServer
o Transports are now handled differently by servers
o The Sync thread has been moved to DirectoryService
o ApacheDS class has been greatly simplified
o SSL is handled by the Transport
Added:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
- copied, changed from r782897, directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java
Removed:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/unit/AbstractServerTest.java
directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java
directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java
directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ExtendedOperationHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/BindHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/LdapRequestHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchAbandonListener.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/UnbindHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/digestMD5/DigestMd5MechanismHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/CertGenerationRequestHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/LaunchDiagnosticUiHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java
directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapServerSettingsTest.java
directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/SettingAlternativeHandlersTest.java
directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java
directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java
directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java
directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java
directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java
directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java
directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java
directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/ExtendedIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/StoredProcedureIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/NegationSearchIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java
directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
directory/apacheds/trunk/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java
directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java
directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DiagnosticCommand.java
directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DisconnectNotificationCommand.java
directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/GracefulShutdownCommand.java
directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
directory/apacheds/trunk/server-xml/src/main/resources/server.xml
directory/apacheds/trunk/server-xml/src/main/resources/serverAuthenticatorInAuthenticationInterceptor.xml
directory/apacheds/trunk/server-xml/src/main/resources/serverJdbmPartition.xml
directory/apacheds/trunk/server-xml/src/test/java/org/apache/directory/server/SpringServerTest.java
directory/installers/trunk/apacheds-noarch/src/main/java/org/apache/directory/server/Service.java
directory/installers/trunk/apacheds-noarch/src/main/java/org/apache/directory/server/UberjarMain.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Sun Jun 14 09:14:31 2009
@@ -202,12 +202,117 @@
TRUE, // The change must me stored
FALSE // The change must not be stred
};
+
+ /** The delay to wait between each sync on disk */
+ private long syncPeriodMillis;
+
+ /** The default delay to wait between sync on disk : 15 seconds */
+ private static final long DEFAULT_SYNC_PERIOD = 15000;
+
+ /** */
+ private Thread workerThread;
+
+ /** The sync worker thread */
+ private SynchWorker worker = new SynchWorker();
+
+ /** The default timeLimit : 100 entries */
+ public static final int MAX_SIZE_LIMIT_DEFAULT = 100;
+
+ /** The default timeLimit : 10 seconds */
+ public static final int MAX_TIME_LIMIT_DEFAULT = 10000;
+
+ /** The instance Id */
+ private String instanceId;
+
+ /** The server working directory */
+ private File workingDirectory = new File( "server-work" );
+
+ /**
+ * A flag used to shutdown the VM when stopping the server. Useful
+ * when the server is standalone. If the server is embedded, we don't
+ * want to shutdown the VM
+ */
+ private boolean exitVmOnShutdown = true; // allow by default
+
+ /** A flag used to indicate that a shutdown hook has been installed */
+ private boolean shutdownHookEnabled = true; // allow by default
+
+ /** Manage anonymous access to entries other than the RootDSE */
+ private boolean allowAnonymousAccess = true; // allow by default
+
+ /** Manage the basic access control checks */
+ private boolean accessControlEnabled; // off by default
+
+ /** Manage the operational attributes denormalization */
+ private boolean denormalizeOpAttrsEnabled; // off by default
+
+ /** The list of declared interceptors */
+ private List<Interceptor> interceptors;
+
+ /** The System partition */
+ private Partition systemPartition;
+
+ /** The set of all declared partitions */
+ private Set<Partition> partitions = new HashSet<Partition>();
+
+ /** A list of LDIF entries to inject at startup */
+ private List<? extends LdifEntry> testEntries = new ArrayList<LdifEntry>(); // List<Attributes>
+
+ /** The event service */
+ private EventService eventService;
+
+ /** The maximum size for an incoming PDU */
+ private int maxPDUSize = Integer.MAX_VALUE;
+
+
+
+ /**
+ * The synchronizer thread. It flush data on disk periodically.
+ */
+ class SynchWorker implements Runnable
+ {
+ final Object lock = new Object();
+
+ /** A flag to stop the thread */
+ boolean stop;
+
+
+ /**
+ * The main loop
+ */
+ public void run()
+ {
+ while ( !stop )
+ {
+ synchronized ( lock )
+ {
+ try
+ {
+ lock.wait( syncPeriodMillis );
+ }
+ catch ( InterruptedException e )
+ {
+ LOG.warn( "SynchWorker failed to wait on lock.", e );
+ }
+ }
+
+ try
+ {
+ partitionNexus.sync();
+ }
+ catch ( Exception e )
+ {
+ LOG.error( "SynchWorker failed to synch directory.", e );
+ }
+ }
+ }
+ }
+
+
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
-
-
/**
* Creates a new instance of the directory service.
*/
@@ -216,6 +321,7 @@
setDefaultInterceptorConfigurations();
changeLog = new DefaultChangeLog();
journal = new DefaultJournal();
+ syncPeriodMillis = DEFAULT_SYNC_PERIOD;
// --------------------------------------------------------------------
// Load the bootstrap schemas to start up the schema partition
@@ -261,55 +367,6 @@
// ------------------------------------------------------------------------
// C O N F I G U R A T I O N M E T H O D S
// ------------------------------------------------------------------------
-
-
- public static final int MAX_SIZE_LIMIT_DEFAULT = 100;
- public static final int MAX_TIME_LIMIT_DEFAULT = 10000;
-
- /** The instance Id */
- private String instanceId;
-
- /** The server working directory */
- private File workingDirectory = new File( "server-work" );
-
- /**
- * A flag used to shutdown the VM when stopping the server. Useful
- * when the server is standalone. If the server is embedded, we don't
- * want to shutdown the VM
- */
- private boolean exitVmOnShutdown = true; // allow by default
-
- /** A flag used to indicate that a shutdown hook has been installed */
- private boolean shutdownHookEnabled = true; // allow by default
-
- /** Manage anonymous access to entries other than the RootDSE */
- private boolean allowAnonymousAccess = true; // allow by default
-
- /** Manage the basic access control checks */
- private boolean accessControlEnabled; // off by default
-
- /** Manage the operational attributes denormalization */
- private boolean denormalizeOpAttrsEnabled; // off by default
-
- /** The list of declared interceptors */
- private List<Interceptor> interceptors;
-
- /** The System partition */
- private Partition systemPartition;
-
- /** The set of all declared partitions */
- private Set<Partition> partitions = new HashSet<Partition>();
-
- /** A list of LDIF entries to inject at startup */
- private List<? extends LdifEntry> testEntries = new ArrayList<LdifEntry>(); // List<Attributes>
- private EventService eventService;
-
-
-
- /** The maximum size for an incoming PDU */
- private int maxPDUSize = Integer.MAX_VALUE;
-
-
public void setInstanceId( String instanceId )
{
this.instanceId = instanceId;
@@ -914,6 +971,15 @@
initialize();
showSecurityWarnings();
+
+ // Start the sync thread if required
+ if ( syncPeriodMillis > 0 )
+ {
+ workerThread = new Thread( worker, "SynchWorkerThread" );
+ workerThread.start();
+ }
+
+
started = true;
if ( !testEntries.isEmpty() )
@@ -963,6 +1029,26 @@
partitionNexus.destroy();
// --------------------------------------------------------------------
+ // Shutdown the sync thread
+ // --------------------------------------------------------------------
+ if ( workerThread != null )
+ {
+ worker.stop = true;
+
+ synchronized ( worker.lock )
+ {
+ worker.lock.notify();
+ }
+
+ while ( workerThread.isAlive() )
+ {
+ LOG.info( "Waiting for SynchWorkerThread to die." );
+ workerThread.join( 500 );
+ }
+ }
+
+
+ // --------------------------------------------------------------------
// And shutdown the server
// --------------------------------------------------------------------
interceptorChain.destroy();
@@ -1778,4 +1864,22 @@
{
return replicationConfig;
}
+
+
+ /**
+ * @return the syncPeriodMillis
+ */
+ public long getSyncPeriodMillis()
+ {
+ return syncPeriodMillis;
+ }
+
+
+ /**
+ * @param syncPeriodMillis the syncPeriodMillis to set
+ */
+ public void setSyncPeriodMillis( long syncPeriodMillis )
+ {
+ this.syncPeriodMillis = syncPeriodMillis;
+ }
}
Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java Sun Jun 14 09:14:31 2009
@@ -58,6 +58,7 @@
import org.apache.directory.server.core.journal.Journal;
import org.apache.directory.server.core.partition.Partition;
import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.replication.ReplicationConfiguration;
import org.apache.directory.server.core.schema.SchemaOperationControl;
import org.apache.directory.server.core.schema.SchemaService;
import org.apache.directory.server.schema.registries.Registries;
@@ -873,6 +874,18 @@
{
}
+
+ public void setReplicationConfiguration( ReplicationConfiguration replicationConfig )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ReplicationConfiguration getReplicationConfiguration()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java Sun Jun 14 09:14:31 2009
@@ -37,6 +37,7 @@
import org.apache.directory.server.core.partition.ByPassConstants;
import org.apache.directory.server.core.partition.Partition;
import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.replication.ReplicationConfiguration;
import org.apache.directory.server.core.schema.SchemaOperationControl;
import org.apache.directory.server.core.schema.SchemaService;
import org.apache.directory.server.schema.registries.Registries;
@@ -685,5 +686,19 @@
// TODO Auto-generated method stub
}
+
+
+ public void setReplicationConfiguration( ReplicationConfiguration replicationConfig )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public ReplicationConfiguration getReplicationConfiguration()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
}
Modified: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Sun Jun 14 09:14:31 2009
@@ -29,7 +29,7 @@
import org.apache.directory.server.core.integ.Level;
import org.apache.directory.server.core.integ.annotations.CleanupLevel;
import org.apache.directory.server.integ.SiRunner;
-import org.apache.directory.server.ldap.LdapService;
+import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.shared.ldap.client.api.LdapConnection;
import org.apache.directory.shared.ldap.client.api.exception.LdapException;
import org.apache.directory.shared.ldap.client.api.messages.BindResponse;
@@ -48,7 +48,7 @@
public class LdapConnectionTest
{
/** The server instance */
- public static LdapService ldapService;
+ public static LdapServer ldapServer;
/**
@@ -59,7 +59,7 @@
@Test
public void testBindRequest()
{
- LdapConnection connection = new LdapConnection( "localhost", ldapService.getPort() );
+ LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort() );
try
{
@@ -90,7 +90,7 @@
@Test
public void testGetSupportedControls() throws Exception
{
- LdapConnection connection = new LdapConnection( "localhost", ldapService.getPort() );
+ LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort() );
LdapDN dn = new LdapDN( "uid=admin,ou=system" );
connection.bind( dn.getUpName(), "secret" );
Modified: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java Sun Jun 14 09:14:31 2009
@@ -29,7 +29,7 @@
import org.apache.directory.server.core.integ.Level;
import org.apache.directory.server.core.integ.annotations.CleanupLevel;
import org.apache.directory.server.integ.SiRunner;
-import org.apache.directory.server.ldap.LdapService;
+import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.shared.ldap.client.api.LdapConnection;
import org.apache.directory.shared.ldap.client.api.messages.AddResponse;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -51,12 +51,12 @@
public class ClientAddRequestTest
{
/** The server instance */
- public static LdapService ldapService;
+ public static LdapServer ldapServer;
@Test
public void testModify() throws Exception
{
- LdapConnection connection = new LdapConnection( "localhost", ldapService.getPort() );
+ LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort() );
LdapDN bindDn = new LdapDN( "uid=admin,ou=system" );
connection.bind( bindDn.getUpName(), "secret" );
@@ -67,7 +67,7 @@
entry.add( SchemaConstants.CN_AT, "testadd_cn" );
entry.add( SchemaConstants.SN_AT, "testadd_sn" );
- CoreSession session = ldapService.getDirectoryService().getSession();
+ CoreSession session = ldapServer.getDirectoryService().getSession();
assertFalse( session.exists( dn ) );
Modified: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java Sun Jun 14 09:14:31 2009
@@ -33,7 +33,7 @@
import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.annotations.CleanupLevel;
import org.apache.directory.server.integ.SiRunner;
-import org.apache.directory.server.ldap.LdapService;
+import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.shared.ldap.client.api.LdapConnection;
import org.apache.directory.shared.ldap.client.api.messages.DeleteResponse;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -88,7 +88,7 @@
})
public class ClientDeleteRequestTest
{
- public static LdapService ldapService;
+ public static LdapServer ldapServer;
private LdapConnection connection;
@@ -97,12 +97,12 @@
@Before
public void setup() throws Exception
{
- connection = new LdapConnection( "localhost", ldapService.getPort() );
+ connection = new LdapConnection( "localhost", ldapServer.getPort() );
LdapDN bindDn = new LdapDN( "uid=admin,ou=system" );
connection.bind( bindDn.getUpName(), "secret" );
- session = ldapService.getDirectoryService().getAdminSession();
+ session = ldapServer.getDirectoryService().getAdminSession();
}
@After
Modified: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java Sun Jun 14 09:14:31 2009
@@ -29,7 +29,7 @@
import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.annotations.CleanupLevel;
import org.apache.directory.server.integ.SiRunner;
-import org.apache.directory.server.ldap.LdapService;
+import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.shared.ldap.client.api.LdapConnection;
import org.apache.directory.shared.ldap.client.api.messages.ModifyDnResponse;
import org.apache.directory.shared.ldap.entry.Entry;
@@ -55,7 +55,7 @@
})
public class ClientModifyDnRequestTest
{
- public static LdapService ldapService;
+ public static LdapServer ldapServer;
private LdapConnection connection;
@@ -66,12 +66,12 @@
@Before
public void setup() throws Exception
{
- connection = new LdapConnection( "localhost", ldapService.getPort() );
+ connection = new LdapConnection( "localhost", ldapServer.getPort() );
LdapDN bindDn = new LdapDN( "uid=admin,ou=system" );
connection.bind( bindDn.getUpName(), "secret" );
- session = ldapService.getDirectoryService().getAdminSession();
+ session = ldapServer.getDirectoryService().getAdminSession();
}
Modified: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java Sun Jun 14 09:14:31 2009
@@ -26,7 +26,7 @@
import org.apache.directory.server.core.integ.Level;
import org.apache.directory.server.core.integ.annotations.CleanupLevel;
import org.apache.directory.server.integ.SiRunner;
-import org.apache.directory.server.ldap.LdapService;
+import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.shared.ldap.client.api.LdapConnection;
import org.apache.directory.shared.ldap.client.api.messages.ModifyRequest;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -49,12 +49,12 @@
public class ClientModifyRequestTest
{
/** The server instance */
- public static LdapService ldapService;
+ public static LdapServer ldapServer;
@Test
public void testModify() throws Exception
{
- LdapConnection connection = new LdapConnection( "localhost", ldapService.getPort() );
+ LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort() );
LdapDN dn = new LdapDN( "uid=admin,ou=system" );
connection.bind( dn.getUpName(), "secret" );
@@ -65,7 +65,7 @@
connection.modify( modRequest, null );
- ServerEntry entry = ldapService.getDirectoryService().getAdminSession().lookup( dn );
+ ServerEntry entry = ldapServer.getDirectoryService().getAdminSession().lookup( dn );
String actual = entry.get( SchemaConstants.SN_AT ).getString();
@@ -76,7 +76,7 @@
@Test
public void testModifyWithEntry() throws Exception
{
- LdapConnection connection = new LdapConnection( "localhost", ldapService.getPort() );
+ LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort() );
LdapDN dn = new LdapDN( "uid=admin,ou=system" );
connection.bind( dn.getUpName(), "secret" );
@@ -92,7 +92,7 @@
connection.modify( entry, ModificationOperation.REPLACE_ATTRIBUTE );
- ServerEntry lookupEntry = ldapService.getDirectoryService().getAdminSession().lookup( dn );
+ ServerEntry lookupEntry = ldapServer.getDirectoryService().getAdminSession().lookup( dn );
String actualSn = lookupEntry.get( SchemaConstants.SN_AT ).getString();
assertEquals( expectedSn, actualSn );
Modified: directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/unit/AbstractServerTest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/unit/AbstractServerTest.java (original)
+++ directory/apacheds/trunk/ldap-api-test/src/test/java/org/apache/directory/shared/client/api/unit/AbstractServerTest.java Sun Jun 14 09:14:31 2009
@@ -44,7 +44,7 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.jndi.CoreContextFactory;
-import org.apache.directory.server.ldap.LdapService;
+import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.server.ldap.handlers.bind.MechanismHandler;
import org.apache.directory.server.ldap.handlers.bind.cramMD5.CramMd5MechanismHandler;
import org.apache.directory.server.ldap.handlers.bind.digestMD5.DigestMd5MechanismHandler;
@@ -99,7 +99,7 @@
protected static int nbTests = 10000;
protected static DirectoryService directoryService;
protected NioSocketAcceptor socketAcceptor;
- protected static LdapService ldapService;
+ protected static LdapServer ldapServer;
private static final String CTX_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory";
@@ -248,11 +248,11 @@
directoryService = new DefaultDirectoryService();
directoryService.setShutdownHookEnabled( false );
port = AvailablePortFinder.getNextAvailable( 1024 );
- ldapService = new LdapService();
- ldapService.setTcpTransport( new TcpTransport( port ) );
- ldapService.setDirectoryService( directoryService );
+ ldapServer = new LdapServer();
+ ldapServer.setTransports( new TcpTransport( port ) );
+ ldapServer.setDirectoryService( directoryService );
- setupSaslMechanisms( ldapService );
+ setupSaslMechanisms( ldapServer );
doDelete( directoryService.getWorkingDirectory() );
configureDirectoryService();
@@ -261,15 +261,15 @@
configureLdapServer();
// TODO shouldn't this be before calling configureLdapServer() ???
- ldapService.addExtendedOperationHandler( new StartTlsHandler() );
- ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
+ ldapServer.addExtendedOperationHandler( new StartTlsHandler() );
+ ldapServer.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
- ldapService.start();
+ ldapServer.start();
setContexts( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
}
- private static void setupSaslMechanisms( LdapService server )
+ private static void setupSaslMechanisms( LdapServer server )
{
Map<String, MechanismHandler> mechanismHandlerMap = new HashMap<String,MechanismHandler>();
@@ -292,7 +292,7 @@
mechanismHandlerMap.put( SupportedSaslMechanisms.NTLM, ntlmMechanismHandler );
mechanismHandlerMap.put( SupportedSaslMechanisms.GSS_SPNEGO, ntlmMechanismHandler );
- ldapService.setSaslMechanismHandlers( mechanismHandlerMap );
+ ldapServer.setSaslMechanismHandlers( mechanismHandlerMap );
}
@@ -378,7 +378,7 @@
@AfterClass
public static void tearDown() throws Exception
{
- ldapService.stop();
+ ldapServer.stop();
try
{
Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java Sun Jun 14 09:14:31 2009
@@ -34,8 +34,13 @@
import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
import org.apache.directory.server.protocol.shared.DirectoryBackedService;
import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.Transport;
import org.apache.directory.server.protocol.shared.transport.UdpTransport;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.mina.core.service.IoAcceptor;
+import org.apache.mina.transport.socket.DatagramAcceptor;
+import org.apache.mina.transport.socket.DatagramSessionConfig;
+import org.apache.mina.transport.socket.SocketAcceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -122,8 +127,7 @@
super.setServiceName( SERVICE_NAME_DEFAULT );
super.setServiceId( SERVICE_PID_DEFAULT );
super.setSearchBaseDn( ServerDNConstants.USER_EXAMPLE_COM_DN );
- setTcpTransport( new TcpTransport( DEFAULT_IP_PORT ) );
- setUdpTransport( new UdpTransport( DEFAULT_IP_PORT ) );
+ setTransports( new TcpTransport( DEFAULT_IP_PORT ), new UdpTransport( DEFAULT_IP_PORT ) );
prepareEncryptionTypes();
}
@@ -269,18 +273,53 @@
{
PrincipalStore store = new DirectoryPrincipalStore( getDirectoryService(), new LdapDN(this.getSearchBaseDn()) );
- if ( getDatagramAcceptor() != null )
+ if ( ( transports == null ) || ( transports.length == 0 ) )
{
- getDatagramAcceptor().setHandler( new ChangePasswordProtocolHandler( this, store ) );
- getDatagramAcceptor().bind();
+ // Default to UDP with port 464
+ // We have to create a DatagramAcceptor
+ UdpTransport transport = new UdpTransport( DEFAULT_IP_PORT );
+ setTransports( transport );
+
+ DatagramAcceptor acceptor = (DatagramAcceptor)transport.getAcceptor();
+
+ // Set the handler
+ acceptor.setHandler( new ChangePasswordProtocolHandler( this, store ) );
+
+ // Allow the port to be reused even if the socket is in TIME_WAIT state
+ ((DatagramSessionConfig)acceptor.getSessionConfig()).setReuseAddress( true );
+
+ // Start the listener
+ acceptor.bind();
}
-
- if ( getSocketAcceptor() != null )
+ else
{
- getSocketAcceptor().setCloseOnDeactivation( false );
- getSocketAcceptor().setReuseAddress( true );
- getSocketAcceptor().setHandler( new ChangePasswordProtocolHandler( this, store ) );
- getSocketAcceptor().bind();
+ for ( Transport transport:transports )
+ {
+ IoAcceptor acceptor = transport.getAcceptor();
+
+ // Disable the disconnection of the clients on unbind
+ acceptor.setCloseOnDeactivation( false );
+
+ if ( transport instanceof UdpTransport )
+ {
+ // Allow the port to be reused even if the socket is in TIME_WAIT state
+ ((DatagramSessionConfig)acceptor.getSessionConfig()).setReuseAddress( true );
+ }
+ else
+ {
+ // Allow the port to be reused even if the socket is in TIME_WAIT state
+ ((SocketAcceptor)acceptor).setReuseAddress( true );
+
+ // No Nagle's algorithm
+ ((SocketAcceptor)acceptor).getSessionConfig().setTcpNoDelay( true );
+ }
+
+ // Set the handler
+ acceptor.setHandler( new ChangePasswordProtocolHandler( this, store ) );
+
+ // Bind
+ acceptor.bind();
+ }
}
LOG.info( "ChangePassword service started." );
@@ -290,13 +329,14 @@
public void stop()
{
- if ( getDatagramAcceptor() != null )
- {
- getDatagramAcceptor().dispose();
- }
- if ( getSocketAcceptor() != null )
+ for ( Transport transport :getTransports() )
{
- getSocketAcceptor().dispose();
+ IoAcceptor acceptor = transport.getAcceptor();
+
+ if ( acceptor != null )
+ {
+ acceptor.dispose();
+ }
}
LOG.info( "ChangePassword service stopped." );
@@ -355,4 +395,25 @@
{
this.policyTokenSize = policyTokenSize;
}
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "ChangePasswordServer[" ).append( getServiceName() ).append( "], listening on :" ).append( '\n' );
+
+ if ( getTransports() != null )
+ {
+ for ( Transport transport:getTransports() )
+ {
+ sb.append( " " ).append( transport ).append( '\n' );
+ }
+ }
+
+ return sb.toString();
+ }
}
Modified: directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java (original)
+++ directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java Sun Jun 14 09:14:31 2009
@@ -27,7 +27,12 @@
import org.apache.directory.server.dns.store.jndi.JndiRecordStoreImpl;
import org.apache.directory.server.protocol.shared.DirectoryBackedService;
import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.Transport;
import org.apache.directory.server.protocol.shared.transport.UdpTransport;
+import org.apache.mina.core.service.IoAcceptor;
+import org.apache.mina.transport.socket.DatagramAcceptor;
+import org.apache.mina.transport.socket.DatagramSessionConfig;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,8 +69,7 @@
{
super.setServiceId( SERVICE_PID_DEFAULT );
super.setServiceName( SERVICE_NAME_DEFAULT );
- setTcpTransport( new TcpTransport( DEFAULT_IP_PORT ) );
- setUdpTransport( new UdpTransport( DEFAULT_IP_PORT ) );
+ setTransports( new TcpTransport( DEFAULT_IP_PORT ), new UdpTransport( DEFAULT_IP_PORT ) );
}
@@ -76,37 +80,94 @@
{
RecordStore store = new JndiRecordStoreImpl( getSearchBaseDn(), getSearchBaseDn(), getDirectoryService() );
- if ( getDatagramAcceptor() != null )
+ if ( ( transports == null ) || ( transports.length == 0 ) )
{
- getDatagramAcceptor().setHandler( new DnsProtocolHandler( this, store ) );
- getDatagramAcceptor().bind();
- }
+ // Default to UDP with port 53
+ // We have to create a DatagramAcceptor
+ UdpTransport transport = new UdpTransport( DEFAULT_IP_PORT );
+ setTransports( transport );
+
+ DatagramAcceptor acceptor = (DatagramAcceptor)transport.getAcceptor();
- if ( getSocketAcceptor() != null )
- {
- getSocketAcceptor().setCloseOnDeactivation( false );
- getSocketAcceptor().setReuseAddress( true );
- getSocketAcceptor().setHandler( new DnsProtocolHandler( this, store ) );
- getSocketAcceptor().bind();
+ // Set the handler
+ acceptor.setHandler( new DnsProtocolHandler( this, store ) );
+
+ // Allow the port to be reused even if the socket is in TIME_WAIT state
+ ((DatagramSessionConfig)acceptor.getSessionConfig()).setReuseAddress( true );
+
+ // Start the listener
+ acceptor.bind();
}
+ else
+ {
+ for ( Transport transport:transports )
+ {
+ // Get the acceptor
+ IoAcceptor acceptor = transport.getAcceptor();
+
+ // Set the handler
+ acceptor.setHandler( new DnsProtocolHandler( this, store ) );
+
+ if ( transport instanceof UdpTransport )
+ {
+ // Allow the port to be reused even if the socket is in TIME_WAIT state
+ ((DatagramSessionConfig)acceptor.getSessionConfig()).setReuseAddress( true );
+ }
+ else
+ {
+ // Disable the disconnection of the clients on unbind
+ acceptor.setCloseOnDeactivation( false );
+
+ // Allow the port to be reused even if the socket is in TIME_WAIT state
+ ((NioSocketAcceptor)acceptor).setReuseAddress( true );
+
+ // No Nagle's algorithm
+ ((NioSocketAcceptor)acceptor).getSessionConfig().setTcpNoDelay( true );
+ }
- LOG.info( "DSN service started." );
- System.out.println( "DSN service started." );
+ // Start the listener
+ acceptor.bind();
+ }
+ }
+
+ LOG.info( "DNS service started." );
+ System.out.println( "DNS service started." );
}
public void stop() {
- if ( getDatagramAcceptor() != null )
+ for ( Transport transport :getTransports() )
{
- getDatagramAcceptor().dispose();
+ IoAcceptor acceptor = transport.getAcceptor();
+
+ if ( acceptor != null )
+ {
+ acceptor.dispose();
+ }
}
- if ( getSocketAcceptor() != null )
+ LOG.info( "DNS service stopped." );
+ System.out.println( "DNS service stopped." );
+ }
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "DNSServer[" ).append( getServiceName() ).append( "], listening on :" ).append( '\n' );
+
+ if ( getTransports() != null )
{
- getSocketAcceptor().dispose();
+ for ( Transport transport:getTransports() )
+ {
+ sb.append( " " ).append( transport ).append( '\n' );
+ }
}
- LOG.info( "DSN service stopped." );
- System.out.println( "DSN service stopped." );
+ return sb.toString();
}
}
Modified: directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java (original)
+++ directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java Sun Jun 14 09:14:31 2009
@@ -66,8 +66,7 @@
dnsConfiguration = new DnsServer();
dnsConfiguration.setDirectoryService( directoryService );
dnsConfiguration.setEnabled( true );
- dnsConfiguration.setTcpTransport( new TcpTransport( 10053 ) );
- dnsConfiguration.setUdpTransport( new UdpTransport( 10053 ) );
+ dnsConfiguration.setTransports( new TcpTransport( 10053 ), new UdpTransport( 10053 ) );
dnsConfiguration.start();
}
Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java Sun Jun 14 09:14:31 2009
@@ -43,6 +43,7 @@
import org.apache.mina.core.filterchain.IoFilterChainBuilder;
import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.transport.socket.DatagramAcceptor;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -161,8 +162,7 @@
super.setServiceName( DEFAULT_NAME );
super.setServiceId( DEFAULT_PID );
super.setSearchBaseDn( ServerDNConstants.USER_EXAMPLE_COM_DN );
- setTcpTransport( new TcpTransport( DEFAULT_IP_PORT ) );
- setUdpTransport( new UdpTransport( DEFAULT_IP_PORT ) );
+ setTransports( new TcpTransport( DEFAULT_IP_PORT ), new UdpTransport( DEFAULT_IP_PORT ) );
prepareEncryptionTypes();
@@ -444,14 +444,15 @@
// TODO - for now ignoring this catalog crap
store = new DirectoryPrincipalStore( getDirectoryService(), new LdapDN(this.getSearchBaseDn()) );
- Transport udpTransport = getUdpTransport();
-
- // Kerberos can use UDP or TCP
- if ( udpTransport != null )
+ if ( ( transports == null ) || ( transports.length == 0 ) )
{
- IoAcceptor udpAcceptor = udpTransport.getAcceptor();
+ // Default to UDP with port 88
+ // We have to create a DatagramAcceptor
+ UdpTransport transport = new UdpTransport( DEFAULT_IP_PORT );
+ setTransports( transport );
- // Now, configure the acceptor
+ DatagramAcceptor acceptor = (DatagramAcceptor)transport.getAcceptor();
+
// Inject the chain
IoFilterChainBuilder udpChainBuilder = new DefaultIoFilterChainBuilder();
@@ -459,45 +460,58 @@
new ProtocolCodecFilter(
KerberosUdpProtocolCodecFactory.getInstance() ) );
- udpAcceptor.setFilterChainBuilder( udpChainBuilder );
-
+ acceptor.setFilterChainBuilder( udpChainBuilder );
+
// Inject the protocol handler
- udpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
+ acceptor.setHandler( new KerberosProtocolHandler( this, store ) );
// Bind to the configured address
- udpAcceptor.bind();
+ acceptor.bind();
}
-
- Transport tcpTransport = getTcpTransport();
-
- if ( tcpTransport != null )
+ else
{
- NioSocketAcceptor tcpAcceptor = (NioSocketAcceptor)tcpTransport.getAcceptor();
-
- // Now, configure the acceptor
- // Disable the disconnection of the clients on unbind
- tcpAcceptor.setCloseOnDeactivation( false );
-
- // No Nagle's algorithm
- tcpAcceptor.getSessionConfig().setTcpNoDelay( true );
-
- // Allow the port to be reused even if the socket is in TIME_WAIT state
- tcpAcceptor.setReuseAddress( true );
-
- // Inject the chain
- IoFilterChainBuilder tcpChainBuilder = new DefaultIoFilterChainBuilder();
-
- ((DefaultIoFilterChainBuilder)tcpChainBuilder).addFirst( "codec",
- new ProtocolCodecFilter(
- KerberosTcpProtocolCodecFactory.getInstance() ) );
+ // Kerberos can use UDP or TCP
+ for ( Transport transport:transports )
+ {
+ IoAcceptor acceptor = transport.getAcceptor();
+
+ // Now, configure the acceptor
+ // Inject the chain
+ IoFilterChainBuilder chainBuilder = new DefaultIoFilterChainBuilder();
+
+ if ( transport instanceof TcpTransport )
+ {
+ // Now, configure the acceptor
+ // Disable the disconnection of the clients on unbind
+ acceptor.setCloseOnDeactivation( false );
+
+ // No Nagle's algorithm
+ ((NioSocketAcceptor)acceptor).getSessionConfig().setTcpNoDelay( true );
+
+ // Allow the port to be reused even if the socket is in TIME_WAIT state
+ ((NioSocketAcceptor)acceptor).setReuseAddress( true );
+
+ // Inject the codec
+ ((DefaultIoFilterChainBuilder)chainBuilder).addFirst( "codec",
+ new ProtocolCodecFilter(
+ KerberosTcpProtocolCodecFactory.getInstance() ) );
+ }
+ else
+ {
+ // Inject the codec
+ ((DefaultIoFilterChainBuilder)chainBuilder).addFirst( "codec",
+ new ProtocolCodecFilter(
+ KerberosUdpProtocolCodecFactory.getInstance() ) );
+ }
- tcpAcceptor.setFilterChainBuilder( tcpChainBuilder );
-
- // Inject the protocol handler
- tcpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
-
- // Bind to the configured address
- tcpAcceptor.bind();
+ acceptor.setFilterChainBuilder( chainBuilder );
+
+ // Inject the protocol handler
+ acceptor.setHandler( new KerberosProtocolHandler( this, store ) );
+
+ // Bind to the configured address
+ acceptor.bind();
+ }
}
LOG.info( "Kerberos service started." );
@@ -507,14 +521,14 @@
public void stop()
{
- if ( getDatagramAcceptor() != null )
- {
- getDatagramAcceptor().dispose();
- }
-
- if ( getSocketAcceptor() != null )
+ for ( Transport transport :getTransports() )
{
- getSocketAcceptor().dispose();
+ IoAcceptor acceptor = transport.getAcceptor();
+
+ if ( acceptor != null )
+ {
+ acceptor.dispose();
+ }
}
LOG.info( "Kerberos service stopped." );
@@ -542,4 +556,25 @@
}
}
}
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "KDCServer[" ).append( getServiceName() ).append( "], listening on :" ).append( '\n' );
+
+ if ( getTransports() != null )
+ {
+ for ( Transport transport:getTransports() )
+ {
+ sb.append( " " ).append( transport ).append( '\n' );
+ }
+ }
+
+ return sb.toString();
+ }
}
Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java Sun Jun 14 09:14:31 2009
@@ -96,13 +96,12 @@
{
super.setUp();
- ldapService.setSaslHost( "localhost" );
- ldapService.setSaslPrincipal( "ldap/localhost@EXAMPLE.COM" );
+ ldapServer.setSaslHost( "localhost" );
+ ldapServer.setSaslPrincipal( "ldap/localhost@EXAMPLE.COM" );
KdcServer kdcConfig = new KdcServer();
kdcConfig.setDirectoryService( directoryService );
- kdcConfig.setTcpTransport( new TcpTransport(6088) );
- kdcConfig.setUdpTransport( new UdpTransport(6088) );
+ kdcConfig.setTransports( new TcpTransport(6088), new UdpTransport(6088) );
kdcConfig.setEnabled( true );
kdcConfig.setSearchBaseDn( "ou=users,dc=example,dc=com" );
kdcConfig.start();
@@ -132,10 +131,10 @@
}
LdapDN contextDn = new LdapDN( "dc=example,dc=com" );
- ServerEntry entry = ldapService.getDirectoryService().newEntry( contextDn );
+ ServerEntry entry = ldapServer.getDirectoryService().newEntry( contextDn );
entry.add( "objectClass", "top", "domain", "extensibleObject" );
entry.add( "dc", "example" );
- ldapService.getDirectoryService().getAdminSession().add( entry );
+ ldapServer.getDirectoryService().getAdminSession().add( entry );
// Get a context, create the ou=users subcontext, then create the 3 principals.
Hashtable<String, Object> env = new Hashtable<String, Object>();
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ExtendedOperationHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ExtendedOperationHandler.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ExtendedOperationHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ExtendedOperationHandler.java Sun Jun 14 09:14:31 2009
@@ -67,7 +67,7 @@
/**
* Sets the LDAP server for this extendedOperation handler.
*
- * @param ldapService the ldap protocol server
+ * @param ldapServer the ldap protocol server
*/
- void setLdapServer( LdapService ldapService );
+ void setLdapServer( LdapServer ldapServer );
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java Sun Jun 14 09:14:31 2009
@@ -40,10 +40,10 @@
/**
* The MINA IoHandler implementation extending {@link DemuxingIoHandler} for
- * the LDAP protocol. THe {@link LdapService} creates this multiplexing
+ * the LDAP protocol. THe {@link LdapServer} creates this multiplexing
* {@link IoHandler} handler and populates it with subordinate handlers for
* the various kinds of LDAP {@link InternalRequest} messages. This is done in the
- * setXxxHandler() methods of the LdapService where Xxxx is Add, Modify, etc.
+ * setXxxHandler() methods of the LdapServer where Xxxx is Add, Modify, etc.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
@@ -53,18 +53,18 @@
/** The logger */
private static final Logger LOG = LoggerFactory.getLogger( LdapProtocolHandler.class );
- /** the {@link LdapService} this handler is associated with */
- private final LdapService ldapService;
+ /** the {@link LdapServer} this handler is associated with */
+ private final LdapServer ldapServer;
/**
* Creates a new instance of LdapProtocolHandler.
*
- * @param ldapService
+ * @param ldapServer
*/
- LdapProtocolHandler( LdapService ldapService )
+ LdapProtocolHandler( LdapServer ldapServer )
{
- this.ldapService = ldapService;
+ this.ldapServer = ldapServer;
}
@@ -75,7 +75,7 @@
public void sessionCreated( IoSession session ) throws Exception
{
LdapSession ldapSession = new LdapSession( session );
- ldapService.getLdapSessionManager().addLdapSession( ldapSession );
+ ldapServer.getLdapSessionManager().addLdapSession( ldapSession );
}
@@ -88,7 +88,7 @@
public void sessionClosed( IoSession session )
{
// Get the associated LdapSession
- LdapSession ldapSession = ldapService.getLdapSessionManager().removeLdapSession( session );
+ LdapSession ldapSession = ldapServer.getLdapSessionManager().removeLdapSession( session );
// Clean it up !
cleanUpSession( ldapSession );
@@ -180,7 +180,7 @@
for ( Control control1 : req.getControls().values() )
{
InternalControl control = ( InternalControl ) control1;
- if ( control.isCritical() && ! ldapService.getSupportedControls().contains( control.getID() ) )
+ if ( control.isCritical() && ! ldapServer.getSupportedControls().contains( control.getID() ) )
{
InternalResultResponse resp = req.getResultResponse();
resp.getLdapResult().setErrorMessage( "Unsupport critical control: " + control.getID() );
@@ -215,7 +215,7 @@
LOG.warn( "Unexpected exception forcing session to close: sending disconnect notice to client.", cause );
session.write( NoticeOfDisconnect.PROTOCOLERROR );
- LdapSession ldapSession = this.ldapService.getLdapSessionManager().removeLdapSession( session );
+ LdapSession ldapSession = this.ldapServer.getLdapSessionManager().removeLdapSession( session );
cleanUpSession( ldapSession );
session.close( true );
}
Copied: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java (from r782897, directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java?p2=directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java&p1=directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java&r1=782897&r2=784530&rev=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java Sun Jun 14 09:14:31 2009
@@ -23,6 +23,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyStore;
+import java.security.KeyStoreSpi;
import java.security.Provider;
import java.security.Security;
import java.util.ArrayList;
@@ -53,6 +54,9 @@
import org.apache.directory.server.ldap.handlers.ssl.LdapsInitializer;
import org.apache.directory.server.ldap.replication.ReplicationSystem;
import org.apache.directory.server.protocol.shared.DirectoryBackedService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.Transport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
import org.apache.directory.shared.ldap.constants.SaslQoP;
import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
import org.apache.directory.shared.ldap.message.InternalAbandonRequest;
@@ -100,8 +104,13 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev: 688548 $
*/
-public class LdapService extends DirectoryBackedService
+public class LdapServer extends DirectoryBackedService
{
+ private static final long serialVersionUID = 3757127143811666817L;
+
+ /** logger for this class */
+ private static final Logger LOG = LoggerFactory.getLogger( LdapServer.class.getName() );
+
/** Value (0) for configuration where size limit is unlimited. */
public static final int NO_SIZE_LIMIT = 0;
@@ -111,12 +120,6 @@
/** the constant service name of this ldap protocol provider **/
public static final String SERVICE_NAME = "ldap";
-
- private static final long serialVersionUID = 3757127143811666817L;
-
- /** logger for this class */
- private static final Logger LOG = LoggerFactory.getLogger( LdapService.class.getName() );
-
/** The default maximum size limit. */
private static final int MAX_SIZE_LIMIT_DEFAULT = 100;
@@ -130,9 +133,9 @@
private static final String SERVICE_NAME_DEFAULT = "ApacheDS LDAP Service";
/** The default IP port. */
- private static final int IP_PORT_DEFAULT = 389;
+ private static final int DEFAULT_IP_PORT = 389;
- /** the session manager for this LdapService */
+ /** the session manager for this LdapServer */
private LdapSessionManager ldapSessionManager = new LdapSessionManager();
/** a set of supported controls */
@@ -140,19 +143,16 @@
/**
* The maximum size limit.
- * @see {@link LdapService#MAX_SIZE_LIMIT_DEFAULT }
+ * @see {@link LdapServer#MAX_SIZE_LIMIT_DEFAULT }
*/
private int maxSizeLimit = MAX_SIZE_LIMIT_DEFAULT;
/**
* The maximum time limit.
- * @see {@link LdapService#MAX_TIME_LIMIT_DEFAULT }
+ * @see {@link LdapServer#MAX_TIME_LIMIT_DEFAULT }
*/
private int maxTimeLimit = MAX_TIME_LIMIT_DEFAULT;
- /** Whether LDAPS is enabled: disabled by default. */
- private boolean enableLdaps;
-
/** If LDAPS is activated : the external Keystore file, if defined */
private String keystoreFile;
@@ -217,7 +217,7 @@
/**
* Creates an LDAP protocol provider.
*/
- public LdapService()
+ public LdapServer()
{
super.setEnabled( true );
super.setServiceId( SERVICE_PID_DEFAULT );
@@ -305,6 +305,14 @@
}
}
+
+ private class AdsKeyStore extends KeyStore
+ {
+ public AdsKeyStore( KeyStoreSpi keyStoreSpi, Provider provider, String type )
+ {
+ super( keyStoreSpi, provider, type );
+ }
+ }
/**
* @throws IOException if we cannot bind to the specified port
@@ -317,129 +325,139 @@
return;
}
- IoFilterChainBuilder chain;
-
- if ( isEnableLdaps() )
+ for ( Transport transport:transports )
{
- KeyStore keyStore = null;
+ if ( !(transport instanceof TcpTransport ) )
+ {
+ LOG.warn( "Cannot listen on an UDP transport : {}", transport );
+ continue;
+ }
- if ( StringTools.isEmpty( keystoreFile ) )
+ IoFilterChainBuilder chain;
+
+ if ( transport.isSSLEnabled() )
{
- Provider provider = Security.getProvider( "SUN" );
- LOG.debug( "provider = {}", provider );
- CoreKeyStoreSpi coreKeyStoreSpi = new CoreKeyStoreSpi( getDirectoryService() );
- keyStore = new KeyStore( coreKeyStoreSpi, provider, "JKS" ) {};
+ KeyStore keyStore = null;
- try
+ if ( StringTools.isEmpty( keystoreFile ) )
{
- keyStore.load( null, null );
+ Provider provider = Security.getProvider( "SUN" );
+ LOG.debug( "provider = {}", provider );
+ CoreKeyStoreSpi coreKeyStoreSpi = new CoreKeyStoreSpi( getDirectoryService() );
+ keyStore = new AdsKeyStore( coreKeyStoreSpi, provider, "JKS" );
+
+ try
+ {
+ keyStore.load( null, null );
+ }
+ catch ( Exception e )
+ {
+ // nothing really happens with this keystore
+ }
}
- catch ( Exception e )
+ else
{
- // nothing really happens with this keystore
+ keyStore = AdsKeyStore.getInstance( KeyStore.getDefaultType() );
+ FileInputStream fis = new FileInputStream( keystoreFile );
+
+
+ keyStore.load( fis, null );
}
+
+ chain = LdapsInitializer.init( keyStore, certificatePassword );
}
else
{
- keyStore = KeyStore.getInstance( KeyStore.getDefaultType() );
- FileInputStream fis = new FileInputStream( keystoreFile );
-
-
- keyStore.load( fis, null );
+ chain = new DefaultIoFilterChainBuilder();
}
- chain = LdapsInitializer.init( keyStore, certificatePassword );
- }
- else
- {
- chain = new DefaultIoFilterChainBuilder();
+ // Inject the codec into the chain
+ ((DefaultIoFilterChainBuilder)chain).addLast( "codec",
+ new ProtocolCodecFilter( this.getProtocolCodecFactory() ) );
+
+ // Now inject an ExecutorFilter for the write operations
+ // We use the same number of thread than the number of IoProcessor
+ // (NOTE : this has to be double checked)
+ ((DefaultIoFilterChainBuilder)chain).addLast( "executor",
+ new ExecutorFilter(
+ new OrderedThreadPoolExecutor( transport.getNbThreads() ) ) );
+
+ /*
+ * The server is now initialized, we can
+ * install the default requests handlers, which need
+ * access to the DirectoryServer instance.
+ */
+ installDefaultHandlers();
+
+ startNetwork( transport, chain );
}
- // Inject the codec into the chain
- ((DefaultIoFilterChainBuilder)chain).addLast( "codec",
- new ProtocolCodecFilter( this.getProtocolCodecFactory() ) );
-
- // Now inject an ExecutorFilter for the write operations
- // We use the same number of thread than the number of IoProcessor
- // (NOTE : this has to be double checked)
- ((DefaultIoFilterChainBuilder)chain).addLast( "executor",
- new ExecutorFilter(
- new OrderedThreadPoolExecutor( getTcpTransport().getNbThreads() ) ) );
-
- /*
- * The server is now initialized, we can
- * install the default requests handlers, which need
- * access to the DirectoryServer instance.
- */
- installDefaultHandlers();
-
- startNetwork(
- getTcpTransport().getAddress(),
- getTcpTransport().getPort(),
- getTcpTransport().getBackLog(), chain );
-
started = true;
- if ( isEnableLdaps() )
- {
- LOG.info( "Ldaps service started." );
- }
- else
- {
- LOG.info( "Ldap service started." );
- }
+ LOG.info( "Ldap service started." );
}
+ /**
+ * {@inheritDoc}
+ */
public void stop()
{
try
{
- // we should unbind the service before we begin sending the notice
- // of disconnect so new connections are not formed while we process
- List<WriteFuture> writeFutures = new ArrayList<WriteFuture>();
-
- // 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
- // sent notices to to the existing active sessions
- List<IoSession> sessions;
-
- try
- {
- sessions = new ArrayList<IoSession>(
- getSocketAcceptor().getManagedSessions().values() );
- }
- catch ( IllegalArgumentException e )
- {
- LOG.warn( "Seems like the LDAP service (" + getPort() + ") has already been unbound." );
- return;
- }
-
- getSocketAcceptor().dispose();
-
- if ( LOG.isInfoEnabled() )
+ for ( Transport transport:transports )
{
- LOG.info( "Unbind of an LDAP service (" + getPort() + ") is complete." );
- LOG.info( "Sending notice of disconnect to existing clients sessions." );
- }
-
- // Send Notification of Disconnection messages to all connected clients.
- if ( sessions != null )
- {
- for ( IoSession session:sessions )
+ if ( !(transport instanceof TcpTransport ) )
{
- writeFutures.add( session.write( NoticeOfDisconnect.UNAVAILABLE ) );
+ continue;
+ }
+
+ // we should unbind the service before we begin sending the notice
+ // of disconnect so new connections are not formed while we process
+ List<WriteFuture> writeFutures = new ArrayList<WriteFuture>();
+
+ // 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
+ // sent notices to to the existing active sessions
+ List<IoSession> sessions;
+
+ try
+ {
+ sessions = new ArrayList<IoSession>(
+ getSocketAcceptor( transport ).getManagedSessions().values() );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ LOG.warn( "Seems like the LDAP service (" + getPort() + ") has already been unbound." );
+ return;
+ }
+
+ getSocketAcceptor( transport ).dispose();
+
+ if ( LOG.isInfoEnabled() )
+ {
+ LOG.info( "Unbind of an LDAP service (" + getPort() + ") is complete." );
+ LOG.info( "Sending notice of disconnect to existing clients sessions." );
+ }
+
+ // Send Notification of Disconnection messages to all connected clients.
+ if ( sessions != null )
+ {
+ for ( IoSession session:sessions )
+ {
+ writeFutures.add( session.write( NoticeOfDisconnect.UNAVAILABLE ) );
+ }
+ }
+
+ // And close the connections when the NoDs are sent.
+ Iterator<IoSession> sessionIt = sessions.iterator();
+
+ for ( WriteFuture future:writeFutures )
+ {
+ future.await( 1000L );
+ sessionIt.next().close( true );
}
- }
-
- // And close the connections when the NoDs are sent.
- Iterator<IoSession> sessionIt = sessions.iterator();
-
- for ( WriteFuture future:writeFutures )
- {
- future.await( 1000L );
- sessionIt.next().close( true );
}
}
catch ( Exception e )
@@ -447,24 +465,17 @@
LOG.warn( "Failed to sent NoD.", e );
}
- if ( isEnableLdaps() )
- {
- LOG.info( "Ldaps service stopped." );
- }
- else
- {
- LOG.info( "Ldap service stopped." );
- }
+ LOG.info( "Ldap service stopped." );
}
- private void startNetwork( String hostname, int port,int backlog, IoFilterChainBuilder chainBuilder )
+ private void startNetwork( Transport transport, IoFilterChainBuilder chainBuilder )
throws Exception
{
- if ( backlog < 0 )
+ if ( transport.getBackLog() < 0 )
{
- // Set the baclog to the default value when it's below 0
- backlog = 50;
+ // Set the backlog to the default value when it's below 0
+ transport.setBackLog( 50 );
}
PartitionNexus nexus = getDirectoryService().getPartitionNexus();
@@ -480,7 +491,7 @@
try
{
- SocketAcceptor acceptor = getSocketAcceptor();
+ SocketAcceptor acceptor = getSocketAcceptor( transport );
// Now, configure the acceptor
// Disable the disconnection of the clients on unbind
@@ -506,12 +517,12 @@
if ( LOG.isInfoEnabled() )
{
- LOG.info( "Successful bind of an LDAP Service (" + port + ") is complete." );
+ LOG.info( "Successful bind of an LDAP Service (" + transport.getPort() + ") is completed." );
}
}
catch ( IOException e )
{
- String msg = "Failed to bind an LDAP service (" + port + ") to the service registry.";
+ String msg = "Failed to bind an LDAP service (" + transport.getPort() + ") to the service registry.";
LdapConfigurationException lce = new LdapConfigurationException( msg );
lce.setRootCause( e );
LOG.error( msg, e );
@@ -620,7 +631,7 @@
/**
- * Sets the mode for this LdapService to accept requests with or without a
+ * Sets the mode for this LdapServer to accept requests with or without a
* TLS secured connection via either StartTLS extended operations or using
* LDAPS.
*
@@ -634,7 +645,7 @@
/**
* Gets whether or not TLS secured connections are required to perform
- * operations on this LdapService.
+ * operations on this LdapServer.
*
* @return true if TLS secured connections are required, false otherwise
*/
@@ -649,20 +660,9 @@
*
* @return True if LDAPS is enabled.
*/
- public boolean isEnableLdaps()
+ public boolean isEnableLdaps( Transport transport )
{
- return enableLdaps;
- }
-
-
- /**
- * Sets if LDAPS is enabled or not.
- *
- * @param enableLdaps Whether LDAPS is enabled.
- */
- public void setEnableLdaps( boolean enableLdaps )
- {
- this.enableLdaps = enableLdaps;
+ return transport.isSSLEnabled();
}
@@ -1124,11 +1124,56 @@
*/
public int getPort()
{
- return getTcpTransport() == null ? -1 : getTcpTransport().getPort();
+ if ( transports == null )
+ {
+ return -1;
+ }
+
+ for ( Transport transport:transports )
+ {
+ if ( transport instanceof UdpTransport )
+ {
+ continue;
+ }
+
+ if ( !transport.isSSLEnabled() )
+ {
+ return transport.getPort();
+ }
+ }
+
+ return -1;
}
/**
+ * @return The underlying SSL enabled TCP transport port, or -1 if no transport has been
+ * initialized
+ */
+ public int getPortSSL()
+ {
+ if ( transports == null )
+ {
+ return -1;
+ }
+
+ for ( Transport transport:transports )
+ {
+ if ( transport instanceof UdpTransport )
+ {
+ continue;
+ }
+
+ if ( transport.isSSLEnabled() )
+ {
+ return transport.getPort();
+ }
+ }
+
+ return -1;
+ }
+
+ /**
* @org.apache.xbean.Property hidden="true"
* @param abandonHandler The UnbindRequest handler
*/
@@ -1210,4 +1255,25 @@
{
return replicationSystem;
}
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "LdapServer[" ).append( getServiceName() ).append( "], listening on :" ).append( '\n' );
+
+ if ( getTransports() != null )
+ {
+ for ( Transport transport:getTransports() )
+ {
+ sb.append( " " ).append( transport ).append( '\n' );
+ }
+ }
+
+ return sb.toString();
+ }
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java Sun Jun 14 09:14:31 2009
@@ -67,8 +67,8 @@
/** The CoreSession */
private CoreSession coreSession;
- /** A reference on the LdapService instance */
- private LdapService ldapService;
+ /** A reference on the LdapServer instance */
+ private LdapServer ldapServer;
/** A map of all the running requests */
private Map<Integer, InternalAbandonableRequest> outstandingRequests;
@@ -364,22 +364,22 @@
/**
- * @return The LdapService reference
+ * @return The LdapServer reference
*/
- public LdapService getLdapServer()
+ public LdapServer getLdapServer()
{
- return ldapService;
+ return ldapServer;
}
/**
- * Store a reference on the LdapService intance
+ * Store a reference on the LdapServer intance
*
- * @param ldapService the LdapService instance
+ * @param ldapServer the LdapServer instance
*/
- public void setLdapServer( LdapService ldapService )
+ public void setLdapServer( LdapServer ldapServer )
{
- this.ldapService = ldapService;
+ this.ldapServer = ldapServer;
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java?rev=784530&r1=784529&r2=784530&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSessionManager.java Sun Jun 14 09:14:31 2009
@@ -27,9 +27,9 @@
/**
- * Manages sessions in a thread safe manner for the LdapService. This class is
+ * Manages sessions in a thread safe manner for the LdapServer. This class is
* used primarily by the {@link LdapProtocolHandler} to manage sessions and is
- * created by the LdapService which makes it available to the handler. It's job
+ * created by the LdapServer which makes it available to the handler. It's job
* is simple and this class was mainly created to be able to expose the session
* manager safely to things like the LdapProtocolHandler.
*
@@ -43,7 +43,7 @@
/**
- * Gets the active sessions managed by the LdapService.
+ * Gets the active sessions managed by the LdapServer.
*/
public LdapSession[] getSessions()
{
@@ -52,7 +52,7 @@
/**
- * Adds a new LdapSession to the LdapService.
+ * Adds a new LdapSession to the LdapServer.
*
* @param ldapSession the newly created {@link LdapSession}
*/
@@ -66,7 +66,7 @@
/**
- * Removes an LdapSession managed by the {@link LdapService}. This method
+ * Removes an LdapSession managed by the {@link LdapServer}. This method
* has no side effects: meaning it does not perform cleanup tasks after
* removing the session. This task is handled by the callers.
*