directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [2/4] directory-kerby git commit: DIRKRB-492. Use hex when dumping ASN1 object tags
Date Wed, 09 Dec 2015 04:42:24 GMT
DIRKRB-492. Use hex when dumping ASN1 object tags


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

Branch: refs/heads/pkinit-support
Commit: d72d7bd46631b2c284378bd6ce0d78866d8debf2
Parents: 7c00ced
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Wed Dec 9 11:06:20 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Wed Dec 9 11:06:20 2015 +0800

----------------------------------------------------------------------
 kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java       | 7 ++++++-
 .../main/java/org/apache/kerby/asn1/parse/Asn1Container.java  | 3 ++-
 .../src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java   | 3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d72d7bd4/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java
index 6b19e1e..89f5e88 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Tag.java
@@ -101,6 +101,11 @@ public class Tag {
         return tagClass().isSpecific();
     }
 
+    public byte tagByte() {
+        int n = tagFlags | (tagNo < 0x1F ? tagNo : 0x1F);
+        return (byte) (n & 0xFF);
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o) {
@@ -128,7 +133,7 @@ public class Tag {
 
     @Override
     public String toString() {
-        return tagNo >= 0x1F ? "N/A" : "" + (tagFlags | tagNo);
+        return String.format("0x%02X", tagByte());
     }
 
     public static Tag newAppTag(int tagNo) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d72d7bd4/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java
index a0e27ca..7cbd471 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Container.java
@@ -75,7 +75,8 @@ public class Asn1Container
             typeStr = "[" + tagNo() + "]";
         }
         return typeStr + " ["
-            + "off=" + getOffset()
+            + "tag=" + tag()
+            + ", off=" + getOffset()
             + ", len=" + getHeaderLength() + "+" + getBodyLength()
             + (isDefinitiveLength() ? "" : "(undefined)")
             + "]";

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d72d7bd4/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java
index 7548629..1e4f6f6 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/parse/Asn1Item.java
@@ -40,7 +40,8 @@ public class Asn1Item extends Asn1ParseResult {
         String typeStr = tag().isUniversal() ? tag().universalTag().toStr()
             : tag().tagClass().name().toLowerCase();
         return typeStr + " ["
-            + "off=" + getOffset()
+            + "tag=" + tag()
+            + ", off=" + getOffset()
             + ", len=" + getHeaderLength() + "+" + getBodyLength()
             + "] "
             + valueStr;


Mime
View raw message