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: Better supporting any type
Date Mon, 30 Nov 2015 02:29:43 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 8483322e5 -> 78f67dc07


Better supporting any type


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

Branch: refs/heads/master
Commit: 78f67dc07b2e7b4c1133c83f78f47fbe2da91688
Parents: 8483322
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Mon Nov 30 10:29:27 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Mon Nov 30 10:29:27 2015 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/kerby/asn1/type/Asn1Any.java |  1 -
 .../org/apache/kerby/asn1/type/Asn1CollectionType.java    | 10 ++++++----
 .../main/java/org/apache/kerby/cms/type/ContentInfo.java  |  4 ++--
 .../org/apache/kerby/cms/type/OtherCertificateFormat.java |  4 ++--
 .../apache/kerby/cms/type/OtherRevocationInfoFormat.java  |  4 ++--
 .../org/apache/kerby/x500/type/AttributeTypeAndValue.java |  4 ++--
 .../org/apache/kerby/x509/type/AlgorithmIdentifier.java   |  4 ++--
 .../main/java/org/apache/kerby/x509/type/OtherName.java   |  4 ++--
 .../org/apache/kerby/x509/type/PolicyQualifierInfo.java   |  4 ++--
 9 files changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/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 b04b4e1..73a82c7 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
@@ -69,7 +69,6 @@ public class Asn1Any extends AbstractAsn1Type<Asn1Type> {
         // Not used
     }
 
-    // Available for encoding phase.
     protected <T extends Asn1Type> T getValueAs(Class<T> t) {
         Asn1Type value = getValue();
         if (value == null) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/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 82f360b..72278d3 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
@@ -176,11 +176,13 @@ public abstract class Asn1CollectionType extends AbstractAsn1Type<Asn1Collection
         setFieldAs(index, new Asn1Integer(value));
     }
 
-    protected Asn1Type getFieldAsAny(int index) {
-        Asn1Any any = getFieldAs(index, Asn1Any.class);
-        if (any != null) {
-            return any.getValue();
+    protected <T extends Asn1Type> T getFieldAsAny(int index, Class<T> t) {
+        Asn1Type value = fields[index];
+        if (value != null && value instanceof Asn1Any) {
+            Asn1Any any = (Asn1Any) value;
+            return any.getValueAs(t);
         }
+
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/kerby-pkix/src/main/java/org/apache/kerby/cms/type/ContentInfo.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/ContentInfo.java b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/ContentInfo.java
index 5244c8f..19c17ea 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/ContentInfo.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/ContentInfo.java
@@ -59,8 +59,8 @@ public class ContentInfo extends Asn1SequenceType {
         setFieldAs(CONTENT_TYPE, contentType);
     }
 
-    public Asn1Type getContent() {
-        return getFieldAsAny(CONTENT);
+    public <T extends Asn1Type> T getContentAs(Class<T> t) {
+        return getFieldAsAny(CONTENT, t);
     }
 
     public void setContent(Asn1Type content) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherCertificateFormat.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherCertificateFormat.java
b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherCertificateFormat.java
index 239848e..74f2d7c 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherCertificateFormat.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherCertificateFormat.java
@@ -53,8 +53,8 @@ public class OtherCertificateFormat extends Asn1SequenceType {
         setFieldAs(OTHER_CERT_FORMAT, otherCertFormat);
     }
 
-    public Asn1Type getOtherCert() {
-        return getFieldAsAny(OTHER_CERT);
+    public <T extends Asn1Type> T getOtherCertAs(Class<T> t) {
+        return getFieldAsAny(OTHER_CERT, t);
     }
 
     public void setOtherCert(Asn1Type otherCert) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherRevocationInfoFormat.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherRevocationInfoFormat.java
b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherRevocationInfoFormat.java
index bf0f53e..e320a09 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherRevocationInfoFormat.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/OtherRevocationInfoFormat.java
@@ -52,8 +52,8 @@ public class OtherRevocationInfoFormat extends Asn1SequenceType {
         setFieldAs(OTHER_REV_INFO_FORMAT, otherRevInfoFormat);
     }
 
-    public Asn1Type getOtherRevInfo() {
-        return getFieldAsAny(OTHER_REV_INFO);
+    public <T extends Asn1Type> T getOtherRevInfoAs(Class<T> t) {
+        return getFieldAsAny(OTHER_REV_INFO, t);
     }
 
     public void setOtherRevInfo(Asn1Type otherRevInfo) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/kerby-pkix/src/main/java/org/apache/kerby/x500/type/AttributeTypeAndValue.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x500/type/AttributeTypeAndValue.java
b/kerby-pkix/src/main/java/org/apache/kerby/x500/type/AttributeTypeAndValue.java
index 3f0c2d8..fd4d40c 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/x500/type/AttributeTypeAndValue.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x500/type/AttributeTypeAndValue.java
@@ -53,8 +53,8 @@ public class AttributeTypeAndValue extends Asn1SequenceType {
         setFieldAs(TYPE, type);
     }
 
-    public Asn1Type getAttributeValue() {
-        return getFieldAsAny(VALUE);
+    public <T extends Asn1Type> T getAttributeValueAs(Class<T> t) {
+        return getFieldAsAny(VALUE, t);
     }
 
     public void setAttributeValue(Asn1Type value) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/kerby-pkix/src/main/java/org/apache/kerby/x509/type/AlgorithmIdentifier.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/AlgorithmIdentifier.java
b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/AlgorithmIdentifier.java
index 14bac49..8fd4db2 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/AlgorithmIdentifier.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/AlgorithmIdentifier.java
@@ -52,8 +52,8 @@ public class AlgorithmIdentifier extends Asn1SequenceType {
         setFieldAs(ALGORITHM, algorithm);
     }
 
-    public Asn1Type getParameters() {
-        return getFieldAsAny(PARAMETERS);
+    public <T extends Asn1Type> T getParametersAs(Class<T> t) {
+        return getFieldAsAny(PARAMETERS, t);
     }
 
     public void setParameters(Asn1Type parameters) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/kerby-pkix/src/main/java/org/apache/kerby/x509/type/OtherName.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/OtherName.java b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/OtherName.java
index 2933161..de21159 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/OtherName.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/OtherName.java
@@ -56,8 +56,8 @@ public class OtherName extends Asn1SequenceType {
         setFieldAs(TYPE_ID, algorithm);
     }
 
-    public Asn1Type getOtherNameValue() {
-        return getFieldAsAny(VALUE);
+    public <T extends Asn1Type> T getOtherNameValueAs(Class<T> t) {
+        return getFieldAsAny(VALUE, t);
     }
 
     public void setOtherNameValue(Asn1Type value) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/78f67dc0/kerby-pkix/src/main/java/org/apache/kerby/x509/type/PolicyQualifierInfo.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/PolicyQualifierInfo.java
b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/PolicyQualifierInfo.java
index ef75f0f..0f9434c 100644
--- a/kerby-pkix/src/main/java/org/apache/kerby/x509/type/PolicyQualifierInfo.java
+++ b/kerby-pkix/src/main/java/org/apache/kerby/x509/type/PolicyQualifierInfo.java
@@ -56,8 +56,8 @@ public class PolicyQualifierInfo extends Asn1SequenceType {
         setFieldAs(POLICY_QUALIFIER_ID, policyQualifierId);
     }
 
-    public Asn1Type getQualifier() {
-        return getFieldAsAny(QUALIFIER);
+    public <T extends Asn1Type> T getQualifierAs(Class<T> t) {
+        return getFieldAsAny(QUALIFIER, t);
     }
 
     public void setQualifier(Asn1Type qualifier) {


Mime
View raw message