harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r764827 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/org/apache/harmony/security/asn1/ main/java/common/org/apache/harmony/security/provider/cert/ main/java/common/org/apache/harmony/security/x501/ main/java/...
Date Tue, 14 Apr 2009 15:24:43 GMT
Author: odeakin
Date: Tue Apr 14 15:24:43 2009
New Revision: 764827

URL: http://svn.apache.org/viewvc?rev=764827&view=rev
Log:
More changes to security code and tests to behave correctly on non-ASCII platforms.

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java?rev=764827&r1=764826&r2=764827&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
Tue Apr 14 15:24:43 2009
@@ -139,11 +139,15 @@
     }
 
     public void setEncodingContent(BerOutputStream out) {
-
-        byte[] bytes = ((String) out.content).getBytes();
-
-        out.content = bytes;
-        out.length = bytes.length;
+        try {
+            byte[] bytes = ((String) out.content).getBytes("UTF-8"); //$NON-NLS-1$
+            out.content = bytes;
+            out.length = bytes.length;
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage());
+        }
     }
 }
 
+
+

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java?rev=764827&r1=764826&r2=764827&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
Tue Apr 14 15:24:43 2009
@@ -23,6 +23,7 @@
 package org.apache.harmony.security.asn1;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
 import java.util.TimeZone;
 
@@ -115,7 +116,11 @@
     public void setEncodingContent(BerOutputStream out) {
         SimpleDateFormat sdf = new SimpleDateFormat(UTC_PATTERN);
         sdf.setTimeZone(TimeZone.getTimeZone("UTC")); //$NON-NLS-1$
-        out.content = sdf.format(out.content).getBytes();
+        try {
+            out.content = sdf.format(out.content).getBytes("UTF-8"); //$NON-NLS-1$
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage());
+        }
         out.length = ((byte[]) out.content).length;
     }
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java?rev=764827&r1=764826&r2=764827&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
Tue Apr 14 15:24:43 2009
@@ -25,6 +25,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.security.cert.CRL;
 import java.security.cert.CRLException;
 import java.security.cert.CertPath;
@@ -446,8 +447,8 @@
     // ------------------------ Staff methods ------------------------------
     // ---------------------------------------------------------------------
 
-    private static byte[] pemBegin = "-----BEGIN".getBytes(); //$NON-NLS-1$
-    private static byte[] pemClose = "-----END".getBytes(); //$NON-NLS-1$
+    private static byte[] pemBegin;
+    private static byte[] pemClose;
     /**
      * Code describing free format for PEM boundary suffix:
      * "^-----BEGIN.*\n"         at the beginning, and<br>
@@ -459,8 +460,18 @@
      * "^-----BEGIN CERTIFICATE-----\n"   at the beginning, and<br>
      * "\n-----END CERTIFICATE-----"   at the end.
      */
-    private static byte[] CERT_BOUND_SUFFIX = 
-        " CERTIFICATE-----".getBytes(); //$NON-NLS-1$
+    private static byte[] CERT_BOUND_SUFFIX;
+
+    static {
+        // Initialise statics
+        try {
+            pemBegin = "-----BEGIN".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+            pemClose = "-----END".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+            CERT_BOUND_SUFFIX = " CERTIFICATE-----".getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
 
     /**
      * Method retrieves the PEM encoded data from the stream 
@@ -929,3 +940,5 @@
     }
 }
 
+
+

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java?rev=764827&r1=764826&r2=764827&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
Tue Apr 14 15:24:43 2009
@@ -28,6 +28,7 @@
 import java.util.Iterator;
 
 import javax.security.auth.x500.X500Principal;
+import java.io.UnsupportedEncodingException;
 
 import org.apache.harmony.security.asn1.ASN1Constants;
 import org.apache.harmony.security.asn1.ASN1Oid;
@@ -449,7 +450,11 @@
                     av.bytes = (byte[]) out.content;
                     out.content = av;
                 } else {
-                    av.bytes = av.rawString.getBytes();
+                    try {
+                        av.bytes = av.rawString.getBytes("UTF-8"); //$NON-NLS-1$
+                    } catch (UnsupportedEncodingException e) {
+                        throw new RuntimeException(e.getMessage());
+                    }
                     out.length = av.bytes.length;
                 }
             }
@@ -538,4 +543,4 @@
         }
         return intHash & 0x7FFFFFFF; // only positive
     }
-}
\ No newline at end of file
+}

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java?rev=764827&r1=764826&r2=764827&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
Tue Apr 14 15:24:43 2009
@@ -583,7 +583,7 @@
      * The correctness is checked as specified in RFC 1034 p. 10.
      */
     public static void checkDNS(String dns) throws IOException {
-        byte[] bytes = dns.toLowerCase().getBytes();
+        byte[] bytes = dns.toLowerCase().getBytes("UTF-8"); //$NON-NLS-1$
         // indicates if it is a first letter of the label
         boolean first_letter = true;
         for (int i=0; i<bytes.length; i++) {
@@ -637,7 +637,7 @@
      * Converts OID into array of bytes.
      */
     public static int[] oidStrToInts(String oid) throws IOException {
-        byte[] bytes = oid.getBytes();
+        byte[] bytes = oid.getBytes("UTF-8"); //$NON-NLS-1$
         if (bytes[bytes.length-1] == '.') {
             throw new IOException(Messages.getString("security.56", oid)); //$NON-NLS-1$
         }
@@ -691,7 +691,7 @@
         }
         // the resulting array
         byte[] result = new byte[num_components];
-        byte[] ip_bytes = ip.getBytes();
+        byte[] ip_bytes = ip.getBytes("UTF-8"); //$NON-NLS-1$
         // number of address component to be read
         int component = 0;
         // if it is reading the second bound of a range

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java?rev=764827&r1=764826&r2=764827&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
Tue Apr 14 15:24:43 2009
@@ -263,12 +263,12 @@
         ByteArrayInputStream is = null;
         CertificateFactory certFactory = CertificateFactory
                 .getInstance("X.509");
-        is = new ByteArrayInputStream(Base64.decode(base64cert.getBytes()));
+        is = new ByteArrayInputStream(Base64.decode(base64cert.getBytes("UTF-8")));
         X509Certificate cert = (X509Certificate) certFactory
                 .generateCertificate(is);
         cert.getExtensionValue("1.1.1.1");
 
-        is = new ByteArrayInputStream(Base64.decode(base64crl.getBytes()));
+        is = new ByteArrayInputStream(Base64.decode(base64crl.getBytes("UTF-8")));
         X509CRL crl = (X509CRL) certFactory.generateCRL(is);
         crl.getExtensionValue("1.1.1.1");
     }
@@ -283,3 +283,4 @@
     }
 }
 
+

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java?rev=764827&r1=764826&r2=764827&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
Tue Apr 14 15:24:43 2009
@@ -316,7 +316,11 @@
         "-----END CERTIFICATE-----\n";
 
     static {
-        certEncoding_b64 = base64certEncoding.getBytes();
+        try {
+            certEncoding_b64 = base64certEncoding.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e.getMessage());
+        }
         stream_b64 = new ByteArrayInputStream(certEncoding_b64);
         stream_b64.mark(certEncoding_b64.length);
     }
@@ -840,3 +844,5 @@
     }
 }
 
+
+



Mime
View raw message