You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/09/23 02:50:47 UTC
svn commit: r1388934 - in /directory:
apacheds/branches/apacheds-mvbt/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core...
Author: elecharny
Date: Sun Sep 23 00:50:46 2012
New Revision: 1388934
URL: http://svn.apache.org/viewvc?rev=1388934&view=rev
Log:
Used the Strings.EMPTY_STRING instead of a new byte[0] in the code
Modified:
directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java
directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java
directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java
directory/apacheds/branches/apacheds-mvbt/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
directory/apacheds/branches/apacheds-mvbt/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java
directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java
directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java
directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java
directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java
directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java
directory/shared/branches/shared-mvbt/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
directory/shared/branches/shared-mvbt/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
directory/shared/branches/shared-mvbt/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/AddNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/BindNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/CompareNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/DeleteNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ExtendedNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyDnNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/NoticeOfDisconnect.java
directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/SearchNoDResponse.java
directory/shared/branches/shared-mvbt/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparatorTest.java
directory/shared/branches/shared-mvbt/util/src/main/java/org/apache/directory/shared/util/Strings.java
Modified: directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java Sun Sep 23 00:50:46 2012
@@ -24,6 +24,8 @@ import java.io.IOException;
import jdbm.helper.Serializer;
+import org.apache.directory.shared.util.Strings;
+
/**
* A custom String serializer to [de]serialize Strings.
@@ -67,8 +69,6 @@ public class StringSerializer implements
return new String( strchars );
}
- private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
-
/* (non-Javadoc)
* @see jdbm.helper.Serializer#serialize(java.lang.Object)
@@ -77,7 +77,7 @@ public class StringSerializer implements
{
if ( ( ( String ) str ).length() == 0 )
{
- return EMPTY_BYTE_ARRAY;
+ return Strings.EMPTY_BYTES;
}
char[] strchars = ( ( String ) str ).toCharArray();
Modified: directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java Sun Sep 23 00:50:46 2012
@@ -36,6 +36,7 @@ import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
import jdbm.recman.BaseRecordManager;
+import org.apache.directory.shared.util.Strings;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +52,6 @@ import org.slf4j.LoggerFactory;
public class KeyBTreeCursorTest
{
private static final Logger LOG = LoggerFactory.getLogger( KeyBTreeCursorTest.class.getSimpleName() );
- private static final byte[] EMPTY_BYTES = new byte[0];
private static final String TEST_OUTPUT_PATH = "test.output.path";
File dbFile;
@@ -78,16 +78,16 @@ public class KeyBTreeCursorTest
bt = new BTree<String, byte[]>( recman, comparator );
// add some data to it
- bt.insert( "0", EMPTY_BYTES, true );
- bt.insert( "1", EMPTY_BYTES, true );
- bt.insert( "2", EMPTY_BYTES, true );
- bt.insert( "3", EMPTY_BYTES, true );
- bt.insert( "4", EMPTY_BYTES, true );
- bt.insert( "5", EMPTY_BYTES, true );
- bt.insert( "6", EMPTY_BYTES, true );
- bt.insert( "7", EMPTY_BYTES, true );
- bt.insert( "8", EMPTY_BYTES, true );
- bt.insert( "9", EMPTY_BYTES, true );
+ bt.insert( "0", Strings.EMPTY_BYTES, true );
+ bt.insert( "1", Strings.EMPTY_BYTES, true );
+ bt.insert( "2", Strings.EMPTY_BYTES, true );
+ bt.insert( "3", Strings.EMPTY_BYTES, true );
+ bt.insert( "4", Strings.EMPTY_BYTES, true );
+ bt.insert( "5", Strings.EMPTY_BYTES, true );
+ bt.insert( "6", Strings.EMPTY_BYTES, true );
+ bt.insert( "7", Strings.EMPTY_BYTES, true );
+ bt.insert( "8", Strings.EMPTY_BYTES, true );
+ bt.insert( "9", Strings.EMPTY_BYTES, true );
cursor = new KeyBTreeCursor<String>( bt, comparator );
LOG.debug( "Created new KeyBTreeCursor and populated it's btree" );
@@ -106,7 +106,7 @@ public class KeyBTreeCursorTest
new File( fileToDelete + ".lg" ).delete();
dbFile = null;
-
+
cursor.close();
}
Modified: directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java Sun Sep 23 00:50:46 2012
@@ -36,6 +36,7 @@ import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
import jdbm.recman.BaseRecordManager;
+import org.apache.directory.shared.util.Strings;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +52,6 @@ import org.slf4j.LoggerFactory;
public class KeyCursorTest
{
private static final Logger LOG = LoggerFactory.getLogger( KeyCursorTest.class.getSimpleName() );
- private static final byte[] EMPTY_BYTES = new byte[0];
private static final String TEST_OUTPUT_PATH = "test.output.path";
File dbFile;
@@ -78,16 +78,16 @@ public class KeyCursorTest
bt = new BTree<String, byte[]>( recman, comparator );
// add some data to it
- bt.insert( "0", EMPTY_BYTES, true );
- bt.insert( "1", EMPTY_BYTES, true );
- bt.insert( "2", EMPTY_BYTES, true );
- bt.insert( "3", EMPTY_BYTES, true );
- bt.insert( "4", EMPTY_BYTES, true );
- bt.insert( "5", EMPTY_BYTES, true );
- bt.insert( "6", EMPTY_BYTES, true );
- bt.insert( "7", EMPTY_BYTES, true );
- bt.insert( "8", EMPTY_BYTES, true );
- bt.insert( "9", EMPTY_BYTES, true );
+ bt.insert( "0", Strings.EMPTY_BYTES, true );
+ bt.insert( "1", Strings.EMPTY_BYTES, true );
+ bt.insert( "2", Strings.EMPTY_BYTES, true );
+ bt.insert( "3", Strings.EMPTY_BYTES, true );
+ bt.insert( "4", Strings.EMPTY_BYTES, true );
+ bt.insert( "5", Strings.EMPTY_BYTES, true );
+ bt.insert( "6", Strings.EMPTY_BYTES, true );
+ bt.insert( "7", Strings.EMPTY_BYTES, true );
+ bt.insert( "8", Strings.EMPTY_BYTES, true );
+ bt.insert( "9", Strings.EMPTY_BYTES, true );
cursor = new KeyBTreeCursor<String>( bt, comparator );
LOG.debug( "Created new KeyBTreeCursor and populated it's btree" );
@@ -106,7 +106,7 @@ public class KeyCursorTest
new File( fileToDelete + ".lg" ).delete();
dbFile = null;
-
+
cursor.close();
}
Modified: directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/Des3CbcSha1KdEncryption.java Sun Sep 23 00:50:46 2012
@@ -31,12 +31,13 @@ import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec;
import org.apache.directory.server.kerberos.shared.crypto.checksum.ChecksumEngine;
-import org.apache.directory.shared.kerberos.exceptions.KerberosException;
import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
import org.apache.directory.shared.kerberos.components.EncryptedData;
import org.apache.directory.shared.kerberos.components.EncryptionKey;
import org.apache.directory.shared.kerberos.crypto.checksum.ChecksumType;
import org.apache.directory.shared.kerberos.exceptions.ErrorType;
+import org.apache.directory.shared.kerberos.exceptions.KerberosException;
+import org.apache.directory.shared.util.Strings;
/**
@@ -172,7 +173,7 @@ public class Des3CbcSha1KdEncryption ext
int kBytes = 24;
byte[] result = new byte[kBytes];
- byte[] fillingKey = new byte[0];
+ byte[] fillingKey = Strings.EMPTY_BYTES;
int pos = 0;
Modified: directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TransitedEncoding.java Sun Sep 23 00:50:46 2012
@@ -27,9 +27,9 @@ import java.util.Arrays;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.tlv.BerValue;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.shared.asn1.ber.tlv.BerValue;
import org.apache.directory.shared.kerberos.KerberosConstants;
import org.apache.directory.shared.kerberos.codec.types.TransitedEncodingType;
import org.apache.directory.shared.util.Strings;
@@ -80,7 +80,7 @@ public class TransitedEncoding extends A
public TransitedEncoding()
{
trType = TransitedEncodingType.NULL;
- contents = new byte[0];
+ contents = Strings.EMPTY_BYTES;
}
Modified: directory/apacheds/branches/apacheds-mvbt/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java Sun Sep 23 00:50:46 2012
@@ -42,6 +42,7 @@ import javax.security.auth.login.LoginEx
import org.apache.directory.ldap.client.api.Krb5LoginConfiguration;
import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.shared.util.Strings;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
@@ -392,9 +393,9 @@ public class KerberosTestUtils
context.requestConf( true );
context.requestInteg( true );
- context.initSecContext( new byte[0], 0, 0 );
+ context.initSecContext( Strings.EMPTY_BYTES, 0, 0 );
- // byte[] outToken = context.initSecContext( new byte[0], 0, 0 );
+ // byte[] outToken = context.initSecContext( Strings.EMPTY_BYTES, 0, 0 );
// System.out.println(new BASE64Encoder().encode(outToken));
context.dispose();
Modified: directory/apacheds/branches/apacheds-mvbt/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/authentication/AuthenticationService.java Sun Sep 23 00:50:46 2012
@@ -24,6 +24,7 @@ import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.List;
+
import javax.security.auth.kerberos.KerberosKey;
import javax.security.auth.kerberos.KerberosPrincipal;
@@ -68,6 +69,7 @@ import org.apache.directory.shared.kerbe
import org.apache.directory.shared.kerberos.messages.AsRep;
import org.apache.directory.shared.kerberos.messages.EncAsRepPart;
import org.apache.directory.shared.kerberos.messages.Ticket;
+import org.apache.directory.shared.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -301,7 +303,8 @@ public class AuthenticationService
if ( timestamp == null )
{
throw new KerberosException( ErrorType.KDC_ERR_PREAUTH_REQUIRED,
- preparePreAuthenticationError( authContext.getRequest().getKdcReqBody().getEType(), config.getEncryptionTypes() ) );
+ preparePreAuthenticationError( authContext.getRequest().getKdcReqBody().getEType(),
+ config.getEncryptionTypes() ) );
}
if ( !timestamp.getPaTimestamp().isInClockSkew( config.getAllowableClockSkew() ) )
@@ -788,13 +791,14 @@ public class AuthenticationService
* @param encryptionTypes
* @return The error message as bytes.
*/
- private static byte[] preparePreAuthenticationError( List<EncryptionType> clientEncryptionTypes, List<EncryptionType> serverEncryptionTypes )
+ private static byte[] preparePreAuthenticationError( List<EncryptionType> clientEncryptionTypes,
+ List<EncryptionType> serverEncryptionTypes )
{
PaData[] paDataSequence = new PaData[2];
PaData paData = new PaData();
paData.setPaDataType( PaDataType.PA_ENC_TIMESTAMP );
- paData.setPaDataValue( new byte[0] );
+ paData.setPaDataValue( Strings.EMPTY_BYTES );
paDataSequence[0] = paData;
Modified: directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/AbstractSaslServer.java Sun Sep 23 00:50:46 2012
@@ -27,6 +27,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.ldap.LdapSession;
import org.apache.directory.shared.ldap.model.message.BindRequest;
import org.apache.directory.shared.util.StringConstants;
+import org.apache.directory.shared.util.Strings;
/**
@@ -73,7 +74,7 @@ public abstract class AbstractSaslServer
*/
public byte[] wrap( byte[] outgoing, int offset, int len ) throws SaslException
{
- return new byte[0];
+ return Strings.EMPTY_BYTES;
}
Modified: directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java Sun Sep 23 00:50:46 2012
@@ -49,6 +49,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl;
import org.apache.directory.shared.ldap.model.message.LdapResult;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
import org.apache.mina.core.filterchain.IoFilterChain;
import org.apache.mina.filter.ssl.SslFilter;
import org.slf4j.Logger;
@@ -99,7 +100,7 @@ public class StartTlsHandler implements
LdapResult result = res.getLdapResult();
result.setResultCode( ResultCodeEnum.SUCCESS );
res.setResponseName( EXTENSION_OID );
- res.setResponseValue( new byte[0] );
+ res.setResponseValue( Strings.EMPTY_BYTES );
// Send a response.
session.getIoSession().setAttribute( SslFilter.DISABLE_ENCRYPTION_ONCE );
Modified: directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java Sun Sep 23 00:50:46 2012
@@ -23,7 +23,6 @@ package org.apache.directory.server.oper
import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-
import netscape.ldap.LDAPConnection;
import netscape.ldap.LDAPConstraints;
import netscape.ldap.LDAPControl;
@@ -38,6 +37,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException;
import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.util.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -160,8 +160,8 @@ public class BindIT extends AbstractLdap
{
LDAPConnection conn = new LDAPConnection();
LDAPConstraints constraints = new LDAPConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
conn.setConstraints( constraints );
try
Modified: directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java Sun Sep 23 00:50:46 2012
@@ -707,8 +707,8 @@ public class AddIT extends AbstractLdapT
{
LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
LDAPConstraints constraints = new LDAPSearchConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
conn.setConstraints( constraints );
// add success
Modified: directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java Sun Sep 23 00:50:46 2012
@@ -39,6 +39,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.annotations.CreateDS;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.util.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -179,8 +180,8 @@ public class BindIT extends AbstractLdap
{
LDAPConnection conn = new LDAPConnection();
LDAPConstraints constraints = new LDAPConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
conn.setConstraints( constraints );
try
Modified: directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java Sun Sep 23 00:50:46 2012
@@ -50,6 +50,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -159,8 +160,8 @@ public class CompareIT extends AbstractL
{
LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
LDAPConstraints constraints = new LDAPConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
conn.setConstraints( constraints );
// comparison success
Modified: directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/DeleteIT.java Sun Sep 23 00:50:46 2012
@@ -49,6 +49,7 @@ import org.apache.directory.server.core.
import org.apache.directory.shared.ldap.model.exception.LdapContextNotEmptyException;
import org.apache.directory.shared.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -185,8 +186,8 @@ public class DeleteIT extends AbstractLd
{
LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
LDAPConstraints constraints = new LDAPSearchConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
conn.setConstraints( constraints );
// delete success
Modified: directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyDnReferralIT.java Sun Sep 23 00:50:46 2012
@@ -45,6 +45,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -103,196 +104,196 @@ import org.slf4j.LoggerFactory;
})
public class ModifyDnReferralIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
- private static final Logger LOG = LoggerFactory.getLogger( ModifyDnReferralIT.class );
-
-
- /**
- * Tests ModifyDN operation on referral entry with the ManageDsaIT control.
- */
- @Test
- public void testOnReferralWithManageDsaITControl() throws Exception
- {
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPSearchConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- conn.setConstraints( constraints );
-
- // ModifyDN success
- conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints );
- LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
- assertNotNull( entry );
- assertEquals( "uid=ref,ou=users,ou=system", entry.getDN() );
-
- conn.disconnect();
- }
-
-
- /**
- * Tests ModifyDN operation with newSuperior on referral entry with the
- * ManageDsaIT control.
- */
- @Test
- public void testNewSuperiorOnReferralWithManageDsaITControl() throws Exception
- {
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPSearchConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- conn.setConstraints( constraints );
-
- // ModifyDN success
- try
- {
- conn.rename( "uid=elecharny,ou=users,ou=system", "uid=newuser",
- "uid=akarasuluref,ou=users,ou=system", true, constraints );
- }
- catch ( LDAPException le )
- {
- assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, le.getLDAPResultCode() );
- }
-
- conn.disconnect();
- }
-
-
- /**
- * Tests ModifyDN operation on normal and referral entries without the
- * ManageDsaIT control. Referrals are sent back to the client with a
- * non-success result code.
- */
- @Test
- public void testOnReferral() throws Exception
- {
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPConstraints();
- constraints.setReferrals( false );
- conn.setConstraints( constraints );
-
- // referrals failure
- LDAPResponseListener listener = null;
- LDAPResponse response = null;
-
- listener = conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, null, constraints );
- response = listener.getResponse();
- assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
- assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
- assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
- assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-
- conn.disconnect();
- }
-
-
- /**
- * Tests ModifyDN operation on normal and referral entries without the
- * ManageDsaIT control. Referrals are sent back to the client with a
- * non-success result code.
- */
- @Test
- public void testNewSupierorOnReferral() throws Exception
- {
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPConstraints();
- constraints.setReferrals( false );
- conn.setConstraints( constraints );
-
- // referrals failure
- try
- {
- conn.rename( "uid=elecharny,ou=users,ou=system", "uid=ref",
- "uid=akarasuluref,ou=users,ou=system", true, constraints );
- }
- catch ( LDAPException e )
- {
- assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
- }
-
- conn.disconnect();
- }
-
-
- /**
- * Tests ModifyDN operation on normal and referral entries without the
- * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
- * are sent back to the client with a non-success result code.
- */
- @Test
- public void testThrowOnReferralWithJndi() throws Exception
- {
- LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
-
- // ModifyDN referrals failure
- try
- {
- ctx.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref,ou=users,ou=system" );
- fail( "Should never get here due to ModifyDN failure on ReferralException" );
- }
- catch ( ReferralException e )
- {
- // seems JNDI only returns the first referral URL and not all so we test for it
- assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
- }
-
- ctx.close();
- }
-
-
- /**
- * Tests referral handling when an ancestor is a referral.
- */
- @Test
- public void testAncestorReferral() throws Exception
- {
- LOG.debug( "" );
-
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPConstraints();
- conn.setConstraints( constraints );
-
- // referrals failure
- LDAPResponseListener listener = null;
- LDAPResponse response = null;
-
- listener = conn.rename( "ou=Computers,uid=akarasuluref,ou=users,ou=system", "ou=Machines", true, null, constraints );
- response = listener.getResponse();
- assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
- assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
- assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
- assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-
- conn.disconnect();
- }
-
-
- /**
- * Tests referral handling when an ancestor is a referral.
- */
- @Test
- public void testNewSuperiorAncestorReferral() throws Exception
- {
- LOG.debug( "" );
-
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPConstraints();
- conn.setConstraints( constraints );
-
- // referrals failure
- try
- {
- conn.rename( "uid=elecharny,ou=users,ou=system", "ou=Machines",
- "ou=Computers,uid=akarasuluref,ou=users,ou=system", true, constraints );
- fail( "Should never get here to affectsMultipleDSA error result code" );
- }
- catch ( LDAPException e )
- {
- assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
- }
-
- conn.disconnect();
+@Rule
+public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
+private static final Logger LOG = LoggerFactory.getLogger( ModifyDnReferralIT.class );
+
+
+/**
+ * Tests ModifyDN operation on referral entry with the ManageDsaIT control.
+ */
+@Test
+public void testOnReferralWithManageDsaITControl() throws Exception
+{
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPSearchConstraints();
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ conn.setConstraints( constraints );
+
+ // ModifyDN success
+ conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints );
+ LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
+ assertNotNull( entry );
+ assertEquals( "uid=ref,ou=users,ou=system", entry.getDN() );
+
+ conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation with newSuperior on referral entry with the
+ * ManageDsaIT control.
+ */
+@Test
+public void testNewSuperiorOnReferralWithManageDsaITControl() throws Exception
+{
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPSearchConstraints();
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ conn.setConstraints( constraints );
+
+ // ModifyDN success
+ try
+ {
+ conn.rename( "uid=elecharny,ou=users,ou=system", "uid=newuser",
+ "uid=akarasuluref,ou=users,ou=system", true, constraints );
+ }
+ catch ( LDAPException le )
+ {
+ assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, le.getLDAPResultCode() );
}
+
+ conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation on normal and referral entries without the
+ * ManageDsaIT control. Referrals are sent back to the client with a
+ * non-success result code.
+ */
+@Test
+public void testOnReferral() throws Exception
+{
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPConstraints();
+ constraints.setReferrals( false );
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ LDAPResponseListener listener = null;
+ LDAPResponse response = null;
+
+ listener = conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, null, constraints );
+ response = listener.getResponse();
+ assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+ assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+ assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+ assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+ conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation on normal and referral entries without the
+ * ManageDsaIT control. Referrals are sent back to the client with a
+ * non-success result code.
+ */
+@Test
+public void testNewSupierorOnReferral() throws Exception
+{
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPConstraints();
+ constraints.setReferrals( false );
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ try
+ {
+ conn.rename( "uid=elecharny,ou=users,ou=system", "uid=ref",
+ "uid=akarasuluref,ou=users,ou=system", true, constraints );
+ }
+ catch ( LDAPException e )
+ {
+ assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
+ }
+
+ conn.disconnect();
+}
+
+
+/**
+ * Tests ModifyDN operation on normal and referral entries without the
+ * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
+ * are sent back to the client with a non-success result code.
+ */
+@Test
+public void testThrowOnReferralWithJndi() throws Exception
+{
+ LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
+
+ // ModifyDN referrals failure
+ try
+ {
+ ctx.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref,ou=users,ou=system" );
+ fail( "Should never get here due to ModifyDN failure on ReferralException" );
+ }
+ catch ( ReferralException e )
+ {
+ // seems JNDI only returns the first referral URL and not all so we test for it
+ assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
+ }
+
+ ctx.close();
+}
+
+
+/**
+ * Tests referral handling when an ancestor is a referral.
+ */
+@Test
+public void testAncestorReferral() throws Exception
+{
+ LOG.debug( "" );
+
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPConstraints();
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ LDAPResponseListener listener = null;
+ LDAPResponse response = null;
+
+ listener = conn.rename( "ou=Computers,uid=akarasuluref,ou=users,ou=system", "ou=Machines", true, null, constraints );
+ response = listener.getResponse();
+ assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+ assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+ assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+ assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+ conn.disconnect();
+}
+
+
+/**
+ * Tests referral handling when an ancestor is a referral.
+ */
+@Test
+public void testNewSuperiorAncestorReferral() throws Exception
+{
+ LOG.debug( "" );
+
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPConstraints();
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ try
+ {
+ conn.rename( "uid=elecharny,ou=users,ou=system", "ou=Machines",
+ "ou=Computers,uid=akarasuluref,ou=users,ou=system", true, constraints );
+ fail( "Should never get here to affectsMultipleDSA error result code" );
+ }
+ catch ( LDAPException e )
+ {
+ assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
+ }
+
+ conn.disconnect();
+}
}
Modified: directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java (original)
+++ directory/apacheds/branches/apacheds-mvbt/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/ModifyReferralIT.java Sun Sep 23 00:50:46 2012
@@ -48,6 +48,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.server.operations.compare.CompareIT;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -111,119 +112,119 @@ import org.slf4j.LoggerFactory;
})
public class ModifyReferralIT extends AbstractLdapTestUnit
{
- @Rule
- public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
- private static final Logger LOG = LoggerFactory.getLogger( CompareIT.class );
-
-
- /**
- * Tests modify operation on referral entry with the ManageDsaIT control.
- */
- @Test
- public void testOnReferralWithManageDsaITControl() throws Exception
- {
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPConstraints();
- constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
- conn.setConstraints( constraints );
-
- // modify success
- LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
- LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
- conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, constraints );
-
- assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints ) );
-
- conn.disconnect();
- }
-
-
- /**
- * Tests modify operation on referral entries without the
- * ManageDsaIT control. Referrals are sent back to the client with a
- * non-success result code.
- */
- @Test
- public void testOnReferral() throws Exception
- {
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPConstraints();
- constraints.setReferrals( false );
- conn.setConstraints( constraints );
-
- // referrals failure
- // modify success
- LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
- LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
- LDAPResponseListener listener = conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
- LDAPResponse response = listener.getResponse();
-
- assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
- assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
- assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
- assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-
- conn.disconnect();
- }
-
-
- /**
- * Tests modify operation on normal and referral entries without the
- * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
- * are sent back to the client with a non-success result code.
- */
- @Test
- public void testThrowOnReferralWithJndi() throws Exception
+@Rule
+public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
+private static final Logger LOG = LoggerFactory.getLogger( CompareIT.class );
+
+
+/**
+ * Tests modify operation on referral entry with the ManageDsaIT control.
+ */
+@Test
+public void testOnReferralWithManageDsaITControl() throws Exception
+{
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPConstraints();
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
+ conn.setConstraints( constraints );
+
+ // modify success
+ LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
+ LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+ conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, constraints );
+
+ assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints ) );
+
+ conn.disconnect();
+}
+
+
+/**
+ * Tests modify operation on referral entries without the
+ * ManageDsaIT control. Referrals are sent back to the client with a
+ * non-success result code.
+ */
+@Test
+public void testOnReferral() throws Exception
+{
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPConstraints();
+ constraints.setReferrals( false );
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ // modify success
+ LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
+ LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+ LDAPResponseListener listener = conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
+ LDAPResponse response = listener.getResponse();
+
+ assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+ assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+ assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+ assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+ conn.disconnect();
+}
+
+
+/**
+ * Tests modify operation on normal and referral entries without the
+ * ManageDsaIT control using JNDI instead of the Netscape API. Referrals
+ * are sent back to the client with a non-success result code.
+ */
+@Test
+public void testThrowOnReferralWithJndi() throws Exception
+{
+ LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
+
+ // modify failure
+ Attribute attr = new BasicAttribute( "description", "referral to akarasulu" );
+ ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+
+ try
{
- LdapContext ctx = getWiredContextThrowOnRefferal( getLdapServer() );
-
- // modify failure
- Attribute attr = new BasicAttribute( "description", "referral to akarasulu" );
- ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
-
- try
- {
- ctx.modifyAttributes( "uid=akarasuluref,ou=users,ou=system", new ModificationItem[]
- { mod } );
- }
- catch ( ReferralException e )
- {
- // seems JNDI only returns the first referral URL and not all so we test for it
- assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
- }
-
- ctx.close();
+ ctx.modifyAttributes( "uid=akarasuluref,ou=users,ou=system", new ModificationItem[]
+ { mod } );
}
-
-
- /**
- * Tests referral handling when an ancestor is a referral.
- */
- @Test
- public void testAncestorReferral() throws Exception
+ catch ( ReferralException e )
{
- LOG.debug( "" );
-
- LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
- LDAPConstraints constraints = new LDAPConstraints();
- conn.setConstraints( constraints );
-
- // referrals failure
- LDAPAttribute attribute = new LDAPAttribute( "ou", "Machines" );
- LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
- LDAPResponseListener listener = null;
- LDAPResponse response = null;
-
- listener = conn.modify( "ou=Computers,uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
- response = listener.getResponse();
- assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
- assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
- assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
- assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
-
- conn.disconnect();
+ // seems JNDI only returns the first referral URL and not all so we test for it
+ assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() );
}
+
+ ctx.close();
+}
+
+
+/**
+ * Tests referral handling when an ancestor is a referral.
+ */
+@Test
+public void testAncestorReferral() throws Exception
+{
+ LOG.debug( "" );
+
+ LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
+ LDAPConstraints constraints = new LDAPConstraints();
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ LDAPAttribute attribute = new LDAPAttribute( "ou", "Machines" );
+ LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+ LDAPResponseListener listener = null;
+ LDAPResponse response = null;
+
+ listener = conn.modify( "ou=Computers,uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
+ response = listener.getResponse();
+ assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
+
+ assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
+ assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
+ assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+
+ conn.disconnect();
+}
}
Modified: directory/shared/branches/shared-mvbt/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java (original)
+++ directory/shared/branches/shared-mvbt/asn1/api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java Sun Sep 23 00:50:46 2012
@@ -37,8 +37,7 @@ public final class Asn1StringUtils
/**
* The empty byte[]
*/
- public static final byte[] EMPTY_BYTES = new byte[]
- {};
+ public static final byte[] EMPTY_BYTES = new byte[0];
/**
@@ -89,7 +88,7 @@ public final class Asn1StringUtils
{
if ( string == null )
{
- return new byte[0];
+ return EMPTY_BYTES;
}
try
Modified: directory/shared/branches/shared-mvbt/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Sun Sep 23 00:50:46 2012
@@ -355,7 +355,7 @@ public class LdapNetworkConnection exten
{
super();
this.config = config;
-
+
if ( config.getBinaryAttributeDetector() == null )
{
config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
@@ -641,8 +641,9 @@ public class LdapNetworkConnection exten
// Store the container into the session if we don't have one
LdapMessageContainer<MessageDecorator<? extends Message>> container =
- (LdapMessageContainer<MessageDecorator<? extends Message>>)ldapSession.getAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR );
-
+ ( LdapMessageContainer<MessageDecorator<? extends Message>> ) ldapSession
+ .getAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR );
+
if ( container == null )
{
ldapSession.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR,
@@ -1134,6 +1135,8 @@ public class LdapNetworkConnection exten
{
return createBindRequest( name.getName(), credentials, null, ( Control[] ) null );
}
+
+
/**
* {@inheritDoc}
*/
@@ -3231,6 +3234,8 @@ public class LdapNetworkConnection exten
{
loadSchema( new DefaultSchemaLoader( this ) );
}
+
+
/**
* loads schema using the specified schema loader
*
@@ -3253,7 +3258,7 @@ public class LdapNetworkConnection exten
}
schemaManager = tmp;
-
+
// Change the container's BinaryDetector
ldapSession.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR,
new LdapMessageContainer<MessageDecorator<? extends Message>>( codec,
@@ -3674,7 +3679,7 @@ public class LdapNetworkConnection exten
// deal with it immediately.
if ( sc.hasInitialResponse() )
{
- byte[] challengeResponse = sc.evaluateChallenge( new byte[0] );
+ byte[] challengeResponse = sc.evaluateChallenge( Strings.EMPTY_BYTES );
// Stores the challenge's response, and send it to the server
bindRequest.setCredentials( challengeResponse );
Modified: directory/shared/branches/shared-mvbt/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/codec/core/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultDoneTest.java Sun Sep 23 00:50:46 2012
@@ -226,7 +226,7 @@ public class SearchResultDoneTest extend
CodecControl<Control> control = ( org.apache.directory.shared.ldap.codec.api.CodecControl<Control> ) controls
.get( "2.16.840.1.113730.3.4.2" );
assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
- assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
+ assertEquals( "", Strings.dumpBytes( control.getValue() ) );
// Check the encoding
try
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/AddNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/AddNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/AddNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/AddNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.AddResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -35,9 +36,6 @@ public class AddNoDResponse extends AddR
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final AddNoDResponse UNAVAILABLE = new AddNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -88,7 +86,7 @@ public class AddNoDResponse extends AddR
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/BindNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/BindNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/BindNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/BindNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.BindResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -35,9 +36,6 @@ public class BindNoDResponse extends Bin
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final BindNoDResponse UNAVAILABLE = new BindNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -88,7 +86,7 @@ public class BindNoDResponse extends Bin
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/CompareNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/CompareNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/CompareNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/CompareNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.CompareResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -35,9 +36,6 @@ public class CompareNoDResponse extends
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final CompareNoDResponse UNAVAILABLE = new CompareNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -82,13 +80,13 @@ public class CompareNoDResponse extends
// ExtendedResponse Interface Method Implementations
// ------------------------------------------------------------------------
/**
- * Gets the reponse OID specific encoded response values.
+ * Gets the response OID specific encoded response values.
*
* @return the response specific encoded response values.
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/DeleteNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/DeleteNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/DeleteNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/DeleteNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.DeleteResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -35,9 +36,6 @@ public class DeleteNoDResponse extends D
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final DeleteNoDResponse UNAVAILABLE = new DeleteNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -88,7 +86,7 @@ public class DeleteNoDResponse extends D
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ExtendedNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ExtendedNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ExtendedNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ExtendedNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -38,9 +39,6 @@ public class ExtendedNoDResponse extends
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final ExtendedNoDResponse UNAVAILABLE = new ExtendedNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -91,7 +89,7 @@ public class ExtendedNoDResponse extends
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyDnNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyDnNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyDnNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyDnNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.ModifyDnResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -35,9 +36,6 @@ public class ModifyDnNoDResponse extends
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final ModifyDnNoDResponse UNAVAILABLE = new ModifyDnNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -88,7 +86,7 @@ public class ModifyDnNoDResponse extends
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/ModifyNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.ModifyResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -35,9 +36,6 @@ public class ModifyNoDResponse extends M
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final ModifyNoDResponse UNAVAILABLE = new ModifyNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -88,7 +86,7 @@ public class ModifyNoDResponse extends M
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/NoticeOfDisconnect.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/NoticeOfDisconnect.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/NoticeOfDisconnect.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/NoticeOfDisconnect.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.util.Strings;
/**
@@ -109,9 +110,6 @@ public final class NoticeOfDisconnect ex
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = "1.3.6.1.4.1.1466.20036";
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final NoticeOfDisconnect UNAVAILABLE = new NoticeOfDisconnect( ResultCodeEnum.UNAVAILABLE );
@@ -163,7 +161,7 @@ public final class NoticeOfDisconnect ex
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/SearchNoDResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/SearchNoDResponse.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/SearchNoDResponse.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/extended/SearchNoDResponse.java Sun Sep 23 00:50:46 2012
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.model.message.SearchResultDoneImpl;
+import org.apache.directory.shared.util.Strings;
/**
@@ -35,9 +36,6 @@ public class SearchNoDResponse extends S
/** The OID of the NotiveOfDisconnect extended operation. */
public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID;
- /** The empty response */
- private static final byte[] EMPTY_RESPONSE = new byte[0];
-
/** The single instance with unavailable result code. */
public static final SearchNoDResponse UNAVAILABLE = new SearchNoDResponse( ResultCodeEnum.UNAVAILABLE );
@@ -88,7 +86,7 @@ public class SearchNoDResponse extends S
*/
public byte[] getResponse()
{
- return EMPTY_RESPONSE;
+ return Strings.EMPTY_BYTES;
}
Modified: directory/shared/branches/shared-mvbt/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparatorTest.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparatorTest.java (original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/schema/comparators/ByteArrayComparatorTest.java Sun Sep 23 00:50:46 2012
@@ -22,12 +22,13 @@ package org.apache.directory.shared.ldap
import static org.junit.Assert.assertEquals;
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-import org.apache.directory.shared.ldap.model.schema.comparators.ByteArrayComparator;
+import org.apache.directory.shared.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
/**
* Testcase to test the ByteArrayComparator.
@@ -48,21 +49,21 @@ public class ByteArrayComparatorTest
@Test
public void testB2Null()
{
- assertEquals( 1, new ByteArrayComparator( null ).compare( new byte[0], null ) );
+ assertEquals( 1, new ByteArrayComparator( null ).compare( Strings.EMPTY_BYTES, null ) );
}
@Test
public void testB1Null()
{
- assertEquals( -1, new ByteArrayComparator( null ).compare( null, new byte[0] ) );
+ assertEquals( -1, new ByteArrayComparator( null ).compare( null, Strings.EMPTY_BYTES ) );
}
@Test
public void testBothEmpty()
{
- assertEquals( 0, new ByteArrayComparator( null ).compare( new byte[0], new byte[0] ) );
+ assertEquals( 0, new ByteArrayComparator( null ).compare( Strings.EMPTY_BYTES, Strings.EMPTY_BYTES ) );
}
Modified: directory/shared/branches/shared-mvbt/util/src/main/java/org/apache/directory/shared/util/Strings.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/util/src/main/java/org/apache/directory/shared/util/Strings.java?rev=1388934&r1=1388933&r2=1388934&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/util/src/main/java/org/apache/directory/shared/util/Strings.java (original)
+++ directory/shared/branches/shared-mvbt/util/src/main/java/org/apache/directory/shared/util/Strings.java Sun Sep 23 00:50:46 2012
@@ -251,6 +251,9 @@ public final class Strings
0, 0, 0, 0, 0, 0, 0, 0
};
+ /** A empty byte array */
+ public static final byte[] EMPTY_BYTES = new byte[0];
+
/**
* Private constructor
@@ -734,6 +737,47 @@ public final class Strings
}
}
+ private static final byte[] UTF8 = new byte[]
+ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
+ 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,
+ 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40,
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
+ 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
+ 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F };
+
+
+ private static String toStringArray( byte[] bytes ) throws Exception
+ {
+ if ( bytes == null )
+ {
+ return null;
+ }
+
+ if ( bytes.length == 0 )
+ {
+ return "";
+ }
+
+ char[] chars = new char[bytes.length];
+ int pos = 0;
+
+ try
+ {
+ for ( byte b : bytes )
+ {
+ chars[pos++] = ( char ) UTF8[b];
+ }
+ }
+ catch ( ArrayIndexOutOfBoundsException aioobe )
+ {
+ return new String( bytes, "UTF-8" );
+ }
+
+ return new String( chars );
+ }
+
/**
* Return an UTF-8 encoded String
@@ -748,15 +792,30 @@ public final class Strings
return "";
}
+ char[] chars = new char[bytes.length];
+ int pos = 0;
+
try
{
- return new String( bytes, "UTF-8" );
+ for ( byte b : bytes )
+ {
+ chars[pos++] = ( char ) UTF8[b];
+ }
}
- catch ( UnsupportedEncodingException uee )
+ catch ( ArrayIndexOutOfBoundsException aioobe )
{
- // if this happens something is really strange
- throw new RuntimeException( uee );
+ try
+ {
+ return new String( bytes, "UTF-8" );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ // if this happens something is really strange
+ throw new RuntimeException( uee );
+ }
}
+
+ return new String( chars );
}
@@ -1551,7 +1610,7 @@ public final class Strings
{
if ( string == null )
{
- return new byte[0];
+ return EMPTY_BYTES;
}
try