assertFalse(keyRecCert.getSerialNumber().equals(orgCert.getSerialNumber()));
}
public void test05GenerateSimpleRevokationRequest() throws Exception {
// revoke first certificate
SubMessages smgs = new SubMessages(null,null,null);
assertNotNull("Missing certificate from previous test.", firstCertificate);
smgs.addSubMessage(new RevocationRequest(10, CertTools.getIssuerDN(firstCertificate), firstCertificate.getSerialNumber(), RevocationRequest.REVOKATION_REASON_UNSPECIFIED));
msghome.create("SimpleRevocationTest", smgs);
Message msg = waitForUser("SimpleRevocationTest");
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() == true);
// revoke second certificate
SubMessages smgs2 = new SubMessages(null,null,null);
assertNotNull("Missing certificate from previous test.", secondCertificate);
smgs2.addSubMessage(new RevocationRequest(6, CertTools.getIssuerDN(secondCertificate), secondCertificate.getSerialNumber(), RevocationRequest.REVOKATION_REASON_UNSPECIFIED));
msghome.create("SimpleRevocationTest", smgs2);
Message msg2 = waitForUser("SimpleRevocationTest");
assertNotNull(msg2);
SubMessages submessagesresp2 = msg2.getSubMessages(null,null,null);
assertTrue("Number of submessages " + submessagesresp2.getSubMessages().size() , submessagesresp2.getSubMessages().size() == 1);
ExtRAResponse resp2 = (ExtRAResponse) submessagesresp2.getSubMessages().iterator().next();
assertTrue(resp2.getRequestId() == 6);
assertTrue(resp2.isSuccessful() == true);
// try to revoke nonexisting certificate
SubMessages smgs3 = new SubMessages(null,null,null);
smgs3.addSubMessage(new RevocationRequest(7, CertTools.getIssuerDN(secondCertificate), new BigInteger("1234"), RevocationRequest.REVOKATION_REASON_UNSPECIFIED));
msghome.create("SimpleRevocationTest", smgs3);
Message msg3 = waitForUser("SimpleRevocationTest");
assertNotNull(msg3);
SubMessages submessagesresp3 = msg3.getSubMessages(null,null,null);
assertTrue(submessagesresp3.getSubMessages().size() == 1);
ExtRAResponse resp3 = (ExtRAResponse) submessagesresp3.getSubMessages().iterator().next();
assertTrue(resp3.getRequestId() == 7);
assertTrue(resp3.isSuccessful() == false);
// try to revoke a users all certificates
SubMessages smgs4 = new SubMessages(null,null,null);
smgs4.addSubMessage(new RevocationRequest(8, CertTools.getIssuerDN(secondCertificate), secondCertificate.getSerialNumber(), RevocationRequest.REVOKATION_REASON_UNSPECIFIED, false, true));
msghome.create("SimpleRevocationTest", smgs4);
Message msg4 = waitForUser("SimpleRevocationTest");
assertNotNull(msg4);
SubMessages submessagesresp4 = msg4.getSubMessages(null,null,null);
assertTrue(submessagesresp4.getSubMessages().size() == 1);
ExtRAResponse resp4 = (ExtRAResponse) submessagesresp4.getSubMessages().iterator().next();
assertTrue(resp4.getRequestId() == 8);
assertTrue(resp4.isSuccessful() == true);
// try to revoke a users all certificates by giving the username
SubMessages smgs5 = new SubMessages(null,null,null);
smgs5.addSubMessage(new RevocationRequest(9, "SimplePKCS10Test1", RevocationRequest.REVOKATION_REASON_UNSPECIFIED, false));
msghome.create("SimpleRevocationTest", smgs5);
Message msg5 = waitForUser("SimpleRevocationTest");
assertNotNull(msg5);
SubMessages submessagesresp5 = msg5.getSubMessages(null,null,null);
assertTrue(submessagesresp5.getSubMessages().size() == 1);
ExtRAResponse resp5 = (ExtRAResponse) submessagesresp5.getSubMessages().iterator().next();
assertTrue(resp5.getRequestId() == 9);
assertTrue(resp5.isSuccessful() == true);
// Try some error cases
// First a message with null as parameters
SubMessages smgs6 = new SubMessages(null,null,null);
smgs6.addSubMessage(new RevocationRequest(10, null, RevocationRequest.REVOKATION_REASON_UNSPECIFIED, false));
msghome.create("SimpleRevocationTest", smgs6);
Message msg6 = waitForUser("SimpleRevocationTest");
assertNotNull(msg6);
SubMessages submessagesresp6 = msg6.getSubMessages(null,null,null);
assertTrue(submessagesresp6.getSubMessages().size() == 1);
ExtRAResponse resp6 = (ExtRAResponse) submessagesresp6.getSubMessages().iterator().next();
assertTrue(resp6.getRequestId() == 10);
assertTrue(resp6.isSuccessful() == false);
assertEquals(resp6.getFailInfo(), "Either username or issuer/serno is required");
// Then a message with a suername that does not exist
SubMessages smgs7 = new SubMessages(null,null,null);
smgs7.addSubMessage(new RevocationRequest(11, "184hjeyyydvv88q", RevocationRequest.REVOKATION_REASON_UNSPECIFIED, false));
msghome.create("SimpleRevocationTest", smgs7);
Message msg7 = waitForUser("SimpleRevocationTest");
assertNotNull(msg7);
SubMessages submessagesresp7 = msg7.getSubMessages(null,null,null);
assertTrue(submessagesresp7.getSubMessages().size() == 1);
ExtRAResponse resp7 = (ExtRAResponse) submessagesresp7.getSubMessages().iterator().next();
assertTrue(resp7.getRequestId() == 11);
assertTrue(resp7.isSuccessful() == false);
assertEquals(resp7.getFailInfo(), "User not found from username: username=184hjeyyydvv88q");
// Then a message with a issuer/serno that does not exist
SubMessages smgs8 = new SubMessages(null,null,null);
smgs8.addSubMessage(new RevocationRequest(12, "CN=ffo558444,O=338qqwaa,C=qq", new BigInteger("123"), RevocationRequest.REVOKATION_REASON_UNSPECIFIED, false, false));
msghome.create("SimpleRevocationTest", smgs8);
Message msg8 = waitForUser("SimpleRevocationTest");
assertNotNull(msg8);
SubMessages submessagesresp8 = msg8.getSubMessages(null,null,null);
assertTrue(submessagesresp8.getSubMessages().size() == 1);
ExtRAResponse resp8 = (ExtRAResponse) submessagesresp8.getSubMessages().iterator().next();
assertTrue(resp8.getRequestId() == 12);
assertTrue(resp8.isSuccessful() == false);
assertEquals(resp8.getFailInfo(), "User not found from issuer/serno: issuer='CN=ffo558444,O=338qqwaa,C=qq', serno=123");
}