v.add(new DERObjectIdentifier(CertTools.KRB5PRINCIPAL_OBJECTID));
// First the Krb5PrincipalName sequence
ASN1EncodableVector krb5p = new ASN1EncodableVector();
// The realm is the first tagged GeneralString
krb5p.add(new DERTaggedObject(true, 0, new DERGeneralString(realm)));
// Second is the sequence of principal names, which is at tagged position 1 in the krb5p
ASN1EncodableVector principals = new ASN1EncodableVector();
// According to rfc4210 the type NT-UNKNOWN is 0, and according to some other rfc this type should be used...
principals.add(new DERTaggedObject(true, 0, new DERInteger(0)));
// The names themselves are yet another sequence
Iterator<String> i = principalarr.iterator();
ASN1EncodableVector names = new ASN1EncodableVector();
while (i.hasNext()) {
String principalName = (String)i.next();
names.add(new DERGeneralString(principalName));
}
principals.add(new DERTaggedObject(true, 1, new DERSequence(names)));
krb5p.add(new DERTaggedObject(true, 1, new DERSequence(principals)));
v.add(new DERTaggedObject(true, 0, new DERSequence(krb5p)));