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 2005/10/31 01:46:11 UTC
svn commit: r329678 - in
/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap:
./ codec/ codec/grammar/ pojo/ pojo/filters/
Author: elecharny
Date: Sun Oct 30 16:45:53 2005
New Revision: 329678
URL: http://svn.apache.org/viewcvs?rev=329678&view=rev
Log:
- No more need of OctetString. All values are either String or byte[]
- Fixed TwixTransformer to accept byte[] and String attributes value
- Changed the test accordingly
- Added the binaries tests
- Changed the TwixDecoder constructor, and added a call to the binary initialization
- Changed all the grammars that store Values
Modified:
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixProvider.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SaslCredentials.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java
directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java Sun Oct 30 16:45:53 2005
@@ -2,6 +2,7 @@
import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.Hashtable;
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1.codec.stateful.DecoderCallback;
@@ -14,6 +15,7 @@
import org.apache.ldap.common.message.spi.Provider;
import org.apache.ldap.common.message.spi.ProviderDecoder;
import org.apache.ldap.common.message.spi.ProviderException;
+import org.apache.ldap.common.schema.SchemaUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,15 +35,17 @@
/** The callback to call when the decoding is done */
private DecoderCallback decoderCallback;
+ private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
+
/**
* Creates an instance of a Twix Decoder implementation.
*
* @param provider the owning provider.
*/
- public TwixDecoder( Provider provider )
+ public TwixDecoder( Provider provider, Hashtable env )
{
this.provider = provider;
- ldapMessageContainer = new LdapMessageContainer();
+ ldapMessageContainer = new LdapMessageContainer( SchemaUtils.initBinaries( env, BINARY_KEY ) );
ldapDecoder = new LdapDecoder();
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixProvider.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixProvider.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixProvider.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixProvider.java Sun Oct 30 16:45:53 2005
@@ -87,7 +87,7 @@
*/
public ProviderDecoder getDecoder( Hashtable env ) throws ProviderException
{
- return new TwixDecoder( this );
+ return new TwixDecoder( this, env );
}
/**
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java Sun Oct 30 16:45:53 2005
@@ -70,7 +70,6 @@
import org.apache.asn1new.ldap.pojo.filters.PresentFilter;
import org.apache.asn1new.ldap.pojo.filters.SubstringFilter;
import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.ldap.common.filter.AbstractExprNode;
import org.apache.ldap.common.filter.BranchNode;
import org.apache.ldap.common.filter.ExprNode;
@@ -210,12 +209,12 @@
if ( authentication instanceof SimpleAuthentication)
{
snickersMessage.setSimple( true );
- snickersMessage.setCredentials( ( (SimpleAuthentication)authentication).getSimple().getValue() );
+ snickersMessage.setCredentials( ( (SimpleAuthentication)authentication).getSimple() );
}
else
{
snickersMessage.setSimple( false );
- snickersMessage.setCredentials( ( (SaslCredentials)authentication).getCredentials().getValue() );
+ snickersMessage.setCredentials( ( (SaslCredentials)authentication).getCredentials() );
snickersMessage.setSaslMechanism( ( (SaslCredentials)authentication).getMechanism() );
}
@@ -240,7 +239,14 @@
snickersMessage.setAttributeId( compareRequest.getAttributeDesc() );
// Twix : OctetString assertionValue -> Snickers : byte[] attrVal
- snickersMessage.setAssertionValue( compareRequest.getAssertionValue().getValue() );
+ if ( compareRequest.getAssertionValue() instanceof String )
+ {
+ snickersMessage.setAssertionValue( (String)compareRequest.getAssertionValue() );
+ }
+ else
+ {
+ snickersMessage.setAssertionValue( (byte[])compareRequest.getAssertionValue() );
+ }
return snickersMessage;
}
@@ -277,7 +283,7 @@
snickersMessage.setOid( extendedRequest.getRequestName() );
// Twix : OctetString requestValue -> Snickers : byte [] payload
- snickersMessage.setPayload( extendedRequest.getRequestValue().getValue() );
+ snickersMessage.setPayload( extendedRequest.getRequestValue() );
return snickersMessage;
}
@@ -818,7 +824,7 @@
if ( serverSaslCreds != null )
{
- bindResponse.setServerSaslCreds( new OctetString( serverSaslCreds ) );
+ bindResponse.setServerSaslCreds( serverSaslCreds );
}
// Transform the ldapResult
@@ -886,8 +892,8 @@
extendedResponse.setResponseName( null );
}
- // Snickers : byte [] value -> Twix : OctetString response
- extendedResponse.setResponse( new OctetString( snickersExtendedResponse.getResponse() ) );
+ // Snickers : byte [] value -> Twix : Object response
+ extendedResponse.setResponse( snickersExtendedResponse.getResponse() );
// Transform the ldapResult
extendedResponse.setLdapResult( transformLdapResult( (LdapResultImpl)snickersExtendedResponse.getLdapResult() ) );
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java Sun Oct 30 16:45:53 2005
@@ -16,6 +16,9 @@
*/
package org.apache.asn1new.ldap.codec;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.asn1new.ber.AbstractContainer;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.IGrammar;
@@ -45,6 +48,7 @@
import org.apache.asn1new.ldap.codec.grammar.SearchResultReferenceGrammar;
import org.apache.asn1new.ldap.codec.grammar.UnBindRequestGrammar;
import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.apache.asn1new.util.StringUtils;
/**
@@ -61,6 +65,9 @@
/** The ldap message */
private LdapMessage ldapMessage;
+ /** A HashSet which contaons the binary attributes */
+ private Set binaries;
+
//~ Constructors -------------------------------------------------------------------------------
/**
@@ -69,6 +76,15 @@
*/
public LdapMessageContainer()
{
+ this( new HashSet() );
+ }
+
+ /**
+ * Creates a new LdapMessageContainer object.
+ * We will store ten grammars, it's enough ...
+ */
+ public LdapMessageContainer( Set binaries )
+ {
super( );
currentGrammar = 0;
grammars = new IGrammar[LdapStatesEnum.NB_GRAMMARS];
@@ -104,6 +120,8 @@
grammarStack[currentGrammar] = grammars[LdapStatesEnum.LDAP_MESSAGE_GRAMMAR];
states = LdapStatesEnum.getInstance();
+
+ this.binaries = binaries;
}
//~ Methods ------------------------------------------------------------------------------------
@@ -132,5 +150,13 @@
super.clean();
ldapMessage = null;
+ }
+
+ /**
+ * @return Returns true if the attribute is binary.
+ */
+ public boolean isBinary( String id )
+ {
+ return binaries.contains( StringUtils.lowerCase( StringUtils.trim( id ) ) );
}
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java Sun Oct 30 16:45:53 2005
@@ -26,7 +26,6 @@
import org.apache.asn1new.ber.grammar.IGrammar;
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.ber.tlv.UniversalTag;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
@@ -330,21 +329,34 @@
ldapMessageContainer.getCurrentTLV();
// Store the value. It can't be null
- OctetString value = OctetString.EMPTY_STRING;
+ Object value = null;
if ( tlv.getLength().getLength() == 0 )
{
- addRequest.addAttributeValue( value );
+ addRequest.addAttributeValue( "" );
}
else
{
- value = new OctetString( tlv.getValue().getData() );
+ if (ldapMessageContainer.isBinary( addRequest.getCurrentAttributeType() ) )
+ {
+ value = tlv.getValue().getData();
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Adding value " + StringUtils.dumpBytes( (byte[])value ) );
+ }
+ }
+ else
+ {
+ value = StringUtils.toUtf8( tlv.getValue().getData() );
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Adding value " + value );
+ }
+ }
+
addRequest.addAttributeValue( value );
- }
-
- if ( log.isDebugEnabled() )
- {
- log.debug( "Adding value " + value );
}
}
} );
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java Sun Oct 30 16:45:53 2005
@@ -30,7 +30,7 @@
import org.apache.asn1new.util.IntegerDecoder;
import org.apache.asn1new.util.IntegerDecoderException;
import org.apache.asn1new.util.StringUtils;
-import org.apache.asn1new.primitives.OctetString;
+//import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.codec.primitives.LdapDN;
@@ -267,11 +267,11 @@
// We have to handle the special case of a 0 length simple
if (tlv.getLength().getLength() == 0)
{
- authentication.setSimple( OctetString.EMPTY_STRING );
+ authentication.setSimple( new byte[]{} );
}
else
{
- authentication.setSimple( new OctetString( tlv.getValue().getData() ) );
+ authentication.setSimple( tlv.getValue().getData() );
}
if ( log.isDebugEnabled() )
@@ -407,11 +407,11 @@
// We have to handle the special case of a 0 length credentials
if (tlv.getLength().getLength() == 0)
{
- credentials.setCredentials( OctetString.EMPTY_STRING );
+ credentials.setCredentials( new byte[]{} );
}
else
{
- credentials.setCredentials( new OctetString( tlv.getValue().getData() ) );
+ credentials.setCredentials( tlv.getValue().getData() );
}
if ( log.isDebugEnabled() )
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java Sun Oct 30 16:45:53 2005
@@ -24,7 +24,6 @@
import org.apache.asn1new.ber.grammar.IGrammar;
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.ber.tlv.UniversalTag;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.pojo.BindResponse;
@@ -158,11 +157,11 @@
// We have to handle the special case of a 0 length server sasl credentials
if ( tlv.getLength().getLength() == 0 )
{
- bindResponseMessage.setServerSaslCreds( OctetString.EMPTY_STRING );
+ bindResponseMessage.setServerSaslCreds( new byte[]{} );
}
else
{
- bindResponseMessage.setServerSaslCreds( new OctetString( tlv.getValue().getData() ) );
+ bindResponseMessage.setServerSaslCreds( tlv.getValue().getData() );
}
if ( log.isDebugEnabled() )
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java Sun Oct 30 16:45:53 2005
@@ -26,7 +26,6 @@
import org.apache.asn1new.ber.grammar.IGrammar;
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.ber.tlv.UniversalTag;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
@@ -260,21 +259,33 @@
// Get the Value and store it in the CompareRequest
TLV tlv = ldapMessageContainer.getCurrentTLV();
- // We have to handle the special case of a 0 length matched DN
+ // We have to handle the special case of a 0 length value
if ( tlv.getLength().getLength() == 0 )
{
- compareRequest.setAssertionValue( OctetString.EMPTY_STRING );
+ compareRequest.setAssertionValue( "" );
}
else
{
- compareRequest.setAssertionValue( new OctetString( tlv.getValue().getData() ) );
- }
-
- if ( log.isDebugEnabled() )
- {
- log.debug( "Comparing attribute value " + compareRequest.getAssertionValue() );
+ if ( ldapMessageContainer.isBinary( compareRequest.getAttributeDesc() ) )
+ {
+ compareRequest.setAssertionValue( tlv.getValue().getData() );
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Comparing attribute value " + compareRequest.getAssertionValue() );
+ }
+ }
+ else
+ {
+ compareRequest.setAssertionValue( StringUtils.toUtf8( tlv.getValue().getData() ) );
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Comparing attribute value " + StringUtils.dumpBytes( (byte[])compareRequest.getAssertionValue() ) );
+ }
+ }
}
- }
+ }
} );
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java Sun Oct 30 16:45:53 2005
@@ -24,7 +24,6 @@
import org.apache.asn1new.ber.grammar.IGrammar;
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.pojo.ExtendedRequest;
@@ -171,14 +170,14 @@
// Get the Value and store it in the ExtendedRequest
TLV tlv = ldapMessageContainer.getCurrentTLV();
- // We have to handle the special case of a 0 length matched OID
+ // We have to handle the special case of a 0 length matched value
if ( tlv.getLength().getLength() == 0 )
{
- extendedRequest.setRequestValue( OctetString.EMPTY_STRING );
+ extendedRequest.setRequestValue( new byte[]{} );
}
else
{
- extendedRequest.setRequestValue( new OctetString( tlv.getValue().getData() ) );
+ extendedRequest.setRequestValue(tlv.getValue().getData() );
}
if ( log.isDebugEnabled() )
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java Sun Oct 30 16:45:53 2005
@@ -25,7 +25,6 @@
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.pojo.ExtendedResponse;
@@ -185,11 +184,11 @@
// We have to handle the special case of a 0 length matched OID
if ( tlv.getLength().getLength() == 0 )
{
- extendedResponse.setResponse( OctetString.EMPTY_STRING );
+ extendedResponse.setResponse( new byte[]{} );
}
else
{
- extendedResponse.setResponse( new OctetString( tlv.getValue().getData() ) );
+ extendedResponse.setResponse( tlv.getValue().getData() );
}
if ( log.isDebugEnabled() )
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java Sun Oct 30 16:45:53 2005
@@ -28,7 +28,6 @@
import org.apache.asn1new.util.BooleanDecoder;
import org.apache.asn1new.util.BooleanDecoderException;
import org.apache.asn1new.util.StringUtils;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.codec.primitives.LdapString;
@@ -485,16 +484,24 @@
TLV tlv = ldapMessageContainer.getCurrentTLV();
// The value can be null.
- OctetString assertionValue = OctetString.EMPTY_STRING;
+ Object assertionValue = "";
if ( tlv.getLength().getLength() != 0 )
{
- assertionValue = new OctetString(tlv.getValue().getData());
+ assertionValue = tlv.getValue().getData();
}
AttributeValueAssertionFilter currentFilter = (AttributeValueAssertionFilter)searchRequest.getCurrentFilter();
AttributeValueAssertion assertion = currentFilter.getAssertion();
- assertion.setAssertionValue(assertionValue);
+
+ if ( ldapMessageContainer.isBinary( assertion.getAttributeDesc() ) )
+ {
+ assertion.setAssertionValue( assertionValue );
+ }
+ else
+ {
+ assertion.setAssertionValue( StringUtils.toUtf8( (byte[])assertionValue ) );
+ }
// We now have to get back to the nearest filter which is not terminal.
unstackFilters( container );
@@ -1199,7 +1206,7 @@
// Store the value.
ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
- extensibleMatchFilter.setMatchValue(new OctetString( tlv.getValue().getData()));
+ extensibleMatchFilter.setMatchValue( StringUtils.toUtf8( tlv.getValue().getData() ) );
}
});
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java Sun Oct 30 16:45:53 2005
@@ -29,7 +29,6 @@
import org.apache.asn1new.util.BooleanDecoderException;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.pojo.Control;
@@ -299,11 +298,11 @@
// We have to handle the special case of a 0 length value
if ( tlv.getLength().getLength() == 0 )
{
- control.setControlValue( OctetString.EMPTY_STRING );
+ control.setControlValue( new byte[]{} );
}
else
{
- control.setControlValue( new OctetString( value.getData() ) );
+ control.setControlValue( value.getData() );
}
if ( log.isDebugEnabled() )
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java Sun Oct 30 16:45:53 2005
@@ -29,7 +29,6 @@
import org.apache.asn1new.util.IntegerDecoder;
import org.apache.asn1new.util.IntegerDecoderException;
import org.apache.asn1new.util.StringUtils;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.codec.primitives.LdapDN;
@@ -448,7 +447,7 @@
ldapMessageContainer.getCurrentTLV();
// Store the value. It can't be null
- OctetString value = OctetString.EMPTY_STRING;
+ Object value = new byte[]{};
if ( tlv.getLength().getLength() == 0 )
{
@@ -456,7 +455,7 @@
}
else
{
- value = new OctetString( tlv.getValue().getData() );
+ value = tlv.getValue().getData();
modifyRequest.addAttributeValue( value );
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java Sun Oct 30 16:45:53 2005
@@ -26,7 +26,6 @@
import org.apache.asn1new.ber.grammar.IGrammar;
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.ber.tlv.UniversalTag;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
@@ -348,25 +347,37 @@
ldapMessageContainer.getCurrentTLV();
// Store the value
- OctetString value = OctetString.EMPTY_STRING;
+ Object value = null;
if ( tlv.getLength().getLength() == 0 )
{
- searchResultEntry.addAttributeValue( value );
+ searchResultEntry.addAttributeValue( "" );
}
else
{
- value = new OctetString( tlv.getValue().getData() );
+ if (ldapMessageContainer.isBinary( searchResultEntry.getCurrentAttributeValueType() ) )
+ {
+ value = tlv.getValue().getData();
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Attribute value " + StringUtils.dumpBytes( (byte[])value ) );
+ }
+ }
+ else
+ {
+ value = StringUtils.toUtf8( tlv.getValue().getData() );
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Attribute value " + value );
+ }
+ }
+
searchResultEntry.addAttributeValue( value );
}
-
- if ( log.isDebugEnabled() )
- {
- log.debug( "Attribute value : " + value );
- }
}
} );
-
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java Sun Oct 30 16:45:53 2005
@@ -20,7 +20,6 @@
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.primitives.LdapDN;
@@ -143,7 +142,7 @@
*
* @param value The value to be added
*/
- public void addAttributeValue( OctetString value )
+ public void addAttributeValue( Object value )
{
currentAttribute.add( value );
}
@@ -244,9 +243,18 @@
while ( values.hasMoreElements() )
{
- OctetString value = (OctetString)values.next();
+ Object value = values.next();
- localValuesLength += 1 + Length.getNbBytes( value.getNbBytes() ) + value.getNbBytes();
+ if ( value instanceof String )
+ {
+ int valueLength = StringUtils.getBytesUtf8( (String)value ).length;
+ localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength;
+ }
+ else
+ {
+ int valueLength = ( (byte[])value ).length;
+ localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength;
+ }
}
localAttributeLength += 1 + Length.getNbBytes( localValuesLength ) + localValuesLength;
@@ -356,9 +364,16 @@
{
while ( values.hasMoreElements() )
{
- OctetString value = (OctetString)values.next();
+ Object value = values.next();
- Value.encode( buffer, value );
+ if ( value instanceof byte[] )
+ {
+ Value.encode( buffer, (byte[])value );
+ }
+ else
+ {
+ Value.encode( buffer, (String)value );
+ }
}
}
@@ -411,5 +426,13 @@
}
return sb.toString();
+ }
+
+ /**
+ * @return Returns the currentAttribute type.
+ */
+ public String getCurrentAttributeType()
+ {
+ return currentAttribute.getID();
}
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java Sun Oct 30 16:45:53 2005
@@ -16,7 +16,6 @@
*/
package org.apache.asn1new.ldap.pojo;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.primitives.LdapString;
@@ -42,7 +41,7 @@
private LdapString attributeDesc;
/** The assertion value */
- private OctetString assertionValue;
+ private Object assertionValue;
//~ Methods ------------------------------------------------------------------------------------
@@ -51,7 +50,7 @@
*
* @return Returns the assertionValue.
*/
- public OctetString getAssertionValue()
+ public Object getAssertionValue()
{
return assertionValue;
}
@@ -61,7 +60,7 @@
*
* @param assertionValue The assertionValue to set.
*/
- public void setAssertionValue( OctetString assertionValue )
+ public void setAssertionValue( Object assertionValue )
{
this.assertionValue = assertionValue;
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java Sun Oct 30 16:45:53 2005
@@ -21,7 +21,6 @@
import org.apache.asn1.codec.EncoderException;
import org.apache.asn1new.ber.tlv.Length;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
/**
@@ -39,7 +38,7 @@
//~ Instance fields ----------------------------------------------------------------------------
/** The server credentials */
- private OctetString serverSaslCreds;
+ private byte[] serverSaslCreds;
/** The bind response length */
private transient int bindResponseLength;
@@ -69,7 +68,7 @@
/**
* @return Returns the serverSaslCreds.
*/
- public OctetString getServerSaslCreds()
+ public byte[] getServerSaslCreds()
{
return serverSaslCreds;
}
@@ -78,7 +77,7 @@
* Set the server sasl credentials
* @param serverSaslCreds The serverSaslCreds to set.
*/
- public void setServerSaslCreds( OctetString serverSaslCreds )
+ public void setServerSaslCreds( byte[] serverSaslCreds )
{
this.serverSaslCreds = serverSaslCreds;
}
@@ -105,7 +104,7 @@
if (serverSaslCreds != null)
{
- bindResponseLength += 1 + Length.getNbBytes(serverSaslCreds.getNbBytes()) + serverSaslCreds.getNbBytes();
+ bindResponseLength += 1 + Length.getNbBytes( ( (byte[])serverSaslCreds).length ) + ( (byte[])serverSaslCreds).length ;
}
return 1 + Length.getNbBytes( bindResponseLength ) + bindResponseLength;
@@ -142,11 +141,12 @@
if ( serverSaslCreds != null )
{
buffer.put( (byte)LdapConstants.SERVER_SASL_CREDENTIAL_TAG );
- buffer.put( Length.getBytes( serverSaslCreds.getNbBytes() ) );
- if ( serverSaslCreds.getNbBytes() != 0 )
+ buffer.put( Length.getBytes( ( (byte[])serverSaslCreds).length ) );
+
+ if ( ( (byte[])serverSaslCreds).length != 0 )
{
- buffer.put( serverSaslCreds.getValue() );
+ buffer.put( (byte[])serverSaslCreds );
}
}
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java Sun Oct 30 16:45:53 2005
@@ -23,10 +23,10 @@
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.primitives.LdapDN;
import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.util.StringUtils;
/**
@@ -56,7 +56,7 @@
private LdapString attributeDesc;
/** The value to be compared */
- private OctetString assertionValue;
+ private Object assertionValue;
/** The compare request length */
private transient int compareRequestLength;
@@ -111,7 +111,7 @@
*
* @return Returns the assertionValue.
*/
- public OctetString getAssertionValue()
+ public Object getAssertionValue()
{
return assertionValue;
}
@@ -121,7 +121,7 @@
*
* @param assertionValue The assertionValue to set.
*/
- public void setAssertionValue( OctetString assertionValue )
+ public void setAssertionValue( Object assertionValue )
{
this.assertionValue = assertionValue;
}
@@ -175,8 +175,19 @@
// The attribute value assertion
avaLength =
- 1 + Length.getNbBytes( attributeDesc.getNbBytes() ) + attributeDesc.getNbBytes() +
- 1 + Length.getNbBytes( assertionValue.getNbBytes() ) + assertionValue.getNbBytes();
+ 1 + Length.getNbBytes( attributeDesc.getNbBytes() ) + attributeDesc.getNbBytes();
+
+ if ( assertionValue instanceof String )
+ {
+ int assertionValueLength = StringUtils.getBytesUtf8( (String)assertionValue ).length;
+ avaLength +=
+ 1 + Length.getNbBytes( assertionValueLength ) + assertionValueLength;
+ }
+ else
+ {
+ avaLength +=
+ 1 + Length.getNbBytes( ((byte[])assertionValue).length ) + ((byte[])assertionValue).length;
+ }
compareRequestLength += 1 + Length.getNbBytes( avaLength ) + avaLength;
@@ -226,7 +237,14 @@
Value.encode( buffer, attributeDesc.getString() );
// The assertionValue
- Value.encode( buffer, assertionValue );
+ if ( assertionValue instanceof String )
+ {
+ Value.encode( buffer, (String)assertionValue );
+ }
+ else
+ {
+ Value.encode( buffer, (byte[])assertionValue );
+ }
return buffer;
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java Sun Oct 30 16:45:53 2005
@@ -25,7 +25,7 @@
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.ber.tlv.Value;
import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.util.StringUtils;
/**
@@ -44,7 +44,7 @@
private boolean criticality = false;
/** Optionnal control value */
- private OctetString controlValue;
+ private Object controlValue;
/** The control length */
private transient int controlLength;
@@ -80,7 +80,18 @@
*/
public byte[] getControlValue()
{
- return controlValue == null ? EMPTY_BYTES : controlValue.getValue();
+ if ( controlValue == null )
+ {
+ return EMPTY_BYTES;
+ }
+ else if ( controlValue instanceof String )
+ {
+ return StringUtils.getBytesUtf8( (String)controlValue );
+ }
+ else
+ {
+ return (byte[])controlValue;
+ }
}
/**
@@ -88,7 +99,7 @@
*
* @param controlValue The control value to store
*/
- public void setControlValue( OctetString controlValue )
+ public void setControlValue( Object controlValue )
{
this.controlValue = controlValue;
}
@@ -144,7 +155,7 @@
// The control value, if any
if (controlValue != null)
{
- controlLength += 1 + Length.getNbBytes( controlValue.getNbBytes() ) + controlValue.getNbBytes();
+ controlLength += 1 + Length.getNbBytes( getControlValue().length ) + getControlValue().length;
}
return 1 + Length.getNbBytes( controlLength ) + controlLength;
@@ -190,7 +201,7 @@
// The control value, if any
if ( controlValue != null )
{
- Value.encode( buffer, controlValue );
+ Value.encode( buffer, getControlValue() );
}
return buffer;
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java Sun Oct 30 16:45:53 2005
@@ -22,7 +22,6 @@
import org.apache.asn1.codec.EncoderException;
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
@@ -42,7 +41,7 @@
private OID requestName;
/** The value */
- private OctetString requestValue;
+ private byte[] requestValue;
/** The extended request length */
private transient int extendedRequestLength;
@@ -94,7 +93,7 @@
*
* @return Returns the request value.
*/
- public OctetString getRequestValue()
+ public byte[] getRequestValue()
{
return requestValue;
}
@@ -104,7 +103,7 @@
*
* @param requestValue The request value to set.
*/
- public void setRequestValue( OctetString requestValue )
+ public void setRequestValue( byte[] requestValue )
{
this.requestValue = requestValue;
}
@@ -130,7 +129,7 @@
if ( requestValue != null)
{
- extendedRequestLength += 1 + Length.getNbBytes( requestValue.getNbBytes() ) + requestValue.getNbBytes();
+ extendedRequestLength += 1 + Length.getNbBytes( ( (byte[])requestValue).length ) + ( (byte[])requestValue).length;
}
return 1 + Length.getNbBytes( extendedRequestLength ) + extendedRequestLength;
@@ -178,11 +177,12 @@
if ( requestValue != null )
{
buffer.put( (byte)LdapConstants.EXTENDED_REQUEST_VALUE_TAG );
- buffer.put( Length.getBytes( requestValue.getNbBytes() ) );
- if ( requestValue.getNbBytes() != 0 )
+ buffer.put( Length.getBytes( requestValue.length ) );
+
+ if ( requestValue.length != 0 )
{
- buffer.put( requestValue.getValue() );
+ buffer.put( requestValue );
}
}
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java Sun Oct 30 16:45:53 2005
@@ -22,7 +22,7 @@
import org.apache.asn1.codec.EncoderException;
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.primitives.OID;
-import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
@@ -43,7 +43,7 @@
private OID responseName;
/** The response */
- private OctetString response;
+ private Object response;
/** The extended response length */
private transient int extendedResponseLength;
@@ -95,7 +95,7 @@
*
* @return Returns the response.
*/
- public OctetString getResponse()
+ public Object getResponse()
{
return response;
}
@@ -105,7 +105,7 @@
*
* @param response The response to set.
*/
- public void setResponse( OctetString response )
+ public void setResponse( Object response )
{
this.response = response;
}
@@ -140,8 +140,15 @@
if ( response != null )
{
- extendedResponseLength += 1 + Length.getNbBytes( response.getNbBytes() ) +
- response.getNbBytes();
+ if ( response instanceof String )
+ {
+ int responseLength = StringUtils.getBytesUtf8( (String)response ).length;
+ extendedResponseLength += 1 + Length.getNbBytes( responseLength ) + responseLength;
+ }
+ else
+ {
+ extendedResponseLength += 1 + Length.getNbBytes( ( (byte[])response).length ) + ( (byte[])response).length;
+ }
}
}
@@ -192,11 +199,25 @@
if ( response != null )
{
buffer.put( (byte)LdapConstants.EXTENDED_RESPONSE_RESPONSE_TAG );
- buffer.put( Length.getBytes( response.getNbBytes() ) );
- if ( response.getNbBytes() != 0 )
+ if ( response instanceof String )
+ {
+ byte[] responseBytes = StringUtils.getBytesUtf8( (String)response );
+ buffer.put( Length.getBytes( responseBytes.length ) );
+
+ if ( responseBytes.length != 0 )
+ {
+ buffer.put( responseBytes );
+ }
+ }
+ else
{
- buffer.put( response.getValue() );
+ buffer.put( Length.getBytes( ( (byte[])response).length ) );
+
+ if ( ( (byte[])response).length != 0 )
+ {
+ buffer.put( (byte[])response );
+ }
}
}
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java Sun Oct 30 16:45:53 2005
@@ -20,7 +20,6 @@
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.primitives.LdapDN;
@@ -189,7 +188,7 @@
*
* @param value The value to add
*/
- public void addAttributeValue( OctetString value )
+ public void addAttributeValue( Object value )
{
currentAttribute.add( value );
}
@@ -313,9 +312,17 @@
{
while ( values.hasMore() )
{
- OctetString value = (OctetString)values.next();
+ Object value = values.next();
- localValuesLength += 1 + Length.getNbBytes( value.getNbBytes() ) + value.getNbBytes();
+ if ( value instanceof String )
+ {
+ int valueLength = StringUtils.getBytesUtf8( (String)value ).length;
+ localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength;
+ }
+ else
+ {
+ localValuesLength += 1 + Length.getNbBytes( ( (byte[])value).length ) + ( (byte[])value).length;
+ }
}
}
@@ -452,9 +459,16 @@
{
while ( values.hasMoreElements() )
{
- OctetString value = (OctetString)values.next();
+ Object value = values.next();
- Value.encode( buffer, value );
+ if ( value instanceof String )
+ {
+ Value.encode( buffer, (String)value );
+ }
+ else
+ {
+ Value.encode( buffer, (byte[])value );
+ }
}
}
@@ -531,10 +545,17 @@
{
- OctetString attributeValue = ( OctetString ) attribute.get( j );
- sb.append( " Val[" ).append( j ).append( "] : '" )
- .append( attributeValue.toString() ).append( "' \n" );
-
+ Object attributeValue = attribute.get( j );
+ sb.append( " Val[" ).append( j ).append( "] : '" );
+
+ if ( attributeValue instanceof String )
+ {
+ sb.append( StringUtils.toUtf8( (byte[])attributeValue ) ).append( "' \n" );
+ }
+ else
+ {
+ sb.append( attributeValue ).append( "' \n" );
+ }
}
}
catch ( NamingException ne )
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SaslCredentials.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SaslCredentials.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SaslCredentials.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SaslCredentials.java Sun Oct 30 16:45:53 2005
@@ -22,7 +22,6 @@
import org.apache.asn1.codec.EncoderException;
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.primitives.LdapString;
import org.slf4j.Logger;
@@ -50,7 +49,7 @@
private LdapString mechanism;
/** optional credentials of the user */
- private OctetString credentials;
+ private byte[] credentials;
//~ Methods ------------------------------------------------------------------------------------
@@ -59,7 +58,7 @@
*
* @return The credentials
*/
- public OctetString getCredentials()
+ public byte[] getCredentials()
{
return credentials;
}
@@ -69,7 +68,7 @@
*
* @param credentials The credentials
*/
- public void setCredentials( OctetString credentials )
+ public void setCredentials( byte[] credentials )
{
this.credentials = credentials;
}
@@ -115,7 +114,7 @@
if (credentials != null)
{
- saslLength += 1 + Length.getNbBytes( credentials.getNbBytes() ) + credentials.getNbBytes();
+ saslLength += 1 + Length.getNbBytes( credentials.length ) + credentials.length;
}
if ( log.isDebugEnabled() )
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java Sun Oct 30 16:45:53 2005
@@ -20,14 +20,12 @@
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.primitives.LdapDN;
import org.apache.asn1new.ldap.codec.primitives.LdapString;
import org.apache.ldap.common.util.AttributeUtils;
-import java.io.UnsupportedEncodingException;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.util.LinkedList;
@@ -177,7 +175,7 @@
* Add a new value to the current attribute
* @param value
*/
- public void addAttributeValue( OctetString value )
+ public void addAttributeValue( Object value )
{
currentAttributeValue.add( value );
}
@@ -264,26 +262,8 @@
{
String stringValue = (String)value;
- try
- {
- int stringLength = stringValue.getBytes( "UTF-8" ).length;
- localValuesLength += 1 + Length.getNbBytes( stringLength ) + stringLength;
- }
- catch ( UnsupportedEncodingException uee )
- {
- // Should not be possible. The encoding of the Attribute value
- // will check that this value is valid, and if not, it will throw
- // an exception.
- // The allocated length will be set to a null length value
- // in order to avoid an exception thrown while encoding the
- // Attribute value.
- localValuesLength += 1 + 1;
- }
- }
- else if ( value instanceof OctetString )
- {
- OctetString octetStringValue = (OctetString)value;
- localValuesLength += 1 + Length.getNbBytes( octetStringValue.getNbBytes() ) + octetStringValue.getNbBytes();
+ int stringLength = StringUtils.getBytesUtf8( stringValue ).length;
+ localValuesLength += 1 + Length.getNbBytes( stringLength ) + stringLength;
}
else
{
@@ -399,10 +379,6 @@
{
Value.encode( buffer, (String)value );
}
- else if ( value instanceof OctetString )
- {
- Value.encode( buffer, (OctetString)value );
- }
else
{
Value.encode( buffer, (byte[])value );
@@ -452,5 +428,13 @@
}
return sb.toString();
+ }
+
+ /**
+ * @return Returns the currentAttributeValue.
+ */
+ public String getCurrentAttributeValueType()
+ {
+ return currentAttributeValue.getID();
}
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java Sun Oct 30 16:45:53 2005
@@ -21,7 +21,6 @@
import org.apache.asn1.codec.EncoderException;
import org.apache.asn1new.ber.tlv.Length;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,7 +39,7 @@
//~ Instance fields ----------------------------------------------------------------------------
/** The simple authentication password */
- private OctetString simple;
+ private byte[] simple;
//~ Methods ------------------------------------------------------------------------------------
@@ -49,7 +48,7 @@
*
* @return The password
*/
- public OctetString getSimple()
+ public byte[] getSimple()
{
return simple;
}
@@ -59,7 +58,7 @@
*
* @param simple The simple password
*/
- public void setSimple( OctetString simple )
+ public void setSimple( byte[] simple )
{
this.simple = simple;
}
@@ -77,7 +76,9 @@
*/
public int computeLength()
{
- int length = 1 + Length.getNbBytes( simple.getNbBytes() ) + simple.getNbBytes();
+ int length = 1;
+
+ length += Length.getNbBytes( simple.length ) + simple.length;
if ( log.isDebugEnabled() )
{
@@ -109,8 +110,12 @@
{
// The simpleAuthentication Tag
buffer.put( (byte)LdapConstants.BIND_REQUEST_SIMPLE_TAG );
- buffer.put( Length.getBytes( simple.getNbBytes() ) ) ;
- buffer.put( simple.getValue() ) ;
+ buffer.put( Length.getBytes( simple.length ) ) ;
+
+ if ( simple.length != 0 )
+ {
+ buffer.put( simple ) ;
+ }
}
catch ( BufferOverflowException boe )
{
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java Sun Oct 30 16:45:53 2005
@@ -24,6 +24,7 @@
import org.apache.asn1new.ber.tlv.Value;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.pojo.AttributeValueAssertion;
+import org.apache.asn1new.util.StringUtils;
/**
@@ -125,7 +126,18 @@
avaLength = 1 + Length.getNbBytes( attributeDescLength ) + attributeDescLength;
- int assertionValueLength = assertion.getAssertionValue().getNbBytes();
+ Object assertionValue = assertion.getAssertionValue();
+
+ int assertionValueLength = 0;
+
+ if ( assertionValue instanceof String )
+ {
+ assertionValueLength = StringUtils.getBytesUtf8( (String)assertionValue ).length;
+ }
+ else
+ {
+ assertionValueLength = ( (byte[])assertionValue).length;
+ }
avaLength += 1 + Length.getNbBytes( assertionValueLength ) + assertionValueLength;
@@ -189,7 +201,14 @@
Value.encode( buffer, assertion.getAttributeDesc() );
// The assertion desc
- Value.encode( buffer, assertion.getAssertionValue() );
+ if ( assertion.getAssertionValue() instanceof String )
+ {
+ Value.encode( buffer, (String)assertion.getAssertionValue() );
+ }
+ else
+ {
+ Value.encode( buffer, (byte[])assertion.getAssertionValue() );
+ }
return buffer;
}
Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java?rev=329678&r1=329677&r2=329678&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java (original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java Sun Oct 30 16:45:53 2005
@@ -23,9 +23,9 @@
import org.apache.asn1new.ber.tlv.Length;
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.util.StringUtils;
/**
@@ -48,7 +48,7 @@
private LdapString type;
/** Matching rule value */
- private OctetString matchValue;
+ private Object matchValue;
/** The dnAttributes flag */
private boolean dnAttributes;
@@ -117,7 +117,7 @@
*
* @return Returns the matchValue.
*/
- public OctetString getMatchValue()
+ public Object getMatchValue()
{
return matchValue;
}
@@ -127,7 +127,7 @@
*
* @param matchValue The matchValue to set.
*/
- public void setMatchValue( OctetString matchValue )
+ public void setMatchValue( Object matchValue )
{
this.matchValue = matchValue;
}
@@ -201,7 +201,15 @@
if ( matchValue != null )
{
- matchingRuleAssertionLength += 1 + Length.getNbBytes( matchValue.getNbBytes() ) + matchValue.getNbBytes();
+ if ( matchValue instanceof String )
+ {
+ int matchValueLength = StringUtils.getBytesUtf8( (String)matchValue ).length;
+ matchingRuleAssertionLength += 1 + Length.getNbBytes( matchValueLength ) + matchValueLength;
+ }
+ else
+ {
+ matchingRuleAssertionLength += 1 + Length.getNbBytes( ((byte[])matchValue).length ) + ((byte[])matchValue).length;
+ }
}
if ( dnAttributes == true )
@@ -276,8 +284,27 @@
if ( matchValue != null )
{
buffer.put( (byte)LdapConstants.SEARCH_MATCH_VALUE_TAG );
- buffer.put( Length.getBytes( matchValue.getNbBytes() ) );
- buffer.put( matchValue.getValue() );
+
+ if ( matchValue instanceof String )
+ {
+ byte[] matchValueBytes = StringUtils.getBytesUtf8( (String)matchValue );
+ buffer.put( Length.getBytes( matchValueBytes.length ) );
+
+ if ( matchValueBytes.length != 0 )
+ {
+ buffer.put( matchValueBytes );
+ }
+ }
+ else
+ {
+ buffer.put( Length.getBytes( ((byte[])matchValue).length ) );
+
+ if ( ((byte[])matchValue).length != 0 )
+ {
+ buffer.put( (byte[])matchValue );
+ }
+ }
+
}
// The dnAttributes flag, if true only