harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r489306 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/ test/api/java/org/apache/harmony/security/tests/java/security/serialization/ test/resources/serialization/org/apache/harmony/security/tests/...
Date Thu, 21 Dec 2006 09:59:33 GMT
Author: smishura
Date: Thu Dec 21 01:59:32 2006
New Revision: 489306

URL: http://svn.apache.org/viewvc?view=rev&rev=489306
Log:
Apply modified patch for HARMONY-2762
[classlib][security]UnresolvedPermission fails in serialization.

Added:
    harmony/enhanced/classlib/trunk/modules/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.ser
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java?view=diff&rev=489306&r1=489305&r2=489306
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
Thu Dec 21 01:59:32 2006
@@ -317,14 +317,14 @@
         fields.put("actions", getUnresolvedActions()); //$NON-NLS-1$
         out.writeFields();
         if (targetCerts == null) {
-            out.write(0);
+            out.writeInt(0);
         } else {
-            out.write(targetCerts.length);
+            out.writeInt(targetCerts.length);
             for (int i = 0; i < targetCerts.length; i++) {
                 try {
                     byte[] enc = targetCerts[i].getEncoded();
                     out.writeUTF(targetCerts[i].getType());
-                    out.write(enc.length);
+                    out.writeInt(enc.length);
                     out.write(enc);
                 } catch (CertificateEncodingException cee) {
                     throw ((IOException)new NotSerializableException(
@@ -349,13 +349,13 @@
         }
         targetName = (String)fields.get("name", null); //$NON-NLS-1$
         targetActions = (String)fields.get("actions", null); //$NON-NLS-1$
-        int certNumber = in.read();
+        int certNumber = in.readInt();
         if (certNumber != 0) {
             targetCerts = new Certificate[certNumber];
             for (int i = 0; i < certNumber; i++) {
                 try {
                     String type = in.readUTF();
-                    int length = in.read();
+                    int length = in.readInt();
                     byte[] enc = new byte[length];
                     in.readFully(enc, 0, length);
                     targetCerts[i] = CertificateFactory.getInstance(type)

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java?view=diff&rev=489306&r1=489305&r2=489306
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java
Thu Dec 21 01:59:32 2006
@@ -22,9 +22,12 @@
 
 package org.apache.harmony.security.tests.java.security.serialization;
 
+import java.io.ByteArrayInputStream;
 import java.security.UnresolvedPermission;
 import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
 
+import org.apache.harmony.security.tests.support.cert.TestUtils;
 import org.apache.harmony.testframework.serialization.SerializationTest;
 
 
@@ -44,5 +47,21 @@
         return new Object[] {
                 new UnresolvedPermission("type", "name", "actions", null),
                 new UnresolvedPermission("type", null, null, new Certificate[0]) };
+    }
+    
+    public void testSerializationWithCertificates() throws Exception {
+
+        // Regression for HARMONY-2762
+        CertificateFactory certificateFactory = CertificateFactory
+                .getInstance("X.509");
+        Certificate certificate = certificateFactory
+                .generateCertificate(new ByteArrayInputStream(TestUtils
+                        .getEncodedX509Certificate()));
+
+        UnresolvedPermission unresolvedPermission = new UnresolvedPermission(
+                "java.security.SecurityPermission", "a.b.c", "action",
+                new Certificate[] { certificate });
+        SerializationTest.verifySelf(unresolvedPermission);
+        SerializationTest.verifyGolden(this, unresolvedPermission);
     }
 }

Added: harmony/enhanced/classlib/trunk/modules/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.ser?view=auto&rev=489306
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message