SubMessages smgs = new SubMessages(null,null,null);
assertNotNull("Missing certificate from previous test.", firstCertificate);
String cert1 = new String(Base64.encode(firstCertificate.getEncoded()));
assertNotNull("Missing certificate from previous test.", secondCertificate);
String cert2 = new String(Base64.encode(secondCertificate.getEncoded()));
smgs.addSubMessage(new CardRenewalRequest(10, cert1, cert1, null, null));
msghome.create("SimpleCardRenewalTest", smgs);
Message msg = waitForUser("SimpleCardRenewalTest");
assertNotNull("No response.", msg);
SubMessages submessagesresp = msg.getSubMessages(null,null,null);
assertTrue("Number of submessages " + submessagesresp.getSubMessages().size(), submessagesresp.getSubMessages().size() == 1);
ExtRAResponse resp = (ExtRAResponse) submessagesresp.getSubMessages().iterator().next();
assertTrue("Wrong Request ID" + resp.getRequestId(), resp.getRequestId() == 10);
assertTrue(resp.isSuccessful() == false);
assertEquals(resp.getFailInfo(), "An authentication cert, a signature cert, an authentication request and a signature request are required");
// Second fail message
smgs = new SubMessages(null,null,null);
smgs.addSubMessage(new CardRenewalRequest(11, null, null, Constants.pkcs10_1, Constants.pkcs10_2));
msghome.create("SimpleCardRenewalTest", smgs);
msg = waitForUser("SimpleCardRenewalTest");
assertNotNull(msg);
submessagesresp = msg.getSubMessages(null,null,null);
assertTrue("Number of submessages " + submessagesresp.getSubMessages().size(), submessagesresp.getSubMessages().size() == 1);
resp = (ExtRAResponse) submessagesresp.getSubMessages().iterator().next();
assertTrue("Wrong Request ID" + resp.getRequestId(), resp.getRequestId() == 11);
assertTrue(resp.isSuccessful() == false);
assertEquals(resp.getFailInfo(), "An authentication cert, a signature cert, an authentication request and a signature request are required");
// Third fail message
smgs = new SubMessages(null,null,null);
smgs.addSubMessage(new CardRenewalRequest(12, cert1, cert1, Constants.pkcs10_1, Constants.pkcs10_2));
msghome.create("SimpleCardRenewalTest", smgs);
msg = waitForUser("SimpleCardRenewalTest");
assertNotNull(msg);
submessagesresp = msg.getSubMessages(null,null,null);
assertTrue("Number of submessages " + submessagesresp.getSubMessages().size(), submessagesresp.getSubMessages().size() == 1);
resp = (ExtRAResponse) submessagesresp.getSubMessages().iterator().next();
assertTrue("Wrong Request ID" + resp.getRequestId(), resp.getRequestId() == 12);
assertTrue(resp.isSuccessful() == false);
assertEquals(resp.getFailInfo(), "Verify failed for signature request");
// Fourth fail message
smgs = new SubMessages(null,null,null);
smgs.addSubMessage(new CardRenewalRequest(12, cert1, cert2, Constants.pkcs10_1, Constants.pkcs10_2));
msghome.create("SimpleCardRenewalTest", smgs);
msg = waitForUser("SimpleCardRenewalTest");
assertNotNull(msg);
submessagesresp = msg.getSubMessages(null,null,null);
assertTrue("Number of submessages " + submessagesresp.getSubMessages().size(), submessagesresp.getSubMessages().size() == 1);