assertEquals(CertTools.stringToBCDNString(racert.getIssuerDN().getName()), CertTools.stringToBCDNString(sinfo.getIssuerAsString()));
// Verify the signature
boolean ret = signerInfo.verify(racert.getPublicKey(), "BC");
assertTrue(ret);
// Get authenticated attributes
AttributeTable tab = signerInfo.getSignedAttributes();
// --Fail info
Attribute attr = tab.get(new DERObjectIdentifier(ScepRequestMessage.id_failInfo));
// No failInfo on this success message
if(expectedResponseStatus == ResponseStatus.SUCCESS){
assertNull(attr);
}
// --Message type
attr = tab.get(new DERObjectIdentifier(ScepRequestMessage.id_messageType));
assertNotNull(attr);
ASN1Set values = attr.getAttrValues();
assertEquals(values.size(), 1);
DERString str = DERPrintableString.getInstance((values.getObjectAt(0)));
String messageType = str.getString();
assertEquals("3", messageType);
// --Success status
attr = tab.get(new DERObjectIdentifier(ScepRequestMessage.id_pkiStatus));
assertNotNull(attr);
values = attr.getAttrValues();
assertEquals(values.size(), 1);
str = DERPrintableString.getInstance((values.getObjectAt(0)));
String responsestatus = str.getString();
assertEquals(expectedResponseStatus.getValue(), responsestatus);
// --SenderNonce
attr = tab.get(new DERObjectIdentifier(ScepRequestMessage.id_senderNonce));
assertNotNull(attr);
values = attr.getAttrValues();
assertEquals(values.size(), 1);
ASN1OctetString octstr = ASN1OctetString.getInstance(values.getObjectAt(0));
// SenderNonce is something the server came up with, but it should be 16 chars
assertTrue(octstr.getOctets().length == 16);
// --Recipient Nonce
attr = tab.get(new DERObjectIdentifier(ScepRequestMessage.id_recipientNonce));
assertNotNull(attr);
values = attr.getAttrValues();
assertEquals(values.size(), 1);
octstr = ASN1OctetString.getInstance(values.getObjectAt(0));
// recipient nonce should be the same as we sent away as sender nonce
assertEquals(senderNonce, new String(Base64.encode(octstr.getOctets())));
// --Transaction ID
attr = tab.get(new DERObjectIdentifier(ScepRequestMessage.id_transId));
assertNotNull(attr);
values = attr.getAttrValues();
assertEquals(values.size(), 1);
str = DERPrintableString.getInstance((values.getObjectAt(0)));
// transid should be the same as the one we sent