directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
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 GMT
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<String, Control> responseControls = new HashMap<String, Control>(4);
 
+    /** Area for storing various user specified parameters */
+    private Map<String, Object> parameters = new HashMap<String, Object>(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<ServerSearchResult> 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<ServerSearchResult> 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<ServerSearchResult> 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<SearchResult> 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 )
             {



Mime
View raw message