From commits-return-10549-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Sun Oct 01 23:08:35 2006 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 53270 invoked from network); 1 Oct 2006 23:08:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Oct 2006 23:08:31 -0000 Received: (qmail 75913 invoked by uid 500); 1 Oct 2006 23:08:21 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 75846 invoked by uid 500); 1 Oct 2006 23:08:21 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 75606 invoked by uid 99); 1 Oct 2006 23:08:20 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Oct 2006 16:08:20 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received: from [140.211.166.113] ([140.211.166.113:50671] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 1B/89-05102-D4A40254 for ; Sun, 01 Oct 2006 16:07:58 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 9B4451A9820; Sun, 1 Oct 2006 16:07:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r451836 [3/11] - in /directory/branches/shared/0.9.5/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/abandon/ main/java/org/apache/directory/shared/ldap/codec/actions/ main/java/o... Date: Sun, 01 Oct 2006 23:07:49 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061001230754.9B4451A9820@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java?view=diff&rev=451836&r1=451835&r2=451836 ============================================================================== --- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java (original) +++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponse.java Sun Oct 1 16:07:44 2006 @@ -71,8 +71,7 @@ /** * Set the ldap result * - * @param ldapResult - * The ldapResult to set. + * @param ldapResult The ldapResult to set. */ public void setLdapResult( LdapResult ldapResult ) { @@ -103,8 +102,7 @@ /** * Encode the AddResponse message to a PDU. * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java?view=diff&rev=451836&r1=451835&r2=451836 ============================================================================== --- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java (original) +++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java Sun Oct 1 16:07:44 2006 @@ -21,14 +21,14 @@ import org.apache.directory.shared.asn1.Asn1Object; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.ber.tlv.UniversalTag; import org.apache.directory.shared.asn1.ber.tlv.Value; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.util.LdapResultEnum; -import org.apache.directory.shared.ldap.codec.util.LdapString; import org.apache.directory.shared.ldap.codec.util.LdapURL; import org.apache.directory.shared.ldap.name.LdapDN; +import org.apache.directory.shared.ldap.util.StringTools; import java.nio.BufferOverflowException; import java.nio.ByteBuffer; @@ -47,25 +47,55 @@ // ---------------------------------------------------------------------------- /** - * The result code. The different values are : success (0), operationsError - * (1), protocolError (2), timeLimitExceeded (3), sizeLimitExceeded (4), - * compareFalse (5), compareTrue (6), authMethodNotSupported (7), - * strongAuthRequired (8), -- 9 reserved -- referral (10), -- new - * adminLimitExceeded (11), -- new unavailableCriticalExtension (12), -- new - * confidentialityRequired (13), -- new saslBindInProgress (14), -- new - * noSuchAttribute (16), undefinedAttributeType (17), inappropriateMatching - * (18), constraintViolation (19), attributeOrValueExists (20), - * invalidAttributeSyntax (21), -- 22-31 unused -- noSuchObject (32), - * aliasProblem (33), invalidDNSyntax (34), -- 35 reserved for undefined - * isLeaf -- aliasDereferencingProblem (36), -- 37-47 unused -- - * inappropriateAuthentication (48), invalidCredentials (49), - * insufficientAccessRights (50), busy (51), unavailable (52), - * unwillingToPerform (53), loopDetect (54), -- 55-63 unused -- - * namingViolation (64), objectClassViolation (65), notAllowedOnNonLeaf - * (66), notAllowedOnRDN (67), entryAlreadyExists (68), - * objectClassModsProhibited (69), -- 70 reserved for CLDAP -- - * affectsMultipleDSAs (71), -- new -- 72-79 unused -- other (80) }, -- - * 81-90 reserved for APIs -- + * The result code. The different values are : + * + * success (0), + * operationsError (1), + * protocolError (2), + * timeLimitExceeded (3), + * sizeLimitExceeded (4), + * compareFalse (5), + * compareTrue (6), + * authMethodNotSupported (7), + * strongAuthRequired (8), + * -- 9 reserved -- + * referral (10), -- new + * adminLimitExceeded (11), -- new + * unavailableCriticalExtension (12), -- new + * confidentialityRequired (13), -- new + * saslBindInProgress (14), -- new + * noSuchAttribute (16), + * undefinedAttributeType (17), + * inappropriateMatching (18), + * constraintViolation (19), + * attributeOrValueExists (20), + * invalidAttributeSyntax (21), + * -- 22-31 unused -- + * noSuchObject (32), + * aliasProblem (33), + * invalidDNSyntax (34), + * -- 35 reserved for undefined isLeaf -- + * aliasDereferencingProblem (36), + * -- 37-47 unused -- + * inappropriateAuthentication (48), + * invalidCredentials (49), + * insufficientAccessRights (50), + * busy (51), + * unavailable (52), + * unwillingToPerform (53), + * loopDetect (54), + * -- 55-63 unused -- + * namingViolation (64), + * objectClassViolation (65), + * notAllowedOnNonLeaf (66), + * notAllowedOnRDN (67), + * entryAlreadyExists (68), + * objectClassModsProhibited (69), + * -- 70 reserved for CLDAP -- + * affectsMultipleDSAs (71), -- new + * -- 72-79 unused -- + * other (80) + * } -- 81-90 reserved for APIs -- */ private int resultCode; @@ -73,7 +103,10 @@ private LdapDN matchedDN; /** The error message */ - private LdapString errorMessage; + private String errorMessage; + + /** Temporary storage for message bytes */ + private transient byte[] errorMessageBytes; /** The referrals, if any. This is an optional element */ private ArrayList referrals; @@ -90,7 +123,6 @@ */ public LdapResult() { - referrals = new ArrayList(); } @@ -98,23 +130,30 @@ // ------------------------------------------------------------------------------------ /** + * Initialize the referrals list + */ + public void initReferrals() + { + referrals = new ArrayList(); + } + + /** * Get the error message * * @return Returns the errorMessage. */ public String getErrorMessage() { - return ( ( errorMessage == null ) ? null : errorMessage.getString() ); + return errorMessage; } /** * Set the error message * - * @param errorMessage - * The errorMessage to set. + * @param errorMessage The errorMessage to set. */ - public void setErrorMessage( LdapString errorMessage ) + public void setErrorMessage( String errorMessage ) { this.errorMessage = errorMessage; } @@ -134,8 +173,7 @@ /** * Set the Matched DN * - * @param matchedDN - * The matchedDN to set. + * @param matchedDN The matchedDN to set. */ public void setMatchedDN( LdapDN matchedDN ) { @@ -157,8 +195,7 @@ /** * Add a referral * - * @param referral - * The referral to add. + * @param referral The referral to add. */ public void addReferral( LdapURL referral ) { @@ -180,8 +217,7 @@ /** * Set the result code * - * @param resultCode - * The resultCode to set. + * @param resultCode The resultCode to set. */ public void setResultCode( int resultCode ) { @@ -190,15 +226,28 @@ /** - * Compute the LdapResult length LdapResult : 0x0A 01 resultCode (0..80) - * 0x04 L1 matchedDN (L1 = Length(matchedDN)) 0x04 L2 errorMessage (L2 = - * Length(errorMessage)) [0x83 L3] referrals | +--> 0x04 L4 referral +--> - * 0x04 L5 referral +--> ... +--> 0x04 Li referral +--> ... +--> 0x04 Ln - * referral L1 = Length(matchedDN) L2 = Length(errorMessage) L3 = - * n*Length(0x04) + sum(Length(L4) .. Length(Ln)) + sum(L4..Ln) L4..n = - * Length(0x04) + Length(Li) + Li Length(LdapResult) = Length(0x0x0A) + - * Length(0x01) + 1 + Length(0x04) + Length(L1) + L1 + Length(0x04) + - * Length(L2) + L2 + Length(0x83) + Length(L3) + L3 + * Compute the LdapResult length + * + * LdapResult : + * 0x0A 01 resultCode (0..80) + * 0x04 L1 matchedDN (L1 = Length(matchedDN)) + * 0x04 L2 errorMessage (L2 = Length(errorMessage)) + * [0x83 L3] referrals + * | + * +--> 0x04 L4 referral + * +--> 0x04 L5 referral + * +--> ... + * +--> 0x04 Li referral + * +--> ... + * +--> 0x04 Ln referral + * + * L1 = Length(matchedDN) + * L2 = Length(errorMessage) + * L3 = n*Length(0x04) + sum(Length(L4) .. Length(Ln)) + sum(L4..Ln) + * L4..n = Length(0x04) + Length(Li) + Li + * Length(LdapResult) = Length(0x0x0A) + + * Length(0x01) + 1 + Length(0x04) + Length(L1) + L1 + Length(0x04) + + * Length(L2) + L2 + Length(0x83) + Length(L3) + L3 */ public int computeLength() { @@ -214,11 +263,12 @@ } else { - ldapResultLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( matchedDN ) ) + LdapDN.getNbBytes( matchedDN ); + ldapResultLength += 1 + TLV.getNbBytes( LdapDN.getNbBytes( matchedDN ) ) + LdapDN.getNbBytes( matchedDN ); } // The errorMessage length - ldapResultLength += 1 + Length.getNbBytes( errorMessage.getNbBytes() ) + errorMessage.getNbBytes(); + errorMessageBytes = StringTools.getBytesUtf8( errorMessage ); + ldapResultLength += 1 + TLV.getNbBytes( errorMessageBytes.length ) + errorMessageBytes.length; if ( ( referrals != null ) && ( referrals.size() != 0 ) ) { @@ -231,11 +281,11 @@ { LdapURL referral = ( LdapURL ) referralIterator.next(); - referralsLength += 1 + Length.getNbBytes( referral.getNbBytes() ) + referral.getNbBytes(); + referralsLength += 1 + TLV.getNbBytes( referral.getNbBytes() ) + referral.getNbBytes(); } // The referrals - ldapResultLength += 1 + Length.getNbBytes( referralsLength ) + referralsLength; + ldapResultLength += 1 + TLV.getNbBytes( referralsLength ) + referralsLength; } return ldapResultLength; @@ -245,8 +295,7 @@ /** * Encode the LdapResult message to a PDU. * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -272,7 +321,7 @@ Value.encode( buffer, LdapDN.getBytes( matchedDN ) ); // The error message - Value.encode( buffer, errorMessage.getBytes() ); + Value.encode( buffer, errorMessageBytes ); // The referrals, if any if ( ( referrals != null ) && ( referrals.size() != 0 ) ) @@ -280,7 +329,7 @@ // Encode the referrals sequence // The referrals length MUST have been computed before ! buffer.put( ( byte ) LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG ); - buffer.put( Length.getBytes( referralsLength ) ); + buffer.put( TLV.getBytes( referralsLength ) ); // Each referral Iterator referralIterator = referrals.iterator();