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/09/26 03:05:14 UTC
svn commit: r291503 [1/2] - in
/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src:
java/main/org/apache/asn1new/ldap/
java/main/org/apache/asn1new/ldap/codec/grammar/
java/main/org/apache/asn1new/ldap/codec/primitives/ java/...
Author: elecharny
Date: Sun Sep 25 18:04:43 2005
New Revision: 291503
URL: http://svn.apache.org/viewcvs?rev=291503&view=rev
Log:
Massive refactoring of the StringUtils, DNUtils, LdapDN, LdapURL classes, and all the classes that uses them.
Modified:
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapString.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapURL.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/RelativeLdapDN.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/CompareRequestTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/DelRequestTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyDNRequestTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyRequestTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/SearchRequestTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/utils/DNUtilsTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/utils/LdapDNTest.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/utils/LdapUrlTest.java
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixTransformer.java Sun Sep 25 18:04:43 2005
@@ -17,10 +17,12 @@
package org.apache.asn1new.ldap;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import javax.naming.InvalidNameException;
import javax.naming.NamingEnumeration;
import javax.naming.directory.Attribute;
import javax.naming.directory.BasicAttribute;
@@ -745,12 +747,12 @@
}
else
{
- twixLdapResult.setMatchedDN( new LdapDN( snickersLdapResult.getMatchedDn().getBytes() ) );
+ twixLdapResult.setMatchedDN( new LdapDN( snickersLdapResult.getMatchedDn() ) );
}
}
- catch ( DecoderException de )
+ catch ( InvalidNameException ine )
{
- log.warn( "The DN " + snickersLdapResult.getMatchedDn() + " is invalid : " + de.getMessage() );
+ log.warn( "The DN " + snickersLdapResult.getMatchedDn() + " is invalid : " + ine.getMessage() );
twixLdapResult.setMatchedDN( LdapDN.EMPTY_STRING );
}
@@ -959,11 +961,11 @@
// Snickers : String dn -> Twix : LdapDN objectName
try
{
- searchResultEntry.setObjectName( new LdapDN( snickersSearchResultResponse.getObjectName().getBytes() ) );
+ searchResultEntry.setObjectName( new LdapDN( snickersSearchResultResponse.getObjectName() ) );
}
- catch (DecoderException de)
+ catch (InvalidNameException ine)
{
- log.warn( "The DN " + snickersSearchResultResponse.getObjectName() + " is invalid : " + de.getMessage() );
+ log.warn( "The DN " + snickersSearchResultResponse.getObjectName() + " is invalid : " + ine.getMessage() );
searchResultEntry.setObjectName( LdapDN.EMPTY_STRING );
}
@@ -1008,6 +1010,10 @@
{
log.warn( "The LdapURL " + urlValue + " is incorrect : " + de.getMessage() );
}
+ catch ( UnsupportedEncodingException uee )
+ {
+ log.warn( "The LdapURL " + urlValue + " is incorrect : " + uee.getMessage() );
+ }
}
}
}
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/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-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -129,8 +131,15 @@
}
else
{
- addRequest.setEntry( new LdapDN(
- tlv.getValue().getData() ) );
+ try
+ {
+ addRequest.setEntry( new LdapDN(
+ tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
}
}
} );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/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-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -178,7 +180,14 @@
}
else
{
- bindRequestMessage.setName( new LdapDN( tlv.getValue().getData() ) );
+ try
+ {
+ bindRequestMessage.setName( new LdapDN( tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
}
return;
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/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-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -130,7 +132,15 @@
}
else
{
- compareRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ try
+ {
+ compareRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
+
}
}
} );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -99,7 +101,14 @@
}
else
{
- delRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ try
+ {
+ delRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
}
// then we associate it to the ldapMessage Object
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -246,7 +248,15 @@
}
else
{
- ldapResult.setMatchedDN( new LdapDN( tlv.getValue().getData() ) );
+ try
+ {
+ ldapResult.setMatchedDN( new LdapDN( tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
+
}
return;
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -135,7 +137,14 @@
}
else
{
- modifyDNRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ try
+ {
+ modifyDNRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect RDN given : " + ine.getMessage() );
+ }
}
return;
@@ -184,8 +193,15 @@
}
else
{
- modifyDNRequest.setNewRDN( new RelativeLdapDN(
- tlv.getValue().getData() ) );
+ try
+ {
+ modifyDNRequest.setNewRDN( new RelativeLdapDN(
+ tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect RDN given : " + ine.getMessage() );
+ }
}
}
} );
@@ -294,8 +310,15 @@
}
else
{
- modifyDNRequest.setNewSuperior( new LdapDN(
- tlv.getValue().getData() ) );
+ try
+ {
+ modifyDNRequest.setNewSuperior( new LdapDN(
+ tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
}
return;
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/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-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -134,8 +136,15 @@
}
else
{
- modifyRequest.setObject( new LdapDN(
- tlv.getValue().getData() ) );
+ try
+ {
+ modifyRequest.setObject( new LdapDN(
+ tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
}
}
} );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -133,17 +135,17 @@
// which is not permitted
if ( tlv.getLength().getLength() == 0 )
{
- throw new DecoderException("The base object must not be null");
+ throw new DecoderException( "The base object must not be null" );
}
try
{
- baseObject = new LdapDN(tlv.getValue().getData());
+ baseObject = new LdapDN( tlv.getValue().getData() );
}
- catch (DecoderException de)
+ catch ( InvalidNameException ine )
{
- log.error("The DN " + baseObject.toString() + " is invalid");
- throw de;
+ log.error( "The DN " + baseObject.toString() + " is invalid" );
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
}
searchRequest.setBaseObject(baseObject);
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/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-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ber.containers.IAsn1Container;
import org.apache.asn1new.ber.grammar.AbstractGrammar;
@@ -145,8 +147,15 @@
}
else
{
- searchResultEntry.setObjectName( new LdapDN(
- tlv.getValue().getData() ) );
+ try
+ {
+ searchResultEntry.setObjectName( new LdapDN(
+ tlv.getValue().getData() ) );
+ }
+ catch ( InvalidNameException ine )
+ {
+ throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
+ }
}
}
} );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java Sun Sep 25 18:04:43 2005
@@ -16,7 +16,15 @@
*/
package org.apache.asn1new.ldap.codec.primitives;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+
import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ldap.codec.utils.DNUtils;
import org.apache.asn1new.util.StringUtils;
/**
@@ -49,9 +57,15 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class LdapDN extends RelativeLdapDN
+public class LdapDN //implements Name
{
//~ Static fields/initializers -----------------------------------------------------------------
+ /** The RDNs that are elements of the DN */
+ private ArrayList rdns = new ArrayList(5);
+
+ private String nameNormalized;
+
+ private String name;
/** A null LdapDN */
public transient static final LdapDN EMPTY_STRING = new LdapDN();
@@ -63,7 +77,25 @@
*/
public LdapDN()
{
- super(0, false);
+ }
+
+ /**
+ * Parse a String and checks that it is a valid DN <br>
+ * <p>
+ * <distinguishedName> ::= <name> | e <br>
+ * <name> ::= <name-component> <name-components> <br>
+ * <name-components> ::= <spaces> <separator> <spaces> <name-component> <name-components> | e <br>
+ * </p>
+ *
+ * @param bytes The byte buffer that contains the DN
+ * @exception A InvalidNameException is thrown if the buffer does not contains a valid DN.
+ */
+ public LdapDN( String string ) throws InvalidNameException
+ {
+ this( string.toCharArray() );
+
+ name = string;
+ nameNormalized = normalize();
}
/**
@@ -75,28 +107,81 @@
* </p>
*
* @param bytes The byte buffer that contains the DN
- * @exception A DecoderException is thrown if the buffer does not contains a valid DN.
+ * @exception A InvalidNameException is thrown if the buffer does not contains a valid DN.
*/
- public LdapDN( byte[] bytes ) throws DecoderException
+ public LdapDN( char[] chars ) throws InvalidNameException
{
+ if ( ( chars == null ) || ( chars.length == 0 ) )
+ {
+ return;
+ }
+
+ int pos = 0;
+ LdapRDN rdn = new LdapRDN();
+ // <name> ::= <name-component> <name-components>
+ // <name-components> ::= <spaces> <separator> <spaces> <name-component> <name-components> | e
+ if ( ( pos = LdapRDN.parseNameComponent( chars, pos, rdn ) ) != DNUtils.PARSING_ERROR )
+ {
+ do
+ {
+ rdns.add( rdn.clone() );
+ rdn.clear();
+
+ if ( ( StringUtils.isCharASCII( chars, pos, ',' ) == false ) &&
+ ( StringUtils.isCharASCII( chars, pos, ';' ) == false ) )
+ {
+ break;
+ }
+
+ chars[pos] = ',';
+ pos++;
+
+ pos = StringUtils.trimLeft( chars, pos );
+ }
+ while ( ( pos = LdapRDN.parseNameComponent( chars, pos, rdn ) ) != DNUtils.PARSING_ERROR );
+ }
+ else
+ {
+ throw new InvalidNameException( "Bad DN : " + new String( chars ) );
+ }
+
+ name = new String( chars );
+ nameNormalized = normalize();
+ }
+
+ /**
+ * Parse a buffer and checks that it is a valid DN <br>
+ * <p>
+ * <distinguishedName> ::= <name> | e <br>
+ * <name> ::= <name-component> <name-components> <br>
+ * <name-components> ::= <spaces> <separator> <spaces> <name-component> <name-components> | e <br>
+ * </p>
+ *
+ * @param bytes The byte buffer that contains the DN
+ * @exception A DecoderException is thrown if the buffer does not contains a valid DN.
+ */
+ public LdapDN( byte[] bytes ) throws InvalidNameException
+ {
if ( bytes == null || bytes.length == 0)
{
return;
}
int pos = 0;
+ LdapRDN rdn = new LdapRDN();
// <name> ::= <name-component> <name-components>
// <name-components> ::= <spaces> <separator> <spaces> <name-component> <name-components> | e
- if ( ( pos = parseNameComponent( bytes, pos ) ) != -1 )
+ if ( ( pos = LdapRDN.parseNameComponent( bytes, pos, rdn ) ) != DNUtils.PARSING_ERROR )
{
-
do
{
+ rdns.add( rdn.clone() );
+ rdn.clear();
if ( ( StringUtils.isCharASCII( bytes, pos, ',' ) == false ) &&
- ( StringUtils.isCharASCII( bytes, pos, ';' ) == false ) )
+ ( StringUtils.isCharASCII( bytes, pos, ';' ) == false ) )
{
break;
@@ -105,15 +190,127 @@
bytes[pos] = ',';
pos++;
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
}
- while ( ( pos = parseNameComponent( bytes, pos ) ) != -1 );
+ while ( ( pos = LdapRDN.parseNameComponent( bytes, pos, rdn ) ) != DNUtils.PARSING_ERROR );
}
else
{
- throw new DecoderException( "Bad DN : " + new String( bytes) );
+ try
+ {
+ throw new InvalidNameException( "Bad DN : " + new String( bytes, "UTF-8" ) );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ throw new InvalidNameException( "Bad DN : " + StringUtils.dumpBytes( bytes ) );
+ }
+
+ }
+
+ try
+ {
+ name = new String( bytes, "UTF-8" );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ throw new InvalidNameException( "Bad LdapDN encoding : " + uee.getMessage() );
+ }
+
+ nameNormalized = normalize();
+ }
+
+ /**
+ * Normalize the DN by triming useless spaces and lowercasing names.
+ * @return a normalized form of the DN
+ */
+ private String normalize()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ if ( rdns == null )
+ {
+ return "";
}
+
+ Iterator elements = rdns.iterator();
+ boolean isFirst = true;
+
+ while ( elements.hasNext() )
+ {
+ LdapRDN rdn = (LdapRDN)elements.next();
+
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ sb.append(',');
+ }
+
+ sb.append( rdn );
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Return the DN as a String
+ * @return A String representing the DN
+ */
+ public String toString()
+ {
+ return name;
+ }
+
+ /**
+ * Get the initial DN (without normalization)
+ * @return The DN as a String
+ */
+ public String getName()
+ {
+ return name;
+ }
- setData(bytes);
+ /**
+ * Get the normalized DN
+ * @return The DN normalized as a String
+ */
+ public String getNameNormalized()
+ {
+ return nameNormalized;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int size()
+ {
+ return 0;
+ }
+
+ /**
+ * Get the number of bytes necessary to encode this UTF-8 String.
+ *
+ * @return A number of bytes
+ */
+ public int getLength()
+ {
+ try
+ {
+ if ( StringUtils.isNotEmpty( nameNormalized ) )
+ {
+ return nameNormalized.getBytes( "UTF-8" ).length;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ return 0;
+ }
}
}
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapString.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapString.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapString.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapString.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,10 @@
*/
package org.apache.asn1new.ldap.codec.primitives;
+import java.io.UnsupportedEncodingException;
+
+import javax.naming.InvalidNameException;
+
import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.util.MutableString;
@@ -58,6 +62,13 @@
return;
}
- setData(bytes);
+ try
+ {
+ setData(bytes);
+ }
+ catch ( UnsupportedEncodingException ine )
+ {
+ throw new DecoderException( "Incorrect LdapString given : " + ine.getMessage() );
+ }
}
}
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapURL.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapURL.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapURL.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapURL.java Sun Sep 25 18:04:43 2005
@@ -25,6 +25,7 @@
import org.apache.ldap.common.filter.FilterParserImpl;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.text.ParseException;
@@ -33,6 +34,7 @@
import java.util.HashSet;
import java.util.Iterator;
+import javax.naming.InvalidNameException;
import javax.naming.directory.SearchControls;
@@ -121,9 +123,9 @@
*
* @throws DecoderException If the String does not comply with RFC 2255
*/
- public LdapURL( String string ) throws DecoderException
+ public LdapURL( String string ) throws DecoderException, UnsupportedEncodingException
{
- this( string.getBytes() );
+ this( string.getBytes( "US-ASCII") );
}
/**
@@ -548,7 +550,7 @@
{
return -1;
}
- catch ( DecoderException de )
+ catch ( InvalidNameException ine )
{
return -1;
}
@@ -936,6 +938,11 @@
*/
private String urlEncode( String string, boolean doubleEncode)
{
+ if ( StringUtils.isEmpty( string ) )
+ {
+ return "";
+ }
+
StringBuffer sb = new StringBuffer();
for (int i = 0; i < string.length(); i++)
@@ -981,7 +988,6 @@
*/
public String toString()
{
-
StringBuffer sb = new StringBuffer( "ldap://" );
sb.append( ( host == null ) ? "" : host );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/RelativeLdapDN.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/RelativeLdapDN.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/RelativeLdapDN.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/RelativeLdapDN.java Sun Sep 25 18:04:43 2005
@@ -16,7 +16,11 @@
*/
package org.apache.asn1new.ldap.codec.primitives;
-import org.apache.asn1.codec.DecoderException;
+import java.io.UnsupportedEncodingException;
+
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+
import org.apache.asn1new.util.MutableString;
import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.utils.DNUtils;
@@ -59,33 +63,15 @@
/** "OID." static */
private static final byte[] OID_UPPER = new byte[] { 'O', 'I', 'D', '.' };
+ /** The internal Name representation of the RelativeLdapDN */
+ private Name rdn;
+
/** A null LdapDN */
public transient static final RelativeLdapDN EMPTY_STRING = new RelativeLdapDN();
-
+
//~ Methods ------------------------------------------------------------------------------------
/**
- * Walk the buffer while the current char is a Space char
- * <p>
- * <spaces> ::= ' ' <spaces> | e
- * </p>
- *
- * @param bytes The buffer to parse
- * @param pos The current position in the byte buffer
- * @return The new position in the byte buffer
- */
- protected static int parseSpaces( byte[] bytes, int pos )
- {
-
- while ( StringUtils.isCharASCII( bytes, pos, ' ' ) )
- {
- pos++;
- }
-
- return pos;
- }
-
- /**
* Parse this rule : <br>
* <p>
* <attributeValue> ::= <pairs-or-strings> | '#' <hexstring> |'"' <quotechar-or-pairs> '"' <br>
@@ -110,7 +96,7 @@
return -1;
}
- return parseSpaces( bytes, pos );
+ return StringUtils.trimLeft( bytes, pos );
}
else if ( StringUtils.isCharASCII( bytes, pos, '"' ) )
{
@@ -148,7 +134,7 @@
{
pos++;
- return parseSpaces( bytes, pos );
+ return StringUtils.trimLeft( bytes, pos );
}
else
{
@@ -184,7 +170,7 @@
// we MUST skip them.
if ( StringUtils.isCharASCII( bytes, pos, ' ') )
{
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
if ( ( DNUtils.isStringChar( bytes, pos ) == -1 ) &&
( StringUtils.isCharASCII( bytes, pos, '\\' ) == false ) )
@@ -304,7 +290,7 @@
* Parse this rule : <br>
* <p>
* <attributType> ::= [a-zA-Z] <keychars> |
- * <oidPrefix> [0-9] <digits> <oids> | [0-9] <digits> <oids>
+ * <oidPrefix> [0-9] <digits> <oids> | [0-9] <digits> <oids>
* </p>
*
* The string *MUST* be an ASCII string, not an unicode string.
@@ -317,21 +303,21 @@
{
// <attributType> ::= [a-zA-Z] <keychars> | <oidPrefix> [0-9] <digits> <oids> | [0-9] <digits> <oids>
-
+
if ( StringUtils.isAlphaASCII( bytes, pos ))
{
// <attributType> ::= [a-zA-Z] <keychars> | <oidPrefix> [0-9] <digits> <oids>
- // We have got an Alpha char, it may be the begining of an OID ?
+ // We have got an Alpha char, it may be the begining of an OID ?
int oldPos = pos;
-
+
if ( ( pos = parseOidPrefix( bytes, oldPos ) ) != -1 )
{
- return parseOidValue(bytes, pos);
- }
+ return parseOidValue(bytes, pos);
+ }
else
{
- // It's not an oid, it's a String (ASCII)
+ // It's not an oid, it's a String (ASCII)
// <attributType> ::= [a-zA-Z] <keychars>
// <keychars> ::= [a-zA-Z] <keychar> | [0-9] <keychar> | '-' <keychar> | e
pos = oldPos + 1;
@@ -349,7 +335,7 @@
// An oid
// <attributType> ::= [0-9] <digits> <oids>
- return parseOidValue(bytes, pos);
+ return parseOidValue(bytes, pos);
}
}
@@ -368,7 +354,7 @@
while ( true )
{
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
if ( StringUtils.isCharASCII( bytes, pos, '+' ) )
{
@@ -381,7 +367,7 @@
return pos;
}
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
if ( ( pos = parseAttributeType( bytes, pos ) ) == -1 )
{
@@ -389,7 +375,7 @@
return -1;
}
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
if ( StringUtils.isCharASCII( bytes, pos, '=' ) )
{
@@ -401,7 +387,7 @@
return -1;
}
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
return parseAttributeValue( bytes, pos );
}
@@ -426,7 +412,7 @@
return -1;
}
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
if ( StringUtils.isCharASCII( bytes, pos, '=' ) == false )
{
@@ -438,7 +424,7 @@
pos++;
}
- pos = parseSpaces( bytes, pos );
+ pos = StringUtils.trimLeft( bytes, pos );
if ( ( pos = parseAttributeValue( bytes, pos ) ) == -1 )
{
@@ -455,6 +441,7 @@
public RelativeLdapDN(int length, boolean isStreamed)
{
super(length, isStreamed);
+ rdn = null;
}
/**
@@ -463,6 +450,7 @@
public RelativeLdapDN()
{
super(0, false);
+ rdn = null;
}
/**
@@ -471,11 +459,11 @@
* @param bytes The byte buffer that contains the relative DN
* @exception A DecoderException is thrown if the buffer does not contains a valid relative DN.
*/
- public RelativeLdapDN( byte[] bytes ) throws DecoderException
+ public RelativeLdapDN( byte[] bytes ) throws InvalidNameException
{
-
if ( bytes == null || bytes.length == 0)
{
+ rdn = null;
return;
}
@@ -484,9 +472,16 @@
// Parse the name component
if ( ( pos = parseNameComponent( bytes, pos ) ) == -1 )
{
- throw new DecoderException( "Bad relative DN : " + new String( bytes) );
+ throw new InvalidNameException( "Bad relative DN : " + new String( bytes) );
}
- setData(bytes);
+ try
+ {
+ setData(bytes);
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ throw new InvalidNameException( "Bad relative DN : " + uee.getMessage() );
+ }
}
}
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.utils;
+import java.io.UnsupportedEncodingException;
+
import org.apache.asn1new.util.StringUtils;
/**
@@ -86,6 +88,37 @@
false, false, false, false, false, false, false, false
};
+ /** "oid." static */
+ public static final char[] OID_LOWER = new char[] { 'o', 'i', 'd', '.' };
+
+ /** "OID." static */
+ public static final char[] OID_UPPER = new char[] { 'O', 'I', 'D', '.' };
+
+ /** "oid." static */
+ public static final byte[] OID_LOWER_BYTES = new byte[] { 'o', 'i', 'd', '.' };
+
+ /** "OID." static */
+ public static final byte[] OID_UPPER_BYTES = new byte[] { 'O', 'I', 'D', '.' };
+
+ /** A value if we got an error while parsing */
+ public static final int PARSING_ERROR = -1;
+
+ /** If an hex pair contains only one char, this value is returned */
+ public static final int BAD_HEX_PAIR = -2;
+
+ /** A constant representing one char length */
+ public static final int ONE_CHAR = 1;
+
+ /** A constant representing two chars length */
+ public static final int TWO_CHARS = 2;
+
+ /** A constant representing one byte length */
+ public static final int ONE_BYTE = 1;
+
+ /** A constant representing two bytes length */
+ public static final int TWO_BYTES = 2;
+
+
//~ Methods ------------------------------------------------------------------------------------
/**
@@ -95,32 +128,32 @@
* <safe-chars> ::= <safe-char> <safe-chars> |
* <safe-char> ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F]
*
- * @param byteArray The buffer which contains the data
+ * @param charArray The buffer which contains the data
* @param index Current position in the buffer
*
* @return The position of the first character which is not a Safe Char
*/
- public static int parseSafeString( byte[] byteArray, int index )
+ public static int parseSafeString( char[] charArray, int index )
{
- if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
- ( index >= byteArray.length ) )
+ if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+ ( index >= charArray.length ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
- byte c = byteArray[index];
+ char c = charArray[index];
if ( ( c > 127 ) || ( SAFE_INIT_CHAR[c] == false ) )
{
- return -1;
+ return PARSING_ERROR;
}
index++;
- while ( index < byteArray.length )
+ while ( index < charArray.length )
{
- c = byteArray[index];
+ c = charArray[index];
if ( ( c > 127 ) || ( SAFE_CHAR[c] == false ) )
{
@@ -138,25 +171,25 @@
* Walk the buffer while characters are Alpha characters :
* <alpha> ::= [0x41-0x5A] | [0x61-0x7A]
*
- * @param byteArray The buffer which contains the data
+ * @param charArray The buffer which contains the data
* @param index Current position in the buffer
*
* @return The position of the first character which is not an Alpha Char
*/
- public static int parseAlphaASCII( byte[] byteArray, int index )
+ public static int parseAlphaASCII( char[] charArray, int index )
{
- if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
- ( index >= byteArray.length ) )
+ if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+ ( index >= charArray.length ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
- byte c = byteArray[index++];
+ char c = charArray[index++];
if ( ( c > 127 ) || ( StringUtils.ALPHA[c] == false ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
@@ -169,6 +202,44 @@
* Check if the current character is a Pair Char
* <pairchar> ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]
*
+ * @param charArray The buffer which contains the data
+ * @param index Current position in the buffer
+ *
+ * @return <code>true</code> if the current character is a Pair Char
+ */
+ public static boolean isPairChar( char[] charArray, int index )
+ {
+ if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+ ( index >= charArray.length ) )
+ {
+ return false;
+ }
+ else
+ {
+ char c = charArray[index];
+
+ if ( ( c > 127 ) || ( PAIR_CHAR[c] == false ) )
+ {
+ return false;
+ }
+ else
+ {
+ if ( StringUtils.isHex( charArray, index++ ) )
+ {
+ return StringUtils.isHex( charArray, index );
+ }
+ else
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if the current character is a Pair Char
+ * <pairchar> ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]
+ *
* @param byteArray The buffer which contains the data
* @param index Current position in the buffer
*
@@ -207,7 +278,48 @@
* Check if the current character is a String Char.
* Chars are Unicode, not ASCII.
* <stringchar> ::= [0x00-0xFFFF] - [,=+<>#;\"\n\r]
- * @param byteArray The buffer which contains the data
+ * @param charArray The buffer which contains the data
+ * @param index Current position in the buffer
+ *
+ * @return The current char if it is a String Char, or '#' (this is
+ * simpler than throwing an exception :)
+ */
+ public static int isStringChar( char[] charArray, int index )
+ {
+ if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+ ( index >= charArray.length ) )
+ {
+ return PARSING_ERROR;
+ }
+ else
+ {
+ char c = charArray[index];
+
+ if ( ( c == 0x0A ) ||
+ ( c == 0x0D ) ||
+ ( c == '"' ) ||
+ ( c == '#' ) ||
+ ( c == '+' ) ||
+ ( c == ',' ) ||
+ ( c == ';' ) ||
+ ( c == '<' ) ||
+ ( c == '=' ) ||
+ ( c == '>' ) )
+ {
+ return PARSING_ERROR;
+ }
+ else
+ {
+ return ONE_CHAR;
+ }
+ }
+ }
+
+ /**
+ * Check if the current character is a String Char.
+ * Chars are Unicode, not ASCII.
+ * <stringchar> ::= [0x00-0xFFFF] - [,=+<>#;\"\n\r]
+ * @param charArray The buffer which contains the data
* @param index Current position in the buffer
*
* @return The current char if it is a String Char, or '#' (this is
@@ -218,7 +330,7 @@
if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
( index >= byteArray.length ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
@@ -235,11 +347,50 @@
( c == '=' ) ||
( c == '>' ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
- return StringUtils.countBytesPerChar(byteArray, index);
+ try
+ {
+ return StringUtils.countBytesPerChar( byteArray, index );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ return PARSING_ERROR;
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if the current character is a Quote Char
+ * We are testing Unicode chars
+ * <quotechar> ::= [0x00-0xFFFF] - [\"]
+ *
+ * @param charArray The buffer which contains the data
+ * @param index Current position in the buffer
+ *
+ * @return <code>true</code> if the current character is a Quote Char
+ */
+ public static int isQuoteChar( char[] charArray, int index )
+ {
+ if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+ ( index >= charArray.length ) )
+ {
+ return PARSING_ERROR;
+ }
+ else
+ {
+ char c = charArray[index];
+
+ if ( ( c == '\\' ) || ( c == '"' ) )
+ {
+ return PARSING_ERROR;
+ }
+ else
+ {
+ return ONE_CHAR;
}
}
}
@@ -259,7 +410,7 @@
if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
( index >= byteArray.length ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
@@ -267,11 +418,11 @@
if ( ( c == '\\' ) || ( c == '"' ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
- return StringUtils.countBytesPerChar(byteArray, index);
+ return ONE_BYTE;
}
}
}
@@ -280,6 +431,35 @@
* Parse an hex pair
* <hexpair> ::= <hex> <hex>
*
+ * @param charArray The buffer which contains the data
+ * @param index Current position in the buffer
+ *
+ * @return The new position, -1 if the buffer does not contain an HexPair, -2 if the
+ * buffer contains an hex byte but not two.
+ */
+ public static int parseHexPair( char[] charArray, int index )
+ {
+ if ( StringUtils.isHex( charArray, index ) )
+ {
+ if ( StringUtils.isHex( charArray, index + 1 ) )
+ {
+ return index + TWO_CHARS;
+ }
+ else
+ {
+ return BAD_HEX_PAIR;
+ }
+ }
+ else
+ {
+ return PARSING_ERROR;
+ }
+ }
+
+ /**
+ * Parse an hex pair
+ * <hexpair> ::= <hex> <hex>
+ *
* @param byteArray The buffer which contains the data
* @param index Current position in the buffer
*
@@ -292,16 +472,16 @@
{
if ( StringUtils.isHex( byteArray, index + 1 ) )
{
- return index + 2;
+ return index + TWO_CHARS;
}
else
{
- return -2;
+ return BAD_HEX_PAIR;
}
}
else
{
- return -1;
+ return PARSING_ERROR;
}
}
@@ -310,6 +490,38 @@
* <hexstring> ::= <hexpair> <hexpairs>
* <hexpairs> ::= <hexpair> <hexpairs> | e
*
+ * @param charArray The buffer which contains the data
+ * @param index Current position in the buffer
+ *
+ * @return Return the first position which is not an hex pair, or -1 if there is no
+ * hexpair at the beginning or if an hexpair is invalid (if we have only one hex instead of 2)
+ */
+ public static int parseHexString( char[] charArray, int index )
+ {
+ int result = parseHexPair( charArray, index );
+
+ if ( result < 0 )
+ {
+ return PARSING_ERROR;
+ }
+ else
+ {
+ index += TWO_CHARS;
+ }
+
+ while ( ( result = parseHexPair( charArray, index ) ) >= 0 )
+ {
+ index += TWO_CHARS;
+ }
+
+ return ( ( result == BAD_HEX_PAIR ) ? PARSING_ERROR : index );
+ }
+
+ /**
+ * Parse an hex string, which is a list of hex pairs
+ * <hexstring> ::= <hexpair> <hexpairs>
+ * <hexpairs> ::= <hexpair> <hexpairs> | e
+ *
* @param byteArray The buffer which contains the data
* @param index Current position in the buffer
*
@@ -322,19 +534,19 @@
if ( result < 0 )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
- index += 2;
+ index += TWO_CHARS;
}
while ( ( result = parseHexPair( byteArray, index ) ) >= 0 )
{
- index += 2;
+ index += TWO_CHARS;
}
- return ( ( result == -2 ) ? -1 : index );
+ return ( ( result == BAD_HEX_PAIR ) ? PARSING_ERROR : index );
}
/**
@@ -343,32 +555,32 @@
* <base64-chars> ::= <base64-char> <base64-chars> |
* <base64-char> ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A]
*
- * @param byteArray The buffer which contains the data
+ * @param charArray The buffer which contains the data
* @param index Current position in the buffer
*
* @return The position of the first character which is not a Base64 Char
*/
- public static int parseBase64String( byte[] byteArray, int index )
+ public static int parseBase64String( char[] charArray, int index )
{
- if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
- ( index >= byteArray.length ) )
+ if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+ ( index >= charArray.length ) )
{
- return -1;
+ return PARSING_ERROR;
}
else
{
- byte c = byteArray[index];
+ char c = charArray[index];
if ( ( c > 127 ) || ( BASE64_CHAR[c] == false ) )
{
- return -1;
+ return PARSING_ERROR;
}
index++;
- while ( index < byteArray.length )
+ while ( index < charArray.length )
{
- c = byteArray[index];
+ c = charArray[index];
if ( ( c > 127 ) || ( BASE64_CHAR[c] == false ) )
{
@@ -381,5 +593,4 @@
return index;
}
}
-
}
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java Sun Sep 25 18:04:43 2005
@@ -317,7 +317,7 @@
buffer.put( Length.getBytes( addRequestLength ) ) ;
// The entry
- Value.encode( buffer, entry );
+ Value.encode( buffer, entry.getNameNormalized() );
// The attributes sequence
buffer.put( UniversalTag.SEQUENCE_TAG );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java Sun Sep 25 18:04:43 2005
@@ -235,7 +235,7 @@
Value.encode( buffer, version );
// The name
- Value.encode( buffer, name );
+ Value.encode( buffer, name.getNameNormalized() );
// The authentication
authentication.encode( buffer );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java Sun Sep 25 18:04:43 2005
@@ -211,7 +211,7 @@
buffer.put( Length.getBytes( compareRequestLength ) ) ;
// The entry
- Value.encode( buffer, entry );
+ Value.encode( buffer, entry.getNameNormalized() );
// The attributeValueAssertion sequence Tag
buffer.put( UniversalTag.SEQUENCE_TAG );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,7 @@
*/
package org.apache.asn1new.ldap.pojo;
+import java.io.UnsupportedEncodingException;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
@@ -121,11 +122,15 @@
// The entry
buffer.put( Length.getBytes( entry.getLength() ) );
- buffer.put( entry.getData() );
+ buffer.put( entry.getNameNormalized().getBytes( "UTF-8" ) );
}
catch ( BufferOverflowException boe )
{
throw new EncoderException("The PDU buffer size is too small !");
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ throw new EncoderException("The entry is not UTF-8 encoded !");
}
return buffer;
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java Sun Sep 25 18:04:43 2005
@@ -282,7 +282,7 @@
}
// The matchedDN
- Value.encode( buffer, matchedDN);
+ Value.encode( buffer, matchedDN.toString() );
// The error message
Value.encode( buffer, errorMessage);
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java Sun Sep 25 18:04:43 2005
@@ -16,6 +16,7 @@
*/
package org.apache.asn1new.ldap.pojo;
+import java.io.UnsupportedEncodingException;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
@@ -221,7 +222,7 @@
buffer.put( Length.getBytes( modifyDNRequestLength ) ) ;
// The entry
- Value.encode( buffer, entry );
+ Value.encode( buffer, entry.getNameNormalized() );
// The newRDN
Value.encode( buffer, newRDN );
@@ -238,13 +239,17 @@
if ( newSuperior.getLength() != 0 )
{
- buffer.put( newSuperior.getData() );
+ buffer.put( newSuperior.getNameNormalized().getBytes( "UTF-8" ) );
}
}
}
catch ( BufferOverflowException boe )
{
throw new EncoderException("The PDU buffer size is too small !");
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ throw new EncoderException("The entry is not UTF-8 encoded !");
}
return buffer;
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java Sun Sep 25 18:04:43 2005
@@ -387,7 +387,7 @@
buffer.put( Length.getBytes( modifyRequestLength ) ) ;
// The entry
- Value.encode( buffer, object );
+ Value.encode( buffer, object.getNameNormalized() );
// The modifications sequence
buffer.put( UniversalTag.SEQUENCE_TAG );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java Sun Sep 25 18:04:43 2005
@@ -403,7 +403,7 @@
buffer.put( Length.getBytes( searchRequestLength ) ) ;
// The baseObject
- Value.encode( buffer, baseObject );
+ Value.encode( buffer, baseObject.getNameNormalized() );
// The scope
Value.encodeEnumerated( buffer, scope );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java Sun Sep 25 18:04:43 2005
@@ -338,7 +338,7 @@
buffer.put( Length.getBytes( searchResultEntryLength ) ) ;
// The objectName
- Value.encode( buffer, objectName );
+ Value.encode( buffer, objectName.getNameNormalized() );
// The attributes sequence
buffer.put( UniversalTag.SEQUENCE_TAG );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java Sun Sep 25 18:04:43 2005
@@ -50,17 +50,17 @@
{
Asn1Decoder ldapDecoder = new LdapDecoder();
- ByteBuffer stream = ByteBuffer.allocate( 0x5B );
+ ByteBuffer stream = ByteBuffer.allocate( 0x59 );
stream.put(
new byte[]
{
- 0x30, 0x59, // LDAPMessage ::= SEQUENCE {
+ 0x30, 0x57, // LDAPMessage ::= SEQUENCE {
0x02, 0x01, 0x01, // messageID MessageID
- 0x68, 0x54, // CHOICE { ..., addRequest AddRequest, ...
+ 0x68, 0x52, // CHOICE { ..., addRequest AddRequest, ...
// AddRequest ::= [APPLICATION 8] SEQUENCE {
// entry LDAPDN,
- 0x04, 0x22, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', ' ', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', ' ', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
// attributes AttributeList }
0x30, 0x2E, // AttributeList ::= SEQUENCE OF SEQUENCE {
0x30, 0x0c, // attribute 1
@@ -99,7 +99,7 @@
// Check the decoded message
Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( "cn=testModify, ou=users, ou=system", addRequest.getEntry() );
+ Assert.assertEquals( "cn=testModify,ou=users,ou=system", addRequest.getEntry() );
Attributes attributes = addRequest.getAttributes();
@@ -155,7 +155,7 @@
}
// Check the length
- Assert.assertEquals(0x5B, message.computeLength());
+ Assert.assertEquals(0x59, message.computeLength());
// Check the encoding
try
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java Sun Sep 25 18:04:43 2005
@@ -196,7 +196,7 @@
Assert.assertEquals( 1, message.getMessageId() );
Assert.assertEquals( 3, br.getVersion() );
- Assert.assertEquals( "", br.getName() );
+ Assert.assertEquals( null, br.getName() );
Assert.assertEquals( true, ( br.getAuthentication() instanceof SimpleAuthentication ) );
Assert.assertEquals( "password", ( ( (SimpleAuthentication)br.getAuthentication() ).getSimple().toString() ) );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/CompareRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/CompareRequestTest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/CompareRequestTest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/CompareRequestTest.java Sun Sep 25 18:04:43 2005
@@ -45,17 +45,17 @@
{
Asn1Decoder ldapDecoder = new LdapDecoder();
- ByteBuffer stream = ByteBuffer.allocate( 0x3A );
+ ByteBuffer stream = ByteBuffer.allocate( 0x38 );
stream.put(
new byte[]
{
- 0x30, 0x38, // LDAPMessage ::= SEQUENCE {
+ 0x30, 0x36, // LDAPMessage ::= SEQUENCE {
0x02, 0x01, 0x01, // messageID MessageID
// CHOICE { ..., compareRequest CompareRequest, ...
- 0x6E, 0x33, // CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ 0x6E, 0x31, // CompareRequest ::= [APPLICATION 14] SEQUENCE {
// entry LDAPDN,
- 0x04, 0x22, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', ' ', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', ' ', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
// ava AttributeValueAssertion }
0x30, 0x0D, // AttributeValueAssertion ::= SEQUENCE {
// attributeDesc AttributeDescription,
@@ -86,12 +86,12 @@
CompareRequest compareRequest = message.getCompareRequest();
Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( "cn=testModify, ou=users, ou=system", compareRequest.getEntry() );
+ Assert.assertEquals( "cn=testModify,ou=users,ou=system", compareRequest.getEntry() );
Assert.assertEquals( "test", compareRequest.getAttributeDesc() );
Assert.assertEquals( "value", compareRequest.getAssertionValue().toString() );
// Check the length
- Assert.assertEquals(0x3A, message.computeLength());
+ Assert.assertEquals(0x38, message.computeLength());
// Check the encoding
try
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/DelRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/DelRequestTest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/DelRequestTest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/DelRequestTest.java Sun Sep 25 18:04:43 2005
@@ -44,18 +44,18 @@
{
Asn1Decoder ldapDecoder = new LdapDecoder();
- ByteBuffer stream = ByteBuffer.allocate( 0x29 );
+ ByteBuffer stream = ByteBuffer.allocate( 0x27 );
stream.put(
new byte[]
{
- 0x30, 0x27, // LDAPMessage ::= SEQUENCE {
+ 0x30, 0x25, // LDAPMessage ::= SEQUENCE {
0x02, 0x01, 0x01, // messageID MessageID
// CHOICE { ..., delRequest DelRequest, ...
// DelRequest ::= [APPLICATION 10] LDAPDN;
- 0x4A, 0x22, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', ' ', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', ' ', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm'
+ 0x4A, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm'
} );
String decodedPdu = StringUtils.dumpBytes( stream.array() );
@@ -80,10 +80,10 @@
DelRequest delRequest = message.getDelRequest();
Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( "cn=testModify, ou=users, ou=system", delRequest.getEntry() );
+ Assert.assertEquals( "cn=testModify,ou=users,ou=system", delRequest.getEntry() );
// Check the length
- Assert.assertEquals(0x29, message.computeLength());
+ Assert.assertEquals(0x27, message.computeLength());
// Check the encoding
try
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyDNRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyDNRequestTest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyDNRequestTest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyDNRequestTest.java Sun Sep 25 18:04:43 2005
@@ -44,19 +44,19 @@
{
Asn1Decoder ldapDecoder = new LdapDecoder();
- ByteBuffer stream = ByteBuffer.allocate( 0x4A );
+ ByteBuffer stream = ByteBuffer.allocate( 0x48 );
stream.put(
new byte[]
{
- 0x30, 0x48, // LDAPMessage ::= SEQUENCE {
+ 0x30, 0x46, // LDAPMessage ::= SEQUENCE {
0x02, 0x01, 0x01, // messageID MessageID
- 0x6C, 0x43, // CHOICE { ..., modifyDNRequest ModifyDNRequest, ...
+ 0x6C, 0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest, ...
// ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
// entry LDAPDN,
- 0x04, 0x22, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', ' ', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', ' ', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
// newrdn RelativeLDAPDN,
0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y',
0x01, 0x01, 0x00, // deleteoldrdn BOOLEAN,
@@ -84,13 +84,13 @@
ModifyDNRequest modifyDNRequest = message.getModifyDNRequest();
Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( "cn=testModify, ou=users, ou=system", modifyDNRequest.getEntry() );
+ Assert.assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry() );
Assert.assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
Assert.assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN() );
Assert.assertEquals( "ou=system", modifyDNRequest.getNewSuperior() );
// Check the length
- Assert.assertEquals(0x4A, message.computeLength());
+ Assert.assertEquals(0x48, message.computeLength());
// Check the encoding
try
@@ -115,19 +115,19 @@
{
Asn1Decoder ldapDecoder = new LdapDecoder();
- ByteBuffer stream = ByteBuffer.allocate( 0x3F );
+ ByteBuffer stream = ByteBuffer.allocate( 0x3D );
stream.put(
new byte[]
{
- 0x30, 0x3D, // LDAPMessage ::= SEQUENCE {
+ 0x30, 0x3B, // LDAPMessage ::= SEQUENCE {
0x02, 0x01, 0x01, // messageID MessageID
- 0x6C, 0x38, // CHOICE { ..., modifyDNRequest ModifyDNRequest, ...
+ 0x6C, 0x36, // CHOICE { ..., modifyDNRequest ModifyDNRequest, ...
// ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
// entry LDAPDN,
- 0x04, 0x22, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', ' ', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', ' ', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
// newrdn RelativeLDAPDN,
0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y',
0x01, 0x01, 0x00 // deleteoldrdn BOOLEAN,
@@ -154,12 +154,12 @@
ModifyDNRequest modifyDNRequest = message.getModifyDNRequest();
Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( "cn=testModify, ou=users, ou=system", modifyDNRequest.getEntry() );
+ Assert.assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry() );
Assert.assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
Assert.assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN() );
// Check the length
- Assert.assertEquals(0x3F, message.computeLength());
+ Assert.assertEquals(0x3D, message.computeLength());
// Check the encoding
try
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyRequestTest.java?rev=291503&r1=291502&r2=291503&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyRequestTest.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/test/org/apache/asn1new/ldap/codec/ModifyRequestTest.java Sun Sep 25 18:04:43 2005
@@ -51,19 +51,19 @@
{
Asn1Decoder ldapDecoder = new LdapDecoder();
- ByteBuffer stream = ByteBuffer.allocate( 0x56 );
+ ByteBuffer stream = ByteBuffer.allocate( 0x54 );
stream.put(
new byte[]
{
- 0x30, 0x54, // LDAPMessage ::= SEQUENCE {
+ 0x30, 0x52, // LDAPMessage ::= SEQUENCE {
0x02, 0x01, 0x01, // messageID MessageID
- 0x66, 0x4f, // CHOICE { ..., modifyRequest ModifyRequest, ...
+ 0x66, 0x4D, // CHOICE { ..., modifyRequest ModifyRequest, ...
// ModifyRequest ::= [APPLICATION 6] SEQUENCE {
// object LDAPDN,
- 0x04, 0x22, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', ' ', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', ' ', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u', 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
0x30, 0x29, // modification SEQUENCE OF SEQUENCE {
0x30, 0x11,
0x0A, 0x01, 0x02, // operation ENUMERATED {
@@ -110,7 +110,7 @@
ModifyRequest modifyRequest = message.getModifyRequest();
Assert.assertEquals( 1, message.getMessageId() );
- Assert.assertEquals( "cn=testModify, ou=users, ou=system", modifyRequest.getObject() );
+ Assert.assertEquals( "cn=testModify,ou=users,ou=system", modifyRequest.getObject() );
ArrayList modifications = modifyRequest.getModifications();
@@ -149,7 +149,7 @@
}
// Check the length
- Assert.assertEquals(0x56, message.computeLength());
+ Assert.assertEquals(0x54, message.computeLength());
// Check the encoding
try