* error
*/
public void test05CRLPeriodOverflow() throws Exception {
log.trace(">test05CRLPeriodOverflow()");
// Fetch CAInfo and save CRLPeriod
CAInfo cainfo = ca.getCAInfo();
long tempCRLPeriod = cainfo.getCRLPeriod();
try {
// Create a user that Should be revoked
boolean userExists = false;
final String userDN = "CN=" + TESTUSERNAME;
try {
int certprofileid = 0;
// add a Certificate Profile with overridable validity
try {
CertificateProfile certProfile = new CertificateProfile();
certProfile.setAllowValidityOverride(true);
certificateProfileSession.addCertificateProfile(admin, TESTPROFILE, certProfile);
} catch (CertificateProfileExistsException cpeee) {
}
certprofileid = certificateProfileSession.getCertificateProfileId(admin, TESTPROFILE);
assertTrue(certprofileid != 0);
// add End Entity Profile with validity limitations
EndEntityProfile profile;
try {
endEntityProfileSession.removeEndEntityProfile(admin, TESTPROFILE);
profile = new EndEntityProfile();
profile.setUse(EndEntityProfile.ENDTIME, 0, true);
profile.setUse(EndEntityProfile.CLEARTEXTPASSWORD, 0, false);
profile.setValue(EndEntityProfile.CLEARTEXTPASSWORD, 0, EndEntityProfile.FALSE);
profile.setValue(EndEntityProfile.AVAILCAS, 0, Integer.valueOf(caid).toString());
profile.setUse(EndEntityProfile.STARTTIME, 0, true);
profile.setValue(EndEntityProfile.AVAILCERTPROFILES, 0, Integer.valueOf(certprofileid).toString());
profile.setValue(EndEntityProfile.DEFAULTCERTPROFILE, 0, Integer.valueOf(certprofileid).toString());
endEntityProfileSession.addEndEntityProfile(admin, TESTPROFILE, profile);
} catch (EndEntityProfileExistsException pee) {
}
// Create a new user
ExtendedInformation ei = new ExtendedInformation();
ei.setCustomData(EndEntityProfile.STARTTIME, "0:00:00");
ei.setCustomData(EndEntityProfile.ENDTIME, "0:00:50");
UserDataVO userdata = new UserDataVO(TESTUSERNAME, userDN, caid, "", "foo@bar.se", UserDataConstants.STATUS_NEW, SecConst.USER_ENDUSER,
endEntityProfileSession.getEndEntityProfileId(admin, TESTPROFILE), certprofileid, new Date(), new Date(), SecConst.TOKEN_SOFT_PEM, 0, ei);
userdata.setPassword("foo123");
try {
userAdminSession.revokeAndDeleteUser(admin, TESTUSERNAME, RevokedCertInfo.REVOCATION_REASON_KEYCOMPROMISE);
} catch (NotFoundException nfe) {
}
userAdminSession.addUser(admin, userdata, false);
log.debug("created user");
} catch (EJBException e) {
if (e.getCause() instanceof PersistenceException) {
userExists = true;
}
}
if (userExists) {
log.info("User testCRLPeriod already exists, resetting status.");
userAdminSession.setUserStatus(admin, TESTUSERNAME, UserDataConstants.STATUS_NEW);
log.debug("Reset status to NEW");
}
KeyPair keys = genKeys();
// user that we know exists...
X509Certificate cert = (X509Certificate) signSession.createCertificate(admin, TESTUSERNAME, "foo123", keys.getPublic());
assertNotNull("Failed to create certificate", cert);
log.debug("Cert=" + cert.toString());
// Revoke the user
certificateStoreSession.revokeCertificate(admin, cert, null, RevokedCertInfo.REVOCATION_REASON_KEYCOMPROMISE, userDN);
// Change CRLPeriod
cainfo.setCRLPeriod(Long.MAX_VALUE);
caAdminSession.editCA(admin, cainfo);
ca = caSession.getCA(admin, caid);
// Create new CRL's
crlCreateSession.run(admin, ca);
// Verify that status is not archived
CertificateInfo certinfo = certificateStoreSession.getCertificateInfo(admin, CertTools.getFingerprintAsString(cert));
assertFalse("Non Expired Revoked Certificate was archived", certinfo.getStatus() == SecConst.CERT_ARCHIVED);
} finally {
// Restore CRL Period
cainfo.setCRLPeriod(tempCRLPeriod);
caAdminSession.editCA(admin, cainfo);
ca = caSession.getCA(admin, caid);
// Delete and revoke User
userAdminSession.revokeAndDeleteUser(admin, TESTUSERNAME, RevokedCertInfo.REVOCATION_REASON_KEYCOMPROMISE);
// Delete end entity profile