Search in sources :

Example 11 with ASN1OutputStream

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

the class PKCS12BagAttributeCarrierImpl method writeObject.

public void writeObject(ObjectOutputStream out) throws IOException {
    if (pkcs12Ordering.size() == 0) {
        out.writeObject(new Hashtable());
        out.writeObject(new Vector());
    } else {
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        ASN1OutputStream aOut = new ASN1OutputStream(bOut);
        Enumeration e = this.getBagAttributeKeys();
        while (e.hasMoreElements()) {
            DERObjectIdentifier oid = (DERObjectIdentifier) e.nextElement();
            aOut.writeObject(oid);
            aOut.writeObject((ASN1Encodable) pkcs12Attributes.get(oid));
        }
        out.writeObject(bOut.toByteArray());
    }
}
Also used : Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ASN1OutputStream(org.bouncycastle.asn1.ASN1OutputStream) Vector(java.util.Vector) DERObjectIdentifier(org.bouncycastle.asn1.DERObjectIdentifier)

Example 12 with ASN1OutputStream

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

the class Attribute method toASN1Primitive.

/** 
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     * Attribute ::= SEQUENCE {
     *     attrType OBJECT IDENTIFIER,
     *     attrValues SET OF AttributeValue
     * }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(attrType);
    v.add(attrValues);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 13 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 14 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 15 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)

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