harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r396532 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/org/apache/harmony/security/provider/cert/X509CertImpl.java test/java/common/org/apache/harmony/security/provider/cert/X509CertImplTest.java
Date Mon, 24 Apr 2006 12:25:32 GMT
Author: smishura
Date: Mon Apr 24 05:25:30 2006
New Revision: 396532

URL: http://svn.apache.org/viewcvs?rev=396532&view=rev
Log:
Fix for X.509 certificate provider: implementation ignores true version of certificate and
allways return version 3. Adding regression test.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertImpl.java
  (contents, props changed)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertImplTest.java
  (contents, props changed)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertImpl.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertImpl.java?rev=396532&r1=396531&r2=396532&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertImpl.java
Mon Apr 24 05:25:30 2006
@@ -134,7 +134,7 @@
     }
     
     public int getVersion() {
-        return 3;
+        return tbsCert.getVersion() + 1;
     }
 
     public BigInteger getSerialNumber() {

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertImplTest.java?rev=396532&r1=396531&r2=396532&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertImplTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertImplTest.java
Mon Apr 24 05:25:30 2006
@@ -42,6 +42,7 @@
 import java.security.cert.X509Certificate;
 
 import org.apache.harmony.security.asn1.ASN1BitString;
+import org.apache.harmony.security.cert.TestUtils;
 import org.apache.harmony.security.provider.cert.X509CertImpl;
 import org.apache.harmony.security.x501.Name;
 import org.apache.harmony.security.x509.*;
@@ -325,11 +326,31 @@
     }
     
     /**
-     * getVersion() method testing.
+     * @tests java.security.cert.X509Certificate#getVersion()
      */
-    public void testGetVersion() {
-        assertEquals("The version of the certificate should be 2", 
-                3, certificate.getVersion());
+    public void testGetVersion() throws IOException {
+
+        byte[] x509CertEnc = TestUtils.getX509Certificate_v1();
+
+        // test initial version that is 1
+        assertEquals("Version 1:", 1, new X509CertImpl(x509CertEnc)
+                .getVersion());
+
+        // as fas as we know offset of version byte in the cert. encoding
+        // it is possible to change it to test other versions
+
+        // offset of version byte in certificate encoding
+        int offset = 8;
+
+        // set version to 2
+        x509CertEnc[offset] = 1;
+        assertEquals("Version 2:", 2, new X509CertImpl(x509CertEnc)
+                .getVersion());
+
+        // set version to 3
+        x509CertEnc[offset] = 2;
+        assertEquals("Version 3:", 3, new X509CertImpl(x509CertEnc)
+                .getVersion());
     }
     
     /**

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message