@SuppressWarnings("unchecked")
public void test19getAltNameStringFromExtension() throws Exception {
PKCS10CertificationRequest p10 = new PKCS10CertificationRequest(
p10ReqWithAltNames);
CertificationRequestInfo info = p10.getCertificationRequestInfo();
ASN1Set set = info.getAttributes();
// The set of attributes contains a sequence of with type oid
// PKCSObjectIdentifiers.pkcs_9_at_extensionRequest
Enumeration<Object> en = set.getObjects();
boolean found = false;
while (en.hasMoreElements()) {
ASN1Sequence seq = ASN1Sequence.getInstance(en.nextElement());
DERObjectIdentifier oid = (DERObjectIdentifier) seq.getObjectAt(0);
if (oid.equals(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest)) {
// The object at position 1 is a SET of x509extensions
DERSet s = (DERSet) seq.getObjectAt(1);
X509Extensions exts = X509Extensions.getInstance(s
.getObjectAt(0));
X509Extension ext = exts
.getExtension(X509Extensions.SubjectAlternativeName);
if (ext != null) {
found = true;
String altNames = CertTools
.getAltNameStringFromExtension(ext);
assertEquals(
"dNSName=ort3-kru.net.polisen.se, iPAddress=10.252.255.237",
altNames);
}
}
}
assertTrue(found);
p10 = new PKCS10CertificationRequest(p10ReqWithAltNames2);
info = p10.getCertificationRequestInfo();
set = info.getAttributes();
// The set of attributes contains a sequence of with type oid
// PKCSObjectIdentifiers.pkcs_9_at_extensionRequest
en = set.getObjects();
found = false;