directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r559645 - in /directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec: ./ actions/ util/
Date Wed, 25 Jul 2007 23:11:30 GMT
Author: elecharny
Date: Wed Jul 25 16:11:28 2007
New Revision: 559645

URL: http://svn.apache.org/viewvc?view=rev&rev=559645
Log:
Fixed the way Strings were created not using UTF-8 (DIRSERVER-1009) in many places

Modified:
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/AttributeDescAction.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescFilterAction.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
Wed Jul 25 16:11:28 2007
@@ -768,7 +768,7 @@
                     }
                     else
                     {
-                        authentication.setMechanism( new String( tlv.getValue().getData()
) );
+                        authentication.setMechanism( StringTools.utf8ToString( tlv.getValue().getData()
) );
                     }
 
                     // We can have an END transition
@@ -1279,7 +1279,7 @@
                     }
                     else
                     {
-                        type = new String( tlv.getValue().getData() );
+                        type = StringTools.utf8ToString( tlv.getValue().getData() );
                         searchResultEntry.addAttributeValues( type );
                     }
 
@@ -1660,7 +1660,7 @@
                     }
                     else
                     {
-                        type = new String( tlv.getValue().getData() );
+                        type = StringTools.utf8ToString( tlv.getValue().getData() );
                         modifyRequest.addAttributeTypeAndValues( type );
                     }
 
@@ -2013,7 +2013,7 @@
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDATTRIBUTESYNTAX,
addRequest.getEntry(), null );
                     }
 
-                    String type = new String( tlv.getValue().getData() );
+                    String type = StringTools.utf8ToString( tlv.getValue().getData() );
 
                     addRequest.addAttributeType( type );
 
@@ -2676,7 +2676,7 @@
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALIDATTRIBUTESYNTAX,
compareRequest.getEntry(), null );
                     }
 
-                    String type = new String( tlv.getValue().getData() );
+                    String type = StringTools.utf8ToString( tlv.getValue().getData() );
                     compareRequest.setAttributeDesc( type );
 
                     if ( IS_DEBUG )
@@ -4952,7 +4952,7 @@
                     }
                     else
                     {
-                        String type = new String( tlv.getValue().getData() );
+                        String type = StringTools.utf8ToString( tlv.getValue().getData()
);
                         substringFilter.setType( type );
 
                         // We now have to get back to the nearest filter which
@@ -5025,7 +5025,7 @@
                         throw new DecoderException( "The substring initial filter is empty"
);
                     }
 
-                    substringFilter.setInitialSubstrings( new String( tlv.getValue().getData()
) );
+                    substringFilter.setInitialSubstrings( StringTools.utf8ToString( tlv.getValue().getData()
) );
 
                     // We now have to get back to the nearest filter which is
                     // not terminal.
@@ -5958,7 +5958,7 @@
                     }
                     else
                     {
-                        extensibleMatchFilter.setMatchingRule( new String( tlv.getValue().getData()
) );
+                        extensibleMatchFilter.setMatchingRule( StringTools.utf8ToString(
tlv.getValue().getData() ) );
                     }
                 }
             } );

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
Wed Jul 25 16:11:28 2007
@@ -108,6 +108,7 @@
 import org.apache.directory.shared.ldap.message.extended.GracefulShutdownRequest;
 import org.apache.directory.shared.ldap.message.spi.Provider;
 import org.apache.directory.shared.ldap.message.spi.TransformerSpi;
+import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -878,7 +879,7 @@
         }
         else
         {
-            twixLdapResult.setErrorMessage( new String( snickersLdapResult.getErrorMessage().getBytes()
) );
+            twixLdapResult.setErrorMessage( errorMessage );
         }
 
         // Snickers : String matchedDn -> Twix : LdapDN matchedDN
@@ -1255,7 +1256,7 @@
             twixControl.setCriticality( control.isCritical() );
             twixControl.setControlValue( control.getEncodedValue() );
             twixControl.setEncodedValue( control.getEncodedValue() );
-            twixControl.setControlType( new String( Asn1StringUtils.getBytesUtf8( control.getID()
) ) );
+            twixControl.setControlType( control.getID() );
             twixControl.setParent( twixMessage );
         }
     }

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/AttributeDescAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/AttributeDescAction.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/AttributeDescAction.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/AttributeDescAction.java
Wed Jul 25 16:11:28 2007
@@ -26,6 +26,7 @@
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -73,7 +74,7 @@
             value = tlv.getValue().getData();
         }
 
