this.adminGroupSession.init(admin, dn.hashCode(), DEFAULT_SUPERADMIN_CN);
} catch (AdminGroupExistsException e) {
log.error("",e);
}
// Search for requested CA
CAInfo caInfo = this.caAdminSessionRemote.getCAInfo(admin, caName);
if (caInfo != null) {
return true;
}
// Create request CA, if necessary
SoftCATokenInfo catokeninfo = new SoftCATokenInfo();
catokeninfo.setSignKeySpec(""+keyStrength);
catokeninfo.setEncKeySpec(""+keyStrength);
catokeninfo.setSignKeyAlgorithm(AlgorithmConstants.KEYALGORITHM_RSA);
catokeninfo.setEncKeyAlgorithm(AlgorithmConstants.KEYALGORITHM_RSA);
catokeninfo.setSignatureAlgorithm(AlgorithmConstants.SIGALG_SHA1_WITH_RSA);
catokeninfo.setEncryptionAlgorithm(AlgorithmConstants.SIGALG_SHA1_WITH_RSA);
// Create and active OSCP CA Service.
ArrayList extendedcaservices = new ArrayList();
extendedcaservices.add(new OCSPCAServiceInfo(ExtendedCAServiceInfo.STATUS_ACTIVE));
extendedcaservices.add(new XKMSCAServiceInfo(ExtendedCAServiceInfo.STATUS_ACTIVE,
"CN=XKMSCertificate, " + dn,
"",
""+keyStrength,
AlgorithmConstants.KEYALGORITHM_RSA));
/*
extendedcaservices.add(new CmsCAServiceInfo(ExtendedCAServiceInfo.STATUS_ACTIVE,
"CN=CMSCertificate, " + dn,
"",
""+keyStrength,
AlgorithmConstants.KEYALGORITHM_RSA));
*/
X509CAInfo cainfo = new X509CAInfo(dn,
caName, SecConst.CA_ACTIVE, new Date(),
"", signedBy==CAInfo.SELFSIGNED ? SecConst.CERTPROFILE_FIXED_ROOTCA : SecConst.CERTPROFILE_FIXED_SUBCA,
3650,
null, // Expiretime
CAInfo.CATYPE_X509,
signedBy,
certificateChain,
catokeninfo,
"JUnit RSA CA",
-1, null,
null, // PolicyId
24, // CRLPeriod
0, // CRLIssueInterval
10, // CRLOverlapTime
10, // Delta CRL period
new ArrayList(),
true, // Authority Key Identifier
false, // Authority Key Identifier Critical
true, // CRL Number
false, // CRL Number Critical
null, // defaultcrldistpoint
null, // defaultcrlissuer
null, // defaultocsplocator
null, // defaultfreshestcrl
true, // Finish User
extendedcaservices,
false, // use default utf8 settings
new ArrayList(), // Approvals Settings
1, // Number of Req approvals
false, // Use UTF8 subject DN by default
true, // Use LDAP DN order by default
false, // Use CRL Distribution Point on CRL
false, // CRL Distribution Point on CRL critical
true,
true, // isDoEnforceUniquePublicKeys
true, // isDoEnforceUniqueDistinguishedName
false, // isDoEnforceUniqueSubjectDNSerialnumber
true, // useCertReqHistory
true, // useUserStorage
true, // useCertificateStorage
null // cmpRaAuthSecret
);
try {
this.caAdminSessionRemote.createCA(admin, cainfo);
} catch (Exception e) {
log.error("", e);
return false;
}
final CAInfo info = this.caAdminSessionRemote.getCAInfo(admin, caName);
final String normalizedDN = CertTools.stringToBCDNString(dn);
final X509Certificate cert = (X509Certificate) info.getCertificateChain().iterator().next();
final String normalizedCertDN = CertTools.stringToBCDNString(cert.getSubjectDN().toString());
if ( !normalizedCertDN.equals(normalizedDN) ) {
log.error("CA certificate DN is not what it should. Is '"+normalizedDN+"'. Should be '"+normalizedCertDN+"'.");
return false;
}
if (!info.getSubjectDN().equals(normalizedCertDN)) {
log.error("Creating CA failed!");
return false;
}
if ( this.certificateStoreSession.findCertificateByFingerprint(admin, CertTools.getFingerprintAsString(cert)) == null) {
log.error("CA certificate not available in database!!");