Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 15678 invoked from network); 10 Jun 2008 20:24:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jun 2008 20:24:47 -0000 Received: (qmail 75424 invoked by uid 500); 10 Jun 2008 20:24:49 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 75389 invoked by uid 500); 10 Jun 2008 20:24:49 -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 75380 invoked by uid 99); 10 Jun 2008 20:24:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 13:24:49 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 20:24:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CE6E42388A0A; Tue, 10 Jun 2008 13:23:47 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r666308 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/interceptor/context/ core/src/main/java/org/apache/directory/server/core/jndi/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ Date: Tue, 10 Jun 2008 20:23:47 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080610202347.CE6E42388A0A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: akarasulu Date: Tue Jun 10 13:23:47 2008 New Revision: 666308 URL: http://svn.apache.org/viewvc?rev=666308&view=rev Log: minor hack which will not be ported to other versions for being able to access the client hostname and port on search operations. Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/DefaultSearchHandler.java Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java?rev=666308&r1=666307&r2=666308&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java Tue Jun 10 13:23:47 2008 @@ -51,12 +51,16 @@ /** The associated response's controls */ private Map responseControls = new HashMap(4); + /** Area for storing various user specified parameters */ + private Map parameters = new HashMap(2); + /** A flag to tell that this is a collateral operation */ private boolean collateralOperation; /** The global registries reference */ private Registries registries; + /** * Creates a new instance of AbstractOperationContext. * @@ -109,6 +113,31 @@ this.registries = registries; } + + /** + * Gets a user specified parameter associated with this operation. + * + * @param key the key for the parameter + * @return the value if one exists for this parameter + */ + public Object get( String key ) + { + return parameters.get( key ); + } + + + /** + * Sets a user specified parameter associated with this operation. + * + * @param key the key for the parameter + * @param value the value of the parameter + * @return the existing value which is replaced for this parameter + */ + public Object put( String key, Object value ) + { + return parameters.put( key, value ); + } + /** * Tells if the current operation is considered a side effect of the Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=666308&r1=666307&r2=666308&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Tue Jun 10 13:23:47 2008 @@ -75,6 +75,7 @@ import javax.naming.spi.DirStateFactory; import javax.naming.spi.DirectoryManager; import java.io.Serializable; +import java.net.InetSocketAddress; import java.util.HashSet; import java.util.Hashtable; import java.util.List; @@ -273,6 +274,36 @@ /** * Used to encapsulate [de]marshalling of controls before and after list operations. + * @param dn + * @param aliasDerefMode + * @param filter + * @param searchControls + * @return NamingEnumeration + */ + protected NamingEnumeration doSearchOperation( LdapDN dn, AliasDerefMode aliasDerefMode, + ExprNode filter, SearchControls searchControls, InetSocketAddress clientAddress ) throws NamingException + { + // setup the op context and populate with request controls + SearchOperationContext opCtx = new SearchOperationContext( registries, dn, aliasDerefMode, filter, + searchControls ); + + opCtx.put( "client_hostname", clientAddress.getHostName() ); + opCtx.put( "client_port", String.valueOf( clientAddress.getPort() ) ); + opCtx.addRequestControls( requestControls ); + + // execute search operation + NamingEnumeration results = nexusProxy.search( opCtx ); + + // clear the request controls and set the response controls + requestControls = EMPTY_CONTROLS; + responseControls = opCtx.getResponseControls(); + + return results; + } + + + /** + * Used to encapsulate [de]marshalling of controls before and after list operations. */ protected NamingEnumeration doListOperation( LdapDN target ) throws NamingException { Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=666308&r1=666307&r2=666308&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Tue Jun 10 13:23:47 2008 @@ -63,6 +63,7 @@ import javax.naming.spi.DirStateFactory; import javax.naming.spi.DirectoryManager; import java.io.Serializable; +import java.net.InetSocketAddress; import java.text.ParseException; import java.util.ArrayList; import java.util.Hashtable; @@ -660,6 +661,26 @@ /** + * A search overload that is used for optimizing search handling in the + * LDAP protocol provider which deals with an ExprNode instance rather than + * a String for the filter. + * + * @param name the relative name of the object serving as the search base + * @param filter the search filter as an expression tree + * @param cons the search controls to use + * @return an enumeration over the SearchResults + * @throws NamingException if there are problems performing the search + */ + public NamingEnumeration search( Name name, ExprNode filter, SearchControls cons, InetSocketAddress clientAddress ) + throws NamingException + { + LdapDN target = buildTarget( name ); + AliasDerefMode aliasDerefMode = AliasDerefMode.getEnum( getEnvironment() ); + return ServerEntryUtils.toSearchResultEnum( doSearchOperation( target, aliasDerefMode, filter, cons, clientAddress ) ); + } + + + /** * @see javax.naming.directory.DirContext#search(javax.naming.Name, * java.lang.String, javax.naming.directory.SearchControls) */ Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/DefaultSearchHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/DefaultSearchHandler.java?rev=666308&r1=666307&r2=666308&view=diff ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/DefaultSearchHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/DefaultSearchHandler.java Tue Jun 10 13:23:47 2008 @@ -53,6 +53,8 @@ import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import javax.naming.ldap.LdapContext; + +import java.net.InetSocketAddress; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -360,7 +362,7 @@ * Iterate through all search results building and sending back responses * for each search result returned. */ - list = ctx.search( req.getBase(), req.getFilter(), controls ); + list = ctx.search( req.getBase(), req.getFilter(), controls, ( InetSocketAddress ) session.getRemoteAddress() ); if ( list instanceof AbandonListener ) {