Example usage for org.bouncycastle.asn1 DERApplicationSpecific DERApplicationSpecific

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

Introduction

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

Prototype

public DERApplicationSpecific(boolean constructed, int tag, ASN1Encodable object) throws IOException 

Source Link

Document

Create an application specific object with the tagging style given by the value of constructed.

Usage

From source file:ca.trustpoint.m2m.M2mCertificate.java

License:Apache License

@Override
public byte[] getEncoded() throws CertificateEncodingException {
    ASN1EncodableVector elements = new ASN1EncodableVector();

    if (!isTbsCertificateValid()) {
        throw new CertificateEncodingException("TBS certificate is invalid.");
    } else if ((caCalcValue == null) || (caCalcValue.length == 0)) {
        throw new CertificateEncodingException("Signature or reconstruction value must be present.");
    }// ww  w.  j  a v a 2  s.c om

    try {
        elements.add(new DERTaggedObject(false, CertificateFields.TBS_CERTIFICATE.getTagNumber(),
                DERSequence.fromByteArray(getTBSCertificate())));
    } catch (IOException ex) {
        throw new CertificateEncodingException("Could not encode TBS certificate fields.", ex);
    }

    elements.add(new DERTaggedObject(false, CertificateFields.CA_CALC_VALUE.getTagNumber(),
            new DEROctetString(caCalcValue)));

    DERApplicationSpecific certificate = null;

    try {
        certificate = new DERApplicationSpecific(false, APPLICATION_TAG_NUMBER, new DERSequence(elements));
    } catch (IOException ex) {
        throw new CertificateEncodingException("Could not construct ASN.1 certificate.", ex);
    }

    byte[] encodedBytes = null;

    try {
        encodedBytes = certificate.getEncoded();
    } catch (IOException ex) {
        throw new CertificateEncodingException("Could not encode certificate.", ex);
    }

    return encodedBytes;
}

From source file:de.tsenger.animamea.asn1.DiscretionaryData.java

License:Open Source License

@Override
public ASN1Primitive toASN1Primitive() {
    try {/*www  . java  2  s . co m*/
        return new DERApplicationSpecific(false, 0x13, data);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}