Search in sources :

Example 1 with DLSequence

use of com.github.zhenwei.core.asn1.DLSequence in project robovm by robovm.

the class SafeBag method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(bagId);
    v.add(new DLTaggedObject(true, 0, bagValue));
    if (bagAttributes != null) {
        v.add(bagAttributes);
    }
    return new DLSequence(v);
}
Also used : DLTaggedObject(org.bouncycastle.asn1.DLTaggedObject) DLSequence(org.bouncycastle.asn1.DLSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 2 with DLSequence

use of com.github.zhenwei.core.asn1.DLSequence in project netty by netty.

the class OcspUtils method ocspUri.

/**
 * Returns the OCSP responder {@link URI} or {@code null} if it doesn't have one.
 */
public static URI ocspUri(X509Certificate certificate) throws IOException {
    byte[] value = certificate.getExtensionValue(Extension.authorityInfoAccess.getId());
    if (value == null) {
        return null;
    }
    ASN1Primitive authorityInfoAccess = X509ExtensionUtil.fromExtensionValue(value);
    if (!(authorityInfoAccess instanceof DLSequence)) {
        return null;
    }
    DLSequence aiaSequence = (DLSequence) authorityInfoAccess;
    DERTaggedObject taggedObject = findObject(aiaSequence, OCSP_RESPONDER_OID, DERTaggedObject.class);
    if (taggedObject == null) {
        return null;
    }
    if (taggedObject.getTagNo() != BERTags.OBJECT_IDENTIFIER) {
        return null;
    }
    byte[] encoded = taggedObject.getEncoded();
    int length = (int) encoded[1] & 0xFF;
    String uri = new String(encoded, 2, length, CharsetUtil.UTF_8);
    return URI.create(uri);
}
Also used : DLSequence(org.bouncycastle.asn1.DLSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 3 with DLSequence

use of com.github.zhenwei.core.asn1.DLSequence 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 4 with DLSequence

use of com.github.zhenwei.core.asn1.DLSequence in project xabber-android by redsolution.

the class CustomDomainVerifier 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 5 with DLSequence

use of com.github.zhenwei.core.asn1.DLSequence in project Pix-Art-Messenger by kriztan.

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)

Aggregations

DLSequence (org.bouncycastle.asn1.DLSequence)53 IOException (java.io.IOException)23 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)19 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)19 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)17 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)17 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)12 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)12 DEROctetString (org.bouncycastle.asn1.DEROctetString)12 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)8 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)8 BigInteger (java.math.BigInteger)7 DERIA5String (org.bouncycastle.asn1.DERIA5String)7 DLSequence (com.github.zhenwei.core.asn1.DLSequence)6 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)6 Pair (android.util.Pair)4 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)4 CertificateEncodingException (java.security.cert.CertificateEncodingException)4 BufferedWriter (java.io.BufferedWriter)3 CertificateException (java.security.cert.CertificateException)3