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-486. Initial work for the support, introducing toStr() method
Date Thu, 03 Dec 2015 01:11:31 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 1d9385611 -> e3197ce25


DIRKRB-486. Initial work for the support, introducing toStr() method


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

Branch: refs/heads/master
Commit: e3197ce25452f6fd34e8cfec1fdf232964c9397f
Parents: 1d93856
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Thu Dec 3 09:11:16 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Thu Dec 3 09:11:16 2015 +0800

----------------------------------------------------------------------
 .../java/org/apache/kerby/asn1/type/AbstractAsn1Type.java     | 5 +++++
 .../src/main/java/org/apache/kerby/asn1/type/Asn1Any.java     | 5 +++++
 .../main/java/org/apache/kerby/asn1/type/Asn1BitString.java   | 7 +++++++
 .../src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java  | 5 +++++
 .../java/org/apache/kerby/asn1/type/Asn1CollectionType.java   | 5 +++++
 .../main/java/org/apache/kerby/asn1/type/Asn1Constructed.java | 5 +++++
 .../src/main/java/org/apache/kerby/asn1/type/Asn1Item.java    | 5 +++++
 .../main/java/org/apache/kerby/asn1/type/Asn1OctetString.java | 7 +++++++
 .../src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java  | 7 +++++++
 .../src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java | 5 +++++
 .../src/main/java/org/apache/kerby/asn1/type/Asn1Type.java    | 7 +++++++
 .../java/org/apache/kerby/asn1/type/TaggingCollection.java    | 5 +++++
 12 files changed, 68 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
index b12c67d..df8ceef 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
@@ -75,4 +75,9 @@ public abstract class AbstractAsn1Type<T> extends Asn1Object {
     public void setValue(T value) {
         this.value = value;
     }
+
+    @Override
+    public String toString() {
+        return toStr();
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Any.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Any.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Any.java
index 617ec12..efcd9a1 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Any.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Any.java
@@ -100,5 +100,10 @@ public class Asn1Any extends AbstractAsn1Type<Asn1Type> {
 
         return result;
     }
+
+    @Override
+    public String toStr() {
+        return "any";
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BitString.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BitString.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BitString.java
index 7d26be3..2ba95b9 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BitString.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BitString.java
@@ -82,4 +82,11 @@ public class Asn1BitString extends Asn1Simple<byte[]> {
             throw new IOException("Bad padding number: " + paddingBits + ", should be in
[0, 7]");
         }
     }
+
+    @Override
+    public String toStr() {
+        String valueStr =
+            (getValue() != null ? (getValue().length + " bytes") : "null");
+        return valueStr;
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
index 91fd54e..aecfaf0 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
@@ -167,4 +167,9 @@ public class Asn1Choice extends AbstractAsn1Type<Asn1Type> {
     protected void setFieldAsInt(int index, int value) {
         setFieldAs(index, new Asn1Integer(value));
     }
+
+    @Override
+    public String toStr() {
+        return "choice";
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
index 3226441..6b5d312 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
@@ -195,4 +195,9 @@ public abstract class Asn1CollectionType extends AbstractAsn1Type<Asn1Collection
             setFieldAs(index, new Asn1Any(value));
         }
     }
+
+    @Override
+    public String toStr() {
+        return "[collection-type]";
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
index 46cb6c6..4a7d904 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
@@ -90,4 +90,9 @@ public class Asn1Constructed extends AbstractAsn1Type<List<Asn1Type>>
{
             }
         }
     }
+
+    @Override
+    public String toStr() {
+        return "[constructed]";
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Item.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Item.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Item.java
index efd0673..c011141 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Item.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Item.java
@@ -143,4 +143,9 @@ public class Asn1Item extends AbstractAsn1Type<Asn1Type> {
         ((Asn1Object) value).taggedDecode(tag(), getBodyContent(), taggingOption);
         setValue(value);
     }
+
+    @Override
+    public String toStr() {
+        return "item";
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1OctetString.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1OctetString.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1OctetString.java
index 6523cf7..c7b89f9 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1OctetString.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1OctetString.java
@@ -48,4 +48,11 @@ public class Asn1OctetString extends Asn1Simple<byte[]> {
     protected void decodeBody(ByteBuffer content) throws IOException {
         setValue(Asn1Util.readAllLeftBytes(content));
     }
+
+    @Override
+    public String toStr() {
+        String valueStr =
+            (getValue() != null ? (getValue().length + " octets") : "null");
+        return valueStr;
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
index d55fb7a..81f6e57 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
@@ -201,4 +201,11 @@ public abstract class Asn1Simple<T> extends AbstractAsn1Type<T>
{
                 throw new IllegalArgumentException("Unexpected tag " + tagNo.getValue());
         }
     }
+
+    @Override
+    public String toStr() {
+        String valueStr =
+            (getValue() != null ? String.valueOf(getValue()) : "null");
+        return valueStr;
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
index b7ad9d4..8dd4511 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
@@ -97,4 +97,9 @@ public class Asn1Tagging<T extends Asn1Type> extends AbstractAsn1Type<T>
{
         }
         setValue((T) value);
     }
+
+    @Override
+    public String toStr() {
+        return "tagging";
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
index 4c1c538..c272915 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
@@ -186,4 +186,11 @@ public interface Asn1Type {
      * @throws IOException e
      */
     void taggedDecode(byte[] content, TaggingOption taggingOption) throws IOException;
+
+    /**
+     * Return a friendly string representation for this object. In primitive
+     * cases, it may be the same with toString().
+     * @return a friendly string representation
+     */
+    String toStr();
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/e3197ce2/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/TaggingCollection.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/TaggingCollection.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/TaggingCollection.java
index b6086b8..cb721ff 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/TaggingCollection.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/TaggingCollection.java
@@ -169,4 +169,9 @@ public abstract class TaggingCollection extends AbstractAsn1Type<Asn1CollectionT
     protected void setFieldAsOctetBytes(int index, byte[] value) {
         tagged.setFieldAsOctets(index, value);
     }
+
+    @Override
+    public String toStr() {
+        return "[tagging-collection]";
+    }
 }


Mime
View raw message