directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject directory-kerby git commit: DIRKRB-495. Fixed x509 GeneralName decoding issue and enabled the test
Date Fri, 11 Dec 2015 23:03:59 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 6e20e8eb5 -> 47c420cab


DIRKRB-495. Fixed x509 GeneralName decoding issue and enabled the test


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/47c420ca
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/47c420ca
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/47c420ca

Branch: refs/heads/master
Commit: 47c420cabb6e69b8a7a7f8c67497ac96b975c935
Parents: 6e20e8e
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Sat Dec 12 07:03:42 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Sat Dec 12 07:03:42 2015 +0800

----------------------------------------------------------------------
 .../org/apache/kerby/asn1/TaggingOption.java    |  6 ++---
 .../org/apache/kerby/x509/type/GeneralName.java | 25 ++++++++++----------
 .../org/apache/kerby/cms/TestGeneralName.java   | 14 +++++++----
 3 files changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/47c420ca/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java
index 898c25e..5ba221a 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/TaggingOption.java
@@ -76,9 +76,9 @@ public final class TaggingOption {
     }
 
     /**
-     * Make tag flags giving it's tagged constructed.
-     * @param isTaggedConstructed Tagged Constructed or not
-     * @return tag flag
+     * Make tag giving it's tagged constructed.
+     * @param isTaggedConstructed Tagged constructed or not
+     * @return tag
      */
     public Tag getTag(boolean isTaggedConstructed) {
         boolean isConstructed = isImplicit ? isTaggedConstructed : true;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/47c420ca/kerby-pkix/src/main/java/org/apache/kerby/x509/type/GeneralName.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/GeneralName.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/GeneralName.java
index 3d68900..7f9217a 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/GeneralName.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/GeneralName.java
@@ -22,6 +22,7 @@ package org.apache.kerby.x509.type;
 import org.apache.kerby.asn1.Asn1FieldInfo;
 import org.apache.kerby.asn1.EnumType;
 import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.asn1.ImplicitField;
 import org.apache.kerby.asn1.type.Asn1Any;
 import org.apache.kerby.asn1.type.Asn1Choice;
 import org.apache.kerby.asn1.type.Asn1IA5String;
@@ -71,16 +72,16 @@ public class GeneralName extends Asn1Choice {
     }
 
     static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
-        new ExplicitField(OTHER_NAME, OtherName.class),
-        new ExplicitField(RFC822_NAME, Asn1IA5String.class),
-        new ExplicitField(DNS_NAME, Asn1IA5String.class),
+        new ImplicitField(OTHER_NAME, OtherName.class),
+        new ImplicitField(RFC822_NAME, Asn1IA5String.class),
+        new ImplicitField(DNS_NAME, Asn1IA5String.class),
         // ORAddress is to be defined.
-        new ExplicitField(X400_ADDRESS, Asn1Any.class),
+        new ImplicitField(X400_ADDRESS, Asn1Any.class),
         new ExplicitField(DIRECTORY_NAME, Name.class),
-        new ExplicitField(EDI_PARTY_NAME, EDIPartyName.class),
-        new ExplicitField(UNIFORM_RESOURCE_IDENTIFIER, Asn1IA5String.class),
-        new ExplicitField(IP_ADDRESS, Asn1OctetString.class),
-        new ExplicitField(REGISTERED_ID, Asn1ObjectIdentifier.class)
+        new ImplicitField(EDI_PARTY_NAME, EDIPartyName.class),
+        new ImplicitField(UNIFORM_RESOURCE_IDENTIFIER, Asn1IA5String.class),
+        new ImplicitField(IP_ADDRESS, Asn1OctetString.class),
+        new ImplicitField(REGISTERED_ID, Asn1ObjectIdentifier.class)
     };
 
     public GeneralName() {
@@ -143,12 +144,12 @@ public class GeneralName extends Asn1Choice {
         setChoiceValue(UNIFORM_RESOURCE_IDENTIFIER, uniformResourceIdentifier);
     }
 
-    public Asn1OctetString getIPAddress() {
-        return getChoiceValueAs(IP_ADDRESS, Asn1OctetString.class);
+    public byte[] getIPAddress() {
+        return getChoiceValueAsOctets(IP_ADDRESS);
     }
 
-    public void setIpAddress(Asn1OctetString ipAddress) {
-        setChoiceValue(IP_ADDRESS, ipAddress);
+    public void setIpAddress(byte[] ipAddress) {
+        setChoiceValueAsOctets(IP_ADDRESS, ipAddress);
     }
 
     public Asn1ObjectIdentifier getRegisteredID() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/47c420ca/kerby-pkix/src/test/java/org/apache/kerby/cms/TestGeneralName.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestGeneralName.java b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestGeneralName.java
index 9611190..daa1542 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestGeneralName.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestGeneralName.java
@@ -21,11 +21,14 @@ package org.apache.kerby.cms;
 
 import org.apache.kerby.asn1.Asn1;
 import org.apache.kerby.asn1.util.HexUtil;
+import org.apache.kerby.x509.type.GeneralName;
 import org.junit.Assert;
 import org.junit.Test;
 
 import java.io.IOException;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 public class TestGeneralName {
     private static final byte[] IPV4 = HexUtil.hex2bytes("87040a090800");
 
@@ -33,11 +36,12 @@ public class TestGeneralName {
     public void testIpAddress() throws IOException {
         try {
             Asn1.dump(IPV4, true);
-            //GeneralName generalName = new GeneralName();
-            //TO BE FIXED
-            //10.9.8.0
-            //generalName.decode(ipv4);
-
+            GeneralName generalName = new GeneralName();
+            generalName.decode(IPV4);
+            assertThat(generalName.getIPAddress()).isNotNull();
+            byte[] addressBytes = generalName.getIPAddress();
+            // "10.9.8.0"
+            assertThat(addressBytes).isEqualTo(new byte[] {0x0a, 0x09, 0x08, 0x00});
         } catch (Exception e) {
             e.printStackTrace();
             Assert.fail();


Mime
View raw message