log.trace(">test02FindAndChange()");
String fp = CertTools.getFingerprintAsString(cert);
X509Certificate ce = (X509Certificate) certificateStoreSession.findCertificateByFingerprint(admin, fp);
assertNotNull("Cannot find certificate with fp=" + fp, ce);
CertificateInfo info = certificateStoreSession.getCertificateInfo(admin, fp);
// log.info("Got certificate info for cert with fp="+fp);
assertEquals("fingerprint does not match.", fp, info.getFingerprint());
assertEquals("CAfingerprint does not match.", "1234", info.getCAFingerprint());
assertEquals("serialnumber does not match.", ce.getSerialNumber(), info.getSerialNumber());
assertEquals("issuerdn does not match.", CertTools.getIssuerDN(ce), info.getIssuerDN());
assertEquals("subjectdn does not match.", CertTools.getSubjectDN(ce), info.getSubjectDN());
// The cert was just stored above with status INACTIVE
assertEquals("status does not match.", SecConst.CERT_INACTIVE, info.getStatus());
assertEquals("type does not match.", SecConst.CERT_TYPE_ENCRYPTION, info.getType());
assertEquals("exiredate does not match.", ce.getNotAfter(), info.getExpireDate());
// We just stored it above, not revoked
assertEquals("revocation reason does not match.", RevokedCertInfo.NOT_REVOKED, info.getRevocationReason());
log.info("revocationdate (before rev)=" + info.getRevocationDate());
assertEquals(SecConst.CERTPROFILE_FIXED_ENDUSER, info.getCertificateProfileId());
assertEquals("footag", info.getTag());
Date now = new Date();
assertNotNull(info.getUpdateTime());
assertTrue(now.after(info.getUpdateTime()));
certificateStoreSession.revokeCertificate(admin, ce, null, RevokedCertInfo.REVOCATION_REASON_KEYCOMPROMISE, null);
CertificateInfo info1 = certificateStoreSession.getCertificateInfo(admin, fp);
assertEquals("revocation reason does not match.", RevokedCertInfo.REVOCATION_REASON_KEYCOMPROMISE, info1.getRevocationReason());
log.info("revocationdate (after rev)=" + info1.getRevocationDate());
assertTrue("Revocation date in future.", new Date().compareTo(info1.getRevocationDate()) >= 0);
log.trace("<test02FindAndChange()");
}