Message msg = waitForUser("SimplePKCS10Test1");
assertNotNull("No response", msg);
SubMessages submessagesresp = msg.getSubMessages(null,null,null);
assertTrue(submessagesresp.getSubMessages().size() == 1);
Iterator iter = submessagesresp.getSubMessages().iterator();
PKCS10Response resp = (PKCS10Response) iter.next();
assertTrue(resp.getRequestId() == 100);
assertTrue(resp.isSuccessful() == false);
// if we create the user first, with correct status, the request should be ok
smgs = new SubMessages(null,null,null);
smgs.addSubMessage(ExtRAMessagesTest.genExtRAPKCS10UserRequest(101,"SimplePKCS10Test1", "foo123"));
msghome.create("SimplePKCS10Test1", smgs);
msg = waitForUser("SimplePKCS10Test1");
assertNotNull(msg);
submessagesresp = msg.getSubMessages(null,null,null);
assertTrue("Number of submessages " + submessagesresp.getSubMessages().size(), submessagesresp.getSubMessages().size() == 1);
ExtRAResponse editresp = (ExtRAResponse) submessagesresp.getSubMessages().iterator().next();
assertTrue("Wrong Request ID" + editresp.getRequestId(), editresp.getRequestId() == 101);
assertTrue("External RA CA Service was not successful.", editresp.isSuccessful() == true);
// Create a new request, now it should be ok
smgs = new SubMessages(null,null,null);
smgs.addSubMessage(ExtRAMessagesTest.genExtRAPKCS10Request(102,"SimplePKCS10Test1", Constants.pkcs10_1, false));
msghome.create("SimplePKCS10Test1", smgs);
msg = waitForUser("SimplePKCS10Test1");
assertNotNull(msg);
submessagesresp = msg.getSubMessages(null,null,null);
assertTrue(submessagesresp.getSubMessages().size() == 1);
iter = submessagesresp.getSubMessages().iterator();
resp = (PKCS10Response) iter.next();
assertTrue(resp.getRequestId() == 102);
assertTrue(resp.isSuccessful() == true);
assertTrue(resp.getCertificate().getSubjectDN().toString().equals("CN=PKCS10REQ"));
firstCertificate = resp.getCertificate();
assertNotNull(firstCertificate);
// Check the pkcs7 response
byte[] pkcs7 = resp.getCertificateAsPKCS7();
assertNotNull(pkcs7);
CMSSignedData s = new CMSSignedData(pkcs7);
// The signer, i.e. the CA, check it's the right CA
SignerInformationStore signers = s.getSignerInfos();
Collection col = signers.getSigners();