Search in sources :

Example 6 with DERTaggedObject

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

the class CertificationRequestInfo method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(version);
    v.add(subject);
    v.add(subjectPKInfo);
    if (attributes != null) {
        v.add(new DERTaggedObject(false, 0, attributes));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 7 with DERTaggedObject

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

the class CMSUtils method getAttributeCertificatesFromStore.

static List getAttributeCertificatesFromStore(Store attrStore) throws CMSException {
    List certs = new ArrayList();
    try {
        for (Iterator it = attrStore.getMatches(null).iterator(); it.hasNext(); ) {
            X509AttributeCertificateHolder attrCert = (X509AttributeCertificateHolder) it.next();
            certs.add(new DERTaggedObject(false, 2, attrCert.toASN1Structure()));
        }
        return certs;
    } catch (ClassCastException e) {
        throw new CMSException("error processing certs", e);
    }
}
Also used : DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) CertificateList(org.bouncycastle.asn1.x509.CertificateList) List(java.util.List) X509AttributeCertificateHolder(org.bouncycastle.cert.X509AttributeCertificateHolder)

Example 8 with DERTaggedObject

use of org.bouncycastle.asn1.DERTaggedObject in project Conversations by siacs.

the class XmppDomainVerifier method parseOtherName.

private static Pair<String, String> parseOtherName(byte[] otherName) {
    try {
        ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName);
        if (asn1Primitive instanceof DERTaggedObject) {
            ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject();
            if (inner instanceof DLSequence) {
                DLSequence sequence = (DLSequence) inner;
                if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) {
                    String oid = sequence.getObjectAt(0).toString();
                    ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject();
                    if (value instanceof DERUTF8String) {
                        return new Pair<>(oid, ((DERUTF8String) value).getString());
                    } else if (value instanceof DERIA5String) {
                        return new Pair<>(oid, ((DERIA5String) value).getString());
                    }
                }
            }
        }
        return null;
    } catch (IOException e) {
        return null;
    }
}
Also used : DERUTF8String(org.bouncycastle.asn1.DERUTF8String) DERIA5String(org.bouncycastle.asn1.DERIA5String) DLSequence(org.bouncycastle.asn1.DLSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) DERIA5String(org.bouncycastle.asn1.DERIA5String) DERUTF8String(org.bouncycastle.asn1.DERUTF8String) IOException(java.io.IOException) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive) Pair(android.util.Pair)

Example 9 with DERTaggedObject

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

the class GeneralSubtree method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * 
     * Returns:
     * 
     * <pre>
     *       GeneralSubtree ::= SEQUENCE 
     *       {
     *         base                    GeneralName,
     *         minimum         [0]     BaseDistance DEFAULT 0,
     *         maximum         [1]     BaseDistance OPTIONAL 
     *       }
     * </pre>
     * 
     * @return a DERObject
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(base);
    if (minimum != null && !minimum.getValue().equals(ZERO)) {
        v.add(new DERTaggedObject(false, 0, minimum));
    }
    if (maximum != null) {
        v.add(new DERTaggedObject(false, 1, maximum));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 10 with DERTaggedObject

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

the class CertBag method toASN1Object.

public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(certId);
    v.add(new DERTaggedObject(0, certValue));
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Aggregations

DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)24 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)19 DERSequence (org.bouncycastle.asn1.DERSequence)17 BERSequence (org.bouncycastle.asn1.BERSequence)4 DEROctetString (org.bouncycastle.asn1.DEROctetString)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)2 BERTaggedObject (org.bouncycastle.asn1.BERTaggedObject)2 DERApplicationSpecific (org.bouncycastle.asn1.DERApplicationSpecific)2 DERIA5String (org.bouncycastle.asn1.DERIA5String)2 DERInteger (org.bouncycastle.asn1.DERInteger)2 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)2 Pair (android.util.Pair)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 CRLException (java.security.cert.CRLException)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 CertificateException (java.security.cert.CertificateException)1 X509CRL (java.security.cert.X509CRL)1