TransactionId transId = msg.getTransactionId();
Nonce recipientNonce = msg.getSenderNonce();
CertRep certRep;
if (msgType == MessageType.GET_CERT) {
final IssuerAndSerialNumber iasn = (IssuerAndSerialNumber) msgData;
final X500Name principal = iasn.getName();
final BigInteger serial = iasn.getSerialNumber().getValue();
try {
List<X509Certificate> issued = doGetCert(principal, serial);
if (issued.size() == 0) {
certRep = new CertRep(transId, senderNonce,
recipientNonce, FailInfo.badCertId);
} else {
CMSSignedData messageData = getMessageData(issued);
certRep = new CertRep(transId, senderNonce,
recipientNonce, messageData);
}
} catch (OperationFailureException e) {
certRep = new CertRep(transId, senderNonce, recipientNonce,
e.getFailInfo());
} catch (Exception e) {
throw new ServletException(e);
}
} else if (msgType == MessageType.GET_CERT_INITIAL) {
final IssuerAndSubject ias = (IssuerAndSubject) msgData;
final X500Name issuer = X500Name.getInstance(ias.getIssuer());
final X500Name subject = X500Name.getInstance(ias.getSubject());
try {
List<X509Certificate> issued = doGetCertInitial(issuer,
subject, transId);
if (issued.size() == 0) {
certRep = new CertRep(transId, senderNonce,
recipientNonce);
} else {
CMSSignedData messageData = getMessageData(issued);
certRep = new CertRep(transId, senderNonce,
recipientNonce, messageData);
}
} catch (OperationFailureException e) {
certRep = new CertRep(transId, senderNonce, recipientNonce,
e.getFailInfo());
} catch (Exception e) {
throw new ServletException(e);
}
} else if (msgType == MessageType.GET_CRL) {
final IssuerAndSerialNumber iasn = (IssuerAndSerialNumber) msgData;
final X500Name issuer = iasn.getName();
final BigInteger serialNumber = iasn.getSerialNumber()
.getValue();
try {
LOGGER.debug("Invoking doGetCrl");
CMSSignedData messageData = getMessageData(doGetCrl(issuer,