You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/08/24 05:59:29 UTC
svn commit: r569237 - 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-kerberos/ protocol-ldap/ protocol-ldap/src/main/java/org/apa...
Author: akarasulu
Date: Thu Aug 23 20:59:28 2007
New Revision: 569237
URL: http://svn.apache.org/viewvc?rev=569237&view=rev
Log:
preparatory changes for DIRSERVER-1030:
o added code in ldap protocol handlers to add request controls to the ctx
before operations, and to extract response controls after operations
o cleaned up some dumb code constructs in handlers
o fixed situation in JNDI provider where controls were not put into the
OperationContexts: controls will now tunnel down through interceptors
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/interceptor/context/OperationContext.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/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
directory/apacheds/trunk/protocol-kerberos/pom.xml
directory/apacheds/trunk/protocol-ldap/pom.xml
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java
directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/MiscTest.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=569237&r1=569236&r2=569237&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 Thu Aug 23 20:59:28 2007
@@ -19,6 +19,7 @@
*/
package org.apache.directory.server.core.interceptor.context;
+
import java.util.HashMap;
import java.util.Map;
@@ -36,6 +37,8 @@
*/
public abstract class AbstractOperationContext implements OperationContext
{
+ private static final Control[] EMPTY_CONTROLS = new Control[0];
+
/** The DN associated with the context */
private LdapDN dn;
private Map<String, Control> requestControls = new HashMap<String, Control>(2);
@@ -117,5 +120,37 @@
public boolean hasResponseControl( String numericOid )
{
return responseControls.containsKey( numericOid );
+ }
+
+
+ public Control[] getResponseControls()
+ {
+ if ( responseControls.isEmpty() )
+ {
+ return EMPTY_CONTROLS;
+ }
+
+ return responseControls.values().toArray( EMPTY_CONTROLS );
+ }
+
+
+ public boolean hasResponseControls()
+ {
+ return ! responseControls.isEmpty();
+ }
+
+
+ public int getResponseControlCount()
+ {
+ return responseControls.size();
+ }
+
+
+ public void addRequestControls( Control[] requestControls )
+ {
+ for ( Control c : requestControls )
+ {
+ this.requestControls.put( c.getID(), c );
+ }
}
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java Thu Aug 23 20:59:28 2007
@@ -20,6 +20,8 @@
package org.apache.directory.server.core.interceptor.context;
+import java.util.Iterator;
+
import javax.naming.ldap.Control;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -75,6 +77,30 @@
/**
+ * Gets all the response controls producted during this operation.
+ *
+ * @return an array over all the response controls
+ */
+ Control[] getResponseControls();
+
+
+ /**
+ * Checks if any response controls have been generated for this operation.
+ *
+ * @return true if any response controls have been generated, false otherwise
+ */
+ boolean hasResponseControls();
+
+
+ /**
+ * Checks the number of response controls have been generated for this operation.
+ *
+ * @return the number of response controls that have been generated
+ */
+ int getResponseControlCount();
+
+
+ /**
* Adds a request control to this operation.
*
* @param requestControl the request control to add to this operation.
@@ -98,4 +124,12 @@
* @return the control if present
*/
Control getRequestControl( String numericOid );
+
+
+ /**
+ * Adds many request controls to this operation.
+ *
+ * @param requestControls the request controls to add to this operation.
+ */
+ void addRequestControls( Control[] requestControls );
}
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=569237&r1=569236&r2=569237&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 Thu Aug 23 20:59:28 2007
@@ -24,6 +24,8 @@
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.naming.Context;
@@ -56,8 +58,10 @@
import org.apache.directory.server.core.interceptor.context.GetRootDSEOperationContext;
import org.apache.directory.server.core.interceptor.context.ListOperationContext;
import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.interceptor.context.OperationContext;
import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.partition.PartitionNexus;
@@ -70,6 +74,7 @@
import org.apache.directory.shared.ldap.filter.PresenceNode;
import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -89,6 +94,9 @@
/** property key used for deleting the old RDN on a rename */
public static final String DELETE_OLD_RDN_PROP = JndiPropertyConstants.JNDI_LDAP_DELETE_RDN;
+ /** Empty array of controls for use in dealing with them */
+ protected static final Control[] EMPTY_CONTROLS = new Control[0];
+
/** The directory service which owns this context **/
private final DirectoryService service;
@@ -106,8 +114,17 @@
/** The Principal associated with this context */
private LdapPrincipal principal;
+
+ /** The request controls to set on operations before performing them */
+ protected Control[] requestControls = EMPTY_CONTROLS;
+
+ /** The response controls to set after performing operations */
+ protected Control[] responseControls = EMPTY_CONTROLS;
+
+ /** Connection level controls associated with the session */
+ protected Control[] connectControls = EMPTY_CONTROLS;
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -139,22 +156,17 @@
LdapJndiProperties props = LdapJndiProperties.getLdapJndiProperties( this.env );
dn = props.getProviderDn();
- BindOperationContext bindContext = new BindOperationContext();
- bindContext.setDn( props.getBindDn() );
- bindContext.setCredentials( props.getCredentials() );
- bindContext.setMechanisms( props.getAuthenticationMechanisms() );
- bindContext.setSaslAuthId( props.getSaslAuthId() );
-
// need to issue a bind operation here
- this.nexusProxy.bind( bindContext );
-
+ doBindOperation( props.getBindDn(), props.getCredentials(), props.getAuthenticationMechanisms(),
+ props.getSaslAuthId() );
+
if ( ! nexusProxy.hasEntry( new EntryOperationContext( dn ) ) )
{
throw new NameNotFoundException( dn + " does not exist" );
}
}
-
-
+
+
/**
* Must be called by all subclasses to initialize the nexus proxy and the
* environment settings to be used by this Context implementation. This
@@ -174,8 +186,244 @@
this.principal = principal;
}
+
+
+ // ------------------------------------------------------------------------
+ // Protected Methods for Control [De]Marshalling
+ // ------------------------------------------------------------------------
+ // Use these methods instead of manually calling the nexusProxy so we can
+ // add request controls to operation contexts before the call and extract
+ // response controls from the contexts after the call. NOTE that the
+ // requestControls must be cleared after each operation. This makes a
+ // context not thread safe.
+ // ------------------------------------------------------------------------
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after add operations.
+ */
+ protected void doAddOperation( LdapDN target, Attributes attributes ) throws NamingException
+ {
+ // setup the op context and populate with request controls
+ AddOperationContext opCtx = new AddOperationContext( target, attributes );
+ opCtx.addRequestControls( requestControls );
+
+ // execute add operation
+ nexusProxy.add( opCtx );
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after delete operations.
+ */
+ protected void doDeleteOperation( LdapDN target ) throws NamingException
+ {
+ // setup the op context and populate with request controls
+ DeleteOperationContext opCtx = new DeleteOperationContext( target );
+ opCtx.addRequestControls( requestControls );
+
+ // execute delete operation
+ nexusProxy.delete( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after list operations.
+ */
+ protected NamingEnumeration doSearchOperation( LdapDN dn, Map env, ExprNode filter, SearchControls searchControls )
+ throws NamingException
+ {
+ // setup the op context and populate with request controls
+ SearchOperationContext opCtx = new SearchOperationContext( dn, env, filter, searchControls );
+ 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
+ {
+ // setup the op context and populate with request controls
+ ListOperationContext opCtx = new ListOperationContext( target );
+ opCtx.addRequestControls( requestControls );
+
+ // execute list operation
+ NamingEnumeration results = nexusProxy.list( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+
+ return results;
+ }
+
+
+ protected Attributes doGetRootDSEOperation( LdapDN target ) throws NamingException
+ {
+ GetRootDSEOperationContext opCtx = new GetRootDSEOperationContext( target );
+ opCtx.addRequestControls( requestControls );
+
+ // do not reset request controls since this is not an external
+ // operation and not do bother setting the response controls either
+ return nexusProxy.getRootDSE( ( GetRootDSEOperationContext ) opCtx );
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after lookup operations.
+ */
+ protected Attributes doLookupOperation( LdapDN target ) throws NamingException
+ {
+ // setup the op context and populate with request controls
+ LookupOperationContext opCtx;
+
+ // execute lookup/getRootDSE operation
+ opCtx = new LookupOperationContext( target );
+ opCtx.addRequestControls( requestControls );
+ Attributes attributes = nexusProxy.lookup( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ return attributes;
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after lookup operations.
+ */
+ protected Attributes doLookupOperation( LdapDN target, String[] attrIds ) throws NamingException
+ {
+ // setup the op context and populate with request controls
+ LookupOperationContext opCtx;
+
+ // execute lookup/getRootDSE operation
+ opCtx = new LookupOperationContext( target, attrIds );
+ opCtx.addRequestControls( requestControls );
+ Attributes attributes = nexusProxy.lookup( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+
+ return attributes;
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after bind operations.
+ */
+ protected void doBindOperation( LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId )
+ throws NamingException
+ {
+ // setup the op context and populate with request controls
+ BindOperationContext opCtx = new BindOperationContext();
+ opCtx.setDn( bindDn );
+ opCtx.setCredentials( credentials );
+ opCtx.setMechanisms( mechanisms );
+ opCtx.setSaslAuthId( saslAuthId );
+ opCtx.addRequestControls( requestControls );
+
+ // execute bind operation
+ this.nexusProxy.bind( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
+ */
+ protected void doMoveAndRenameOperation( LdapDN oldDn, LdapDN parent, String newRdn, boolean delOldDn )
+ throws NamingException
+ {
+ // setup the op context and populate with request controls
+ MoveAndRenameOperationContext opCtx = new MoveAndRenameOperationContext( oldDn, parent, newRdn, delOldDn );
+ opCtx.addRequestControls( requestControls );
+
+ // execute moveAndRename operation
+ nexusProxy.moveAndRename( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after modify operations.
+ */
+ protected void doModifyOperation( LdapDN dn, ModificationItemImpl[] modItems ) throws NamingException
+ {
+ // setup the op context and populate with request controls
+ ModifyOperationContext opCtx = new ModifyOperationContext( dn, modItems );
+ opCtx.addRequestControls( requestControls );
+
+ // execute modify operation
+ nexusProxy.modify( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
+ */
+ protected void doMove( LdapDN oldDn, LdapDN target ) throws NamingException
+ {
+ // setup the op context and populate with request controls
+ MoveOperationContext opCtx = new MoveOperationContext( oldDn, target );
+ opCtx.addRequestControls( requestControls );
+
+ // execute move operation
+ nexusProxy.move( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ }
+
+
+ /**
+ * Used to encapsulate [de]marshalling of controls before and after rename operations.
+ */
+ protected void doRename( LdapDN oldDn, String newRdn, boolean delOldRdn ) throws NamingException
+ {
+ // setup the op context and populate with request controls
+ RenameOperationContext opCtx = new RenameOperationContext( oldDn, newRdn, delOldRdn );
+ opCtx.addRequestControls( requestControls );
+
+ // execute rename operation
+ nexusProxy.rename( opCtx );
+
+ // clear the request controls and set the response controls
+ requestControls = EMPTY_CONTROLS;
+ responseControls = opCtx.getResponseControls();
+ }
+
+
// ------------------------------------------------------------------------
// New Impl Specific Public Methods
// ------------------------------------------------------------------------
@@ -352,7 +600,7 @@
* we need to copy over the controls as well to propagate the complete
* environment besides whats in the hashtable for env.
*/
- nexusProxy.add( new AddOperationContext( target, attributes ) );
+ doAddOperation( target, attributes );
return new ServerLdapContext( service, principal, target );
}
@@ -378,7 +626,7 @@
throw new LdapNoPermissionException( "can't delete the rootDSE" );
}
- nexusProxy.delete( new DeleteOperationContext( target ) );
+ doDeleteOperation( target );
}
@@ -424,7 +672,7 @@
if ( outAttrs != null )
{
LdapDN target = buildTarget( name );
- nexusProxy.add( new AddOperationContext( target, outAttrs ) );
+ doAddOperation( target, outAttrs );
return;
}
@@ -459,7 +707,7 @@
// Serialize object into entry attributes and add it.
JavaLdapSupport.serialize( attributes, obj );
- nexusProxy.add( new AddOperationContext( target, attributes ) );
+ doAddOperation( target, attributes );
}
else if ( obj instanceof DirContext )
{
@@ -476,7 +724,7 @@
LdapDN target = buildTarget( name );
injectRdnAttributeValues( target, attributes );
- nexusProxy.add( new AddOperationContext( target, attributes ) );
+ doAddOperation( target, attributes );
}
else
{
@@ -539,7 +787,7 @@
*/
if ( ( oldName.size() == newName.size() ) && oldBase.equals( newBase ) )
{
- nexusProxy.rename( new RenameOperationContext( oldDn, newRdn, delOldRdn ) );
+ doRename( oldDn, newRdn, delOldRdn );
}
else
{
@@ -548,11 +796,11 @@
if ( newRdn.equalsIgnoreCase( oldRdn ) )
{
- nexusProxy.move( new MoveOperationContext( oldDn, target ) );
+ doMove( oldDn, target );
}
else
{
- nexusProxy.moveAndRename( new MoveAndRenameOperationContext( oldDn, target, newRdn, delOldRdn ) );
+ doMoveAndRenameOperation( oldDn, target, newRdn, delOldRdn );
}
}
}
@@ -576,7 +824,7 @@
if ( nexusProxy.hasEntry( new EntryOperationContext( target ) ) )
{
- nexusProxy.delete( new DeleteOperationContext( target ) );
+ doDeleteOperation( target );
}
bind( name, obj );
@@ -597,7 +845,7 @@
*/
public void unbind( Name name ) throws NamingException
{
- nexusProxy.delete( new DeleteOperationContext( buildTarget( name ) ) );
+ doDeleteOperation( buildTarget( name ) );
}
@@ -629,11 +877,11 @@
if ( name.size() == 0 )
{
- attributes = nexusProxy.getRootDSE( new GetRootDSEOperationContext( target ) );
+ attributes = doGetRootDSEOperation( target );
}
else
{
- attributes = nexusProxy.lookup( new LookupOperationContext( target ) );
+ attributes = doLookupOperation( target );
}
try
@@ -662,17 +910,7 @@
}
// Initialize and return a context since the entry is not a java object
- ServerLdapContext ctx = new ServerLdapContext( service, principal, target );
-
- // Need to add controls to propagate extended ldap operational env
- Control[] controls = ( ( ServerLdapContext ) this ).getRequestControls();
-
- if ( null != controls )
- {
- ctx.setRequestControls( controls.clone() );
- }
-
- return ctx;
+ return new ServerLdapContext( service, principal, target );
}
@@ -748,7 +986,7 @@
*/
public NamingEnumeration list( Name name ) throws NamingException
{
- return nexusProxy.list( new ListOperationContext( buildTarget( name ) ) );
+ return doListOperation( buildTarget( name ) );
}
@@ -771,7 +1009,7 @@
PresenceNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
SearchControls ctls = new SearchControls();
ctls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- return nexusProxy.search( new SearchOperationContext( base, getEnvironment(), filter, ctls ) );
+ return doSearchOperation( base, getEnvironment(), filter, ctls );
}
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=569237&r1=569236&r2=569237&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 Thu Aug 23 20:59:28 2007
@@ -45,12 +45,7 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.authn.LdapPrincipal;
-import org.apache.directory.server.core.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
-import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
-import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
-import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.partition.PartitionNexusProxy;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.filter.AssertionEnum;
@@ -125,9 +120,7 @@
*/
public Attributes getAttributes( Name name ) throws NamingException
{
- LookupOperationContext lookupContext = new LookupOperationContext( buildTarget( name ) );
-
- return getNexusProxy().lookup( lookupContext );
+ return doLookupOperation( buildTarget( name ) );
}
@@ -147,9 +140,7 @@
*/
public Attributes getAttributes( Name name, String[] attrIds ) throws NamingException
{
- LookupOperationContext lookupContext = new LookupOperationContext( buildTarget( name ), attrIds );
-
- return getNexusProxy().lookup( lookupContext );
+ return doLookupOperation( buildTarget( name ), attrIds );
}
@@ -184,11 +175,11 @@
if ( name instanceof LdapDN )
{
- getNexusProxy().modify( new ModifyOperationContext( buildTarget( name ), modItems ) );
+ doModifyOperation( buildTarget( name ), modItems );
}
else
{
- getNexusProxy().modify( new ModifyOperationContext( buildTarget( new LdapDN( name ) ), modItems ) );
+ doModifyOperation( buildTarget( new LdapDN( name ) ), modItems );
}
}
@@ -232,7 +223,7 @@
newMods[i] = new ModificationItemImpl( mods[i] );
}
- getNexusProxy().modify( new ModifyOperationContext( buildTarget( new LdapDN( name ) ), newMods ) );
+ doModifyOperation( buildTarget( new LdapDN( name ) ), newMods );
}
@@ -242,7 +233,7 @@
*/
public void modifyAttributes( Name name, ModificationItemImpl[] mods ) throws NamingException
{
- getNexusProxy().modify( new ModifyOperationContext( buildTarget( new LdapDN( name ) ), mods ) );
+ doModifyOperation( buildTarget( new LdapDN( name ) ), mods );
}
@@ -282,7 +273,7 @@
{
Attributes clone = ( Attributes ) attrs.clone();
LdapDN target = buildTarget( name );
- getNexusProxy().add( new AddOperationContext( target, clone ) );
+ doAddOperation( target, clone );
return;
}
@@ -302,7 +293,7 @@
attributes.put( ( Attribute ) list.next() );
}
}
- getNexusProxy().add( new AddOperationContext( target, attributes ) );
+ doAddOperation( target, attributes );
return;
}
@@ -334,7 +325,7 @@
// Serialize object into entry attributes and add it.
JavaLdapSupport.serialize( attributes, obj );
- getNexusProxy().add( new AddOperationContext( target, attributes ) );
+ doAddOperation( target, attributes );
}
else if ( obj instanceof DirContext )
{
@@ -349,7 +340,7 @@
}
}
LdapDN target = buildTarget( name );
- getNexusProxy().add( new AddOperationContext( target, attributes ) );
+ doAddOperation( target, attributes );
}
else
{
@@ -378,7 +369,7 @@
if ( getNexusProxy().hasEntry( new EntryOperationContext( target ) ) )
{
- getNexusProxy().delete( new DeleteOperationContext( target ) );
+ doDeleteOperation( target );
}
bind( name, obj, AttributeUtils.toCaseInsensitive( attrs ) );
@@ -450,7 +441,7 @@
}
// Add the new context to the server which as a side effect adds
- getNexusProxy().add( new AddOperationContext( target, attributes ) );
+ doAddOperation( target, attributes );
// Initialize the new context
return new ServerLdapContext( getService(), getPrincipal(), target );
@@ -550,8 +541,7 @@
if ( ( null == matchingAttributes ) || ( matchingAttributes.size() <= 0 ) )
{
PresenceNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
- return getNexusProxy().search(
- new SearchOperationContext( target, getEnvironment(), filter, ctls ) );
+ return doSearchOperation( target, getEnvironment(), filter, ctls );
}
// Handle simple filter expressions without multiple terms
@@ -575,8 +565,7 @@
node = new SimpleNode( attr.getID(), ( String ) value, AssertionEnum.EQUALITY );
}
- return getNexusProxy().search(
- new SearchOperationContext( target, getEnvironment(), node, ctls ) );
+ return doSearchOperation( target, getEnvironment(), node, ctls );
}
}
@@ -622,8 +611,7 @@
}
}
- return getNexusProxy().search(
- new SearchOperationContext( target, getEnvironment(), filter, ctls ) );
+ return doSearchOperation( target, getEnvironment(), filter, ctls );
}
@@ -651,8 +639,7 @@
public NamingEnumeration<SearchResult> search( Name name, ExprNode filter, SearchControls cons ) throws NamingException
{
LdapDN target = buildTarget( name );
- return getNexusProxy().search(
- new SearchOperationContext( target, getEnvironment(), filter, cons ) );
+ return doSearchOperation( target, getEnvironment(), filter, cons );
}
@@ -683,8 +670,7 @@
throw ne;
}
- return getNexusProxy().search(
- new SearchOperationContext( target, getEnvironment(), filterNode, cons ) );
+ return doSearchOperation( target, getEnvironment(), filterNode, cons );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java Thu Aug 23 20:59:28 2007
@@ -47,11 +47,6 @@
*/
public class ServerLdapContext extends ServerDirContext implements LdapContext
{
- private static final Control[] EMPTY_CONTROLS = new Control[0];
- private Control[] requestControls = EMPTY_CONTROLS;
- private Control[] responseControls = EMPTY_CONTROLS;
- private Control[] connectControls = EMPTY_CONTROLS;
-
/** A reference to the RTeferralService interceptor */
private transient ReferralService refService = null;
@@ -173,7 +168,17 @@
*/
public boolean compare( LdapDN name, String oid, Object value ) throws NamingException
{
- return super.getNexusProxy().compare( new CompareOperationContext( name, oid, value ) );
+ // make sure we add the request controls to operation
+ CompareOperationContext opCtx = new CompareOperationContext( name, oid, value );
+ opCtx.addRequestControls( requestControls );
+
+ // execute operation
+ boolean result = super.getNexusProxy().compare( opCtx );
+
+ // extract the response controls from the operation and return
+ responseControls = getResponseControls();
+ requestControls = EMPTY_CONTROLS;
+ return result;
}
@@ -187,18 +192,24 @@
*/
public void ldapUnbind() throws NamingException
{
- Object dn = getEnvironment().get( Context.SECURITY_PRINCIPAL );
+ LdapDN principalDn = null;
+ Object principalDnValue = getEnvironment().get( Context.SECURITY_PRINCIPAL );
- if ( dn instanceof LdapDN )
+ if ( principalDnValue instanceof LdapDN )
{
- super.getNexusProxy().unbind( new UnbindOperationContext( ( LdapDN ) dn ) );
+ principalDn = ( LdapDN ) principalDnValue;
}
else
{
- String bindDn = ( String ) dn;
-
- super.getNexusProxy().unbind( new UnbindOperationContext( new LdapDN( bindDn ) ) );
+ String bindDn = ( String ) principalDnValue;
+ principalDn = new LdapDN( bindDn );
}
+
+ UnbindOperationContext opCtx = new UnbindOperationContext( principalDn );
+ opCtx.addRequestControls( requestControls );
+ super.getNexusProxy().unbind( opCtx );
+ responseControls = opCtx.getResponseControls();
+ requestControls = EMPTY_CONTROLS;
}
Modified: directory/apacheds/trunk/protocol-kerberos/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/pom.xml?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/pom.xml (original)
+++ directory/apacheds/trunk/protocol-kerberos/pom.xml Thu Aug 23 20:59:28 2007
@@ -39,5 +39,18 @@
<version>${pom.version}</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/TestUtils.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: directory/apacheds/trunk/protocol-ldap/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/pom.xml?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/pom.xml (original)
+++ directory/apacheds/trunk/protocol-ldap/pom.xml Thu Aug 23 20:59:28 2007
@@ -33,7 +33,6 @@
<packaging>jar</packaging>
<dependencies>
-
<dependency>
<groupId>org.apache.directory.shared</groupId>
<artifactId>shared-asn1-codec</artifactId>
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -52,7 +52,7 @@
import org.apache.directory.shared.ldap.message.CascadeControl;
import org.apache.directory.shared.ldap.message.CompareRequest;
import org.apache.directory.shared.ldap.message.CompareRequestImpl;
-import org.apache.directory.shared.ldap.message.Control;
+import org.apache.directory.shared.ldap.message.MutableControl;
import org.apache.directory.shared.ldap.message.DeleteRequest;
import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
import org.apache.directory.shared.ldap.message.EntryChangeControl;
@@ -413,7 +413,7 @@
Iterator controls = req.getControls().values().iterator();
while ( controls.hasNext() )
{
- Control control = ( Control ) controls.next();
+ MutableControl control = ( MutableControl ) controls.next();
if ( control.isCritical() && !SUPPORTED_CONTROLS.contains( control.getID() ) )
{
ResultResponse resp = req.getResultResponse();
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java Thu Aug 23 20:59:28 2007
@@ -19,14 +19,16 @@
*/
package org.apache.directory.server.ldap.support;
+
import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;
-import org.apache.directory.shared.ldap.message.Control;
+import org.apache.directory.shared.ldap.message.MutableControl;
import org.apache.directory.shared.ldap.message.Message;
import org.apache.mina.handler.demux.MessageHandler;
+
/**
* An abstract class to handle common methods used by all the handlers
*
@@ -41,9 +43,9 @@
* @param context The context in which we will store teh found controls
* @param message The message for which we want to extract the controls
*/
- protected void setControls( LdapContext context, Message message ) throws NamingException
+ protected void setRequestControls( LdapContext context, Message message ) throws NamingException
{
- Control[] controls = null;
+ MutableControl[] controls = null;
if ( message.getControls() != null )
{
@@ -51,7 +53,7 @@
if ( nbControls != 0 )
{
- controls = new Control[ nbControls ];
+ controls = new MutableControl[ nbControls ];
context.setRequestControls( message.getControls().values().toArray( controls ) );
}
}
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -34,8 +34,10 @@
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;
@@ -77,9 +79,11 @@
}
// Inject controls into the context
- setControls( ctx, req );
-
+ setRequestControls( ctx, req );
ctx.createSubcontext( req.getEntry(), req.getAttributes() );
+ result.setResultCode( ResultCodeEnum.SUCCESS );
+ req.getResultResponse().addAll( ctx.getResponseControls() );
+ session.write( req.getResultResponse() );
}
catch ( ReferralException e )
{
@@ -95,7 +99,6 @@
}
while ( e.skipReferral() );
session.write( req.getResultResponse() );
- return;
}
catch ( NamingException e )
{
@@ -128,10 +131,6 @@
}
session.write( req.getResultResponse() );
- return;
}
-
- result.setResultCode( ResultCodeEnum.SUCCESS );
- session.write( req.getResultResponse() );
}
}
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -36,7 +36,7 @@
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.BindRequest;
import org.apache.directory.shared.ldap.message.BindResponse;
-import org.apache.directory.shared.ldap.message.Control;
+import org.apache.directory.shared.ldap.message.MutableControl;
import org.apache.directory.shared.ldap.message.LdapResult;
import org.apache.directory.shared.ldap.message.ManageDsaITControl;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -70,7 +70,7 @@
//private static final String STRONG_AUTHENTICATION_LEVEL = "strong";
/** An empty Contol array used to get back the controls if any */
- private static final Control[] EMPTY_CONTROL = new Control[0];
+ private static final MutableControl[] EMPTY_CONTROL = new MutableControl[0];
/**
@@ -158,7 +158,7 @@
}
else
{
- Control[] connCtls = bindRequest.getControls().values().toArray( EMPTY_CONTROL );
+ MutableControl[] connCtls = bindRequest.getControls().values().toArray( EMPTY_CONTROL );
ctx = new InitialLdapContext( env, connCtls );
}
}
@@ -234,7 +234,7 @@
ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
// Inject controls into the context
- setControls( newCtx, bindRequest );
+ setRequestControls( newCtx, bindRequest );
// Test that we successfully got one. If not, an error has already been returned.
if ( ctx != null )
@@ -242,7 +242,7 @@
SessionRegistry.getSingleton().setLdapContext( session, ctx );
bindResult.setResultCode( ResultCodeEnum.SUCCESS );
BindResponse response = ( BindResponse ) bindRequest.getResultResponse();
-
+ response.addAll( newCtx.getResponseControls() );
session.write( response );
log.debug( "Returned SUCCESS message." );
}
@@ -275,7 +275,6 @@
{
log.error( "Bind error : Only LDAP v3 is supported." );
LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
-
bindResult.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
bindResult.setErrorMessage( "Only LDAP v3 is supported." );
session.write( bindRequest.getResultResponse() );
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -74,7 +74,7 @@
}
// Inject controls into the context
- setControls( newCtx, req );
+ setRequestControls( newCtx, req );
if ( newCtx.compare( req.getName(), req.getAttributeId(), req.getAssertionValue() ) )
{
@@ -84,6 +84,10 @@
{
result.setResultCode( ResultCodeEnum.COMPARE_FALSE );
}
+
+ result.setMatchedDn( req.getName() );
+ req.getResultResponse().addAll( newCtx.getResponseControls() );
+ session.write( req.getResultResponse() );
}
catch ( ReferralException e )
{
@@ -99,9 +103,7 @@
refs.addLdapUrl( ( String ) e.getReferralInfo() );
}
while ( e.skipReferral() );
-
session.write( req.getResultResponse() );
- return;
}
catch ( Exception e )
{
@@ -139,10 +141,6 @@
}
session.write( req.getResultResponse() );
- return;
}
-
- result.setMatchedDn( req.getName() );
- session.write( req.getResultResponse() );
}
}
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -71,9 +71,12 @@
}
// Inject controls into the context
- setControls( ctx, req );
+ setRequestControls( ctx, req );
ctx.destroySubcontext( req.getName() );
+ result.setResultCode( ResultCodeEnum.SUCCESS );
+ req.getResultResponse().addAll( ctx.getResponseControls() );
+ session.write( req.getResultResponse() );
}
catch ( ReferralException e )
{
@@ -89,7 +92,6 @@
}
while ( e.skipReferral() );
session.write( req.getResultResponse() );
- return;
}
catch ( NamingException e )
{
@@ -120,10 +122,6 @@
}
session.write( req.getResultResponse() );
- return;
}
-
- result.setResultCode( ResultCodeEnum.SUCCESS );
- session.write( req.getResultResponse() );
}
}
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -104,7 +104,7 @@
}
// Inject controls into the context
- setControls( ctx, req );
+ setRequestControls( ctx, req );
String deleteRDN = String.valueOf( req.getDeleteOldRdn() );
ctx.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DELETE_RDN, deleteRDN );
@@ -136,6 +136,10 @@
newDn.add( req.getNewRdn() );
ctx.rename( req.getName(), newDn );
}
+
+ req.getResultResponse().addAll( ctx.getResponseControls() );
+ result.setResultCode( ResultCodeEnum.SUCCESS );
+ session.write( req.getResultResponse() );
}
catch ( ReferralException e )
{
@@ -152,7 +156,6 @@
while ( e.skipReferral() );
session.write( req.getResultResponse() );
- return;
}
catch ( NamingException e )
{
@@ -185,11 +188,7 @@
}
session.write( req.getResultResponse() );
- return;
}
-
- result.setResultCode( ResultCodeEnum.SUCCESS );
- session.write( req.getResultResponse() );
}
}
}
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -72,7 +72,7 @@
}
// Inject controls into the context
- setControls( ctx, req );
+ setRequestControls( ctx, req );
// Process the modifications
if ( req.getModificationItems() != null )
@@ -93,6 +93,10 @@
{
// What should we do if we don't have any modification ???
}
+
+ result.setResultCode( ResultCodeEnum.SUCCESS );
+ req.getResultResponse().addAll( ctx.getResponseControls() );
+ session.write( req.getResultResponse() );
}
catch ( ReferralException e )
{
@@ -108,7 +112,6 @@
}
while ( e.skipReferral() );
session.write( req.getResultResponse() );
- return;
}
catch ( NamingException e )
{
@@ -140,11 +143,6 @@
}
session.write( req.getResultResponse() );
- return;
}
-
- result.setResultCode( ResultCodeEnum.SUCCESS );
- session.write( req.getResultResponse() );
- return;
}
}
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?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- 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 Thu Aug 23 20:59:28 2007
@@ -210,11 +210,10 @@
{
ctx = ( ServerLdapContext ) unknown;
}
-
}
// Inject controls into the context
- setControls( ctx, req );
+ setRequestControls( ctx, req );
ctx.addToEnvironment( DEREFALIASES_KEY, req.getDerefAliases() );
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java Thu Aug 23 20:59:28 2007
@@ -36,6 +36,7 @@
import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.ManageDsaITControl;
+import org.apache.directory.shared.ldap.message.Message;
import org.apache.directory.shared.ldap.message.ReferralImpl;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.message.SearchRequest;
@@ -109,9 +110,7 @@
SearchResponseEntry respEntry;
respEntry = new SearchResponseEntryImpl( req.getMessageId() );
respEntry.setAttributes( result.getAttributes() );
-
respEntry.setObjectName( result.getDn() );
-
prefetched = respEntry;
}
else
@@ -176,6 +175,21 @@
public Object next()
{
Object next = prefetched;
+
+ try
+ {
+ if ( prefetched != null )
+ {
+ ( ( Message ) prefetched ).addAll( ctx.getResponseControls() );
+ }
+ }
+ catch ( NamingException e )
+ {
+ NoSuchElementException nsee = new NoSuchElementException();
+ nsee.initCause( e );
+ throw nsee;
+ }
+
SearchResult result = null;
// if we're done we got nothing to give back
@@ -188,6 +202,18 @@
if ( respDone != null )
{
done = true;
+
+ try
+ {
+ respDone.addAll( ctx.getResponseControls() );
+ }
+ catch ( NamingException e )
+ {
+ NoSuchElementException nsee = new NoSuchElementException();
+ nsee.initCause( e );
+ throw nsee;
+ }
+
return respDone;
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java Thu Aug 23 20:59:28 2007
@@ -36,7 +36,7 @@
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.BindRequest;
-import org.apache.directory.shared.ldap.message.Control;
+import org.apache.directory.shared.ldap.message.MutableControl;
import org.apache.directory.shared.ldap.message.LdapResult;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -58,7 +58,7 @@
{
private static final Logger log = LoggerFactory.getLogger( AbstractSaslCallbackHandler.class );
- private static final Control[] EMPTY = new Control[0];
+ private static final MutableControl[] EMPTY = new MutableControl[0];
private String username;
private String realm;
@@ -211,7 +211,7 @@
}
else
{
- Control[] connCtls = request.getControls().values().toArray( EMPTY );
+ MutableControl[] connCtls = request.getControls().values().toArray( EMPTY );
ctx = new InitialLdapContext( env, connCtls );
}
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java Thu Aug 23 20:59:28 2007
@@ -31,7 +31,7 @@
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.Control;
+import org.apache.directory.shared.ldap.message.MutableControl;
import org.apache.directory.shared.ldap.message.LdapResult;
import org.apache.directory.shared.ldap.message.ManageDsaITControl;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -51,7 +51,7 @@
{
private static final Logger log = LoggerFactory.getLogger( GetLdapContext.class );
- private static final Control[] EMPTY = new Control[0];
+ private static final MutableControl[] EMPTY = new MutableControl[0];
public void execute( NextCommand next, IoSession session, Object message ) throws Exception
@@ -78,12 +78,15 @@
}
else
{
- Control[] connCtls = request.getControls().values().toArray( EMPTY );
+ MutableControl[] connCtls = request.getControls().values().toArray( EMPTY );
ctx = new InitialLdapContext( env, connCtls );
}
SessionRegistry.getSingleton().setLdapContext( session, ctx );
-
+
+ // add the bind response controls
+ request.getResultResponse().addAll( ctx.getResponseControls() );
+
next.execute( session, message );
}
catch ( NamingException e )
Modified: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/MiscTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/MiscTest.java?rev=569237&r1=569236&r2=569237&view=diff
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/MiscTest.java (original)
+++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/MiscTest.java Thu Aug 23 20:59:28 2007
@@ -30,7 +30,7 @@
import org.apache.directory.shared.asn1.util.Asn1StringUtils;
import org.apache.directory.shared.ldap.message.AttributeImpl;
import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.message.Control;
+import org.apache.directory.shared.ldap.message.MutableControl;
import org.apache.directory.shared.ldap.util.ArrayUtils;
import org.apache.directory.shared.ldap.util.EmptyEnumeration;
@@ -371,7 +371,7 @@
public void testFailureWithUnsupportedControl() throws Exception
{
- Control unsupported = new Control()
+ MutableControl unsupported = new MutableControl()
{
boolean isCritical = true;
private static final long serialVersionUID = 1L;
@@ -383,7 +383,7 @@
}
- public void setType( String oid )
+ public void setID( String oid )
{
}
@@ -441,7 +441,7 @@
user.put( oc );
user.put( "sn", "Bush" );
user.put( "userPassword", "Aerial" );
- ctx.setRequestControls( new Control[]
+ ctx.setRequestControls( new MutableControl[]
{ unsupported } );
try