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);
}
}
Aggregations