@Test(expected = CodedException.class) @WithMockUser(authorities = { "DELETE_SIGN_CERT", "DELETE_AUTH_CERT" }) public void deleteCertificateSignerTokenReadonly() throws Exception { tokenCertificateService.deleteCertificate(SIGNER_EX_TOKEN_READONLY_HASH); }
private void deleteCertificate(String certificateId, List<TokenInfo> allTokens) throws CertificateNotFoundException, ActionNotPossibleException { 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"); }
TokenCertificateService { private void deleteCertificate(String certificateId, List<TokenInfo> allTokens) throws CertificateNotFoundException, ActionNotPossibleException { 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"); } }
TokenCertificateService { private void deleteCertificate(String certificateId, List<TokenInfo> allTokens) throws CertificateNotFoundException, ActionNotPossibleException { 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")  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); }
TokenCertificateService { private void deleteCertificate(String certificateId, List<TokenInfo> allTokens) throws CertificateNotFoundException, ActionNotPossibleException { 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")  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); GeneratedCertRequestInfo generateCertRequest(String keyId, ClientId memberId, KeyUsageInfo keyUsage,
            String caName, Map<String, String> subjectFieldValues, CertificateRequestFormat format); GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format); CertificateInfo getCertificateInfo(String hash); CertificateInfo importCertificateFromToken(String hash); void activateCertificate(String hash); void deactivateCertificate(String hash); CertificateInfo importCertificate(byte[] certificateBytes); boolean isAuthCertBytes(byte[] certificateBytes); void registerAuthCert(String hash, String securityServerAddress); void unregisterAuthCert(String hash); void markAuthCertForDeletion(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCertificate(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCsr(
            String csrId); void deleteCertificates(List<CertificateInfo> certificateInfos); void deleteCertificate(String hash); String getKeyIdForCertificateHash(String hash); void deleteCsr(String csrId); }
TokenCertificateService { private void deleteCertificate(String certificateId, List<TokenInfo> allTokens) throws CertificateNotFoundException, ActionNotPossibleException { 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")  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); GeneratedCertRequestInfo generateCertRequest(String keyId, ClientId memberId, KeyUsageInfo keyUsage,
            String caName, Map<String, String> subjectFieldValues, CertificateRequestFormat format); GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format); CertificateInfo getCertificateInfo(String hash); CertificateInfo importCertificateFromToken(String hash); void activateCertificate(String hash); void deactivateCertificate(String hash); CertificateInfo importCertificate(byte[] certificateBytes); boolean isAuthCertBytes(byte[] certificateBytes); void registerAuthCert(String hash, String securityServerAddress); void unregisterAuthCert(String hash); void markAuthCertForDeletion(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCertificate(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCsr(
            String csrId); void deleteCertificates(List<CertificateInfo> certificateInfos); void deleteCertificate(String hash); String getKeyIdForCertificateHash(String hash); void deleteCsr(String csrId);  }