Example usage for org.bouncycastle.asn1 ASN1OctetString getOctetStream

List of usage examples for org.bouncycastle.asn1 ASN1OctetString getOctetStream

Introduction

In this page you can find the example usage for org.bouncycastle.asn1 ASN1OctetString getOctetStream.

Prototype

public InputStream getOctetStream() 

Source Link

Document

Return the content of the OCTET STRING as an InputStream.

Usage

From source file:support.revocation.OCSP.java

License:Apache License

/**
 * @return the parsed encoded ASN1 structure
 * @param octets/*from ww  w  .j a  v  a2s .  co  m*/
 * @throws IOException
 */
private static ASN1Primitive parseASN1(ASN1OctetString octets) throws IOException {
    try (InputStream octetStream = octets.getOctetStream();
            ASN1InputStream asn1stream = new ASN1InputStream(octetStream)) {
        return asn1stream.readObject();
    }
}

From source file:support.revocation.RevocationInfo.java

License:Apache License

/**
 * @return the parsed X.509 certificate extension with the specified OID for
 * the given certificate//  www.  j av a 2 s  .  c  o m
 * @param certificate
 * @param oid
 */
private static ASN1Primitive certificateExtension(X509Certificate certificate, String oid) {
    byte[] value = certificate.getExtensionValue(oid);
    ASN1OctetString octetString;

    if (value != null)
        try {
            try (ByteArrayInputStream valueStream = new ByteArrayInputStream(value);
                    ASN1InputStream asn1stream = new ASN1InputStream(valueStream)) {
                octetString = (ASN1OctetString) asn1stream.readObject();
            }

            try (InputStream octetStream = octetString.getOctetStream();
                    ASN1InputStream asn1stream = new ASN1InputStream(octetStream)) {
                return asn1stream.readObject();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    return null;
}