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 2006/12/13 18:15:33 UTC
svn commit: r486748 - in /directory/trunks:
apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/
shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/
shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ shared/ld...
Author: elecharny
Date: Wed Dec 13 09:15:29 2006
New Revision: 486748
URL: http://svn.apache.org/viewvc?view=rev&rev=486748
Log:
Fixed a nasty bug in DN parsing (DIRSERVER-796)
Modified:
directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DNUtils.java
directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java
directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Modified: directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java (original)
+++ directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java Wed Dec 13 09:15:29 2006
@@ -291,7 +291,7 @@
try
{
- pcfg.setSuffix( "ou=test=testing" );
+ pcfg.setSuffix( "ou=test+testing" );
}
catch ( LdapConfigurationException ce )
{
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java Wed Dec 13 09:15:29 2006
@@ -47,434 +47,534 @@
*/
public class AttributeTypeAndValue implements Cloneable, Comparable, Serializable
{
- /**
- * Declares the Serial Version Uid.
- *
- * @see <a
- * href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
- * Declare Serial Version Uid</a>
- */
- private static final long serialVersionUID = 1L;
-
- /** The LoggerFactory used by this class */
- private static Logger log = LoggerFactory.getLogger( AttributeTypeAndValue.class );
-
- /** The Name type */
- private String type;
-
- /** The name value. It can be a String or a byte array */
- private Object value;
-
- /** The user provided atav */
- private String upName;
-
- /** The starting position of this atav in the given string from which
- * we have extracted the upName */
- private int start;
-
- /** The length of this atav upName */
- private int length;
-
- /** Two values used for comparizon */
- private static final boolean CASE_SENSITIVE = true;
-
- private static final boolean CASE_INSENSITIVE = false;
-
-
- /**
- * Construct an empty AttributeTypeAndValue
- */
- public AttributeTypeAndValue()
- {
- type = null;
- value = null;
- upName = "";
- start = -1;
- length = 0;
- }
-
-
- /**
- * Construct an AttributeTypeAndValue. The type and value are normalized :
- * - the type is trimmed and lowercased
- * - the value is trimmed
- *
- * @param type
- * The type
- * @param value
- * the value
- */
- public AttributeTypeAndValue(String type, Object value) throws InvalidNameException
- {
- if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
- {
- log.error( "The type cannot be empty or null" );
- throw new InvalidNameException( "Null or empty type is not allowed" );
- }
-
- this.type = type.trim().toLowerCase();
-
- if ( value instanceof String )
- {
- this.value = StringTools.isEmpty( (String)value ) ? "" : value;
- }
- else
- {
- this.value = value;
- }
-
- upName = type + '=' + value;
- start = 0;
- length = upName.length();
- }
-
- /**
- * Get the type of a AttributeTypeAndValue
- *
- * @return The type
- */
- public String getType()
- {
- return type;
- }
-
-
- /**
- * Store the type
- *
- * @param type
- * The AttributeTypeAndValue type
- */
- public void setType( String type ) throws InvalidNameException
- {
- if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
- {
- log.error( "The type cannot be empty or null" );
- throw new InvalidNameException( "The AttributeTypeAndValue type cannot be null or empty " );
- }
-
- this.type = type.trim().toLowerCase();
- upName = type + upName.substring( upName.indexOf( '=' ) );
- start = -1;
- length = upName.length();
- }
-
-
- /**
- * Store the type, after having trimmed and lowercased it.
- *
- * @param type
- * The AttributeTypeAndValue type
- */
- public void setTypeNormalized( String type ) throws InvalidNameException
- {
- if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
- {
- log.error( "The type cannot be empty or null" );
- throw new InvalidNameException( "The AttributeTypeAndValue type cannot be null or empty " );
- }
-
- this.type = type.trim().toLowerCase();
- upName = type + upName.substring( upName.indexOf( '=' ) );
- start = -1;
- length = upName.length();
- }
-
-
- /**
- * Get the Value of a AttributeTypeAndValue
- *
- * @return The value
- */
- public Object getValue()
- {
- return value;
- }
-
-
- /**
- * Store the value of a AttributeTypeAndValue.
- *
- * @param value
- * The value of the AttributeTypeAndValue
- */
- public void setValue( Object value )
- {
- if ( value instanceof String )
- {
- this.value = StringTools.isEmpty( (String)value ) ? "" : (String)value;
- }
- else
- {
- this.value = value;
- }
-
- upName = upName.substring( 0, upName.indexOf( '=' ) + 1 ) + value;
- start = -1;
- length = upName.length();
- }
-
- /**
- * Get the upName length
- *
- * @return the upName length
- */
- public int getLength() {
- return length;
- }
-
- /**
- * get the position in the original upName where this atav starts.
- *
- * @return The starting position of this atav
- */
- public int getStart() {
- return start;
- }
-
-
- /**
- * Get the user provided form of this attribute type and value
- *
- * @return The user provided form of this atav
- */
- public String getUpName() {
- return upName;
- }
-
- /**
- * Store the value of a AttributeTypeAndValue, after having trimmed it.
- *
- * @param value
- * The value of the AttributeTypeAndValue
- */
- public void setValueNormalized( String value )
- {
- String newValue = StringTools.trim( value );
-
- if ( StringTools.isEmpty( newValue ) )
- {
- this.value = "";
- }
- else
- {
- this.value = newValue;
- }
-
- upName = upName.substring( 0, upName.indexOf( '=' ) + 1 ) + value;
- start = -1;
- length = upName.length();
- }
-
-
- /**
- * Implements the cloning.
- *
- * @return a clone of this object
- */
- public Object clone()
- {
- try
- {
- return super.clone();
- }
- catch ( CloneNotSupportedException cnse )
- {
- throw new Error( "Assertion failure" );
- }
- }
-
-
- /**
- * Compares two NameComponents. They are equals if : - types are equals,
- * case insensitive, - values are equals, case sensitive
- *
- * @param object
- * @return 0 if both NC are equals, otherwise a positive value if the
- * original NC is superior to the second one, a negative value if
- * the second NC is superior.
- */
- public int compareTo( Object object )
- {
- if ( object instanceof AttributeTypeAndValue )
- {
- AttributeTypeAndValue nc = ( AttributeTypeAndValue ) object;
-
- int res = compareType( type, nc.type );
-
- if ( res != 0 )
- {
- return res;
- }
- else
- {
- return compareValue( value, nc.value, CASE_SENSITIVE);
- }
- }
- else
- {
- return 1;
- }
- }
-
-
- /**
- * Compares two NameComponents. They are equals if : - types are equals,
- * case insensitive, - values are equals, case insensitive
- *
- * @param object
- * @return 0 if both NC are equals, otherwise a positive value if the
- * original NC is superior to the second one, a negative value if
- * the second NC is superior.
- */
- public int compareToIgnoreCase( Object object )
- {
- if ( object instanceof AttributeTypeAndValue )
- {
- AttributeTypeAndValue nc = ( AttributeTypeAndValue ) object;
-
- int res = compareType( type, nc.type );
-
- if ( res != 0 )
- {
- return res;
- }
- else
- {
- return compareValue( value, nc.value, CASE_INSENSITIVE );
- }
- }
- else
- {
- return 1;
- }
- }
-
-
- /**
- * Compare two types, trimed and case insensitive
- *
- * @param val1
- * First String
- * @param val2
- * Second String
- * @return true if both strings are equals or null.
- */
- private int compareType( String val1, String val2 )
- {
- if ( StringTools.isEmpty( val1 ) )
- {
- return StringTools.isEmpty( val2 ) ? 0 : -1;
- }
- else if ( StringTools.isEmpty( val2 ) )
- {
- return 1;
- }
- else
- {
- return ( StringTools.trim( val1 ) ).compareToIgnoreCase( StringTools.trim( val2 ) );
- }
- }
-
-
- /**
- * Compare two values
- *
- * @param val1
- * First String
- * @param val2
- * Second String
- * @return true if both strings are equals or null.
- */
- private int compareValue( Object val1, Object val2, boolean sensitivity )
- {
- if ( val1 instanceof String )
- {
- if ( val2 instanceof String )
- {
- int val = ( sensitivity == CASE_SENSITIVE ) ?
- ((String)val1).compareTo( (String)val2 ) :
- ((String)val1).compareToIgnoreCase( (String)val2 );
-
- return ( val < 0 ? -1 : ( val > 0 ? 1 : val ) );
- }
- else
- {
- return 1;
- }
- }
- else if ( val1 instanceof byte[] )
- {
- if ( Arrays.equals( (byte[])val1, (byte[])val2 ) )
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- else
- {
- return 1;
- }
- }
-
-
- /**
- * A Normalized String representation of a AttributeTypeAndValue : - type is
- * trimed and lowercased - value is trimed and lowercased
- *
- * @return A normalized string representing a AttributeTypeAndValue
- */
- public String normalize()
- {
- if ( value instanceof String )
- {
- return StringTools.lowerCase( StringTools.trim( type ) ) + '=' + StringTools.trim( (String)value );
- }
- else
- {
- return StringTools.lowerCase( StringTools.trim( type ) ) + "=#" + StringTools.dumpHexPairs( (byte[])value );
- }
- }
-
- /**
- * Gets the hashcode of this object.
- *
- * @see java.lang.Object#hashCode()
- */
- public int hashCode()
- {
- int result = 17;
-
- result = result * 37 + ( type != null ? type.hashCode() : 0 );
- result = result * 37 + ( value != null ? type.hashCode() : 0 );
-
- return result;
- }
-
- /**
- * A String representation of a AttributeTypeAndValue.
- *
- * @return A string representing a AttributeTypeAndValue
- */
- public String toString()
- {
- StringBuffer sb = new StringBuffer();
-
- if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
- {
- return "";
- }
-
- sb.append( type ).append( "=" );
-
- if ( value != null )
- {
- sb.append( value );
- }
+ /**
+ * Declares the Serial Version Uid.
+ *
+ * @see <a
+ * href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always
+ * Declare Serial Version Uid</a>
+ */
+ private static final long serialVersionUID = 1L;
+
+ /** The LoggerFactory used by this class */
+ private static Logger log = LoggerFactory.getLogger( AttributeTypeAndValue.class );
+
+ /** The Name type */
+ private String type;
+
+ /** The name value. It can be a String or a byte array */
+ private Object value;
+
+ /** The user provided atav */
+ private String upName;
+
+ /** The starting position of this atav in the given string from which
+ * we have extracted the upName */
+ private int start;
+
+ /** The length of this atav upName */
+ private int length;
+
+ /** Two values used for comparizon */
+ private static final boolean CASE_SENSITIVE = true;
+
+ private static final boolean CASE_INSENSITIVE = false;
+
+
+ /**
+ * Construct an empty AttributeTypeAndValue
+ */
+ public AttributeTypeAndValue()
+ {
+ type = null;
+ value = null;
+ upName = "";
+ start = -1;
+ length = 0;
+ }
+
+
+ /**
+ * Construct an AttributeTypeAndValue. The type and value are normalized :
+ * - the type is trimmed and lowercased
+ * - the value is trimmed
+ *
+ * @param type
+ * The type
+ * @param value
+ * the value
+ */
+ public AttributeTypeAndValue( String type, Object value ) throws InvalidNameException
+ {
+ if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
+ {
+ log.error( "The type cannot be empty or null" );
+ throw new InvalidNameException( "Null or empty type is not allowed" );
+ }
+
+ this.type = type.trim().toLowerCase();
+
+ if ( value instanceof String )
+ {
+ this.value = StringTools.isEmpty( ( String ) value ) ? "" : value;
+ }
+ else
+ {
+ this.value = value;
+ }
+
+ upName = type + '=' + value;
+ start = 0;
+ length = upName.length();
+ }
+
+
+ /**
+ * Get the type of a AttributeTypeAndValue
+ *
+ * @return The type
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * Store the type
+ *
+ * @param type
+ * The AttributeTypeAndValue type
+ */
+ public void setType( String type ) throws InvalidNameException
+ {
+ if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
+ {
+ log.error( "The type cannot be empty or null" );
+ throw new InvalidNameException( "The AttributeTypeAndValue type cannot be null or empty " );
+ }
+
+ this.type = type.trim().toLowerCase();
+ upName = type + upName.substring( upName.indexOf( '=' ) );
+ start = -1;
+ length = upName.length();
+ }
+
+
+ /**
+ * Store the type, after having trimmed and lowercased it.
+ *
+ * @param type
+ * The AttributeTypeAndValue type
+ */
+ public void setTypeNormalized( String type ) throws InvalidNameException
+ {
+ if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
+ {
+ log.error( "The type cannot be empty or null" );
+ throw new InvalidNameException( "The AttributeTypeAndValue type cannot be null or empty " );
+ }
+
+ this.type = type.trim().toLowerCase();
+ upName = type + upName.substring( upName.indexOf( '=' ) );
+ start = -1;
+ length = upName.length();
+ }
+
+
+ /**
+ * Get the Value of a AttributeTypeAndValue
+ *
+ * @return The value
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Get the normalized Value of a AttributeTypeAndValue
+ *
+ * @return The value
+ */
+ public String getNormalizedValue()
+ {
+ return normalize();
+ }
+
+
+ /**
+ * Store the value of a AttributeTypeAndValue.
+ *
+ * @param value
+ * The value of the AttributeTypeAndValue
+ */
+ public void setValue( Object value )
+ {
+ if ( value instanceof String )
+ {
+ this.value = StringTools.isEmpty( ( String ) value ) ? "" : ( String ) value;
+ }
+ else
+ {
+ this.value = value;
+ }
+
+ upName = upName.substring( 0, upName.indexOf( '=' ) + 1 ) + value;
+ start = -1;
+ length = upName.length();
+ }
+
+
+ /**
+ * Get the upName length
+ *
+ * @return the upName length
+ */
+ public int getLength()
+ {
+ return length;
+ }
+
+
+ /**
+ * get the position in the original upName where this atav starts.
+ *
+ * @return The starting position of this atav
+ */
+ public int getStart()
+ {
+ return start;
+ }
+
+
+ /**
+ * Get the user provided form of this attribute type and value
+ *
+ * @return The user provided form of this atav
+ */
+ public String getUpName()
+ {
+ return upName;
+ }
+
+
+ /**
+ * Store the value of a AttributeTypeAndValue, after having trimmed it.
+ *
+ * @param value
+ * The value of the AttributeTypeAndValue
+ */
+ public void setValueNormalized( String value )
+ {
+ String newValue = StringTools.trim( value );
+
+ if ( StringTools.isEmpty( newValue ) )
+ {
+ this.value = "";
+ }
+ else
+ {
+ this.value = newValue;
+ }
+
+ upName = upName.substring( 0, upName.indexOf( '=' ) + 1 ) + value;
+ start = -1;
+ length = upName.length();
+ }
+
+
+ /**
+ * Implements the cloning.
+ *
+ * @return a clone of this object
+ */
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch ( CloneNotSupportedException cnse )
+ {
+ throw new Error( "Assertion failure" );
+ }
+ }
+
+
+ /**
+ * Compares two NameComponents. They are equals if : - types are equals,
+ * case insensitive, - values are equals, case sensitive
+ *
+ * @param object
+ * @return 0 if both NC are equals, otherwise a positive value if the
+ * original NC is superior to the second one, a negative value if
+ * the second NC is superior.
+ */
+ public int compareTo( Object object )
+ {
+ if ( object instanceof AttributeTypeAndValue )
+ {
+ AttributeTypeAndValue nc = ( AttributeTypeAndValue ) object;
+
+ int res = compareType( type, nc.type );
+
+ if ( res != 0 )
+ {
+ return res;
+ }
+ else
+ {
+ return compareValue( value, nc.value, CASE_SENSITIVE );
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+
+
+ /**
+ * Compares two NameComponents. They are equals if : - types are equals,
+ * case insensitive, - values are equals, case insensitive
+ *
+ * @param object
+ * @return 0 if both NC are equals, otherwise a positive value if the
+ * original NC is superior to the second one, a negative value if
+ * the second NC is superior.
+ */
+ public int compareToIgnoreCase( Object object )
+ {
+ if ( object instanceof AttributeTypeAndValue )
+ {
+ AttributeTypeAndValue nc = ( AttributeTypeAndValue ) object;
+
+ int res = compareType( type, nc.type );
+
+ if ( res != 0 )
+ {
+ return res;
+ }
+ else
+ {
+ return compareValue( value, nc.value, CASE_INSENSITIVE );
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+
+
+ /**
+ * Compare two types, trimed and case insensitive
+ *
+ * @param val1
+ * First String
+ * @param val2
+ * Second String
+ * @return true if both strings are equals or null.
+ */
+ private int compareType( String val1, String val2 )
+ {
+ if ( StringTools.isEmpty( val1 ) )
+ {
+ return StringTools.isEmpty( val2 ) ? 0 : -1;
+ }
+ else if ( StringTools.isEmpty( val2 ) )
+ {
+ return 1;
+ }
+ else
+ {
+ return ( StringTools.trim( val1 ) ).compareToIgnoreCase( StringTools.trim( val2 ) );
+ }
+ }
+
+
+ /**
+ * Compare two values
+ *
+ * @param val1
+ * First String
+ * @param val2
+ * Second String
+ * @return true if both strings are equals or null.
+ */
+ private int compareValue( Object val1, Object val2, boolean sensitivity )
+ {
+ if ( val1 instanceof String )
+ {
+ if ( val2 instanceof String )
+ {
+ int val = ( sensitivity == CASE_SENSITIVE ) ? ( ( String ) val1 ).compareTo( ( String ) val2 )
+ : ( ( String ) val1 ).compareToIgnoreCase( ( String ) val2 );
+
+ return ( val < 0 ? -1 : ( val > 0 ? 1 : val ) );
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else if ( val1 instanceof byte[] )
+ {
+ if ( Arrays.equals( ( byte[] ) val1, ( byte[] ) val2 ) )
+ {
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+
+ private static final boolean[] DN_ESCAPED_CHARS = new boolean[]
+ {
+ true, true, true, true, true, true, true, true, // 0x00 -> 0x07
+ true, true, true, true, true, true, true, true, // 0x08 -> 0x0F
+ true, true, true, true, true, true, true, true, // 0x10 -> 0x17
+ true, true, true, true, true, true, true, true, // 0x18 -> 0x1F
+ true, false, true, true, false, false, false, false, // 0x20 -> 0x27 ' ', '"', '#'
+ false, false, false, true, true, false, false, false, // 0x28 -> 0x2F '+', ','
+ false, false, false, false, false, false, false, false, // 0x30 -> 0x37
+ false, false, false, true, true, false, true, false, // 0x38 -> 0x3F ';', '<', '>'
+ false, false, false, false, false, false, false, false, // 0x40 -> 0x47
+ false, false, false, false, false, false, false, false, // 0x48 -> 0x4F
+ false, false, false, false, false, false, false, false, // 0x50 -> 0x57
+ false, false, false, false, true, false, false, false, // 0x58 -> 0x5F
+ false, false, false, false, false, false, false, false, // 0x60 -> 0x67
+ false, false, false, false, false, false, false, false, // 0x68 -> 0x6F
+ false, false, false, false, false, false, false, false, // 0x70 -> 0x77
+ false, false, false, false, false, false, false, false, // 0x78 -> 0x7F
+ };
+
+ /**
+ * A Normalized String representation of a AttributeTypeAndValue : - type is
+ * trimed and lowercased - value is trimed and lowercased, and special characters
+ * are escaped if needed.
+ *
+ * @return A normalized string representing a AttributeTypeAndValue
+ */
+ public String normalize()
+ {
+ if ( value instanceof String )
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append( StringTools.lowerCase( StringTools.trim( type ) ) ).append( '=' );
+ String normalizedValue = ( String ) value;
+ int valueLength = normalizedValue.length();
+
+ if ( normalizedValue.length() > 0 )
+ {
+ for ( int i = 0; i < valueLength; i++ )
+ {
+ char c = normalizedValue.charAt( i );
+
+ if ( ( c < 0) || ( c > 128 ) )
+ {
+ byte[] bb = StringTools.getBytesUtf8( normalizedValue.substring( i, i + 1 ) );
+
+ for ( byte b:bb )
+ {
+ sb.append( '\\' ).
+ append( StringTools.dumpHex( (byte)(( b & 0x00F0 ) >> 4) ) ).
+ append( StringTools.dumpHex( b ) );
+ }
+ }
+ else if ( DN_ESCAPED_CHARS[ c ] )
+ {
+ if ( c == ' ' )
+ {
+ if ( ( i == 0 ) || ( i == valueLength - 1 ) )
+ {
+ sb.append( '\\' ).append( c );
+ }
+ else
+ {
+ sb.append( ' ' );
+ }
+
+ continue;
+ }
+ else if ( c == '#' )
+ {
+ if ( i == 0 )
+ {
+ sb.append( "\\#" );
+ continue;
+ }
+ else
+ {
+ sb.append( '#' );
+ }
+
+ continue;
+ }
+
+ sb.append( '\\' ).append( c );
+ }
+ else
+ {
+ sb.append( c );
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+ else
+ {
+ return StringTools.lowerCase( StringTools.trim( type ) ) + "=#"
+ + StringTools.dumpHexPairs( ( byte[] ) value );
+ }
+ }
+
+
+ /**
+ * Gets the hashcode of this object.
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode()
+ {
+ int result = 17;
+
+ result = result * 37 + ( type != null ? type.hashCode() : 0 );
+ result = result * 37 + ( value != null ? type.hashCode() : 0 );
+
+ return result;
+ }
+
+
+ /**
+ * A String representation of a AttributeTypeAndValue.
+ *
+ * @return A string representing a AttributeTypeAndValue
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ if ( StringTools.isEmpty( type ) || StringTools.isEmpty( type.trim() ) )
+ {
+ return "";
+ }
+
+ sb.append( type ).append( "=" );
+
+ if ( value != null )
+ {
+ sb.append( value );
+ }
- return sb.toString();
- }
+ return sb.toString();
+ }
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java Wed Dec 13 09:15:29 2006
@@ -1392,7 +1392,7 @@
Rdn rdn = rdns.nextElement();
String upName = rdn.getUpName();
rdnOidToName( rdn, oidsMap );
- rdn.normalizeString();
+ rdn.normalize();
rdn.setUpName( upName );
}
@@ -1431,7 +1431,7 @@
Rdn rdn = rdns.nextElement();
String upName = rdn.getUpName();
rdnOidToName( rdn, oidsMap );
- rdn.normalizeString();
+ rdn.normalize();
rdn.setUpName( upName );
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java Wed Dec 13 09:15:29 2006
@@ -116,7 +116,7 @@
private String upName = null;
/** The normalized RDN */
- private String string = null;
+ private String normName = null;
/** The starting position of this RDN in the given string from which
* we have extracted the upName */
@@ -178,7 +178,7 @@
// name-components in a RDN... So we won't initialize the Map and the
// treeSet.
upName = "";
- string = "";
+ normName = "";
}
@@ -201,15 +201,15 @@
// create the internal normalized form
// and store the user provided form
- normalizeString();
+ normalize();
upName = rdn;
- length = rdn.length();
+ length = rdn.length();
}
else
{
upName = "";
- string = "";
- length = 0;
+ normName = "";
+ length = 0;
}
}
@@ -237,7 +237,7 @@
start = 0;
length = upName.length();
// create the internal normalized form
- normalizeString();
+ normalize();
}
@@ -252,7 +252,7 @@
{
super();
nbAtavs = rdn.getNbAtavs();
- this.string = new String( rdn.string );
+ this.normName = new String( rdn.normName );
this.upName = new String( rdn.getUpName() );
this.start = rdn.start;
this.length = rdn.length;
@@ -291,13 +291,13 @@
// WARNING : The protection level is left unspecified intentionnaly.
// We need this method to be visible from the DnParser class, but not
// from outside this package.
- /* Unspecified protection */void normalizeString()
+ /* Unspecified protection */void normalize()
{
switch ( nbAtavs )
{
case 0:
// An empty RDN
- string = "";
+ normName = "";
break;
case 1:
@@ -305,11 +305,11 @@
// We will trim and lowercase type and value.
if ( atav.getValue() instanceof String )
{
- string = atav.getType() + '=' + (String)atav.getValue();
+ normName = atav.getNormalizedValue();
}
else
{
- string = atav.getType() + "=#" + StringTools.dumpHexPairs( (byte[])atav.getValue() );
+ normName = atav.getType() + "=#" + StringTools.dumpHexPairs( (byte[])atav.getValue() );
}
break;
@@ -334,7 +334,7 @@
sb.append( ata.normalize() );
}
- string = sb.toString();
+ normName = sb.toString();
break;
}
}
@@ -407,7 +407,7 @@
atavType = null;
atavTypes.clear();
nbAtavs = 0;
- string = "";
+ normName = "";
upName = "";
start = -1;
length = 0;
@@ -734,7 +734,7 @@
*/
public String toString()
{
- return string;
+ return normName == null ? "" : normName;
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java Wed Dec 13 09:15:29 2006
@@ -481,7 +481,7 @@
else
{
// <attributeTypeAndValues> ::= e
- rdn.normalizeString();
+ rdn.normalize();
return DNUtils.PARSING_OK;
}
@@ -613,13 +613,16 @@
if ( rdn != null )
{
rdn.addAttributeTypeAndValue( type, value );
- rdn.normalizeString();
+ rdn.normalize();
pos.start = pos.end;
pos.length = 0;
}
- parseNameComponents( dn, pos, rdn );
+ if ( parseNameComponents( dn, pos, rdn ) == DNUtils.PARSING_ERROR )
+ {
+ return DNUtils.PARSING_ERROR;
+ }
rdn.setUpName( dn.substring( start, pos.end ) );
pos.start = pos.end;
@@ -643,6 +646,6 @@
public static void parse( String string, Rdn rdn ) throws InvalidNameException
{
parse( string, new Position(), rdn );
- rdn.normalizeString();
+ rdn.normalize();
}
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DNUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DNUtils.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DNUtils.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DNUtils.java Wed Dec 13 09:15:29 2006
@@ -162,14 +162,14 @@
ONE_CHAR, ONE_CHAR, ONE_CHAR, ONE_CHAR, // 14 -> 17
ONE_CHAR, ONE_CHAR, ONE_CHAR, ONE_CHAR, // 18 -> 1B
ONE_CHAR, ONE_CHAR, ONE_CHAR, ONE_CHAR, // 1C -> 1F
- ONE_CHAR, ONE_CHAR, PARSING_ERROR, PARSING_ERROR,// 20 -> 23
+ ONE_CHAR, ONE_CHAR, PARSING_ERROR, ONE_CHAR, // 20 -> 23
ONE_CHAR, ONE_CHAR, ONE_CHAR, ONE_CHAR, // 24 -> 27
ONE_CHAR, ONE_CHAR, ONE_CHAR, PARSING_ERROR,// 28 -> 2B
PARSING_ERROR, ONE_CHAR, ONE_CHAR, ONE_CHAR, // 2C -> 2F
ONE_CHAR, ONE_CHAR, ONE_CHAR, ONE_CHAR, // 30 -> 33
ONE_CHAR, ONE_CHAR, ONE_CHAR, ONE_CHAR, // 34 -> 37
ONE_CHAR, ONE_CHAR, ONE_CHAR, PARSING_ERROR,// 38 -> 3B
- PARSING_ERROR, PARSING_ERROR, PARSING_ERROR, ONE_CHAR // 3C -> 3F
+ PARSING_ERROR, ONE_CHAR, PARSING_ERROR, ONE_CHAR // 3C -> 3F
};
/** "oid." static */
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/DnParserDIRSERVER_584_Test.java Wed Dec 13 09:15:29 2006
@@ -43,7 +43,7 @@
{
try
{
- LdapDnParser.parseInternal( "ou=test=testing", new ArrayList<Rdn>() );
+ LdapDnParser.parseInternal( "ou=test+testing", new ArrayList<Rdn>() );
fail( "should never get here" );
}
catch ( InvalidNameException e )
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java Wed Dec 13 09:15:29 2006
@@ -247,8 +247,7 @@
{
LdapDN dn = new LdapDN( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D" );
- byte[] expected = new byte[] { 'a', '=', ',', '=', '+', '<', '>', '#', ';', '\\', '"', (byte)0xC4, (byte)0x8D};
- Assert.assertEquals( StringTools.utf8ToString( expected ), dn.toString() );
+ Assert.assertEquals( "a=\\,=\\+\\<\\>#\\;\\\\\\\"\\C4\\8D", dn.toString() );
Assert.assertEquals( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D", dn.getUpName() );
}
@@ -259,7 +258,7 @@
{
LdapDN dn = new LdapDN( "SN=Lu\\C4\\8Di\\C4\\87" );
byte[] lucic = new byte[] { 's', 'n', '=', 'L', 'u', (byte)0xC4, (byte)0x8D, 'i', (byte)0xC4, (byte)0x87};
- Assert.assertEquals( StringTools.utf8ToString( lucic ), dn.toString() );
+ Assert.assertEquals( "sn=Lu\\C4\\8Di\\C4\\87", dn.toString() );
Assert.assertEquals( "SN=Lu\\C4\\8Di\\C4\\87", dn.getUpName() );
}
@@ -274,6 +273,16 @@
}
/**
+ * test a simple DN with a # on first position
+ */
+ public void testLdapDNSharpFirst() throws InvalidNameException
+ {
+ LdapDN dn = new LdapDN( "a = \\#this is a sharp" );
+ Assert.assertEquals( "a=\\#this is a sharp", dn.toString() );
+ Assert.assertEquals( "a = \\#this is a sharp", dn.getUpName() );
+ }
+
+ /**
* test a simple DN with a wrong hexString attribute value : a = #0010Z0AAFF
*/
public void testLdapDNWrongHexStringAttributeValue() throws InvalidNameException
@@ -311,7 +320,7 @@
public void testLdapDNQuoteInAttributeValue() throws InvalidNameException
{
LdapDN dn = new LdapDN( "a = quoted \\\"value\\\"" );
- Assert.assertEquals( "a=quoted \"value\"", dn.toString() );
+ Assert.assertEquals( "a=quoted \\\"value\\\"", dn.toString() );
Assert.assertEquals( "a = quoted \\\"value\\\"", dn.getUpName() );
}
@@ -321,7 +330,7 @@
public void testLdapDNQuotedAttributeValue() throws InvalidNameException
{
LdapDN dn = new LdapDN( "a = \\\" quoted value \\\"" );
- Assert.assertEquals( "a=\" quoted value \"", dn.toString() );
+ Assert.assertEquals( "a=\\\" quoted value \\\"", dn.toString() );
Assert.assertEquals( "a = \\\" quoted value \\\"", dn.getUpName() );
}
@@ -1280,13 +1289,10 @@
String dn = StringTools.utf8ToString( new byte[]{'C', 'N', ' ', '=', ' ', 'E', 'm', 'm', 'a', 'n', 'u', 'e',
'l', ' ', ' ', 'L', (byte)0xc3, (byte)0xa9, 'c', 'h', 'a', 'r', 'n', 'y'} );
- String expected = StringTools.utf8ToString( new byte[]{'c', 'n', '=','E', 'm', 'm', 'a', 'n', 'u', 'e',
- 'l', ' ', ' ', 'L', (byte)0xc3, (byte)0xa9, 'c', 'h', 'a', 'r', 'n', 'y'} );
-
Name name = LdapDnParser.getNameParser().parse( dn );
Assert.assertEquals( dn, ( ( LdapDN ) name ).getUpName() );
- Assert.assertEquals( expected, name.toString() );
+ Assert.assertEquals( "cn=Emmanuel L\\C3\\A9charny", name.toString() );
}
@@ -2100,11 +2106,11 @@
public void testNameFrenchChars() throws Exception
{
String cn = new String( new byte[]
- { 'c', 'n', '=', 0x4A, ( byte ) 0xC3, ( byte ) 0xA9, 0x72, ( byte ) 0xC3, ( byte ) 0xB4, 0x6D, 0x65 } );
+ { 'c', 'n', '=', 0x4A, ( byte ) 0xC3, ( byte ) 0xA9, 0x72, ( byte ) 0xC3, ( byte ) 0xB4, 0x6D, 0x65 }, "UTF-8" );
Name name = new LdapDN( cn );
- assertEquals( cn, name.toString() );
+ assertEquals( "cn=J\\C3\\A9r\\C3\\B4me", name.toString() );
}
@@ -2117,7 +2123,7 @@
Name name = new LdapDN( cn );
- assertEquals( cn, name.toString() );
+ assertEquals( "cn=\\C3\\84\\C3\\96\\C3\\9C\\C3\\9F\\C3\\A4\\C3\\B6\\C3\\BC", name.toString() );
}
@@ -2131,7 +2137,7 @@
Name name = new LdapDN( cn );
- assertEquals( cn, name.toString() );
+ assertEquals( "cn=\\C4\\B0\\C4\\B1\\C5\\9E\\C5\\9F\\C3\\96\\C3\\B6\\C3\\9C\\C3\\BC\\C4\\9E\\C4\\9F", name.toString() );
}
@@ -2517,10 +2523,13 @@
*/
public void testDoubleQuoteInNameDIRSERVER_642_1() throws NamingException
{
+ LdapDN dn1 = new LdapDN( "cn= a " );
+ LdapDN dn2 = new LdapDN( "cn=\" a \"" );
+ LdapDN dn3 = new LdapDN( "cn= \" a \" " );
LdapDN dn = new LdapDN( "cn=\" Kylie Minogue \",dc=example,dc=com" );
Assert.assertEquals( "cn=\" Kylie Minogue \",dc=example,dc=com", dn.getUpName() );
- Assert.assertEquals( "cn= Kylie Minogue ,dc=example,dc=com", dn.toString() );
+ Assert.assertEquals( "cn=\\ Kylie Minogue\\ ,dc=example,dc=com", dn.toString() );
}
/**
@@ -2531,7 +2540,7 @@
{
LdapDN name = new LdapDN( "dn= \\ four spaces leading and 3 trailing \\ " );
- Assert.assertEquals( "dn= four spaces leading and 3 trailing ", name.toString() );
+ Assert.assertEquals( "dn=\\ four spaces leading and 3 trailing \\ ", name.toString() );
Assert.assertEquals( "dn= \\ four spaces leading and 3 trailing \\ ", name.getUpName() );
}
@@ -2575,7 +2584,7 @@
{
LdapDN name = new LdapDN( "dn=\\# a leading pound" );
- Assert.assertEquals( "dn=# a leading pound", name.toString() );
+ Assert.assertEquals( "dn=\\# a leading pound", name.toString() );
Assert.assertEquals( "dn=\\# a leading pound", name.getUpName() );
}
@@ -2639,7 +2648,7 @@
{
LdapDN name = new LdapDN( "cn=Bush\\, Kate,dc=example,dc=com" );
- Assert.assertEquals( "cn=Bush, Kate,dc=example,dc=com", name.toString() );
+ Assert.assertEquals( "cn=Bush\\, Kate,dc=example,dc=com", name.toString() );
Assert.assertEquals( "cn=Bush\\, Kate,dc=example,dc=com", name.getUpName() );
}
@@ -2678,5 +2687,13 @@
System.out.println( ldapDn.toString() );
assertEquals( "cn=xyz,cn=blah,dc=example,dc=com", ldapDn.toString() );
+ }
+
+ public void testDNEquals() throws NamingException
+ {
+ LdapDN dn1 = new LdapDN( "a=b,c=d,e=f" );
+ LdapDN dn2 = new LdapDN( "a=b\\,c\\=d,e=f" );
+
+ assertFalse( dn1.toString().equals( dn2.toString() ) );
}
}
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java Wed Dec 13 09:15:29 2006
@@ -193,9 +193,8 @@
public void testLdapDNPairCharAttributeValue() throws NamingException
{
NameParser dnParser = LdapDnParser.getNameParser();
- String expected = StringTools.utf8ToString( new byte[]{'a', '=', ',', '=', '+', '<', '>', '#', ';', '\\', '"', (byte)0xC3, (byte)0xA9});
LdapDN dn = ( LdapDN ) dnParser.parse( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C3\\A9" );
- Assert.assertEquals( expected, dn.toString() );
+ Assert.assertEquals( "a=\\,=\\+\\<\\>#\\;\\\\\\\"\\C3\\A9", dn.toString() );
Assert.assertEquals( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C3\\A9", dn.getUpName() );
}
@@ -219,7 +218,7 @@
{
NameParser dnParser = LdapDnParser.getNameParser();
LdapDN dn = ( LdapDN ) dnParser.parse( "a = quoted \\\"value" );
- Assert.assertEquals( "a=quoted \"value", dn.toString() );
+ Assert.assertEquals( "a=quoted \\\"value", dn.toString() );
Assert.assertEquals( "a = quoted \\\"value", dn.getUpName() );
}
@@ -244,14 +243,11 @@
String dn = StringTools.utf8ToString( new byte[]{'C', 'N', ' ', '=', ' ', 'E', 'm', 'm', 'a', 'n', 'u', 'e',
'l', ' ', ' ', 'L', (byte)0xc3, (byte)0xa9, 'c', 'h', 'a', 'r', 'n', 'y'} );
- String expected = StringTools.utf8ToString( new byte[]{'c', 'n', '=','E', 'm', 'm', 'a', 'n', 'u', 'e',
- 'l', ' ', ' ', 'L', (byte)0xc3, (byte)0xa9, 'c', 'h', 'a', 'r', 'n', 'y'} );
-
NameParser dnParser = LdapDnParser.getNameParser();
LdapDN name = ( LdapDN ) dnParser.parse( dn );
Assert.assertEquals( dn, name.getUpName() );
- Assert.assertEquals( expected, name.toString() );
+ Assert.assertEquals( "cn=Emmanuel L\\C3\\A9charny", name.toString() );
}
@@ -387,7 +383,7 @@
assertEquals( "RFC2253_3 : ", "CN=L. Eagle, O=Sue\\, Grabbit and Runn, C=GB", ( ( LdapDN ) nameRFC2253_3 )
.getUpName() );
- assertEquals( "RFC2253_3 : ", "cn=L. Eagle,o=Sue, Grabbit and Runn,c=GB", nameRFC2253_3.toString() );
+ assertEquals( "RFC2253_3 : ", "cn=L. Eagle,o=Sue\\, Grabbit and Runn,c=GB", nameRFC2253_3.toString() );
}
@@ -475,7 +471,7 @@
NameParser parser = LdapDnParser.getNameParser();
String input = "ou=some test\\, something else";
String result = parser.parse( input ).toString();
- assertEquals( "ou=some test, something else", result );
+ assertEquals( "ou=some test\\, something else", result );
}
@@ -486,19 +482,19 @@
NameParser parser = LdapDnParser.getNameParser();
Name result = parser.parse( path );
assertEquals( path, ( ( LdapDN ) result ).getUpName() );
- assertEquals( "windowsfilepath=C:\\cygwin", result.toString() );
+ assertEquals( "windowsfilepath=C:\\\\cygwin", result.toString() );
}
public void testNameFrenchChars() throws Exception
{
String cn = new String( new byte[]
- { 'c', 'n', '=', 0x4A, ( byte ) 0xC3, ( byte ) 0xA9, 0x72, ( byte ) 0xC3, ( byte ) 0xB4, 0x6D, 0x65 } );
+ { 'c', 'n', '=', 0x4A, ( byte ) 0xC3, ( byte ) 0xA9, 0x72, ( byte ) 0xC3, ( byte ) 0xB4, 0x6D, 0x65 }, "UTF-8" );
NameParser parser = LdapDnParser.getNameParser();
String result = parser.parse( cn ).toString();
- assertEquals( cn, result.toString() );
+ assertEquals( "cn=J\\C3\\A9r\\C3\\B4me", result.toString() );
}
@@ -513,7 +509,7 @@
NameParser parser = LdapDnParser.getNameParser();
String result = parser.parse( cn ).toString();
- assertEquals( cn, result.toString() );
+ assertEquals( "cn=\\C3\\84\\C3\\96\\C3\\9C\\C3\\9F\\C3\\A4\\C3\\B6\\C3\\BC", result.toString() );
}
@@ -528,7 +524,7 @@
NameParser parser = LdapDnParser.getNameParser();
String result = parser.parse( cn ).toString();
- assertEquals( cn, result.toString() );
+ assertEquals( "cn=\\C4\\B0\\C4\\B1\\C5\\9E\\C5\\9F\\C3\\96\\C3\\B6\\C3\\9C\\C3\\BC\\C4\\9E\\C4\\9F", result.toString() );
}
@@ -542,11 +538,12 @@
public final void testNonEscapedChars() throws NamingException
{
NameParser parser = LdapDnParser.getNameParser();
- String input = "ou=ou=test";
+ String input = "ou=ou+test";
try
{
- parser.parse( input ).toString();
+ String res = parser.parse( input ).toString();
+ System.out.println( res);
}
catch ( NamingException ne )
{
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java?view=diff&rev=486748&r1=486747&r2=486748
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java Wed Dec 13 09:15:29 2006
@@ -183,9 +183,10 @@
*/
public void testRdnPairCharAttributeValue() throws InvalidNameException
{
- String rdn = StringTools.utf8ToString( new byte[]{'a', '=', ',', '=', '+', '<', '>', '#', ';', '\\', '"', (byte)0xC3, (byte)0xA9});
+ String rdn = StringTools.utf8ToString( new byte[]{'a', '=', '\\', ',', '=', '\\', '+', '\\', '<',
+ '\\', '>', '#', '\\', ';', '\\', '\\', '\\', '"', '\\', 'C', '3', '\\', 'A', '9' });
Assert.assertEquals( rdn, new Rdn(
- "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C3\\A9" ).toString() );
+ "a = \\,=\\+\\<\\>#\\;\\\\\\\"\\C3\\A9" ).toString() );
}
@@ -203,7 +204,7 @@
*/
public void testRdnQuotedAttributeValue() throws InvalidNameException
{
- Assert.assertEquals( "a=quoted \"value", new Rdn( "a = quoted \\\"value" ).toString() );
+ Assert.assertEquals( "a=quoted \\\"value", new Rdn( "a = quoted \\\"value" ).toString() );
}