try {
prepare(request, request.getPrototypeKeyBinding());
validate(request);
PrototypeKeyBinding pkb = request.getPrototypeKeyBinding();
String identifer = getSubjectDN(pkb);
if (identifer == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("No SubjectDN is specified");
}
throw new XKMSException(XKMSException.FAILURE, "NoSubjectDN");
}
PublicKey public1 = pkb.getKeyValue();
PrivateKey private1 = null;
// if a public key is not provided we need to generate both the
// public key and private key
if (public1 == null) {
KeyPair keypair = XKMSKeyUtil.generateRSAKeyPair();
public1 = keypair.getPublic();
private1 = keypair.getPrivate();
}
// calculating the start and expiery dates.
ValidityInterval validityInterval = pkb.getValidityInterval();
Date[] adjustedInterval;
if (validityInterval != null) {
adjustedInterval = getAdjustedValidityInterval(validityInterval
.getNotBefore(), validityInterval.getOnOrAfter());
} else {
adjustedInterval = getAdjustedValidityInterval((Date) null,
(Date) null);
}
long serialNum = nextSerialNumber();
String aliase = createAlias(serialNum);
BigInteger serialNumber = BigInteger.valueOf(serialNum);
X509Certificate cert;
List keyUsage = pkb.getKeyUsage();
if (keyUsage == null
|| keyUsage.isEmpty()
|| (keyUsage.size() == 1 && keyUsage
.contains(KeyUsage.EXCHANGE))) {
cert = XKMSKeyUtil.getX509Certificate(identifer, serialNumber,