Search in sources :

Example 1 with DLSet

use of org.bouncycastle.asn1.DLSet in project jruby-openssl by jruby.

the class X509Name method to_der.

@JRubyMethod
public RubyString to_der(final ThreadContext context) {
    final Ruby runtime = context.runtime;
    final DLSequence seq;
    if (oids.size() > 0) {
        ASN1EncodableVector vec = new ASN1EncodableVector();
        ASN1EncodableVector sVec = new ASN1EncodableVector();
        ASN1ObjectIdentifier lastOid = null;
        for (int i = 0; i != oids.size(); i++) {
            final ASN1ObjectIdentifier oid = oids.get(i);
            ASN1EncodableVector v = new ASN1EncodableVector();
            v.add(oid);
            // TODO DO NOT USE DL types !
            // final String value = values.get(i);
            // final int type = RubyNumeric.fix2int(types.get(i));
            // v.add( convert(oid, value, type) );
            v.add(values.get(i));
            if (lastOid == null) {
                sVec.add(new DLSequence(v));
            } else {
                vec.add(new DLSet(sVec));
                sVec = new ASN1EncodableVector();
                sVec.add(new DLSequence(v));
            }
            lastOid = oid;
        }
        vec.add(new DLSet(sVec));
        seq = new DLSequence(vec);
    } else {
        seq = new DLSequence();
    }
    try {
        return StringHelper.newString(runtime, seq.getEncoded(ASN1Encoding.DER));
    } catch (IOException e) {
        throw newNameError(runtime, e);
    }
}
Also used : DLSequence(org.bouncycastle.asn1.DLSequence) DLSet(org.bouncycastle.asn1.DLSet) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) IOException(java.io.IOException) Ruby(org.jruby.Ruby) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) JRubyMethod(org.jruby.anno.JRubyMethod)

Aggregations

IOException (java.io.IOException)1 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)1 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)1 DLSequence (org.bouncycastle.asn1.DLSequence)1 DLSet (org.bouncycastle.asn1.DLSet)1 Ruby (org.jruby.Ruby)1 JRubyMethod (org.jruby.anno.JRubyMethod)1