class TokenCertificateService {

    private void deleteCertificate(String certificateId, List<TokenInfo> allTokens) throws
            CertificateNotFoundException, ActionNotPossibleException {
        // find token, key, and certificate info
        for (TokenInfo tokenInfo: allTokens) {
            for (KeyInfo keyInfo: tokenInfo.getKeyInfo()) {
                for (CertificateInfo certificateInfo: keyInfo.getCerts()) {
                    if (certificateInfo.getId().equals(certificateId)) {
                        auditDataHelper.addCertificateHash(certificateInfo);
                        deleteCertificate(certificateInfo, keyInfo, tokenInfo);
                        return;
                    }
                }
            }
        }
        throw new CertificateNotFoundException("did not find certificate with id " + certificateId + " in tokens");
    }

    @Autowired @SuppressWarnings("checkstyle:ParameterNumber") public  TokenCertificateService(SignerProxyFacade signerProxyFacade, ClientService clientService,
            CertificateAuthorityService certificateAuthorityService, KeyService keyService, DnFieldHelper dnFieldHelper,
            GlobalConfService globalConfService, GlobalConfFacade globalConfFacade, ClientRepository clientRepository,
            ManagementRequestSenderService managementRequestSenderService, ServerConfService serverConfService,
            PossibleActionsRuleEngine possibleActionsRuleEngine, TokenService tokenService,
            SecurityHelper securityHelper, AuditDataHelper auditDataHelper,
            AuditEventHelper auditEventHelper);

}