public void setUp() throws Exception {
log.trace(">setUp()");
CryptoProviderTools.installBCProvider();
Certificate cert;
Admin adm = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
m_certs = new HashSet<Certificate>();
m_certfps = new HashSet<String>();
cert = CertTools.getCertfromByteArray(testrootcert);
m_certs.add(cert);
m_certfps.add(CertTools.getFingerprintAsString(cert));
// log.debug(cert.getIssuerDN().getName()+";"+cert.getSerialNumber().toString(16)+";"+CertTools.getFingerprintAsString(cert));
rootCaFp = CertTools.getFingerprintAsString(cert);
try {
if (certificateStoreSession.findCertificateByFingerprint(adm, rootCaFp) == null) {
certificateStoreSession.storeCertificate(adm, cert, "o=AnaTom,c=SE", rootCaFp, SecConst.CERT_ACTIVE, SecConst.CERTTYPE_ROOTCA,
SecConst.CERTPROFILE_FIXED_ROOTCA, null, new Date().getTime());
}
cert = CertTools.getCertfromByteArray(testcacert);
m_certs.add(cert);
m_certfps.add(CertTools.getFingerprintAsString(cert));
// log.debug(cert.getIssuerDN().getName()+";"+cert.getSerialNumber().toString(16)+";"+CertTools.getFingerprintAsString(cert));
subCaFp = CertTools.getFingerprintAsString(cert);
if (certificateStoreSession.findCertificateByFingerprint(adm, subCaFp) == null) {
certificateStoreSession.storeCertificate(adm, cert, "o=AnaTom,c=SE", subCaFp, SecConst.CERT_ACTIVE, SecConst.CERTTYPE_SUBCA,
SecConst.CERTPROFILE_FIXED_SUBCA, null, new Date().getTime());
}
cert = CertTools.getCertfromByteArray(testcert);
m_certs.add(cert);
m_certfps.add(CertTools.getFingerprintAsString(cert));
// log.debug(cert.getIssuerDN().getName()+";"+cert.getSerialNumber().toString(16)+";"+CertTools.getFingerprintAsString(cert));
endEntityFp = CertTools.getFingerprintAsString(cert);
if (certificateStoreSession.findCertificateByFingerprint(adm, endEntityFp) == null) {
certificateStoreSession.storeCertificate(adm, cert, "o=AnaTom,c=SE", endEntityFp, SecConst.CERT_ACTIVE, SecConst.CERTTYPE_ENDENTITY,
SecConst.CERTPROFILE_FIXED_ENDUSER, null, new Date().getTime());
}
} catch (Exception e) {
log.error("Error: ", e);
assertTrue("Error seting up tests: " + e.getMessage(), false);
}
admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
log.trace("<setUp()");
}