class OrphanRemovalService {

    boolean isOrphanKey(KeyInfo keyInfo, ClientId clientId) {
        List<CertificateInfo> orphanCerts = getCerts(keyInfo, clientId);
        List<CertRequestInfo> orphanCsrs = getCsrs(keyInfo, clientId);
        if (!orphanCerts.isEmpty() || !orphanCsrs.isEmpty()) {
            // some orphan certs or csrs, make sure there are none that belong to others
            List<CertificateInfo> otherCerts = new ArrayList<>(keyInfo.getCerts());
            otherCerts.removeAll(orphanCerts);
            List<CertRequestInfo> otherCsrs = new ArrayList<>(keyInfo.getCertRequests());
            otherCsrs.removeAll(orphanCsrs);
            if (otherCerts.isEmpty() && otherCsrs.isEmpty()) {
                return true;
            }
        }
        return false;
    }

    @Autowired public  OrphanRemovalService(TokenService tokenService,
            TokenCertificateService tokenCertificateService,
            ClientService clientService,
            KeyService keyService,
            AuditDataHelper auditDataHelper);

}