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: ASN1. Allow to register value type for Any to avoid blindly decoding when possible
Date Mon, 21 Dec 2015 23:06:33 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 6dca5950e -> d9030f648


ASN1. Allow to register value type for Any to avoid blindly decoding when possible


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

Branch: refs/heads/master
Commit: d9030f64830dd096a16b0abf814260a3c5780fae
Parents: 6dca595
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Tue Dec 22 07:06:01 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Tue Dec 22 07:06:01 2015 +0800

----------------------------------------------------------------------
 .../org/apache/kerby/asn1/type/Asn1Any.java     | 41 +++++++++++++-------
 .../kerby/asn1/type/Asn1CollectionType.java     | 22 +++++++++--
 .../kerb/preauth/pkinit/PkinitCrypto.java       |  6 +--
 .../kerby/cms/type/CompressedContentInfo.java   | 41 ++++++++++++++++++++
 .../kerby/cms/type/EnvelopedContentInfo.java    | 41 ++++++++++++++++++++
 .../kerby/cms/type/SignedContentInfo.java       | 41 ++++++++++++++++++++
 .../apache/kerby/cms/TestCompressedData.java    |  7 ++--
 .../org/apache/kerby/cms/TestEnvelopedData.java | 17 ++++----
 .../org/apache/kerby/cms/TestExtension.java     |  2 +-
 .../org/apache/kerby/cms/TestGeneralName.java   |  2 +-
 .../org/apache/kerby/cms/TestSignedData.java    | 14 +++----
 11 files changed, 192 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/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 79d41df..3c35173 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
@@ -37,6 +37,7 @@ import java.nio.ByteBuffer;
  */
 public class Asn1Any
     extends AbstractAsn1Type<Asn1Type> implements Asn1Dumpable {
+    private Class<? extends Asn1Type> valueType;
     private Asn1FieldInfo decodeInfo;
     private Asn1ParseResult parseResult;
     private boolean isBlindlyDecoded = true;
@@ -60,6 +61,10 @@ public class Asn1Any
         return super.tag();
     }
 
+    public void setValueType(Class<? extends Asn1Type> valueType) {
+        this.valueType = valueType;
+    }
+
     public void setDecodeInfo(Asn1FieldInfo decodeInfo) {
         this.decodeInfo = decodeInfo;
     }
@@ -135,7 +140,12 @@ public class Asn1Any
     @Override
     protected void decodeBody(Asn1ParseResult parseResult) throws IOException {
         this.parseResult = parseResult;
-        blindlyDecode();
+
+        if (valueType != null) {
+            typeAwareDecode(valueType);
+        } else {
+            blindlyDecode();
+        }
     }
 
     private void blindlyDecode() throws IOException {
@@ -158,28 +168,33 @@ public class Asn1Any
             return (T) value;
         }
 
-        typeAwareDecode(t);
+        if (valueType != null && valueType != t) {
+            throw new RuntimeException("Required value type isn't the same"
+            + " with the value type set before");
+        }
+
+        try {
+            typeAwareDecode(t);
+        } catch (IOException e) {
+            throw new RuntimeException("Type aware decoding of Any type failed");
+        }
 
         return (T) getValue();
     }
 
