本文整理汇总了Java中org.bouncycastle.asn1.ASN1StreamParser.readObject方法的典型用法代码示例。如果您正苦于以下问题:Java ASN1StreamParser.readObject方法的具体用法?Java ASN1StreamParser.readObject怎么用?Java ASN1StreamParser.readObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.ASN1StreamParser
的用法示例。
在下文中一共展示了ASN1StreamParser.readObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parserTest
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
private void parserTest()
{
for (int i = 0; i != streams.length; i++)
{
ASN1StreamParser aIn = new ASN1StreamParser(Base64.decode(streams[i]));
try
{
Object obj;
while ((obj = aIn.readObject()) != null)
{
}
fail("bad stream parsed successfully!");
}
catch (IOException e)
{
// ignore
}
}
}
示例2: readAsn1Encodable
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
private static ASN1Encodable readAsn1Encodable(byte[] encoded) throws CertprofileException {
ASN1StreamParser parser = new ASN1StreamParser(encoded);
try {
return parser.readObject();
} catch (IOException ex) {
throw new CertprofileException("could not parse the constant extension value", ex);
}
}
示例3: buildConstantExtesions
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public static Map<ASN1ObjectIdentifier, ExtensionValue> buildConstantExtesions(
ExtensionsType extensionsType) throws CertprofileException {
if (extensionsType == null) {
return null;
}
Map<ASN1ObjectIdentifier, ExtensionValue> map = new HashMap<>();
for (ExtensionType m : extensionsType.getExtension()) {
ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(m.getType().getValue());
if (Extension.subjectAlternativeName.equals(oid)
|| Extension.subjectInfoAccess.equals(oid)
|| Extension.biometricInfo.equals(oid)) {
continue;
}
if (m.getValue() == null || !(m.getValue().getAny() instanceof ConstantExtValue)) {
continue;
}
ConstantExtValue extConf = (ConstantExtValue) m.getValue().getAny();
byte[] encodedValue = extConf.getValue();
ASN1StreamParser parser = new ASN1StreamParser(encodedValue);
ASN1Encodable value;
try {
value = parser.readObject();
} catch (IOException ex) {
throw new CertprofileException("could not parse the constant extension value", ex);
}
ExtensionValue extension = new ExtensionValue(m.isCritical(), value);
map.put(oid, extension);
}
if (CollectionUtil.isEmpty(map)) {
return null;
}
return Collections.unmodifiableMap(map);
}
示例4: buildConstantExtesions
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public static Map<ASN1ObjectIdentifier, QaExtensionValue> buildConstantExtesions(
ExtensionsType extensionsType) throws CertprofileException {
if (extensionsType == null) {
return null;
}
Map<ASN1ObjectIdentifier, QaExtensionValue> map = new HashMap<>();
for (ExtensionType m : extensionsType.getExtension()) {
if (m.getValue() == null || !(m.getValue().getAny() instanceof ConstantExtValue)) {
continue;
}
ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(m.getType().getValue());
if (Extension.subjectAlternativeName.equals(oid)
|| Extension.subjectInfoAccess.equals(oid)
|| Extension.biometricInfo.equals(oid)) {
continue;
}
ConstantExtValue extConf = (ConstantExtValue) m.getValue().getAny();
byte[] encodedValue = extConf.getValue();
ASN1StreamParser parser = new ASN1StreamParser(encodedValue);
try {
parser.readObject();
} catch (IOException ex) {
throw new CertprofileException("could not parse the constant extension value", ex);
}
QaExtensionValue extension = new QaExtensionValue(m.isCritical(), encodedValue);
map.put(oid, extension);
}
if (CollectionUtil.isEmpty(map)) {
return null;
}
return Collections.unmodifiableMap(map);
}
示例5: testDERReading
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public void testDERReading()
throws Exception
{
ASN1StreamParser aIn = new ASN1StreamParser(seqData);
ASN1SequenceParser seq = (ASN1SequenceParser)aIn.readObject();
Object o;
int count = 0;
assertNotNull("null sequence returned", seq);
while ((o = seq.readObject()) != null)
{
switch (count)
{
case 0:
assertTrue(o instanceof DERInteger);
break;
case 1:
assertTrue(o instanceof DERObjectIdentifier);
break;
}
count++;
}
assertEquals("wrong number of objects in sequence", 2, count);
}
示例6: testNestedReading
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
private void testNestedReading(
byte[] data)
throws Exception
{
ASN1StreamParser aIn = new ASN1StreamParser(data);
ASN1SequenceParser seq = (ASN1SequenceParser)aIn.readObject();
Object o;
int count = 0;
assertNotNull("null sequence returned", seq);
while ((o = seq.readObject()) != null)
{
switch (count)
{
case 0:
assertTrue(o instanceof DERInteger);
break;
case 1:
assertTrue(o instanceof DERObjectIdentifier);
break;
case 2:
assertTrue(o instanceof ASN1SequenceParser);
ASN1SequenceParser s = (ASN1SequenceParser)o;
// NB: Must exhaust the nested parser
while (s.readObject() != null)
{
// Nothing
}
break;
}
count++;
}
assertEquals("wrong number of objects in sequence", 3, count);
}
示例7: testBERReading
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public void testBERReading()
throws Exception
{
ASN1StreamParser aIn = new ASN1StreamParser(berSeqData);
ASN1SequenceParser seq = (ASN1SequenceParser)aIn.readObject();
Object o;
int count = 0;
assertNotNull("null sequence returned", seq);
while ((o = seq.readObject()) != null)
{
switch (count)
{
case 0:
assertTrue(o instanceof DERInteger);
break;
case 1:
assertTrue(o instanceof DERObjectIdentifier);
break;
}
count++;
}
assertEquals("wrong number of objects in sequence", 2, count);
}
示例8: testParseWithNull
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
private void testParseWithNull(byte[] data)
throws IOException
{
ASN1StreamParser aIn = new ASN1StreamParser(data);
ASN1SequenceParser seq = (ASN1SequenceParser)aIn.readObject();
Object o;
int count = 0;
assertNotNull("null sequence returned", seq);
while ((o = seq.readObject()) != null)
{
switch (count)
{
case 0:
assertTrue(o instanceof ASN1Null);
break;
case 1:
assertTrue(o instanceof DERInteger);
break;
case 2:
assertTrue(o instanceof DERObjectIdentifier);
break;
}
count++;
}
assertEquals("wrong number of objects in sequence", 3, count);
}
示例9: testReadingWriting
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public void testReadingWriting()
throws Exception
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BEROctetStringGenerator octGen = new BEROctetStringGenerator(bOut);
OutputStream out = octGen.getOctetOutputStream();
out.write(new byte[] { 1, 2, 3, 4 });
out.write(new byte[4]);
out.close();
ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());
ASN1OctetStringParser s = (ASN1OctetStringParser)aIn.readObject();
InputStream in = s.getOctetStream();
int count = 0;
while (in.read() >= 0)
{
count++;
}
assertEquals(8, count);
}
示例10: testReadingWritingZeroInLength
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public void testReadingWritingZeroInLength()
throws Exception
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BEROctetStringGenerator octGen = new BEROctetStringGenerator(bOut);
OutputStream out = octGen.getOctetOutputStream();
out.write(new byte[] { 1, 2, 3, 4 });
out.write(new byte[512]); // forces a zero to appear in length
out.close();
ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());
ASN1OctetStringParser s = (ASN1OctetStringParser)aIn.readObject();
InputStream in = s.getOctetStream();
int count = 0;
while (in.read() >= 0)
{
count++;
}
assertEquals(516, count);
}
示例11: testLongTag
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public void testLongTag()
throws IOException
{
ASN1StreamParser aIn = new ASN1StreamParser(longTagged);
ASN1TaggedObjectParser tagged = (ASN1TaggedObjectParser)aIn.readObject();
assertEquals(31, tagged.getTagNo());
}
示例12: CVCertificate
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public CVCertificate(byte[] in) throws IllegalArgumentException, IOException {
ASN1StreamParser asn1Parser = new ASN1StreamParser(in);
DERApplicationSpecific cvcert = (DERApplicationSpecific) asn1Parser.readObject();
if (cvcert.getApplicationTag()!=0x21) throw new IllegalArgumentException("Can't find a CV Certificate");
ASN1Sequence derCert= (ASN1Sequence)cvcert.getObject(BERTags.SEQUENCE); // Das CV Cerificate ist eine Sequence
DERApplicationSpecific body = (DERApplicationSpecific) derCert.getObjectAt(0); //Das erste Objekt des Certificates ist der Cert-Body
if (body.getApplicationTag()!=0x4E) throw new IllegalArgumentException("Can't find a Body in the CV Certificate");
certBody = new CVCertBody(body);
DERApplicationSpecific signature = (DERApplicationSpecific) derCert.getObjectAt(1); //Das zweite Objekt des Certificates ist die Signatur
if (signature.getApplicationTag()!=0x37) throw new IllegalArgumentException("Can't find a Signature in the CV Certificate");
certSignature = new CVCertSignature(signature.getContents());
}
示例13: testNestedStructure
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public void testNestedStructure()
throws Exception
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BERSequenceGenerator sGen = new BERSequenceGenerator(bOut);
sGen.addObject(new DERObjectIdentifier(CMSObjectIdentifiers.compressedData.getId()));
BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true);
cGen.addObject(new DERInteger(0));
//
// AlgorithmIdentifier
//
DERSequenceGenerator algGen = new DERSequenceGenerator(cGen.getRawOutputStream());
algGen.addObject(new DERObjectIdentifier("1.2"));
algGen.close();
//
// Encapsulated ContentInfo
//
BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream());
eiGen.addObject(new DERObjectIdentifier("1.1"));
BEROctetStringGenerator octGen = new BEROctetStringGenerator(eiGen.getRawOutputStream(), 0, true);
//
// output containing zeroes
//
OutputStream out = octGen.getOctetOutputStream();
out.write(new byte[] { 1, 2, 3, 4 });
out.write(new byte[4]);
out.write(new byte[20]);
out.close();
eiGen.close();
cGen.close();
sGen.close();
//
// reading back
//
ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());
ContentInfoParser cp = new ContentInfoParser((ASN1SequenceParser)aIn.readObject());
CompressedDataParser comData = new CompressedDataParser((ASN1SequenceParser)cp.getContent(BERTags.SEQUENCE));
ContentInfoParser content = comData.getEncapContentInfo();
ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);
InputStream in = bytes.getOctetStream();
int count = 0;
while (in.read() >= 0)
{
count++;
}
assertEquals(28, count);
}
示例14: parseEnveloped
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
private void parseEnveloped(byte[] data) throws IOException
{
ASN1StreamParser aIn = new ASN1StreamParser(data);
ContentInfoParser cP = new ContentInfoParser((ASN1SequenceParser)aIn.readObject());
EnvelopedDataParser eP = new EnvelopedDataParser((ASN1SequenceParser)cP.getContent(BERTags.SEQUENCE));
eP.getRecipientInfos().toASN1Primitive(); // Must drain the parser!
EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();
ASN1OctetStringParser content = (ASN1OctetStringParser)ecP.getEncryptedContent(BERTags.OCTET_STRING);
Streams.drain(content.getOctetStream());
}
示例15: testReadingWritingNested
import org.bouncycastle.asn1.ASN1StreamParser; //导入方法依赖的package包/类
public void testReadingWritingNested()
throws Exception
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BERSequenceGenerator sGen = new BERSequenceGenerator(bOut);
BEROctetStringGenerator octGen = new BEROctetStringGenerator(sGen.getRawOutputStream());
OutputStream out = octGen.getOctetOutputStream();
BERSequenceGenerator inSGen = new BERSequenceGenerator(out);
BEROctetStringGenerator inOctGen = new BEROctetStringGenerator(inSGen.getRawOutputStream());
OutputStream inOut = inOctGen.getOctetOutputStream();
inOut.write(new byte[] { 1, 2, 3, 4 });
inOut.write(new byte[10]);
inOut.close();
inSGen.close();
out.close();
sGen.close();
ASN1StreamParser aIn = new ASN1StreamParser(bOut.toByteArray());
ASN1SequenceParser sq = (ASN1SequenceParser)aIn.readObject();
ASN1OctetStringParser s = (ASN1OctetStringParser)sq.readObject();
ASN1StreamParser aIn2 = new ASN1StreamParser(s.getOctetStream());
ASN1SequenceParser sq2 = (ASN1SequenceParser)aIn2.readObject();
ASN1OctetStringParser inS = (ASN1OctetStringParser)sq2.readObject();
InputStream in = inS.getOctetStream();
int count = 0;
while (in.read() >= 0)
{
count++;
}
assertEquals(14, count);
}