Search in sources :

Example 31 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project XobotOS by xamarin.

the class AttributeCertificateInfo method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  AttributeCertificateInfo ::= SEQUENCE {
     *       version              AttCertVersion -- version is v2,
     *       holder               Holder,
     *       issuer               AttCertIssuer,
     *       signature            AlgorithmIdentifier,
     *       serialNumber         CertificateSerialNumber,
     *       attrCertValidityPeriod   AttCertValidityPeriod,
     *       attributes           SEQUENCE OF Attribute,
     *       issuerUniqueID       UniqueIdentifier OPTIONAL,
     *       extensions           Extensions OPTIONAL
     *  }
     *
     *  AttCertVersion ::= INTEGER { v2(1) }
     * </pre>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(version);
    v.add(holder);
    v.add(issuer);
    v.add(signature);
    v.add(serialNumber);
    v.add(attrCertValidityPeriod);
    v.add(attributes);
    if (issuerUniqueID != null) {
        v.add(issuerUniqueID);
    }
    if (extensions != null) {
        v.add(extensions);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 32 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project XobotOS by xamarin.

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(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 33 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project XobotOS by xamarin.

the class X509CRLObject 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 34 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project XobotOS by xamarin.

the class X509CertificateObject method getSubjectX500Principal.

public X500Principal getSubjectX500Principal() {
    try {
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        ASN1OutputStream aOut = new ASN1OutputStream(bOut);
        aOut.writeObject(c.getSubject());
        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 35 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project XobotOS by xamarin.

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)

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