Search in sources :

Example 1 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class X509CertificateObject method getIssuerX500Principal.

public X500Principal getIssuerX500Principal() {
    try {
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        ASN1OutputStream aOut = new ASN1OutputStream(bOut);
        aOut.writeObject(c.getIssuer());
        return new X500Principal(bOut.toByteArray());
    } catch (IOException e) {
        throw new IllegalStateException("can't encode issuer DN");
    }
}
Also used : X500Principal(javax.security.auth.x500.X500Principal) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ASN1OutputStream(org.bouncycastle.asn1.ASN1OutputStream)

Example 2 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class SignedData method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  SignedData ::= SEQUENCE {
     *      version Version,
     *      digestAlgorithms DigestAlgorithmIdentifiers,
     *      contentInfo ContentInfo,
     *      certificates
     *          [0] IMPLICIT ExtendedCertificatesAndCertificates
     *                   OPTIONAL,
     *      crls
     *          [1] IMPLICIT CertificateRevocationLists OPTIONAL,
     *      signerInfos SignerInfos }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(version);
    v.add(digestAlgorithms);
    v.add(contentInfo);
    if (certificates != null) {
        v.add(new DERTaggedObject(false, 0, certificates));
    }
    if (crls != null) {
        v.add(new DERTaggedObject(false, 1, crls));
    }
    v.add(signerInfos);
    return new BERSequence(v);
}
Also used : DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) BERSequence(org.bouncycastle.asn1.BERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 3 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class IssuerSerial method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  IssuerSerial  ::=  SEQUENCE {
     *       issuer         GeneralNames,
     *       serial         CertificateSerialNumber,
     *       issuerUID      UniqueIdentifier OPTIONAL
     *  }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(issuer);
    v.add(serial);
    if (issuerUID != null) {
        v.add(issuerUID);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 4 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class SubjectPublicKeyInfo method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     * SubjectPublicKeyInfo ::= SEQUENCE {
     *                          algorithm AlgorithmIdentifier,
     *                          publicKey BIT STRING }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(algId);
    v.add(keyData);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 5 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class ContentInfo method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     * ContentInfo ::= SEQUENCE {
     *          contentType ContentType,
     *          content
     *          [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(contentType);
    if (content != null) {
        v.add(new BERTaggedObject(0, content));
    }
    return new BERSequence(v);
}
Also used : BERSequence(org.bouncycastle.asn1.BERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) BERTaggedObject(org.bouncycastle.asn1.BERTaggedObject)

Aggregations

ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)33 DERSequence (org.bouncycastle.asn1.DERSequence)26 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ASN1OutputStream (org.bouncycastle.asn1.ASN1OutputStream)11 IOException (java.io.IOException)9 X500Principal (javax.security.auth.x500.X500Principal)7 BERSequence (org.bouncycastle.asn1.BERSequence)7 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)6 BERTaggedObject (org.bouncycastle.asn1.BERTaggedObject)5 Enumeration (java.util.Enumeration)4 PolicyQualifierInfo (java.security.cert.PolicyQualifierInfo)2 HashSet (java.util.HashSet)2 Hashtable (java.util.Hashtable)2 Set (java.util.Set)2 Vector (java.util.Vector)2 DERBitString (org.bouncycastle.asn1.DERBitString)2 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)2 ExtCertPathValidatorException (org.bouncycastle.jce.exception.ExtCertPathValidatorException)2 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)1 DERInteger (org.bouncycastle.asn1.DERInteger)1