CompressedData ::= SEQUENCE { version CMSVersion, compressionAlgorithm CompressionAlgorithmIdentifier, encapContentInfo EncapsulatedContentInfo }
454647484950515253545556
public CMSTypedStream getContent() throws CMSException { try { CompressedDataParser comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(DERTags.SEQUENCE)); ContentInfoParser content = comData.getEncapContentInfo(); ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(DERTags.OCTET_STRING); return new CMSTypedStream(content.getContentType().toString(), new InflaterInputStream(bytes.getOctetStream())); }
2627282930313233343536373839
String oid, byte[] enc) throws IOException { ByteArrayInputStream bIn = new ByteArrayInputStream(enc); Asn1InputStream aIn = new Asn1InputStream(bIn); Asn1ObjectIdentifier o = new Asn1ObjectIdentifier(oid); Asn1ObjectIdentifier encO = (Asn1ObjectIdentifier)aIn.readObject(); if (!o.equals(encO)) { fail("oid ID didn't match - got: " + o + " expected " + encO); }
58596061626364656667686970
String oid) throws IOException { Asn1ObjectIdentifier o = new Asn1ObjectIdentifier(oid); ByteArrayInputStream bIn = new ByteArrayInputStream(o.getEncoded()); Asn1InputStream aIn = new Asn1InputStream(bIn); o = (Asn1ObjectIdentifier)aIn.readObject(); if (!o.toString().equals(oid)) { fail("failed oid check for " + oid); }
200201202203204205206207208209210211212
} public void testDerReading() throws Exception { Asn1InputStream aIn = new Asn1InputStream(seqData); Asn1Sequence seq = (Asn1Sequence)aIn.readObject(); Object o = null; int count = 0; assertNotNull("null sequence returned", seq);
229230231232233234235236237238239240241
public void testNestedReading( byte[] data) throws Exception { Asn1InputStream aIn = new Asn1InputStream(data); Asn1Sequence seq = (Asn1Sequence)aIn.readObject(); Object o = null; int count = 0; assertNotNull("null sequence returned", seq);
271272273274275276277278279280281282283
} public void testBerReading() throws Exception { Asn1InputStream aIn = new Asn1InputStream(berSeqData); Asn1Sequence seq = (Asn1Sequence)aIn.readObject(); Object o = null; int count = 0; assertNotNull("null sequence returned", seq);
284285286287288289290291292293294
} public void testLongTag() throws IOException { Asn1InputStream aIn = new Asn1InputStream(longTagged); Asn1TaggedObject tagged = (Asn1TaggedObject)aIn.readObject(); assertEquals(31, tagged.getTagNumber()); }
293294295296297298299300301302303304305
assertEquals(31, tagged.getTagNumber()); } private void parseEnveloped(byte[] data) throws IOException { Asn1InputStream aIn = new Asn1InputStream(data); ContentInfoParser cP = new ContentInfoParser((Asn1Sequence)aIn.readObject()); EnvelopedDataParser eP = new EnvelopedDataParser((Asn1Sequence)cP.getContent(BerTag.SEQUENCE)); eP.getRecipientInfos();
40414243444546474849505152
out.write(new byte[] { 1, 2, 3, 4 }); out.write(new byte[4]); out.close(); Asn1InputStream aIn = new Asn1InputStream(bOut.toByteArray()); BerOctetString s = (BerOctetString)aIn.readObject(); InputStream in = s.getOctetStream(); int count = 0; while (in.read() >= 0)
68697071727374757677787980
out.write(new byte[] { 1, 2, 3, 4 }); out.write(new byte[512]); // forces a zero to appear in length out.close(); Asn1InputStream aIn = new Asn1InputStream(bOut.toByteArray()); BerOctetString s = (BerOctetString)aIn.readObject(); InputStream in = s.getOctetStream(); int count = 0; while (in.read() >= 0)