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 2006/01/09 19:26:19 UTC
svn commit: r367353 - in /directory/trunks:
apacheds-server-unit/src/test/java/org/apache/ldap/server/
apacheds/src/main/java/org/apache/ldap/server/partition/
ldap-common/src/main/java/org/apache/ldap/common/codec/
ldap-common/src/main/java/org/apache...
Author: akarasulu
Date: Mon Jan 9 10:25:55 2006
New Revision: 367353
URL: http://svn.apache.org/viewcvs?rev=367353&view=rev
Log:
changes ...
o made all operations add request controls to LdapContext before issuing
any commands against the apacheds JNDI LDAP provider: this is to allow
the LDAP provider to alter its behavoir based on the presence of request
controls
o made all protocol operations now set the Context.REFERRAL property in the
environment before making JNDI calls on the ApacheDS JNDI Provider
o deleting unused HandlerUtil class (junk that got accidentally committed)
o removed search through a collection for a particular control now that we
use a Map as returned by getControls() on a request
o added logger to unbind handler
o started using control's CONTROL_OID constant rather than replicating the use
of the control's OID string
o added a new ManageDsaIT control but have not rigged in the processing logic
yet ... will add this as I finish off referral support
Added:
directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControl.java (with props)
directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControlDecoder.java (with props)
directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/ManageDsaITControl.java (with props)
Removed:
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/HandlerUtil.java
Modified:
directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/ChangeListener.java
directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/PersistentSearchTest.java
directory/trunks/apacheds/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java
directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ControlValueAction.java
directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/EntryChangeControl.java
directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/PersistentSearchControl.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/UnbindHandler.java
Modified: directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/ChangeListener.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/ChangeListener.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/ChangeListener.java (original)
+++ directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/ChangeListener.java Mon Jan 9 10:25:55 2006
@@ -74,7 +74,7 @@
for ( int ii = 0; ii < respCtls.length; ii ++ )
{
if ( respCtls[ii].getID().equals(
- org.apache.ldap.common.message.EntryChangeControl.CONTROL_ID ) )
+ org.apache.ldap.common.message.EntryChangeControl.CONTROL_OID ) )
{
EntryChangeControlDecoder decoder = new EntryChangeControlDecoder();
ecCtl = ( EntryChangeControl ) decoder.decode( respCtls[ii].getEncodedValue() );
Modified: directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/PersistentSearchTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/PersistentSearchTest.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/PersistentSearchTest.java (original)
+++ directory/trunks/apacheds-server-unit/src/test/java/org/apache/ldap/server/PersistentSearchTest.java Mon Jan 9 10:25:55 2006
@@ -705,7 +705,7 @@
for ( int ii = 0; ii < controls.length; ii ++ )
{
if ( controls[ii].getID().equals(
- org.apache.ldap.common.message.EntryChangeControl.CONTROL_ID ) )
+ org.apache.ldap.common.message.EntryChangeControl.CONTROL_OID ) )
{
EntryChangeControlDecoder decoder = new EntryChangeControlDecoder();
ecControl = ( EntryChangeControl ) decoder.decode( controls[ii].getEncodedValue() );
Modified: directory/trunks/apacheds/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/apacheds/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java (original)
+++ directory/trunks/apacheds/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java Mon Jan 9 10:25:55 2006
@@ -52,8 +52,11 @@
import org.apache.ldap.common.exception.LdapNoSuchAttributeException;
import org.apache.ldap.common.filter.ExprNode;
import org.apache.ldap.common.filter.PresenceNode;
+import org.apache.ldap.common.message.EntryChangeControl;
import org.apache.ldap.common.message.LockableAttributeImpl;
import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.message.ManageDsaITControl;
+import org.apache.ldap.common.message.PersistentSearchControl;
import org.apache.ldap.common.name.LdapName;
import org.apache.ldap.common.util.DateUtils;
import org.apache.ldap.common.util.NamespaceTools;
@@ -132,8 +135,9 @@
attr = new LockableAttributeImpl( "supportedControls" );
rootDSE.put( attr );
- attr.add( "2.16.840.1.113730.3.4.3" ); // PersistentSearch control
- attr.add( "2.16.840.1.113730.3.4.7" ); // EntryChangeNotification control
+ attr.add( PersistentSearchControl.CONTROL_OID );
+ attr.add( EntryChangeControl.CONTROL_OID );
+ attr.add( ManageDsaITControl.CONTROL_OID );
attr = new LockableAttributeImpl( "objectClass" );
rootDSE.put( attr );
Modified: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ControlValueAction.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ControlValueAction.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ControlValueAction.java (original)
+++ directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ControlValueAction.java Mon Jan 9 10:25:55 2006
@@ -49,7 +49,11 @@
public ControlValueAction()
{
super( "Sets the control value" );
- PSearchControlDecoder decoder = new PSearchControlDecoder();
+
+ ControlDecoder decoder;
+ decoder = new PSearchControlDecoder();
+ controlDecoders.put( decoder.getControlType(), decoder );
+ decoder = new ManageDsaITControlDecoder();
controlDecoders.put( decoder.getControlType(), decoder );
}
Added: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControl.java?rev=367353&view=auto
==============================================================================
--- directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControl.java (added)
+++ directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControl.java Mon Jan 9 10:25:55 2006
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.common.codec;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.Asn1Object;
+import org.apache.asn1.codec.EncoderException;
+
+
+/**
+ * Control which allows for the management of referrals and other DSA
+ * specific entities without processing them: meaning the referrals are
+ * treated as regular entries using this control. More information is
+ * available in <a href="">RFC 3296</a>. Below we have included
+ * section 3 of the RFC describing this control:
+ * <pre>
+ * 3. The ManageDsaIT Control
+ *
+ * The client may provide the ManageDsaIT control with an operation to
+ * indicate that the operation is intended to manage objects within the
+ * DSA (server) Information Tree. The control causes Directory-specific
+ * entries (DSEs), regardless of type, to be treated as normal entries
+ * allowing clients to interrogate and update these entries using LDAP
+ * operations.
+ *
+ * A client MAY specify the following control when issuing an add,
+ * compare, delete, modify, modifyDN, search request or an extended
+ * operation for which the control is defined.
+ *
+ * The control type is 2.16.840.1.113730.3.4.2. The control criticality
+ * may be TRUE or, if FALSE, absent. The control value is absent.
+ *
+ * When the control is present in the request, the server SHALL NOT
+ * generate a referral or continuation reference based upon information
+ * held in referral objects and instead SHALL treat the referral object
+ * as a normal entry. The server, however, is still free to return
+ * referrals for other reasons. When not present, referral objects
+ * SHALL be handled as described above.
+ *
+ * The control MAY cause other objects to be treated as normal entries
+ * as defined by subsequent documents.
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ManageDsaITControl extends Asn1Object
+{
+ private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate( 0 );
+
+
+ /**
+ * Returns 0 everytime.
+ */
+ public int computeLength()
+ {
+ return 0;
+ }
+
+
+ /**
+ * Encodes the control: does nothing but returns an empty buffer.
+ */
+ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+ {
+ return EMPTY_BUFFER;
+ }
+}
Propchange: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControlDecoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControlDecoder.java?rev=367353&view=auto
==============================================================================
--- directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControlDecoder.java (added)
+++ directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControlDecoder.java Mon Jan 9 10:25:55 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.common.codec;
+
+
+import org.apache.asn1.Asn1Object;
+import org.apache.asn1.codec.DecoderException;
+import org.apache.ldap.common.message.ManageDsaITControl;
+
+
+/**
+ * A decoder for EntryChangeControls.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ManageDsaITControlDecoder implements ControlDecoder
+{
+ public String getControlType()
+ {
+ return ManageDsaITControl.CONTROL_OID;
+ }
+
+
+ public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+ {
+ return new org.apache.ldap.common.codec.ManageDsaITControl();
+ }
+}
Propchange: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/codec/ManageDsaITControlDecoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/EntryChangeControl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/EntryChangeControl.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/EntryChangeControl.java (original)
+++ directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/EntryChangeControl.java Mon Jan 9 10:25:55 2006
@@ -76,7 +76,7 @@
{
private static final long serialVersionUID = -2356861450876343999L;
private static final Logger log = LoggerFactory.getLogger( EntryChangeControl.class );
- public static final String CONTROL_ID = "2.16.840.1.113730.3.4.7";
+ public static final String CONTROL_OID = "2.16.840.1.113730.3.4.7";
public static final int UNDEFINED_CHANGE_NUMBER =
org.apache.ldap.common.codec.search.controls.EntryChangeControl.UNDEFINED_CHANGE_NUMBER;
@@ -88,7 +88,7 @@
public EntryChangeControl()
{
super();
- setType( CONTROL_ID );
+ setType( CONTROL_OID );
}
Added: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/ManageDsaITControl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/ManageDsaITControl.java?rev=367353&view=auto
==============================================================================
--- directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/ManageDsaITControl.java (added)
+++ directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/ManageDsaITControl.java Mon Jan 9 10:25:55 2006
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.common.message;
+
+
+/**
+ * Control which allows for the management of referrals and other DSA
+ * specific entities without processing them: meaning the referrals are
+ * treated as regular entries using this control. More information is
+ * available in <a href="">RFC 3296</a>. Below we have included
+ * section 3 of the RFC describing this control:
+ * <pre>
+ * 3. The ManageDsaIT Control
+ *
+ * The client may provide the ManageDsaIT control with an operation to
+ * indicate that the operation is intended to manage objects within the
+ * DSA (server) Information Tree. The control causes Directory-specific
+ * entries (DSEs), regardless of type, to be treated as normal entries
+ * allowing clients to interrogate and update these entries using LDAP
+ * operations.
+ *
+ * A client MAY specify the following control when issuing an add,
+ * compare, delete, modify, modifyDN, search request or an extended
+ * operation for which the control is defined.
+ *
+ * The control type is 2.16.840.1.113730.3.4.2. The control criticality
+ * may be TRUE or, if FALSE, absent. The control value is absent.
+ *
+ * When the control is present in the request, the server SHALL NOT
+ * generate a referral or continuation reference based upon information
+ * held in referral objects and instead SHALL treat the referral object
+ * as a normal entry. The server, however, is still free to return
+ * referrals for other reasons. When not present, referral objects
+ * SHALL be handled as described above.
+ *
+ * The control MAY cause other objects to be treated as normal entries
+ * as defined by subsequent documents.
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ManageDsaITControl extends ControlImpl
+{
+ public static final String CONTROL_OID = "2.16.840.1.113730.3.4.2";
+ private static final long serialVersionUID = -8844249964346248321L;
+ private final static byte[] EMPTY_BYTES = new byte[0];
+
+
+ /**
+ * Returns an empty byte[] everytime.
+ */
+ public byte[] getEncodedValue()
+ {
+ return EMPTY_BYTES;
+ }
+
+
+ /**
+ * Returns an empty byte[] everytime.
+ */
+ public byte[] getValue()
+ {
+ return EMPTY_BYTES;
+ }
+
+
+ /**
+ * Returns "2.16.840.1.113730.3.4.2" everytime.
+ */
+ public String getType()
+ {
+ return CONTROL_OID;
+ }
+
+
+ /**
+ * Returns "2.16.840.1.113730.3.4.2" everytime.
+ */
+ public String getID()
+ {
+ return CONTROL_OID;
+ }
+}
Propchange: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/ManageDsaITControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/PersistentSearchControl.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/PersistentSearchControl.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/PersistentSearchControl.java (original)
+++ directory/trunks/ldap-common/src/main/java/org/apache/ldap/common/message/PersistentSearchControl.java Mon Jan 9 10:25:55 2006
@@ -33,7 +33,7 @@
{
private static final long serialVersionUID = -2356861450876343999L;
private static final Logger log = LoggerFactory.getLogger( PersistentSearchControl.class );
- public static final String CONTROL_ID = "2.16.840.1.113730.3.4.3";
+ public static final String CONTROL_OID = "2.16.840.1.113730.3.4.3";
public static final int ALL_CHANGES = 1 | 2 | 4 | 8;
/**
@@ -67,7 +67,7 @@
public PersistentSearchControl()
{
super();
- setType( CONTROL_ID );
+ setType( CONTROL_OID );
}
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java Mon Jan 9 10:25:55 2006
@@ -41,14 +41,17 @@
import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.DeleteRequest;
import org.apache.ldap.common.message.DeleteRequestImpl;
+import org.apache.ldap.common.message.EntryChangeControl;
import org.apache.ldap.common.message.ExtendedRequest;
import org.apache.ldap.common.message.ExtendedRequestImpl;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.MessageDecoder;
import org.apache.ldap.common.message.MessageEncoder;
import org.apache.ldap.common.message.ModifyDnRequest;
import org.apache.ldap.common.message.ModifyDnRequestImpl;
import org.apache.ldap.common.message.ModifyRequest;
import org.apache.ldap.common.message.ModifyRequestImpl;
+import org.apache.ldap.common.message.PersistentSearchControl;
import org.apache.ldap.common.message.Request;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.message.ResultResponse;
@@ -144,8 +147,9 @@
DEFAULT_HANDLERS = Collections.unmodifiableMap( map );
HashSet set = new HashSet();
- set.add( "2.16.840.1.113730.3.4.3" ); // PersistentSearch control
- set.add( "2.16.840.1.113730.3.4.7" ); // EntryChangeNotification control
+ set.add( PersistentSearchControl.CONTROL_OID );
+ set.add( EntryChangeControl.CONTROL_OID );
+ set.add( ManageDsaITControl.CONTROL_OID );
SUPPORTED_CONTROLS = Collections.unmodifiableSet( set );
}
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/AddHandler.java Mon Jan 9 10:25:55 2006
@@ -17,12 +17,15 @@
package org.apache.ldap.server.protocol.support;
+import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;
import org.apache.ldap.common.exception.LdapException;
import org.apache.ldap.common.message.AddRequest;
+import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.util.ExceptionUtils;
import org.apache.ldap.server.protocol.SessionRegistry;
@@ -42,7 +45,9 @@
public class AddHandler implements MessageHandler
{
private static final Logger log = LoggerFactory.getLogger( AddHandler.class );
+ private static Control[] EMPTY_CONTROLS = new Control[0];
+
public void messageReceived( IoSession session, Object request )
{
AddRequest req = ( AddRequest ) request;
@@ -56,6 +61,15 @@
try
{
LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "ignore" );
+ }
+ else
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "throw" );
+ }
+ ctx.setRequestControls( ( Control[] ) req.getControls().values().toArray( EMPTY_CONTROLS ) );
ctx.createSubcontext( req.getEntry(), req.getAttributes() );
}
catch( NamingException e )
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java Mon Jan 9 10:25:55 2006
@@ -29,6 +29,7 @@
import org.apache.ldap.common.message.BindRequest;
import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.util.ExceptionUtils;
import org.apache.ldap.common.util.StringTools;
@@ -57,9 +58,8 @@
LdapContext ctx;
BindRequest req = ( BindRequest ) request;
LdapResult result = req.getResultResponse().getLdapResult();
-
Hashtable env = SessionRegistry.getSingleton().getEnvironment();
-
+
// if the bind request is not simple then we freak: no strong auth yet
if ( ! req.isSimple() )
{
@@ -73,7 +73,6 @@
// clone the environment first then add the required security settings
String dn = ( emptyDn ? "" : req.getName() );
-
byte[] creds = req.getCredentials();
Hashtable cloned = ( Hashtable ) env.clone();
@@ -81,7 +80,14 @@
cloned.put( Context.SECURITY_CREDENTIALS, creds );
cloned.put( Context.SECURITY_AUTHENTICATION, "simple" );
- Control[] connCtls = ( Control[] ) req.getControls().values().toArray( EMPTY );
+ if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
+ {
+ cloned.put( Context.REFERRAL, "ignore" );
+ }
+ else
+ {
+ cloned.put( Context.REFERRAL, "throw" );
+ }
try
{
@@ -94,10 +100,12 @@
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( cloned );
}
else
{
+ Control[] connCtls = ( Control[] ) req.getControls().values().toArray( EMPTY );
ctx = new InitialLdapContext( cloned, connCtls );
}
}
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java Mon Jan 9 10:25:55 2006
@@ -17,12 +17,15 @@
package org.apache.ldap.server.protocol.support;
+import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;
import org.apache.ldap.common.exception.LdapException;
import org.apache.ldap.common.message.CompareRequest;
+import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.name.LdapName;
import org.apache.ldap.common.util.ExceptionUtils;
@@ -44,7 +47,9 @@
public class CompareHandler implements MessageHandler
{
private static final Logger log = LoggerFactory.getLogger( CompareHandler.class );
+ private static Control[] EMPTY_CONTROLS = new Control[0];
+
public void messageReceived( IoSession session, Object request )
{
CompareRequest req = ( CompareRequest ) request;
@@ -54,8 +59,17 @@
{
LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
+ if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
+ {
+ newCtx.addToEnvironment( Context.REFERRAL, "ignore" );
+ }
+ else
+ {
+ newCtx.addToEnvironment( Context.REFERRAL, "throw" );
+ }
+ newCtx.setRequestControls( ( Control[] ) req.getControls().values().toArray( EMPTY_CONTROLS ) );
+
LdapName name = new LdapName( req.getName() );
-
if ( newCtx.compare( name, req.getAttributeId(), req.getAssertionValue() ) )
{
result.setResultCode( ResultCodeEnum.COMPARETRUE );
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java Mon Jan 9 10:25:55 2006
@@ -17,12 +17,15 @@
package org.apache.ldap.server.protocol.support;
+import javax.naming.Context;
import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
import org.apache.ldap.common.exception.LdapException;
+import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.DeleteRequest;
import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.util.ExceptionUtils;
import org.apache.ldap.server.protocol.SessionRegistry;
@@ -42,7 +45,9 @@
public class DeleteHandler implements MessageHandler
{
private static final Logger log = LoggerFactory.getLogger( DeleteHandler.class );
+ private static Control[] EMPTY_CONTROLS = new Control[0];
+
public void messageReceived( IoSession session, Object request )
{
DeleteRequest req = ( DeleteRequest ) request;
@@ -50,7 +55,16 @@
try
{
- DirContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "ignore" );
+ }
+ else
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "throw" );
+ }
+ ctx.setRequestControls( ( Control[] ) req.getControls().values().toArray( EMPTY_CONTROLS ) );
ctx.destroySubcontext( req.getName() );
}
catch( NamingException e )
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java Mon Jan 9 10:25:55 2006
@@ -92,8 +92,7 @@
{
try
{
- handler.handleExtendedOperation( session,
- SessionRegistry.getSingleton(), req );
+ handler.handleExtendedOperation( session, SessionRegistry.getSingleton(), req );
}
catch( Exception e )
{
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java Mon Jan 9 10:25:55 2006
@@ -17,11 +17,14 @@
package org.apache.ldap.server.protocol.support;
+import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;
import org.apache.ldap.common.exception.LdapException;
+import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.ModifyDnRequest;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.name.LdapName;
@@ -44,6 +47,8 @@
public class ModifyDnHandler implements MessageHandler
{
private static final Logger LOG = LoggerFactory.getLogger( ModifyDnHandler.class );
+ private static Control[] EMPTY_CONTROLS = new Control[0];
+
public void messageReceived( IoSession session, Object request )
{
@@ -64,6 +69,15 @@
try
{
LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "ignore" );
+ }
+ else
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "throw" );
+ }
+ ctx.setRequestControls( ( Control[] ) req.getControls().values().toArray( EMPTY_CONTROLS ) );
String deleteRDN = String.valueOf( req.getDeleteOldRdn() );
ctx.addToEnvironment( "java.naming.ldap.deleteRDN", deleteRDN );
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java Mon Jan 9 10:25:55 2006
@@ -17,12 +17,15 @@
package org.apache.ldap.server.protocol.support;
+import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.LdapContext;
import org.apache.ldap.common.exception.LdapException;
+import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.ModifyRequest;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.util.ExceptionUtils;
@@ -44,6 +47,7 @@
{
private static final Logger LOG = LoggerFactory.getLogger( ModifyHandler.class );
private static final ModificationItem[] EMPTY = new ModificationItem[0];
+ private static Control[] EMPTY_CONTROLS = new Control[0];
public void messageReceived( IoSession session, Object request )
@@ -54,6 +58,15 @@
try
{
LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "ignore" );
+ }
+ else
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "throw" );
+ }
+ ctx.setRequestControls( ( Control[] ) req.getControls().values().toArray( EMPTY_CONTROLS ) );
Object[] mods = req.getModificationItems().toArray( EMPTY );
ctx.modifyAttributes( req.getName(), ( ModificationItem[] ) mods );
}
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java Mon Jan 9 10:25:55 2006
@@ -16,8 +16,6 @@
package org.apache.ldap.server.protocol.support;
-import java.util.Iterator;
-
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.event.NamespaceChangeListener;
@@ -30,7 +28,6 @@
import org.apache.ldap.common.exception.OperationAbandonedException;
import org.apache.ldap.common.message.AbandonListener;
import org.apache.ldap.common.message.AbandonableRequest;
-import org.apache.ldap.common.message.Control;
import org.apache.ldap.common.message.EntryChangeControl;
import org.apache.ldap.common.message.LdapResult;
import org.apache.ldap.common.message.PersistentSearchControl;
@@ -75,7 +72,7 @@
this.req = req;
req.addAbandonListener( this );
this.ctx = ctx;
- this.control = getPersistentSearchControl( req );
+ this.control = ( PersistentSearchControl ) req.getControls().get( PersistentSearchControl.CONTROL_OID );
}
@@ -246,28 +243,6 @@
}
session.write( respEntry );
- }
-
-
- /**
- * Searches for and returns the PersistentSearchControl in the request if present.
- *
- * @param req the request searched
- * @return the psearch control or null if one does not exist for this req
- */
- static PersistentSearchControl getPersistentSearchControl( SearchRequest req )
- {
- Iterator list = req.getControls().values().iterator();
- while ( list.hasNext() )
- {
- Control control = ( Control ) list.next();
- if ( control.getID().equals( "2.16.840.1.113730.3.4.3" ) )
- {
- return ( PersistentSearchControl ) control;
- }
- }
-
- return null;
}
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java Mon Jan 9 10:25:55 2006
@@ -21,6 +21,7 @@
import java.util.HashSet;
import java.util.Iterator;
+import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.SearchControls;
@@ -32,6 +33,7 @@
import org.apache.ldap.common.filter.PresenceNode;
import org.apache.ldap.common.message.AbandonListener;
import org.apache.ldap.common.message.LdapResult;
+import org.apache.ldap.common.message.ManageDsaITControl;
import org.apache.ldap.common.message.PersistentSearchControl;
import org.apache.ldap.common.message.Response;
import org.apache.ldap.common.message.ResultCodeEnum;
@@ -164,6 +166,14 @@
}
}
ctx.addToEnvironment( DEREFALIASES_KEY, req.getDerefAliases().getName() );
+ if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "ignore" );
+ }
+ else
+ {
+ ctx.addToEnvironment( Context.REFERRAL, "throw" );
+ }
// ===============================================================
// Handle annonymous binds
@@ -187,7 +197,8 @@
// Handle psearch differently
// ===============================================================
- PersistentSearchControl psearchControl = PersistentSearchListener.getPersistentSearchControl( req );
+ PersistentSearchControl psearchControl = ( PersistentSearchControl )
+ req.getControls().get( PersistentSearchControl.CONTROL_OID );
if ( psearchControl != null )
{
// there are no limits for psearch processing
Modified: directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/UnbindHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/UnbindHandler.java?rev=367353&r1=367352&r2=367353&view=diff
==============================================================================
--- directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/UnbindHandler.java (original)
+++ directory/trunks/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/UnbindHandler.java Mon Jan 9 10:25:55 2006
@@ -24,6 +24,9 @@
import org.apache.mina.common.IoSession;
import org.apache.mina.handler.demux.MessageHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* A no reply protocol handler implementation for LDAP {@link
@@ -34,6 +37,9 @@
*/
public class UnbindHandler implements MessageHandler
{
+ private static final Logger log = LoggerFactory.getLogger( UnbindHandler.class );
+
+
public void messageReceived( IoSession session, Object request )
{
SessionRegistry registry = SessionRegistry.getSingleton();
@@ -41,20 +47,16 @@
try
{
LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, false );
-
if ( ctx != null )
{
ctx.close();
}
-
registry.terminateSession( session );
-
registry.remove( session );
}
catch ( NamingException e )
{
- // @todo not much we can do here but monitoring would be good
- e.printStackTrace();
+ log.error( "failed to unbind session properly", e );
}
}
}