Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 33755 invoked from network); 24 May 2007 04:09:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 May 2007 04:09:26 -0000 Received: (qmail 18010 invoked by uid 500); 24 May 2007 04:09:31 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 17962 invoked by uid 500); 24 May 2007 04:09:31 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 17951 invoked by uid 99); 24 May 2007 04:09:31 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 May 2007 21:09:31 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 May 2007 21:09:21 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 5232F1A9820; Wed, 23 May 2007 21:09:01 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r541149 [2/3] - in /directory/apacheds/trunk: ./ constants/src/main/java/org/apache/directory/server/ldap/ constants/src/main/java/org/apache/directory/server/ldap/constants/ core/src/main/java/org/apache/directory/server/core/ core/src/mai... Date: Thu, 24 May 2007 04:08:58 -0000 To: commits@directory.apache.org From: erodriguez@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070524040901.5232F1A9820@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java (original) +++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolHandler.java Wed May 23 21:08:50 2007 @@ -187,13 +187,13 @@ log.warn( ke.getMessage() ); } - session.write( getErrorMessage( config.getKdcPrincipal(), ke ) ); + session.write( getErrorMessage( config.getServicePrincipal(), ke ) ); } catch ( Exception e ) { log.error( "Unexpected exception: " + e.getMessage(), e ); - session.write( getErrorMessage( config.getKdcPrincipal(), new KerberosException( + session.write( getErrorMessage( config.getServicePrincipal(), new KerberosException( ErrorType.KDC_ERR_SVC_UNAVAILABLE ) ) ); } } Modified: directory/apacheds/trunk/protocol-ldap/pom.xml URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/pom.xml?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/pom.xml (original) +++ directory/apacheds/trunk/protocol-ldap/pom.xml Wed May 23 21:08:50 2007 @@ -21,6 +21,7 @@ org.apache.directory.shared shared-asn1-codec + 0.9.6-SNAPSHOT org.apache.mina @@ -28,7 +29,7 @@ org.apache.directory.server - apacheds-core + apacheds-kerberos-shared ${pom.version} Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java Wed May 23 21:08:50 2007 @@ -30,14 +30,12 @@ import javax.naming.Context; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.ldap.support.AbandonHandler; import org.apache.directory.server.ldap.support.AddHandler; import org.apache.directory.server.ldap.support.BindHandler; import org.apache.directory.server.ldap.support.CompareHandler; import org.apache.directory.server.ldap.support.DeleteHandler; import org.apache.directory.server.ldap.support.ExtendedHandler; -import org.apache.directory.server.ldap.support.LdapMessageHandler; import org.apache.directory.server.ldap.support.ModifyDnHandler; import org.apache.directory.server.ldap.support.ModifyHandler; import org.apache.directory.server.ldap.support.SearchHandler; @@ -87,6 +85,7 @@ import org.apache.mina.filter.codec.ProtocolDecoder; import org.apache.mina.filter.codec.ProtocolEncoder; import org.apache.mina.handler.demux.DemuxingIoHandler; +import org.apache.mina.handler.demux.MessageHandler; import org.apache.mina.util.SessionLog; @@ -109,11 +108,12 @@ private static final Map DEFAULT_HANDLERS; /** a set of supported controls */ private static final Set SUPPORTED_CONTROLS; - + /** configuration for the LDAP protocol provider **/ + private LdapConfiguration cfg; static { - HashMap map = new HashMap(); + Map map = new HashMap(); /* * Note: @@ -157,7 +157,7 @@ DEFAULT_HANDLERS = Collections.unmodifiableMap( map ); - HashSet set = new HashSet(); + Set set = new HashSet(); set.add( PersistentSearchControl.CONTROL_OID ); set.add( EntryChangeControl.CONTROL_OID ); set.add( ManageDsaITControl.CONTROL_OID ); @@ -181,17 +181,19 @@ * @param env environment properties used to configure the provider and * underlying codec providers if any */ - public LdapProtocolProvider( StartupConfiguration cfg, Hashtable env) throws LdapNamingException + public LdapProtocolProvider( LdapConfiguration cfg, Hashtable env) throws LdapNamingException { + this.cfg = cfg; + Hashtable copy = ( Hashtable ) env.clone(); copy.put( Context.PROVIDER_URL, "" ); SessionRegistry.releaseSingleton(); - new SessionRegistry( copy ); + new SessionRegistry( cfg, copy ); Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator(); while ( requestTypes.hasNext() ) { - LdapMessageHandler handler = null; + MessageHandler handler = null; String type = ( String ) requestTypes.next(); Class clazz = null; @@ -219,8 +221,7 @@ try { Class typeClass = Class.forName( type ); - handler = ( LdapMessageHandler ) clazz.newInstance(); - handler.init( cfg ); + handler = ( MessageHandler ) clazz.newInstance(); this.handler.addMessageHandler( typeClass, handler ); } catch ( Exception e ) @@ -362,13 +363,10 @@ { public void sessionCreated( IoSession session ) throws Exception { + session.setAttribute( LdapConfiguration.class.toString(), cfg ); + IoFilterChain filters = session.getFilterChain(); filters.addLast( "codec", new ProtocolCodecFilter( codecFactory ) ); - - // TODO : The filter is logging too much information. - // Right now, I have commented it, but it may be - // used with some parameter to disable it - filters.addLast( "logger", new LoggingFilter() ); } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java Wed May 23 21:08:50 2007 @@ -33,8 +33,6 @@ import javax.naming.ldap.LdapContext; import javax.naming.spi.InitialContextFactory; -import org.apache.directory.server.core.configuration.Configuration; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.core.jndi.ServerLdapContext; import org.apache.directory.shared.ldap.exception.LdapNoPermissionException; import org.apache.directory.shared.ldap.message.AbandonableRequest; @@ -62,6 +60,9 @@ /** the properties associated with this SessionRegistry */ private Hashtable env; + /** the configuration associated with this SessionRegistry */ + private LdapConfiguration cfg; + /** * Gets the singleton instance for this SessionRegistry. If the singleton @@ -73,7 +74,7 @@ { if ( s_singleton == null ) { - s_singleton = new SessionRegistry( new Hashtable() ); + s_singleton = new SessionRegistry( new LdapConfiguration(), new Hashtable() ); } return s_singleton; @@ -91,7 +92,7 @@ * * @param env the properties associated with this SessionRegistry */ - SessionRegistry( Hashtable env ) + SessionRegistry( LdapConfiguration cfg, Hashtable env ) { if ( s_singleton == null ) { @@ -99,7 +100,7 @@ } else { - throw new IllegalStateException( "there can only be one singlton" ); + throw new IllegalStateException( "There can only be one singleton." ); } if ( env == null ) @@ -113,6 +114,15 @@ this.env = env; this.env.put( Context.PROVIDER_URL, "" ); } + + if ( cfg == null ) + { + this.cfg = new LdapConfiguration(); + } + else + { + this.cfg = cfg; + } } @@ -268,10 +278,8 @@ // there is no context so its an implicit bind, no bind operation is being performed if ( ctx == null && allowAnonymous ) { - // if configuration says disable anonymous binds we throw exection - StartupConfiguration config = ( StartupConfiguration ) Configuration.toConfiguration( env ); - - if ( ! config.isAllowAnonymousAccess() ) + // if configuration says disable anonymous binds we throw exception + if ( !cfg.isAllowAnonymousAccess() ) { throw new LdapNoPermissionException( "Anonymous binds have been disabled!" ); } @@ -309,7 +317,6 @@ slc = ( ServerLdapContext ) ctx; } boolean isAnonymousUser = slc.getPrincipal().getName().trim().equals( "" ); - StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration( env ); // if the user principal is anonymous and the configuration does not allow anonymous binds we // prevent the operation by blowing a NoPermissionsException Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java Wed May 23 21:08:50 2007 @@ -20,13 +20,12 @@ package org.apache.directory.server.ldap.support; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.message.AbandonRequest; import org.apache.directory.shared.ldap.message.AbandonableRequest; import org.apache.directory.shared.ldap.message.Request; import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +36,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class AbandonHandler implements LdapMessageHandler +public class AbandonHandler implements MessageHandler { private static final Logger log = LoggerFactory.getLogger( AbandonHandler.class ); @@ -88,10 +87,5 @@ log.debug( "Abandoned request: " + req ); } } - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java Wed May 23 21:08:50 2007 @@ -25,7 +25,6 @@ import javax.naming.ReferralException; import javax.naming.ldap.LdapContext; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.exception.LdapException; import org.apache.directory.shared.ldap.message.AddRequest; @@ -36,9 +35,8 @@ import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.ExceptionUtils; - import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +47,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class AddHandler implements LdapMessageHandler +public class AddHandler implements MessageHandler { private static final Logger log = LoggerFactory.getLogger( AddHandler.class ); private static Control[] EMPTY_CONTROLS = new Control[0]; @@ -133,10 +131,5 @@ result.setResultCode( ResultCodeEnum.SUCCESS ); session.write( req.getResultResponse() ); - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java Wed May 23 21:08:50 2007 @@ -20,145 +20,36 @@ package org.apache.directory.server.ldap.support; -import java.util.Hashtable; - -import javax.naming.Context; -import javax.naming.NamingException; -import javax.naming.ldap.LdapContext; -import javax.naming.spi.InitialContextFactory; - -import org.apache.directory.server.core.DirectoryService; -import org.apache.directory.server.core.configuration.StartupConfiguration; -import org.apache.directory.server.core.jndi.PropertyKeys; -import org.apache.directory.server.core.jndi.ServerLdapContext; -import org.apache.directory.server.ldap.SessionRegistry; -import org.apache.directory.shared.ldap.exception.LdapException; -import org.apache.directory.shared.ldap.message.BindRequest; -import org.apache.directory.shared.ldap.message.LdapResult; -import org.apache.directory.shared.ldap.message.ManageDsaITControl; -import org.apache.directory.shared.ldap.message.ResultCodeEnum; -import org.apache.directory.shared.ldap.name.LdapDN; -import org.apache.directory.shared.ldap.util.ExceptionUtils; - +import org.apache.directory.server.ldap.support.bind.BindHandlerChain; import org.apache.mina.common.IoSession; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.mina.handler.chain.IoHandlerCommand; +import org.apache.mina.handler.demux.MessageHandler; /** * A single reply handler for {@link org.apache.directory.shared.ldap.message.BindRequest}s. - * + * + * Implements server-side of RFC 2222, sections 4.2 and 4.3. + * * @author Apache Directory Project + * @version $Rev$, $Date$ */ -public class BindHandler implements LdapMessageHandler +public class BindHandler implements MessageHandler { - private static final Logger log = LoggerFactory.getLogger( BindHandler.class ); + private IoHandlerCommand bindHandler; - /** Speedup for logs */ - private static final boolean IS_DEBUG = log.isDebugEnabled(); - public void messageReceived( IoSession session, Object request ) throws Exception + /** + * Creates a new instance of BindHandler. + */ + public BindHandler() { - LdapContext ctx; - BindRequest req = ( BindRequest ) request; - LdapResult result = req.getResultResponse().getLdapResult(); - - if ( !req.getVersion3() ) - { - result.setResultCode( ResultCodeEnum.PROTOCOL_ERROR ); - result.setErrorMessage( "Only LDAP v3 is supported" ); - session.write( req.getResultResponse() ); - return; - } - - // if the bind request is not simple then we freak: no strong auth yet - if ( !req.isSimple() ) - { - result.setResultCode( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED ); - result.setErrorMessage( "Only simple binds currently supported" ); - session.write( req.getResultResponse() ); - return; - } - - // clone the environment first then add the required security settings - Hashtable env = SessionRegistry.getSingleton().getEnvironmentByCopy(); - byte[] creds = req.getCredentials(); - env.put( Context.SECURITY_PRINCIPAL, req.getName() ); - env.put( Context.SECURITY_CREDENTIALS, creds ); - env.put( Context.SECURITY_AUTHENTICATION, "simple" ); - env.put( PropertyKeys.PARSED_BIND_DN, req.getName() ); - - if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) ) - { - env.put( Context.REFERRAL, "ignore" ); - } - else - { - env.put( Context.REFERRAL, "throw" ); - } - - try - { - if ( env.containsKey( "server.use.factory.instance" ) ) - { - InitialContextFactory factory = ( InitialContextFactory ) env.get( "server.use.factory.instance" ); - - if ( factory == null ) - { - throw new NullPointerException( "server.use.factory.instance was set in env but was null" ); - } - - // Bind is a special case where we have to use the referral property to deal - ctx = ( LdapContext ) factory.getInitialContext( env ); - } - else - { - ctx = new ServerLdapContext( DirectoryService.getInstance(), env ); - } - } - catch ( NamingException e ) - { - ResultCodeEnum code; - - if ( e instanceof LdapException ) - { - code = ( ( LdapException ) e ).getResultCode(); - result.setResultCode( code ); - } - else - { - code = ResultCodeEnum.getBestEstimate( e, req.getType() ); - result.setResultCode( code ); - } - - String msg = "Bind failed: " + e.getMessage(); - - if ( IS_DEBUG ) - { - msg += ":\n" + ExceptionUtils.getStackTrace( e ); - msg += "\n\nBindRequest = \n" + req.toString(); - } - - if ( ( e.getResolvedName() != null ) - && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM ) - || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) ) - { - result.setMatchedDn( (LdapDN)e.getResolvedName() ); - } - - result.setErrorMessage( msg ); - session.write( req.getResultResponse() ); - return; - } - - SessionRegistry.getSingleton().setLdapContext( session, ctx ); - result.setResultCode( ResultCodeEnum.SUCCESS ); - session.write( req.getResultResponse() ); + bindHandler = new BindHandlerChain(); } - public void init( StartupConfiguration cfg ) + public void messageReceived( IoSession session, Object message ) throws Exception { + bindHandler.execute( null, session, message ); } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java Wed May 23 21:08:50 2007 @@ -25,7 +25,6 @@ import javax.naming.ReferralException; import javax.naming.ldap.LdapContext; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.core.jndi.ServerLdapContext; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.exception.LdapException; @@ -37,9 +36,8 @@ import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.ExceptionUtils; - import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +48,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class CompareHandler implements LdapMessageHandler +public class CompareHandler implements MessageHandler { private static final Logger log = LoggerFactory.getLogger( CompareHandler.class ); private static Control[] EMPTY_CONTROLS = new Control[0]; @@ -146,10 +144,5 @@ result.setMatchedDn( req.getName() ); session.write( req.getResultResponse() ); - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java Wed May 23 21:08:50 2007 @@ -25,7 +25,6 @@ import javax.naming.ReferralException; import javax.naming.ldap.LdapContext; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.exception.LdapException; import org.apache.directory.shared.ldap.message.Control; @@ -36,9 +35,8 @@ import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.ExceptionUtils; - import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +47,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class DeleteHandler implements LdapMessageHandler +public class DeleteHandler implements MessageHandler { private static final Logger log = LoggerFactory.getLogger( DeleteHandler.class ); private static Control[] EMPTY_CONTROLS = new Control[0]; @@ -126,10 +124,5 @@ result.setResultCode( ResultCodeEnum.SUCCESS ); session.write( req.getResultResponse() ); - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java Wed May 23 21:08:50 2007 @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.Map; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.ldap.ExtendedOperationHandler; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.message.ExtendedRequest; @@ -32,8 +31,8 @@ import org.apache.directory.shared.ldap.message.LdapResult; import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.util.ExceptionUtils; - import org.apache.mina.common.IoSession; +import org.apache.mina.handler.demux.MessageHandler; /** @@ -42,7 +41,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class ExtendedHandler implements LdapMessageHandler +public class ExtendedHandler implements MessageHandler { private Map handlers = new HashMap(); @@ -109,10 +108,5 @@ session.write( req.getResultResponse() ); } } - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java Wed May 23 21:08:50 2007 @@ -25,7 +25,6 @@ import javax.naming.ReferralException; import javax.naming.ldap.LdapContext; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.constants.JndiPropertyConstants; import org.apache.directory.shared.ldap.exception.LdapException; @@ -37,9 +36,8 @@ import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.ExceptionUtils; - import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +48,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class ModifyDnHandler implements LdapMessageHandler +public class ModifyDnHandler implements MessageHandler { private static final Logger log = LoggerFactory.getLogger( ModifyDnHandler.class ); private static Control[] EMPTY_CONTROLS = new Control[0]; @@ -193,10 +191,5 @@ result.setResultCode( ResultCodeEnum.SUCCESS ); session.write( req.getResultResponse() ); } - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java Wed May 23 21:08:50 2007 @@ -25,7 +25,6 @@ import javax.naming.ReferralException; import javax.naming.ldap.LdapContext; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.exception.LdapException; import org.apache.directory.shared.ldap.message.Control; @@ -37,9 +36,8 @@ import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.ExceptionUtils; - import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +48,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class ModifyHandler implements LdapMessageHandler +public class ModifyHandler implements MessageHandler { private static final Logger log = LoggerFactory.getLogger( ModifyHandler.class ); private static final ModificationItemImpl[] EMPTY = new ModificationItemImpl[0]; @@ -131,10 +129,5 @@ result.setResultCode( ResultCodeEnum.SUCCESS ); session.write( req.getResultResponse() ); return; - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java Wed May 23 21:08:50 2007 @@ -33,9 +33,9 @@ import javax.naming.ldap.Control; import javax.naming.ldap.LdapContext; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.core.jndi.ServerLdapContext; import org.apache.directory.server.core.partition.PartitionNexus; +import org.apache.directory.server.ldap.LdapConfiguration; import org.apache.directory.server.ldap.SessionRegistry; import org.apache.directory.shared.ldap.constants.JndiPropertyConstants; import org.apache.directory.shared.ldap.constants.SchemaConstants; @@ -55,9 +55,8 @@ import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.ArrayUtils; import org.apache.directory.shared.ldap.util.ExceptionUtils; - import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,7 +67,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class SearchHandler implements LdapMessageHandler +public class SearchHandler implements MessageHandler { //TM private static long cumul = 0L; //TM private static long count = 0; @@ -76,7 +75,6 @@ private static final Logger log = LoggerFactory.getLogger( SearchHandler.class ); private static final String DEREFALIASES_KEY = JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES; - private StartupConfiguration cfg; /** Speedup for logs */ private static final boolean IS_DEBUG = log.isDebugEnabled(); @@ -88,7 +86,7 @@ * @param ids the ids to return * @return the SearchControls to use with the ApacheDS server side JNDI provider */ - private SearchControls getSearchControls( SearchRequest req, String[] ids, boolean isAdmin ) + private SearchControls getSearchControls( SearchRequest req, String[] ids, boolean isAdmin, int maxSize, int maxTime ) { // prepare all the search controls SearchControls controls = new SearchControls(); @@ -114,8 +112,8 @@ } else { - controls.setCountLimit( Math.min( req.getSizeLimit(), cfg.getMaxSizeLimit() ) ); - controls.setTimeLimit( ( int ) Math.min( req.getTimeLimit(), cfg.getMaxTimeLimit() ) ); + controls.setCountLimit( Math.min( req.getSizeLimit(), maxSize ) ); + controls.setTimeLimit( ( int ) Math.min( req.getTimeLimit(), maxTime ) ); } controls.setSearchScope( req.getScope().getValue() ); @@ -150,7 +148,8 @@ */ public void messageReceived( IoSession session, Object request ) throws Exception { - //TM long t0 = System.nanoTime(); + LdapConfiguration cfg = ( LdapConfiguration ) session.getAttribute( LdapConfiguration.class.toString() ); + if ( IS_DEBUG ) { log.debug( "Message received : " + request.toString() ); @@ -259,19 +258,22 @@ // Set search limits differently based on user's identity // =============================================================== + int maxSize = cfg.getMaxSizeLimit(); + int maxTime = cfg.getMaxTimeLimit(); + SearchControls controls = null; if ( isAnonymousUser ) { - controls = getSearchControls( req, ids, false ); + controls = getSearchControls( req, ids, false, maxSize, maxTime ); } else if ( ( ( ServerLdapContext ) ctx ).getPrincipal().getName() .trim().equals( PartitionNexus.ADMIN_PRINCIPAL_NORMALIZED ) ) { - controls = getSearchControls( req, ids, true ); + controls = getSearchControls( req, ids, true, maxSize, maxTime ); } else { - controls = getSearchControls( req, ids, false ); + controls = getSearchControls( req, ids, false, maxSize, maxTime ); } @@ -532,11 +534,5 @@ } } } - } - - - public void init( StartupConfiguration cfg ) - { - this.cfg = cfg; } } Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java Wed May 23 21:08:50 2007 @@ -23,12 +23,10 @@ import javax.naming.NamingException; import javax.naming.ldap.LdapContext; -import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.core.jndi.ServerLdapContext; import org.apache.directory.server.ldap.SessionRegistry; - import org.apache.mina.common.IoSession; - +import org.apache.mina.handler.demux.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +38,7 @@ * @author Apache Directory Project * @version $Rev$ */ -public class UnbindHandler implements LdapMessageHandler +public class UnbindHandler implements MessageHandler { private static final Logger log = LoggerFactory.getLogger( UnbindHandler.class ); @@ -68,10 +66,5 @@ { log.error( "failed to unbind session properly", e ); } - } - - - public void init( StartupConfiguration cfg ) - { } } Modified: directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java Wed May 23 21:08:50 2007 @@ -24,10 +24,7 @@ import junit.framework.TestCase; -import org.apache.directory.server.core.configuration.StartupConfiguration; -import org.apache.directory.server.ldap.LdapProtocolProvider; import org.apache.directory.server.ldap.support.ExtendedHandler; -import org.apache.directory.server.ldap.support.LdapMessageHandler; import org.apache.directory.shared.ldap.NotImplementedException; import org.apache.directory.shared.ldap.exception.LdapNamingException; import org.apache.directory.shared.ldap.message.AbandonRequest; @@ -50,8 +47,8 @@ import org.apache.directory.shared.ldap.message.SearchRequestImpl; import org.apache.directory.shared.ldap.message.UnbindRequest; import org.apache.directory.shared.ldap.message.UnbindRequestImpl; - import org.apache.mina.common.IoSession; +import org.apache.mina.handler.demux.MessageHandler; /** @@ -72,7 +69,7 @@ */ public void testDefaultOperation() throws LdapNamingException { - LdapProtocolProvider provider = new LdapProtocolProvider( new StartupConfiguration(), new Properties() ); + LdapProtocolProvider provider = new LdapProtocolProvider( new LdapConfiguration(), new Properties() ); assertNotNull( provider.getCodecFactory() ); assertTrue( provider.getName() == LdapProtocolProvider.SERVICE_NAME ); } @@ -119,116 +116,80 @@ props.setProperty( UnbindRequest.class.getName(), BogusUnbindHandler.class.getName() ); props.setProperty( UnbindRequestImpl.class.getName(), BogusUnbindHandler.class.getName() ); - LdapProtocolProvider provider = new LdapProtocolProvider( new StartupConfiguration(), props ); + LdapProtocolProvider provider = new LdapProtocolProvider( new LdapConfiguration(), props ); assertNotNull( provider.getCodecFactory() ); assertTrue( provider.getName() == LdapProtocolProvider.SERVICE_NAME ); } - public static class BogusAbandonHandler implements LdapMessageHandler + public static class BogusAbandonHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusUnbindHandler implements LdapMessageHandler + public static class BogusUnbindHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusAddHandler implements LdapMessageHandler + public static class BogusAddHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusBindHandler implements LdapMessageHandler + public static class BogusBindHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusCompareHandler implements LdapMessageHandler + public static class BogusCompareHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusDeleteHandler implements LdapMessageHandler + public static class BogusDeleteHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusModifyDnHandler implements LdapMessageHandler + public static class BogusModifyDnHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusModifyHandler implements LdapMessageHandler + public static class BogusModifyHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); } - - public void init( StartupConfiguration cfg ) - { - } } - public static class BogusSearchHandler implements LdapMessageHandler + public static class BogusSearchHandler implements MessageHandler { public void messageReceived( IoSession session, Object request ) { throw new NotImplementedException( "handler not implemented!" ); - } - - public void init( StartupConfiguration cfg ) - { } } } Modified: directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java (original) +++ directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpConfiguration.java Wed May 23 21:08:50 2007 @@ -17,21 +17,15 @@ * under the License. * */ - package org.apache.directory.server.ntp; -import java.util.Dictionary; -import java.util.HashMap; -import java.util.Map; - -import org.apache.directory.server.core.DirectoryService; -import org.apache.directory.server.core.configuration.ConfigurationException; -import org.apache.directory.server.protocol.shared.LoadStrategy; import org.apache.directory.server.protocol.shared.ServiceConfiguration; /** + * Contains the configuration parameters for the NTP protocol provider. + * * @author Apache Directory Project * @version $Rev$, $Date$ */ @@ -39,104 +33,23 @@ { private static final long serialVersionUID = 2961795205765175775L; - /** the default port */ - private static final String DEFAULT_IP_PORT = "123"; - - /** the default pid */ - private static final String DEFAULT_PID = "org.apache.ntp"; + /** The default IP port. */ + private static final int IP_PORT_DEFAULT = 123; - /** the default name */ - private static final String DEFAULT_NAME = "Apache NTP Service"; + /** The default service pid. */ + private static final String SERVICE_PID_DEFAULT = "org.apache.directory.server.ntp"; - /** the default prefix */ - private static final String DEFAULT_PREFIX = "ntp."; + /** The default service name. */ + private static final String SERVICE_NAME_DEFAULT = "ApacheDS NTP Service"; /** - * Creates a new instance with default settings. + * Creates a new instance of NtpConfiguration. */ public NtpConfiguration() { - this( getDefaultConfig(), LoadStrategy.LDAP ); - } - - - /** - * Creates a new instance with default settings that operates on the - * {@link DirectoryService} with the specified ID. - */ - public NtpConfiguration( String instanceId ) - { - this( getDefaultConfig(), LoadStrategy.LDAP ); - setInstanceId( instanceId ); - } - - - public NtpConfiguration( Map properties ) - { - this( properties, LoadStrategy.LDAP ); - } - - - public NtpConfiguration( Map properties, int strategy ) - { - if ( properties == null ) - { - configuration = getDefaultConfig(); - } - else - { - loadProperties( DEFAULT_PREFIX, properties, strategy ); - } - - int port = getPort(); - - if ( port < 1 || port > 0xFFFF ) - { - throw new ConfigurationException( "Invalid value: " + IP_PORT_KEY + "=" + port ); - } - } - - - public static Map getDefaultConfig() - { - Map defaults = new HashMap(); - - defaults.put( SERVICE_PID, DEFAULT_PID ); - defaults.put( IP_PORT_KEY, DEFAULT_IP_PORT ); - - return defaults; - } - - - public boolean isDifferent( Dictionary config ) - { - int port = getPort(); - - if ( port == Integer.parseInt( ( String ) config.get( IP_PORT_KEY ) ) ) - { - return false; - } - - return true; - } - - - public String getName() - { - return DEFAULT_NAME; - } - - - public int getPort() - { - String key = IP_PORT_KEY; - - if ( configuration.containsKey( key ) ) - { - return Integer.parseInt( get( key ) ); - } - - return Integer.parseInt( DEFAULT_IP_PORT ); + super.setIpPort( IP_PORT_DEFAULT ); + super.setServicePid( SERVICE_PID_DEFAULT ); + super.setServiceName( SERVICE_NAME_DEFAULT ); } } Modified: directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java (original) +++ directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java Wed May 23 21:08:50 2007 @@ -53,8 +53,8 @@ this.config = config; this.acceptor = acceptor; - String name = config.getName(); - int port = config.getPort(); + String name = config.getServiceName(); + int port = config.getIpPort(); try { @@ -79,11 +79,11 @@ public void destroy() { - acceptor.unbind( new InetSocketAddress( config.getPort() ) ); + acceptor.unbind( new InetSocketAddress( config.getIpPort() ) ); acceptor = null; handler = null; - log.debug( config.getName() + " has stopped listening on port " + config.getPort() ); + log.debug( config.getServiceName() + " has stopped listening on port " + config.getIpPort() ); } } Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java (original) +++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ServiceConfiguration.java Wed May 23 21:08:50 2007 @@ -17,15 +17,16 @@ * under the License. * */ - package org.apache.directory.server.protocol.shared; -import java.util.HashMap; +import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; + +import javax.naming.spi.InitialContextFactory; import org.apache.directory.server.core.configuration.Configuration; +import org.apache.directory.server.core.configuration.ConfigurationUtil; /** @@ -36,119 +37,334 @@ */ public abstract class ServiceConfiguration extends Configuration { - /** the prop key const for the port */ + /** The prop key const for the port. */ public static final String IP_PORT_KEY = "ipPort"; - /** the prop key const for the port */ - public static final String IP_ADDRESS_KEY = "ipAddress"; + /** The number of milliseconds in a minute. */ + public static final int MINUTE = 60000; + + /** The default MINA buffer size. */ + public static final int DEFAULT_BUFFER_SIZE = 1024; + + protected static final String APACHE_SERVICE_CONFIGURATION = "apacheServiceConfiguration"; + protected static final String SERVICE_PID = "service.pid"; + protected static final String SERVICE_FACTORYPID = "service.factoryPid"; + + /** The MINA buffer size for this service. */ + private int bufferSize; + + /** The IP port for this service. */ + private int ipPort; - /** the prop key const for the catalog's base DN */ - public static final String CATALOG_BASEDN_KEY = "catalogBaseDn"; + /** The IP address for this service. */ + private String ipAddress; /** - * The key of the property specifying the single location where entries - * are stored. If this property is not set the store will search the system + * The single location where catalog entries are stored. If this + * property is not set the store will expect a single search base + * DN to be set. + */ + private String catalogBaseDn; + + /** + * The single location where entries are stored. If this + * property is not set the store will search the system * partition configuration for catalog entries. */ - public static final String ENTRY_BASEDN_KEY = "entryBaseDn"; + private String searchBaseDn = "ou=users,dc=example,dc=com"; - public static final String INITIAL_CONTEXT_FACTORY_KEY = "initialContextFactory"; + /** The JNDI initial context factory to use. */ + private String initialContextFactory = "org.apache.directory.server.core.jndi.CoreContextFactory"; - public static final String APACHE_SERVICE_PID_KEY = "apacheServicePid"; - public static final String APACHE_FACTORY_PID_KEY = "apacheServiceFactoryPid"; + /** The authentication mechanism to use for establishing a JNDI context. */ + private String securityAuthentication = "simple"; - /** the prop key const for buffer.size */ - public static final String BUFFER_SIZE_KEY = "buffer.size"; + /** The principal to use for establishing a JNDI context. */ + private String securityPrincipal = "uid=admin,ou=system"; - public static final String DEFAULT_ENTRY_BASEDN = "dc=example,dc=com"; + /** The credentials to use for establishing a JNDI context. */ + private String securityCredentials = "secret"; - public static final String DEFAULT_INITIAL_CONTEXT_FACTORY = "org.apache.directory.server.core.jndi.CoreContextFactory"; + /** The friendly name of this service. */ + private String serviceName; - public static final String APACHE_SERVICE_CONFIGURATION = "apacheServiceConfiguration"; + /** The PID for this service. */ + private String servicePid; - public static final String SERVICE_PID = "service.pid"; - public static final String SERVICE_FACTORYPID = "service.factoryPid"; + /** Whether this service is enabled. */ + private boolean isEnabled = false; - /** the default buffer size */ - public static final int DEFAULT_BUFFER_SIZE = 1024; - /** the number of milliseconds in a minute */ - public static final int MINUTE = 60000; + /** + * Returns the buffer size. + * + * @return The bufferSize. + */ + public int getBufferSize() + { + return bufferSize; + } - /** the map of configuration */ - protected Map configuration = new HashMap(); + + /** + * Sets the buffer size. + * + * @param bufferSize The bufferSize to set. + */ + public void setBufferSize( int bufferSize ) + { + this.bufferSize = bufferSize; + } - public String getCatalogBaseDn() + /** + * Returns whether this service is enabled or not. + * + * @return True if this service is enabled. + */ + public boolean isEnabled() { - String key = CATALOG_BASEDN_KEY; + return isEnabled; + } - if ( configuration.containsKey( key ) ) - { - return get( key ); - } - return null; + /** + * Sets whether this service is enabled or not. + * + * @param isEnabled True if this service is to be enabled. + */ + public void setEnabled( boolean isEnabled ) + { + this.isEnabled = isEnabled; } - public String getEntryBaseDn() + /** + * Returns the service PID. + * + * @return The servicePid. + */ + public String getServicePid() { - String key = ENTRY_BASEDN_KEY; + return servicePid; + } - if ( configuration.containsKey( key ) ) + + /** + * Sets the service PID. + * + * @param servicePid The servicePid to set. + */ + public void setServicePid( String servicePid ) + { + this.servicePid = servicePid; + } + + + /** + * Compares whether a Dictionary of configuration is + * different from the current instance of configuration. + * + * @param config + * @return Whether the configuration is different. + */ + public boolean isDifferent( Dictionary config ) + { + int port = getIpPort(); + + if ( port == Integer.parseInt( ( String ) config.get( IP_PORT_KEY ) ) ) { - return get( key ); + return false; } - return DEFAULT_ENTRY_BASEDN; + return true; + } + + + /** + * Returns the service name. + * + * @return The serviceName. + */ + public String getServiceName() + { + return serviceName; + } + + + /** + * Sets the service name. + * + * @param serviceName The service name to set. + */ + public void setServiceName( String serviceName ) + { + this.serviceName = serviceName; + } + + + /** + * Returns the IP address. + * + * @return The IP address. + */ + public String getIpAddress() + { + return ipAddress; + } + + + /** + * Returns the IP port. + * + * @return The IP port. + */ + public int getIpPort() + { + return ipPort; + } + + + /** + * Returns the catalog base DN. + * + * @return The catalog base DN. + */ + public String getCatalogBaseDn() + { + return catalogBaseDn; + } + + + /** + * Returns the search base DN. + * + * @return The search base DN. + */ + public String getSearchBaseDn() + { + return searchBaseDn; } + /** + * Returns the {@link InitialContextFactory}. + * + * @return The {@link InitialContextFactory}. + */ public String getInitialContextFactory() { - String key = INITIAL_CONTEXT_FACTORY_KEY; + return initialContextFactory; + } - if ( configuration.containsKey( key ) ) - { - return get( key ); - } - return DEFAULT_INITIAL_CONTEXT_FACTORY; + /** + * Returns The authentication mechanism. + * + * @return The securityAuthentication. + */ + public String getSecurityAuthentication() + { + return securityAuthentication; } - public Hashtable toJndiEnvironment() + /** + * @return The securityCredentials. + */ + public String getSecurityCredentials() { - Hashtable env = new Hashtable(); - env.put( JNDI_KEY, this ); - env.putAll( configuration ); + return securityCredentials; + } - return env; + + /** + * @return The securityPrincipal. + */ + public String getSecurityPrincipal() + { + return securityPrincipal; } - protected void loadProperties( String prefix, Map properties, int strategy ) + /** + * @param catalogBaseDn The catalogBaseDn to set. + */ + public void setCatalogBaseDn( String catalogBaseDn ) { - LoadStrategy loader; + this.catalogBaseDn = catalogBaseDn; + } - switch ( strategy ) - { - case LoadStrategy.LDAP: - loader = new LdapLoader(); - break; - case LoadStrategy.PROPS: - default: - loader = new PropsLoader(); - break; - } - configuration.putAll( loader.load( prefix, properties ) ); + /** + * @param initialContextFactory The initialContextFactory to set. + */ + public void setInitialContextFactory( String initialContextFactory ) + { + this.initialContextFactory = initialContextFactory; } - protected String get( String key ) + /** + * @param ipAddress The ipAddress to set. + */ + public void setIpAddress( String ipAddress ) { - return ( String ) configuration.get( key ); + this.ipAddress = ipAddress; + } + + + /** + * @param ipPort The ipPort to set. + */ + public void setIpPort( int ipPort ) + { + ConfigurationUtil.validatePortNumber( ipPort ); + this.ipPort = ipPort; + } + + + /** + * @param searchBaseDn The searchBaseDn to set. + */ + public void setSearchBaseDn( String searchBaseDn ) + { + this.searchBaseDn = searchBaseDn; + } + + + /** + * @param securityAuthentication The securityAuthentication to set. + */ + public void setSecurityAuthentication( String securityAuthentication ) + { + this.securityAuthentication = securityAuthentication; + } + + + /** + * @param securityCredentials The securityCredentials to set. + */ + public void setSecurityCredentials( String securityCredentials ) + { + this.securityCredentials = securityCredentials; + } + + + /** + * @param securityPrincipal The securityPrincipal to set. + */ + public void setSecurityPrincipal( String securityPrincipal ) + { + this.securityPrincipal = securityPrincipal; + } + + + public Hashtable toJndiEnvironment() + { + Hashtable env = new Hashtable(); + env.put( JNDI_KEY, this ); + + return env; } } Modified: directory/apacheds/trunk/server-jndi/pom.xml URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/pom.xml?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/server-jndi/pom.xml (original) +++ directory/apacheds/trunk/server-jndi/pom.xml Wed May 23 21:08:50 2007 @@ -48,6 +48,11 @@ org.apache.directory.server + apacheds-protocol-dns + ${pom.version} + + + org.apache.directory.server apacheds-core ${pom.version} Modified: directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java (original) +++ directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java Wed May 23 21:08:50 2007 @@ -18,14 +18,19 @@ * */ package org.apache.directory.server.configuration; - + import java.io.File; -import java.util.Collection; import java.util.List; import java.util.Set; +import org.apache.directory.server.changepw.ChangePasswordConfiguration; import org.apache.directory.server.core.configuration.PartitionConfiguration; +import org.apache.directory.server.dns.DnsConfiguration; +import org.apache.directory.server.kerberos.kdc.KdcConfiguration; +import org.apache.directory.server.ldap.LdapConfiguration; +import org.apache.directory.server.ntp.NtpConfiguration; + /** * A mutable version of {@link ServerStartupConfiguration}. @@ -38,46 +43,44 @@ private static final long serialVersionUID = 515104910980600099L; + /** + * Creates a new instance of MutableServerStartupConfiguration. + */ public MutableServerStartupConfiguration() { super(); } - + + + /** + * Creates a new instance of MutableServerStartupConfiguration. + * + * @param instanceId + */ public MutableServerStartupConfiguration( String instanceId ) { - super( instanceId ); + super( instanceId ); } + public void setSystemPartitionConfiguration( PartitionConfiguration systemPartitionConfiguration ) { super.setSystemPartitionConfiguration( systemPartitionConfiguration ); } - - + + public void setMaxThreads( int maxThreads ) { super.setMaxThreads( maxThreads ); } - - - public void setMaxTimeLimit( int maxTimeLimit ) - { - super.setMaxTimeLimit( maxTimeLimit ); - } - - - public void setMaxSizeLimit( int maxSizeLimit ) - { - super.setMaxSizeLimit( maxSizeLimit ); - } - + public void setSynchPeriodMillis( long synchPeriodMillis ) { super.setSynchPeriodMillis( synchPeriodMillis ); } - - + + public void setAccessControlEnabled( boolean accessControlEnabled ) { super.setAccessControlEnabled( accessControlEnabled ); @@ -87,14 +90,15 @@ public void setAllowAnonymousAccess( boolean arg0 ) { super.setAllowAnonymousAccess( arg0 ); + getLdapConfiguration().setAllowAnonymousAccess( arg0 ); } - + public void setDenormalizeOpAttrsEnabled( boolean denormalizeOpAttrsEnabled ) { super.setDenormalizeOpAttrsEnabled( denormalizeOpAttrsEnabled ); } - + public void setAuthenticatorConfigurations( Set arg0 ) { @@ -126,80 +130,62 @@ } - public void setEnableKerberos( boolean enableKerberos ) - { - super.setEnableKerberos( enableKerberos ); - } - - - public void setEnableChangePassword( boolean enableChangePassword ) - { - super.setEnableChangePassword( enableChangePassword ); - } - - - public void setEnableNtp( boolean enableNtp ) - { - super.setEnableNtp( enableNtp ); - } - - - public void setLdapPort( int ldapPort ) + public void setLdifDirectory( File ldifDirectory ) { - super.setLdapPort( ldapPort ); + super.setLdifDirectory( ldifDirectory ); } - public void setLdapsPort( int ldapsPort ) + public void setLdifFilters( List ldifFilters ) { - super.setLdapsPort( ldapsPort ); + super.setLdifFilters( ldifFilters ); } - public void setExtendedOperationHandlers( Collection handlers ) + public void setShutdownHookEnabled( boolean shutdownHookEnabled ) { - super.setExtendedOperationHandlers( handlers ); + super.setShutdownHookEnabled( shutdownHookEnabled ); } - public void setLdifDirectory( File ldifDirectory ) + public void setExitVmOnShutdown( boolean exitVmOnShutdown ) { - super.setLdifDirectory( ldifDirectory ); + super.setExitVmOnShutdown( exitVmOnShutdown ); } - public void setLdifFilters( List ldifFilters ) + public void setKdcConfiguration( KdcConfiguration kdcConfiguration ) { - super.setLdifFilters( ldifFilters ); + super.setKdcConfiguration( kdcConfiguration ); } - public void setEnableLdaps( boolean enableLdaps ) + public void setLdapConfiguration( LdapConfiguration ldapConfiguration ) { - super.setEnableLdaps( enableLdaps ); + super.setLdapConfiguration( ldapConfiguration ); } - public void setLdapsCertificateFile( File ldapsCertificateFile ) + public void setLdapsConfiguration( LdapConfiguration ldapsConfiguration ) { - super.setLdapsCertificateFile( ldapsCertificateFile ); + super.setLdapsConfiguration( ldapsConfiguration ); } - public void setLdapsCertificatePassword( String ldapsCertificatePassword ) + public void setNtpConfiguration( NtpConfiguration ntpConfiguration ) { - super.setLdapsCertificatePassword( ldapsCertificatePassword ); + super.setNtpConfiguration( ntpConfiguration ); } - public void setShutdownHookEnabled( boolean shutdownHookEnabled ) + public void setChangePasswordConfiguration( ChangePasswordConfiguration changePasswordConfiguration ) { - super.setShutdownHookEnabled( shutdownHookEnabled ); + super.setChangePasswordConfiguration( changePasswordConfiguration ); } - public void setExitVmOnShutdown( boolean exitVmOnShutdown ) + public void setDnsConfiguration( DnsConfiguration dnsConfiguration ) { - super.setExitVmOnShutdown( exitVmOnShutdown ); + super.setDnsConfiguration( dnsConfiguration ); } } Modified: directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ServerStartupConfiguration.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ServerStartupConfiguration.java?view=diff&rev=541149&r1=541148&r2=541149 ============================================================================== --- directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ServerStartupConfiguration.java (original) +++ directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ServerStartupConfiguration.java Wed May 23 21:08:50 2007 @@ -20,16 +20,16 @@ package org.apache.directory.server.configuration; +import java.io.File; import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; import java.util.List; -import java.io.File; -import org.apache.directory.server.core.configuration.ConfigurationException; -import org.apache.directory.server.core.configuration.ConfigurationUtil; +import org.apache.directory.server.changepw.ChangePasswordConfiguration; import org.apache.directory.server.core.configuration.StartupConfiguration; -import org.apache.directory.server.ldap.ExtendedOperationHandler; +import org.apache.directory.server.dns.DnsConfiguration; +import org.apache.directory.server.kerberos.kdc.KdcConfiguration; +import org.apache.directory.server.ldap.LdapConfiguration; +import org.apache.directory.server.ntp.NtpConfiguration; import org.apache.directory.server.protocol.shared.store.LdifLoadFilter; @@ -45,31 +45,32 @@ private static final long DEFAULT_SYNC_PERIOD_MILLIS = 20000; - private boolean enableNetworking = true; private long synchPeriodMillis = DEFAULT_SYNC_PERIOD_MILLIS; - private int ldapPort = 389; - private int ldapsPort = 636; - private File ldapsCertificateFile = new File( this.getWorkingDirectory().getPath() + File.separator - + "certificates" + File.separator + "server.cert" ); - private String ldapsCertificatePassword = "changeit"; - private boolean enableLdaps = false; - private boolean enableKerberos = false; - private boolean enableChangePassword = false; - private boolean enableNtp = false; - private final Collection extendedOperationHandlers = new ArrayList(); + + private boolean enableNetworking = true; + private File ldifDirectory = null; private final List ldifFilters = new ArrayList(); + private KdcConfiguration kdcConfiguration = new KdcConfiguration(); + private LdapConfiguration ldapConfiguration = new LdapConfiguration(); + private LdapConfiguration ldapsConfiguration = new LdapConfiguration(); + private ChangePasswordConfiguration changePasswordConfiguration = new ChangePasswordConfiguration(); + private NtpConfiguration ntpConfiguration = new NtpConfiguration(); + private DnsConfiguration dnsConfiguration = new DnsConfiguration(); + protected ServerStartupConfiguration() { } + protected ServerStartupConfiguration( String instanceId ) { - super( instanceId ); + super( instanceId ); } + /** * Returns true if networking (LDAP, LDAPS, and Kerberos) is enabled. */ @@ -88,230 +89,120 @@ } - /** - * Returns true if Kerberos support is enabled. - */ - public boolean isEnableKerberos() - { - return enableKerberos; - } - - - /** - * Returns true if Change Password support is enabled. - */ - public boolean isEnableChangePassword() - { - return enableChangePassword; - } - - - /** - * Returns true if Kerberos support is enabled. - */ - public boolean isEnableNtp() - { - return enableNtp; - } - - - /** - * Sets whether to enable Kerberos support or not. - */ - protected void setEnableKerberos( boolean enableKerberos ) - { - this.enableKerberos = enableKerberos; - } - - - /** - * Sets whether to enable Change Password support or not. - */ - protected void setEnableChangePassword( boolean enableChangePassword ) - { - this.enableChangePassword = enableChangePassword; - } - - - /** - * Sets whether to enable Ntp support or not. - */ - protected void setEnableNtp( boolean enableNtp ) + public File getLdifDirectory() { - this.enableNtp = enableNtp; + return this.ldifDirectory; } - /** - * Returns LDAP TCP/IP port number to listen to. - */ - public int getLdapPort() + protected void setLdifDirectory( File ldifDirectory ) { - return ldapPort; + this.ldifDirectory = ldifDirectory; } - /** - * Sets LDAP TCP/IP port number to listen to. - */ - protected void setLdapPort( int ldapPort ) + public List getLdifFilters() { - ConfigurationUtil.validatePortNumber( ldapPort ); - this.ldapPort = ldapPort; + return new ArrayList( ldifFilters ); } - /** - * Returns LDAPS TCP/IP port number to listen to. - */ - public int getLdapsPort() + protected void setLdifFilters( List filters ) { - return ldapsPort; - } - + for ( int ii = 0; ii < filters.size(); ii++ ) + { + if ( !( filters.get( ii ) instanceof LdifLoadFilter ) ) + { + throw new IllegalArgumentException( + "The specified filter collection contains an element which is not an LdifLoadFilter." ); + } + } - /** - * Sets LDAPS TCP/IP port number to listen to. - */ - protected void setLdapsPort( int ldapsPort ) - { - ConfigurationUtil.validatePortNumber( ldapsPort ); - this.ldapsPort = ldapsPort; + this.ldifFilters.clear(); + this.ldifFilters.addAll( filters ); } - /** - * Returns true if LDAPS is enabled. - */ - public boolean isEnableLdaps() + protected void setSynchPeriodMillis( long synchPeriodMillis ) { - return enableLdaps; + this.synchPeriodMillis = synchPeriodMillis; } - /** - * Sets if LDAPS is enabled or not. - */ - protected void setEnableLdaps( boolean enableLdaps ) + public long getSynchPeriodMillis() { - this.enableLdaps = enableLdaps; + return synchPeriodMillis; } - /** - * Returns the path of the X509 (or JKS) certificate file for LDAPS. - * The default value is "<WORKDIR>/certificates/server.cert". - */ - public File getLdapsCertificateFile() + protected void setKdcConfiguration( KdcConfiguration kdcConfiguration ) { - return ldapsCertificateFile; + this.kdcConfiguration = kdcConfiguration; } - /** - * Sets the path of the SunX509 certificate file (either PKCS12 or JKS format) - * for LDAPS. - */ - protected void setLdapsCertificateFile( File ldapsCertificateFile ) + public KdcConfiguration getKdcConfiguration() { - if ( ldapsCertificateFile == null ) - { - throw new ConfigurationException( "LdapsCertificateFile cannot be null." ); - } - this.ldapsCertificateFile = ldapsCertificateFile; + return kdcConfiguration; } - /** - * Returns the password which is used to load the the SunX509 certificate file - * (either PKCS12 or JKS format). - * The default value is "changeit". This is the same value with what - * Apache Jakarta Tomcat uses by - * default. - */ - public String getLdapsCertificatePassword() + protected void setLdapConfiguration( LdapConfiguration ldapConfiguration ) { - return ldapsCertificatePassword; + this.ldapConfiguration = ldapConfiguration; } - /** - * Sets the password which is used to load the LDAPS certificate file. - */ - protected void setLdapsCertificatePassword( String ldapsCertificatePassword ) + public LdapConfiguration getLdapConfiguration() { - if ( ldapsCertificatePassword == null ) - { - throw new ConfigurationException( "LdapsCertificatePassword cannot be null." ); - } - this.ldapsCertificatePassword = ldapsCertificatePassword; + return ldapConfiguration; } - public Collection getExtendedOperationHandlers() + protected void setLdapsConfiguration( LdapConfiguration ldapsConfiguration ) { - return new ArrayList( extendedOperationHandlers ); + this.ldapsConfiguration = ldapsConfiguration; } - protected void setExtendedOperationHandlers( Collection handlers ) + public LdapConfiguration getLdapsConfiguration() { - for ( Iterator i = handlers.iterator(); i.hasNext(); ) - { - if ( !( i.next() instanceof ExtendedOperationHandler ) ) - { - throw new IllegalArgumentException( - "The specified handler collection contains an element which is not an ExtendedOperationHandler." ); - } - } - - this.extendedOperationHandlers.clear(); - this.extendedOperationHandlers.addAll( handlers ); + return ldapsConfiguration; } - public File getLdifDirectory() + protected void setNtpConfiguration( NtpConfiguration ntpConfiguration ) { - return this.ldifDirectory; + this.ntpConfiguration = ntpConfiguration; } - protected void setLdifDirectory( File ldifDirectory ) + public NtpConfiguration getNtpConfiguration() { - this.ldifDirectory = ldifDirectory; + return ntpConfiguration; } - public List getLdifFilters() + protected void setChangePasswordConfiguration( ChangePasswordConfiguration changePasswordConfiguration ) { - return new ArrayList( ldifFilters ); + this.changePasswordConfiguration = changePasswordConfiguration; } - protected void setLdifFilters( List filters ) + public ChangePasswordConfiguration getChangePasswordConfiguration() { - for ( int ii = 0; ii < filters.size(); ii++ ) - { - if ( !( filters.get( ii ) instanceof LdifLoadFilter ) ) - { - throw new IllegalArgumentException( - "The specified filter collection contains an element which is not an LdifLoadFilter." ); - } - } - - this.ldifFilters.clear(); - this.ldifFilters.addAll( filters ); + return changePasswordConfiguration; } - protected void setSynchPeriodMillis( long synchPeriodMillis ) + protected void setDnsConfiguration( DnsConfiguration dnsConfiguration ) { - this.synchPeriodMillis = synchPeriodMillis; + this.dnsConfiguration = dnsConfiguration; } - public long getSynchPeriodMillis() + public DnsConfiguration getDnsConfiguration() { - return synchPeriodMillis; + return dnsConfiguration; } }