-        attributeDescription = new String( value );
+        attributeDescription = StringTools.utf8ToString( value );
         searchRequest.addAttribute( attributeDescription );
 
         // We can have an END transition

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescFilterAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescFilterAction.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescFilterAction.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAttributeDescFilterAction.java
Wed Jul 25 16:11:28 2007
@@ -29,6 +29,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -72,7 +73,7 @@
         }
         else
         {
-            String type = new String( tlv.getValue().getData() );
+            String type = StringTools.utf8ToString( tlv.getValue().getData() );
             assertion.setAttributeDesc( type );
 
             AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter
) searchRequest

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ReferralAction.java
Wed Jul 25 16:11:28 2007
@@ -33,6 +33,7 @@
 import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -82,7 +83,7 @@
                 }
                 catch ( LdapURLEncodingException luee )
                 {
-                    String badUrl = new String( tlv.getValue().getData() );
+                    String badUrl = StringTools.utf8ToString( tlv.getValue().getData() );
                     log.error( "The URL " + badUrl + " is not valid : " + luee.getMessage()
);
                     throw new DecoderException( "Invalid URL : " + luee.getMessage() );
                 }

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
Wed Jul 25 16:11:28 2007
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,7 +72,7 @@
             throw new DecoderException( "The substring any filter is empty" );
         }
 
-        String any = new String( tlv.getValue().getData() );
+        String any = StringTools.utf8ToString( tlv.getValue().getData() );
         substringFilter.addAnySubstrings( any );
 
         // We now have to get back to the nearest filter which is

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
Wed Jul 25 16:11:28 2007
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -71,7 +72,7 @@
             throw new DecoderException( "The substring final filter is empty" );
         }
 
-        String finalValue = new String( tlv.getValue().getData() );
+        String finalValue = StringTools.utf8ToString( tlv.getValue().getData() );
         substringFilter.setFinalSubstrings( finalValue );
 
         // We now have to get back to the nearest filter which is

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
Wed Jul 25 16:11:28 2007
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -82,7 +83,7 @@
             }
             catch ( LdapURLEncodingException luee )
             {
-                String badUrl = new String( tlv.getValue().getData() );
+                String badUrl = StringTools.utf8ToString( tlv.getValue().getData() );
                 log.error( "The URL {} is not valid : {}", badUrl, luee.getMessage() );
                 throw new DecoderException( "Invalid URL : " + luee.getMessage() );
             }

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
Wed Jul 25 16:11:28 2007
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -73,7 +74,7 @@
             ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
                 .getTerminalFilter();
 
-            String type = new String( tlv.getValue().getData() );
+            String type = StringTools.utf8ToString( tlv.getValue().getData() );
             extensibleMatchFilter.setType( type );
 
             if ( IS_DEBUG )

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java?view=diff&rev=559645&r1=559644&r2=559645
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
Wed Jul 25 16:11:28 2007
@@ -332,16 +332,8 @@
             throw new LdapURLEncodingException( "The byte array is empty : this is not a
valid LdapURL." );
         }
 
-        try
-        {
-            string = new String( bytes, "UTF-8" );
-            this.bytes = bytes;
-        }
-        catch ( UnsupportedEncodingException uee )
-        {
-            throw new LdapURLEncodingException( "The byte array is not an UTF-8 encoded Unicode
String : "
-                + uee.getMessage() );
-        }
+        string = StringTools.utf8ToString( bytes );
+        this.bytes = bytes;
 
         parse( string.toCharArray() );
     }
@@ -1050,7 +1042,7 @@
                     }
                     else
                     {
-                        value = new String( decode( new String( chars, start, i - start )
) ).trim();
+                        value = decode( new String( chars, start, i - start ) ).trim();
 
                         if ( value.length() == 0 )
                         {
@@ -1085,7 +1077,7 @@
                     }
 
                     // An optionnal value
-                    extension = new String( decode( new String( chars, start, i - start )
) ).trim();
+                    extension = decode( new String( chars, start, i - start ) ).trim();
 
                     if ( extension.length() == 0 )
                     {
@@ -1115,11 +1107,11 @@
 
             if ( extension == null )
             {
-                extension = new String( decode( new String( chars, start, chars.length -
start ) ) ).trim();
+                extension = decode( new String( chars, start, chars.length - start ) ).trim();
             }
             else
             {
-                value = new String( decode( new String( chars, start, chars.length - start
) ) ).trim();
+                value = decode( new String( chars, start, chars.length - start ) ).trim();
             }
 
             if ( isCritical )



Mime
View raw message