Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 98854 invoked from network); 3 Feb 2006 10:32:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Feb 2006 10:32:13 -0000 Received: (qmail 62361 invoked by uid 500); 3 Feb 2006 10:32:12 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 62318 invoked by uid 500); 3 Feb 2006 10:32:11 -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 62307 invoked by uid 99); 3 Feb 2006 10:32:11 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Feb 2006 02:32:11 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 03 Feb 2006 02:32:09 -0800 Received: (qmail 98741 invoked by uid 65534); 3 Feb 2006 10:31:49 -0000 Message-ID: <20060203103149.98740.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r374636 - in /directory/sandbox/akarasulu/rc1refactor/apacheds: core/src/main/java/org/apache/ldap/server/authn/ core/src/main/java/org/apache/ldap/server/interceptor/ core/src/main/java/org/apache/ldap/server/jndi/ core/src/main/java/org/a... Date: Fri, 03 Feb 2006 10:31:45 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: akarasulu Date: Fri Feb 3 02:31:25 2006 New Revision: 374636 URL: http://svn.apache.org/viewcvs?rev=374636&view=rev Log: added bind and unbind operations to the interceptor pipeline operations Added: directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/jndi/LdapJndiProperties.java (with props) directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/test/java/org/apache/ldap/server/jndi/LdapJndiPropertiesTest.java (with props) Modified: directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/interceptor/BaseInterceptor.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/interceptor/Interceptor.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/interceptor/InterceptorChain.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/interceptor/NextInterceptor.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/jndi/ServerContext.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/jndi/ServerLdapContext.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/partition/DirectoryPartition.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/partition/DirectoryPartitionNexusProxy.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmDirectoryPartition.java directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/test/java/org/apache/ldap/server/interceptor/InterceptorChainTest.java directory/sandbox/akarasulu/rc1refactor/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/UnbindHandler.java Modified: directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java?rev=374636&r1=374635&r2=374636&view=diff ============================================================================== --- directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java (original) +++ directory/sandbox/akarasulu/rc1refactor/apacheds/core/src/main/java/org/apache/ldap/server/authn/AuthenticationService.java Fri Feb 3 02:31:25 2006 @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import javax.naming.Context; @@ -32,11 +33,8 @@ import javax.naming.directory.SearchControls; import org.apache.ldap.common.exception.LdapAuthenticationException; -import org.apache.ldap.common.exception.LdapAuthenticationNotSupportedException; import org.apache.ldap.common.filter.ExprNode; -import org.apache.ldap.common.message.ResultCodeEnum; import org.apache.ldap.common.util.AttributeUtils; -import org.apache.ldap.common.util.StringTools; import org.apache.ldap.server.DirectoryServiceConfiguration; import org.apache.ldap.server.configuration.AuthenticatorConfiguration; import org.apache.ldap.server.configuration.InterceptorConfiguration; @@ -184,7 +182,7 @@ log.debug( "Adding the entry " + AttributeUtils.toString( entry ) + " for DN = '" + upName + "'" ); } - authenticate(); + checkAuthenticated(); next.add( upName, normName, entry ); } @@ -196,7 +194,7 @@ log.debug( "Deleting name = '" + name.toString() + "'" ); } - authenticate(); + checkAuthenticated(); next.delete( name ); } @@ -208,7 +206,7 @@ log.debug( "Matching name = '" + dn.toString() + "'" ); } - authenticate(); + checkAuthenticated(); return next.getMatchedName( dn, normalized ); } @@ -220,7 +218,7 @@ log.debug( "Getting root DSE" ); } - authenticate(); + checkAuthenticated(); return next.getRootDSE(); } @@ -232,7 +230,7 @@ log.debug( "Getting suffix for name = '" + dn.toString() + "'" ); } - authenticate(); + checkAuthenticated(); return next.getSuffix( dn, normalized ); } @@ -244,7 +242,7 @@ log.debug( "Testing if entry name = '" + name.toString() + "' exists"); } - authenticate(); + checkAuthenticated(); return next.hasEntry( name ); } @@ -256,7 +254,7 @@ log.debug( "Testing suffix for name = '" + name.toString() + "'" ); } - authenticate(); + checkAuthenticated(); return next.isSuffix( name ); } @@ -268,7 +266,7 @@ log.debug( "Listing base = '" + base.toString() + "'" ); } - authenticate(); + checkAuthenticated(); return next.list( base ); } @@ -280,7 +278,7 @@ log.debug( "Listing suffixes" ); } - authenticate(); + checkAuthenticated(); return next.listSuffixes( normalized ); } @@ -292,7 +290,7 @@ log.debug( "Lookup name = '" + dn.toString() + "', attributes = " + attrIds ); } - authenticate(); + checkAuthenticated(); return next.lookup( dn, attrIds ); } @@ -304,7 +302,7 @@ log.debug( "Lookup name = '" + name.toString() + "'" ); } - authenticate(); + checkAuthenticated(); return next.lookup( name ); } @@ -316,7 +314,7 @@ log.debug( "Modifying name = '" + name.toString() + "', modifs = " + AttributeUtils.toString( mods ) ); } - authenticate(); + checkAuthenticated(); next.modify( name, modOp, mods ); } @@ -328,7 +326,7 @@ log.debug( "Modifying name = '" + name.toString() + "'" ); } - authenticate(); + checkAuthenticated(); next.modify( name, mods ); } @@ -340,7 +338,7 @@ log.debug( "Modifying name = '" + name.toString() + "', new RDN = '" + newRn + "', oldRDN = '" + deleteOldRn + "'" ); } - authenticate(); + checkAuthenticated(); next.modifyRn( name, newRn, deleteOldRn ); } @@ -352,7 +350,7 @@ log.debug( "Moving name = '" + oriChildName.toString() + "' to name = '" + newParentName + "', new RDN = '" + newRn + "', oldRDN = '" + deleteOldRn + "'" ); } - authenticate(); + checkAuthenticated(); next.move( oriChildName, newParentName, newRn, deleteOldRn ); } @@ -364,7 +362,7 @@ log.debug( "Moving name = '" + oriChildName.toString() + " to name = '" + newParentName + "'" ); } - authenticate(); + checkAuthenticated(); next.move( oriChildName, newParentName ); } @@ -376,17 +374,14 @@ log.debug( "Search for base = '" + base.toString() + "'" ); } - authenticate(); + checkAuthenticated(); return next.search( base, env, filter, searchCtls ); } - private void authenticate() throws NamingException + private void checkAuthenticated() throws NamingException { - // check if we are already authenticated and if so we return making - // sure first that the credentials are not exposed within context - ServerContext ctx = - ( ServerContext ) InvocationStack.getInstance().peek().getCaller(); + ServerContext ctx = ( ServerContext ) InvocationStack.getInstance().peek().getCaller(); if ( ctx.getPrincipal() != null ) { @@ -397,36 +392,32 @@ return; } - String authList = ( String ) ctx.getEnvironment().get( Context.SECURITY_AUTHENTICATION ); + throw new IllegalStateException( "Attempted operation by unauthenticated caller." ); + } + + + public void bind( NextInterceptor next, Name bindDn, byte[] credentials, List mechanisms, String saslAuthId ) + throws NamingException + { + // check if we are already authenticated and if so we return making + // sure first that the credentials are not exposed within context + ServerContext ctx = + ( ServerContext ) InvocationStack.getInstance().peek().getCaller(); - if ( authList == null ) + if ( ctx.getPrincipal() != null ) { if ( ctx.getEnvironment().containsKey( Context.SECURITY_CREDENTIALS ) ) { - // authentication type is simple here - - authList = "simple"; - } - else - { - // authentication type is anonymous - - authList = "none"; + ctx.removeFromEnvironment( Context.SECURITY_CREDENTIALS ); } - + return; } - authList = StringTools.deepTrim( authList ); - - String[] auth = authList.split( " " ); - - Collection authenticators = null; - // pick the first matching authenticator type - - for ( int i=0; i