final int caid = CertTools.getIssuerDN(certificate).hashCode();
final CertificateInfo certinfo = certificateStoreSession.getCertificateInfo(admin, CertTools.getFingerprintAsString(certificate));
// Check if approvals is required.
int numOfApprovalsRequired = caAdminSession.getNumOfApprovalRequired(admin, CAInfo.REQ_APPROVAL_KEYRECOVER, caid, certinfo.getCertificateProfileId());
if (numOfApprovalsRequired > 0){
KeyRecoveryApprovalRequest ar = new KeyRecoveryApprovalRequest(certificate,username,checkNewest, admin,null,numOfApprovalsRequired,caid,endEntityProfileId);
if (ApprovalExecutorUtil.requireApproval(ar, NONAPPROVABLECLASSNAMES_KEYRECOVERY)){
approvalSession.addApprovalRequest(admin, ar, gc);
String msg = intres.getLocalizedMessage("keyrecovery.addedforapproval");
throw new WaitingForApprovalException(msg, ar.generateApprovalId());
}
}
}