@Test @WithMockUser(authorities = { "DELETE_SIGN_CERT", "DELETE_AUTH_CERT" }) public void deleteCsr() throws Exception { tokenCertificateService.deleteCsr(GOOD_CSR_ID); verify(signerProxyFacade, times(1)).deleteCertRequest(GOOD_CSR_ID); }
public void deleteCsr(String csrId) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_ORPHANS)) { auditDataHelper.addListPropertyItem(CERT_REQUEST_IDS, csrId); } else if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(CSR_ID, csrId); } TokenInfoAndKeyId tokenInfoAndKeyId = tokenService.getTokenAndKeyIdForCertificateRequestId(csrId); TokenInfo tokenInfo = tokenInfoAndKeyId.getTokenInfo(); KeyInfo keyInfo = tokenInfoAndKeyId.getKeyInfo(); if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(tokenInfo); auditDataHelper.put(keyInfo); } CertRequestInfo certRequestInfo = getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("DELETE_SIGN_CERT"); } else { securityHelper.verifyAuthority("DELETE_AUTH_CERT"); } possibleActionsRuleEngine.requirePossibleCsrAction( PossibleActionEnum.DELETE, tokenInfo, keyInfo, certRequestInfo); try { signerProxyFacade.deleteCertRequest(csrId); } catch (CodedException e) { if (isCausedByCsrNotFound(e)) { throw new CsrNotFoundException(e); } else { throw e; } } catch (Exception other) { throw new SignerNotReachableException("deleting a csr failed", other); } }
TokenCertificateService { public void deleteCsr(String csrId) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_ORPHANS)) { auditDataHelper.addListPropertyItem(CERT_REQUEST_IDS, csrId); } else if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(CSR_ID, csrId); } TokenInfoAndKeyId tokenInfoAndKeyId = tokenService.getTokenAndKeyIdForCertificateRequestId(csrId); TokenInfo tokenInfo = tokenInfoAndKeyId.getTokenInfo(); KeyInfo keyInfo = tokenInfoAndKeyId.getKeyInfo(); if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(tokenInfo); auditDataHelper.put(keyInfo); } CertRequestInfo certRequestInfo = getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("DELETE_SIGN_CERT"); } else { securityHelper.verifyAuthority("DELETE_AUTH_CERT"); } possibleActionsRuleEngine.requirePossibleCsrAction( PossibleActionEnum.DELETE, tokenInfo, keyInfo, certRequestInfo); try { signerProxyFacade.deleteCertRequest(csrId); } catch (CodedException e) { if (isCausedByCsrNotFound(e)) { throw new CsrNotFoundException(e); } else { throw e; } } catch (Exception other) { throw new SignerNotReachableException("deleting a csr failed", other); } } }
TokenCertificateService { public void deleteCsr(String csrId) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_ORPHANS)) { auditDataHelper.addListPropertyItem(CERT_REQUEST_IDS, csrId); } else if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(CSR_ID, csrId); } TokenInfoAndKeyId tokenInfoAndKeyId = tokenService.getTokenAndKeyIdForCertificateRequestId(csrId); TokenInfo tokenInfo = tokenInfoAndKeyId.getTokenInfo(); KeyInfo keyInfo = tokenInfoAndKeyId.getKeyInfo(); if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(tokenInfo); auditDataHelper.put(keyInfo); } CertRequestInfo certRequestInfo = getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("DELETE_SIGN_CERT"); } else { securityHelper.verifyAuthority("DELETE_AUTH_CERT"); } possibleActionsRuleEngine.requirePossibleCsrAction( PossibleActionEnum.DELETE, tokenInfo, keyInfo, certRequestInfo); try { signerProxyFacade.deleteCertRequest(csrId); } catch (CodedException e) { if (isCausedByCsrNotFound(e)) { throw new CsrNotFoundException(e); } else { throw e; } } catch (Exception other) { throw new SignerNotReachableException("deleting a csr failed", other); } } @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 { public void deleteCsr(String csrId) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_ORPHANS)) { auditDataHelper.addListPropertyItem(CERT_REQUEST_IDS, csrId); } else if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(CSR_ID, csrId); } TokenInfoAndKeyId tokenInfoAndKeyId = tokenService.getTokenAndKeyIdForCertificateRequestId(csrId); TokenInfo tokenInfo = tokenInfoAndKeyId.getTokenInfo(); KeyInfo keyInfo = tokenInfoAndKeyId.getKeyInfo(); if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(tokenInfo); auditDataHelper.put(keyInfo); } CertRequestInfo certRequestInfo = getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("DELETE_SIGN_CERT"); } else { securityHelper.verifyAuthority("DELETE_AUTH_CERT"); } possibleActionsRuleEngine.requirePossibleCsrAction( PossibleActionEnum.DELETE, tokenInfo, keyInfo, certRequestInfo); try { signerProxyFacade.deleteCertRequest(csrId); } catch (CodedException e) { if (isCausedByCsrNotFound(e)) { throw new CsrNotFoundException(e); } else { throw e; } } catch (Exception other) { throw new SignerNotReachableException("deleting a csr failed", other); } } @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 { public void deleteCsr(String csrId) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_ORPHANS)) { auditDataHelper.addListPropertyItem(CERT_REQUEST_IDS, csrId); } else if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(CSR_ID, csrId); } TokenInfoAndKeyId tokenInfoAndKeyId = tokenService.getTokenAndKeyIdForCertificateRequestId(csrId); TokenInfo tokenInfo = tokenInfoAndKeyId.getTokenInfo(); KeyInfo keyInfo = tokenInfoAndKeyId.getKeyInfo(); if (auditDataHelper.dataIsForEvent(RestApiAuditEvent.DELETE_CSR)) { auditDataHelper.put(tokenInfo); auditDataHelper.put(keyInfo); } CertRequestInfo certRequestInfo = getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("DELETE_SIGN_CERT"); } else { securityHelper.verifyAuthority("DELETE_AUTH_CERT"); } possibleActionsRuleEngine.requirePossibleCsrAction( PossibleActionEnum.DELETE, tokenInfo, keyInfo, certRequestInfo); try { signerProxyFacade.deleteCertRequest(csrId); } catch (CodedException e) { if (isCausedByCsrNotFound(e)) { throw new CsrNotFoundException(e); } else { throw e; } } catch (Exception other) { throw new SignerNotReachableException("deleting a csr failed", other); } } @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);  }