directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1681561 [2/2] - in /directory/shared/trunk: asn1/api/src/main/java/org/apache/directory/api/asn1/ asn1/api/src/main/java/org/apache/directory/api/asn1/util/ asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/ dsml/engine/src/main...
Date Mon, 25 May 2015 06:24:21 GMT
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java?rev=1681561&r1=1681560&r2=1681561&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Mon May 25 06:24:20 2015
@@ -1720,7 +1720,7 @@ public class LdifReader implements Itera
                         break;
                 }
 
-                byte[] data = line.getBytes();
+                byte[] data = Strings.getBytesUtf8( line );
                 // FIXME might fail on windows in the new line issue, yet to check
                 offset += ( data.length + 1 );
                 entryLen += ( data.length + 1 );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java?rev=1681561&r1=1681560&r2=1681561&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
Mon May 25 06:24:20 2015
@@ -21,7 +21,6 @@ package org.apache.directory.api.ldap.mo
 
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 
 import javax.naming.directory.Attributes;
 
@@ -527,19 +526,8 @@ public final class LdifUtils
      */
     private static String encodeBase64( String str )
     {
-        char[] encoded = null;
-
-        try
-        {
-            // force encoding using UTF-8 charset, as required in RFC2849 note 7
-            encoded = Base64.encode( str.getBytes( "UTF-8" ) );
-        }
-        catch ( UnsupportedEncodingException e )
-        {
-            encoded = Base64.encode( str.getBytes() );
-        }
-
-        return new String( encoded );
+        // force encoding using UTF-8 charset, as required in RFC2849 note 7
+        return new String( Base64.encode( Strings.getBytesUtf8( str ) ) );
     }
 
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java?rev=1681561&r1=1681560&r2=1681561&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/password/PasswordUtil.java
Mon May 25 06:24:20 2015
@@ -104,7 +104,7 @@ public class PasswordUtil
                     return null;
                 }
 
-                String algorithm = Strings.toLowerCase( new String( credentials, 1, pos -
1 ) );
+                String algorithm = Strings.toLowerCase( Strings.utf8ToString( credentials,
1, pos - 1 ) );
 
                 return LdapSecurityConstants.getAlgorithm( algorithm );
             }

Modified: directory/shared/trunk/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java?rev=1681561&r1=1681560&r2=1681561&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java
(original)
+++ directory/shared/trunk/ldap/schema/converter/src/main/java/org/apache/directory/api/ldap/schema/converter/SchemaParser.java
Mon May 25 06:24:20 2015
@@ -32,6 +32,7 @@ import java.util.List;
 
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.directory.api.i18n.I18n;
+import org.apache.directory.api.util.Strings;
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
@@ -110,7 +111,7 @@ public class SchemaParser
             throw new ParseException( I18n.err( I18n.ERR_06001_EMPTY_OR_NULL_SCHEMA_OBJECT
), 0 );
         }
 
-        schemaIn = new ByteArrayInputStream( schemaObject.getBytes() );
+        schemaIn = new ByteArrayInputStream( Strings.getBytesUtf8( schemaObject ) );
 
         if ( producerThread == null )
         {
@@ -215,7 +216,7 @@ public class SchemaParser
                 }
 
                 // using an input termination token END - need extra space to return
-                parserIn.write( "END ".getBytes() );
+                parserIn.write( Strings.getBytesUtf8( "END " ) );
             }
             catch ( IOException e )
             {

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Strings.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Strings.java?rev=1681561&r1=1681560&r2=1681561&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Strings.java (original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/Strings.java Mon
May 25 06:24:20 2015
@@ -259,7 +259,7 @@ public final class Strings
      */
     public static String dumpByte( byte octet )
     {
-        return new String( new byte[]
+        return Strings.utf8ToString( new byte[]
             { '0', 'x', HEX_CHAR[( octet & 0x00F0 ) >> 4], HEX_CHAR[octet &
0x000F] } );
     }
 
@@ -1936,7 +1936,7 @@ public final class Strings
             value[i] = TO_LOWER_CASE_BYTE[value[i]];
         }
 
-        return new String( value );
+        return Strings.utf8ToString( value );
     }
 
 
@@ -2138,25 +2138,23 @@ public final class Strings
      */
     public static boolean isValidUuid( String uuid )
     {
-        byte[] b = uuid.getBytes();
-
-        if ( b.length < 36 )
+        if ( uuid.length() < 36 )
         {
             return false;
         }
 
-        if ( isHex( b[0] ) && isHex( b[1] ) && isHex( b[2] ) && isHex(
b[3] )
-            && isHex( b[4] ) && isHex( b[5] ) && isHex( b[6] ) &&
isHex( b[7] )
-            && ( b[8] == '-' )
-            && isHex( b[9] ) && isHex( b[10] ) && isHex( b[11] )
&& isHex( b[12] )
-            && ( b[13] == '-' )
-            && isHex( b[14] ) && isHex( b[15] ) && isHex( b[16] )
&& isHex( b[17] )
-            && ( b[18] == '-' )
-            && isHex( b[19] ) && isHex( b[20] ) && isHex( b[21] )
&& isHex( b[22] )
-            && ( b[23] == '-' )
-            && isHex( b[24] ) && isHex( b[25] ) && isHex( b[26] )
&& isHex( b[27] )
-            && isHex( b[28] ) && isHex( b[29] ) && isHex( b[30] )
&& isHex( b[31] )
-            && isHex( b[32] ) && isHex( b[33] ) && isHex( b[34] )
&& isHex( b[35] ) )
+        if ( isHex( uuid.charAt(0) ) && isHex( uuid.charAt(1) ) && isHex(
uuid.charAt(2) ) && isHex( uuid.charAt(3) )
+            && isHex( uuid.charAt(4) ) && isHex( uuid.charAt(5) ) &&
isHex( uuid.charAt(6) ) && isHex( uuid.charAt(7) )
+            && ( uuid.charAt(8) == '-' )
+            && isHex( uuid.charAt(9) ) && isHex( uuid.charAt(10) ) &&
isHex( uuid.charAt(11) ) && isHex( uuid.charAt(12) )
+            && ( uuid.charAt(13) == '-' )
+            && isHex( uuid.charAt(14) ) && isHex( uuid.charAt(15) ) &&
isHex( uuid.charAt(16) ) && isHex( uuid.charAt(17) )
+            && ( uuid.charAt(18) == '-' )
+            && isHex( uuid.charAt(19) ) && isHex( uuid.charAt(20) ) &&
isHex( uuid.charAt(21) ) && isHex( uuid.charAt(22) )
+            && ( uuid.charAt(23) == '-' )
+            && isHex( uuid.charAt(24) ) && isHex( uuid.charAt(25) ) &&
isHex( uuid.charAt(26) ) && isHex( uuid.charAt(27) )
+            && isHex( uuid.charAt(28) ) && isHex( uuid.charAt(29) ) &&
isHex( uuid.charAt(30) ) && isHex( uuid.charAt(31) )
+            && isHex( uuid.charAt(32) ) && isHex( uuid.charAt(33) ) &&
isHex( uuid.charAt(34) ) && isHex( uuid.charAt(35) ) )
         {
             // There is not that much more we can check.
             LOG.debug( "Syntax valid for '{}'", uuid );



Mime
View raw message