-    private <T extends Asn1Type> void typeAwareDecode(Class<T> t) {
+    private <T extends Asn1Type> void typeAwareDecode(Class<T> t) throws IOException
{
         T result;
         try {
             result = t.newInstance();
         } catch (Exception e) {
-            throw new RuntimeException("No default constructor?", e);
+            throw new IOException("No default constructor?", e);
         }
 
-        try {
-            if (parseResult.isContextSpecific()) {
-                Asn1Binder.bindWithTagging(parseResult, result,
-                    decodeInfo.getTaggingOption());
-            } else {
-                Asn1Binder.bind(parseResult, result);
-            }
-        } catch (IOException e) {
-            throw new RuntimeException("Fully decoding failed", e);
+        if (parseResult.isContextSpecific()) {
+            Asn1Binder.bindWithTagging(parseResult, result,
+                decodeInfo.getTaggingOption());
+        } else {
+            Asn1Binder.bind(parseResult, result);
         }
 
         setValue(result);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/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 0812fb7..16e40b3 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
@@ -166,9 +166,13 @@ public abstract class Asn1CollectionType
 
     private void checkAndInitFields() {
         for (int i = 0; i < fieldInfos.length; ++i) {
-            if (fields[i] == null) {
-                fields[i] = fieldInfos[i].createFieldValue();
-            }
+            checkAndInitField(i);
+        }
+    }
+
+    private void checkAndInitField(int index) {
+        if (fields[index] == null) {
+            fields[index] = fieldInfos[index].createFieldValue();
         }
     }
 
@@ -245,6 +249,18 @@ public abstract class Asn1CollectionType
         }
     }
 
+    protected void setAnyFieldValueType(EnumType index,
+                                        Class<? extends Asn1Type> valueType) {
+        if (valueType != null) {
+            checkAndInitField(index.getValue());
+            Asn1Type value = fields[index.getValue()];
+            if (value != null && value instanceof Asn1Any) {
+                Asn1Any any = (Asn1Any) value;
+                any.setValueType(valueType);
+            }
+        }
+    }
+
     @Override
     public void dumpWith(Asn1Dumper dumper, int indents) {
         dumper.indent(indents).appendType(getClass());

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/pkinit/PkinitCrypto.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/pkinit/PkinitCrypto.java
b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/pkinit/PkinitCrypto.java
index 409ef44..e9cca99 100644
--- a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/pkinit/PkinitCrypto.java
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/pkinit/PkinitCrypto.java
@@ -20,10 +20,10 @@ package org.apache.kerby.kerberos.kerb.preauth.pkinit;
 
 import org.apache.kerby.asn1.type.Asn1ObjectIdentifier;
 import org.apache.kerby.cms.type.CertificateSet;
-import org.apache.kerby.cms.type.ContentInfo;
 import org.apache.kerby.cms.type.DigestAlgorithmIdentifiers;
 import org.apache.kerby.cms.type.EncapsulatedContentInfo;
 import org.apache.kerby.cms.type.RevocationInfoChoices;
+import org.apache.kerby.cms.type.SignedContentInfo;
 import org.apache.kerby.cms.type.SignedData;
 import org.apache.kerby.cms.type.SignerInfos;
 import org.apache.kerby.kerberos.kerb.KrbCodec;
@@ -225,7 +225,7 @@ public class PkinitCrypto {
                                              DigestAlgorithmIdentifiers digestAlgorithmIdentifiers,
                                              CertificateSet certificateSet,
                                              RevocationInfoChoices crls, SignerInfos signerInfos)
throws KrbException {
-        ContentInfo contentInfo = new ContentInfo();
+        SignedContentInfo contentInfo = new SignedContentInfo();
         contentInfo.setContentType(new Asn1ObjectIdentifier("1.2.840.113549.1.7.2"));
         SignedData signedData = new SignedData();
         signedData.setVersion(version);
@@ -245,7 +245,7 @@ public class PkinitCrypto {
         if (signerInfos != null) {
             signedData.setSignerInfos(signerInfos);
         }
-        contentInfo.setContent(signedData);
+        contentInfo.setSignedData(signedData);
         return KrbCodec.encode(contentInfo);
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-pkix/src/main/java/org/apache/kerby/cms/type/CompressedContentInfo.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/CompressedContentInfo.java
b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/CompressedContentInfo.java
new file mode 100644
index 0000000..ab26f64
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/CompressedContentInfo.java
@@ -0,0 +1,41 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.cms.type;
+
+import static org.apache.kerby.cms.type.ContentInfo.MyEnum.*;
+
+/**
+ * A ContentInfo that wraps CompressedData.
+ */
+public class CompressedContentInfo extends ContentInfo {
+
+    public CompressedContentInfo() {
+        super();
+        setAnyFieldValueType(CONTENT, CompressedData.class);
+    }
+
+    public CompressedData getCompressedData() {
+        return getFieldAsAny(CONTENT, CompressedData.class);
+    }
+
+    public void setCompressedData(CompressedData signedData) {
+        setFieldAsAny(CONTENT, signedData);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-pkix/src/main/java/org/apache/kerby/cms/type/EnvelopedContentInfo.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/EnvelopedContentInfo.java
b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/EnvelopedContentInfo.java
new file mode 100644
index 0000000..7674b87
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/EnvelopedContentInfo.java
@@ -0,0 +1,41 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.cms.type;
+
+import static org.apache.kerby.cms.type.ContentInfo.MyEnum.*;
+
+/**
+ * A ContentInfo that wraps EnvelopedData.
+ */
+public class EnvelopedContentInfo extends ContentInfo {
+
+    public EnvelopedContentInfo() {
+        super();
+        setAnyFieldValueType(CONTENT, EnvelopedData.class);
+    }
+
+    public EnvelopedData getEnvelopedData() {
+        return getFieldAsAny(CONTENT, EnvelopedData.class);
+    }
+
+    public void setEnvelopedData(EnvelopedData signedData) {
+        setFieldAsAny(CONTENT, signedData);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-pkix/src/main/java/org/apache/kerby/cms/type/SignedContentInfo.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/cms/type/SignedContentInfo.java b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/SignedContentInfo.java
new file mode 100644
index 0000000..5d99d61
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/cms/type/SignedContentInfo.java
@@ -0,0 +1,41 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.cms.type;
+
+import static org.apache.kerby.cms.type.ContentInfo.MyEnum.*;
+
+/**
+ * A ContentInfo that wraps SignedData.
+ */
+public class SignedContentInfo extends ContentInfo {
+
+    public SignedContentInfo() {
+        super();
+        setAnyFieldValueType(CONTENT, SignedData.class);
+    }
+
+    public SignedData getSignedData() {
+        return getFieldAsAny(CONTENT, SignedData.class);
+    }
+
+    public void setSignedData(SignedData signedData) {
+        setFieldAsAny(CONTENT, signedData);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
index 254df43..8ad721a 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestCompressedData.java
@@ -20,8 +20,8 @@
 package org.apache.kerby.cms;
 
 import org.apache.kerby.asn1.Asn1;
+import org.apache.kerby.cms.type.CompressedContentInfo;
 import org.apache.kerby.cms.type.CompressedData;
-import org.apache.kerby.cms.type.ContentInfo;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -35,12 +35,11 @@ public class TestCompressedData extends CmsTestBase {
         try {
             Asn1.parseAndDump(data);
 
-            ContentInfo contentInfo = new ContentInfo();
+            CompressedContentInfo contentInfo = new CompressedContentInfo();
             contentInfo.decode(data);
             Asn1.dump(contentInfo);
 
-            CompressedData compressedData =
-                contentInfo.getContentAs(CompressedData.class);
+            CompressedData compressedData = contentInfo.getCompressedData();
             Asn1.dump(compressedData);
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-pkix/src/test/java/org/apache/kerby/cms/TestEnvelopedData.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestEnvelopedData.java b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestEnvelopedData.java
index edd9e4b..e30007a 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestEnvelopedData.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestEnvelopedData.java
@@ -20,7 +20,7 @@
 package org.apache.kerby.cms;
 
 import org.apache.kerby.asn1.Asn1;
-import org.apache.kerby.cms.type.ContentInfo;
+import org.apache.kerby.cms.type.EnvelopedContentInfo;
 import org.apache.kerby.cms.type.EnvelopedData;
 import org.junit.Assert;
 import org.junit.Test;
@@ -35,12 +35,11 @@ public class TestEnvelopedData extends CmsTestBase {
         try {
             Asn1.parseAndDump(data);
 
-            ContentInfo contentInfo = new ContentInfo();
+            EnvelopedContentInfo contentInfo = new EnvelopedContentInfo();
             contentInfo.decode(data);
             Asn1.dump(contentInfo);
 
-            EnvelopedData envelopedData =
-                    contentInfo.getContentAs(EnvelopedData.class);
+            EnvelopedData envelopedData = contentInfo.getEnvelopedData();
             Asn1.dump(envelopedData);
         } catch (Exception e) {
             e.printStackTrace();
@@ -54,12 +53,11 @@ public class TestEnvelopedData extends CmsTestBase {
         try {
             Asn1.parseAndDump(data);
 
-            ContentInfo contentInfo = new ContentInfo();
+            EnvelopedContentInfo contentInfo = new EnvelopedContentInfo();
             contentInfo.decode(data);
             Asn1.dump(contentInfo);
 
-            EnvelopedData envelopedData =
-                    contentInfo.getContentAs(EnvelopedData.class);
+            EnvelopedData envelopedData = contentInfo.getEnvelopedData();
             Asn1.dump(envelopedData);
         } catch (Exception e) {
             e.printStackTrace();
@@ -73,12 +71,11 @@ public class TestEnvelopedData extends CmsTestBase {
         try {
             Asn1.parseAndDump(data);
 
-            ContentInfo contentInfo = new ContentInfo();
+            EnvelopedContentInfo contentInfo = new EnvelopedContentInfo();
             contentInfo.decode(data);
             Asn1.dump(contentInfo);
 
-            EnvelopedData envelopedData =
-                    contentInfo.getContentAs(EnvelopedData.class);
+            EnvelopedData envelopedData = contentInfo.getEnvelopedData();
             Asn1.dump(envelopedData);
         } catch (Exception e) {
             e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-pkix/src/test/java/org/apache/kerby/cms/TestExtension.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestExtension.java b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestExtension.java
index 1857e28..56c44af 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestExtension.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestExtension.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 import java.io.IOException;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.*;
 
 public class TestExtension {
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/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 a9a4f5b..54b60b7 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
@@ -27,7 +27,7 @@ import org.junit.Test;
 
 import java.io.IOException;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.*;
 
 public class TestGeneralName {
     private static final byte[] IPV4 = HexUtil.hex2bytes("87040a090800");

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d9030f64/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
index 4b67bd2..18d452e 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/cms/TestSignedData.java
@@ -25,6 +25,7 @@ import org.apache.kerby.cms.type.CertificateChoices;
 import org.apache.kerby.cms.type.CertificateSet;
 import org.apache.kerby.cms.type.ContentInfo;
 import org.apache.kerby.cms.type.EncapsulatedContentInfo;
+import org.apache.kerby.cms.type.SignedContentInfo;
 import org.apache.kerby.cms.type.SignedData;
 import org.apache.kerby.x509.type.Certificate;
 import org.junit.Assert;
@@ -41,12 +42,11 @@ public class TestSignedData extends CmsTestBase {
             Asn1.parseAndDump(data);
             //Asn1.decodeAndDump(data);
 
-            ContentInfo contentInfo = new ContentInfo();
+            SignedContentInfo contentInfo = new SignedContentInfo();
             contentInfo.decode(data);
             //Asn1.dump(contentInfo);
 
-            SignedData signedData =
-            contentInfo.getContentAs(SignedData.class);
+            SignedData signedData = contentInfo.getSignedData();
             Asn1.dump(signedData);
 
             Asn1.dump(contentInfo);
@@ -60,7 +60,7 @@ public class TestSignedData extends CmsTestBase {
 
     @Test
     public void testEncoding() throws IOException {
-        ContentInfo contentInfo = new ContentInfo();
+        SignedContentInfo contentInfo = new SignedContentInfo();
         contentInfo.setContentType(new Asn1ObjectIdentifier("1.2.840.113549.1.7.2"));
         SignedData signedData = new SignedData();
         EncapsulatedContentInfo eContentInfo = new EncapsulatedContentInfo();
@@ -77,18 +77,18 @@ public class TestSignedData extends CmsTestBase {
         certificateSet.addElement(certificateChoices);
         signedData.setCertificates(certificateSet);
 
-        contentInfo.setContent(signedData);
+        contentInfo.setSignedData(signedData);
         Asn1.dump(contentInfo);
 
         byte[] encodedData = contentInfo.encode();
         Asn1.parseAndDump(encodedData);
 
-        ContentInfo decodedContentInfo = new ContentInfo();
+        SignedContentInfo decodedContentInfo = new SignedContentInfo();
         decodedContentInfo.decode(encodedData);
         Asn1.dump(decodedContentInfo);
 
         SignedData decodedSignedData =
-                decodedContentInfo.getContentAs(SignedData.class);
+                decodedContentInfo.getSignedData();
         Asn1.dump(decodedSignedData);
     }
 


Mime
View raw message