Example usage for org.bouncycastle.asn1 ASN1Boolean ASN1Boolean

List of usage examples for org.bouncycastle.asn1 ASN1Boolean ASN1Boolean

Introduction

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

Prototype

private ASN1Boolean(byte value) 

Source Link

Usage

From source file:tests.asn1.TstInfoTest.java

License:Apache License

/**
 * Produces input stream containing ASN.1 representation of TST info.
 */// w  w  w .  j av a2s . c  o m
private InputStream getDerStream(Integer version, String policy, byte[] messageImprint, BigInteger serialNumber,
        String genTime, byte[] accuracy, Boolean ordering, BigInteger nonce, DERTaggedObject tsa)
        throws IOException {
    ASN1EncodableVector v = new ASN1EncodableVector();

    if (version != null) {
        v.add(new ASN1Integer(version.intValue()));
    }

    if (policy != null) {
        v.add(new ASN1ObjectIdentifier(policy));
    }

    if (messageImprint != null) {
        v.add(new ASN1InputStream(messageImprint).readObject());
    }

    if (serialNumber != null) {
        v.add(new ASN1Integer(serialNumber));
    }

    if (genTime != null) {
        v.add(new ASN1GeneralizedTime(genTime));
    }

    if (accuracy != null) {
        v.add(new ASN1InputStream(accuracy).readObject());
    }

    if (ordering != null) {
        v.add(new ASN1Boolean(ordering.booleanValue()));
    }

    if (nonce != null) {
        v.add(new ASN1Integer(nonce.intValue()));
    }

    if (tsa != null) {
        v.add(tsa);
    }

    // Extensions skipped -- see TstInfo code for comments

    byte[] der = new DERSequence(v).getEncoded(ASN1Encoding.DER);

    return new ByteArrayInputStream(der);
}