@Test(expected = AccessDeniedException.class) @WithMockUser(authorities = { "GENERATE_SIGN_CERT_REQ" }) public void regenerateAuthCsrPermission() throws Exception { SignerProxy.GeneratedCertRequestInfo csrInfo = tokenCertificateService .regenerateCertRequest(AUTH_KEY_ID, GOOD_AUTH_CSR_ID, CertificateRequestFormat.PEM); }
public GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { TokenInfo tokenInfo = tokenService.getTokenForKeyId(keyId); KeyInfo keyInfo = keyService.getKey(tokenInfo, keyId); getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("GENERATE_SIGN_CERT_REQ"); } else { securityHelper.verifyAuthority("GENERATE_AUTH_CERT_REQ"); } if (keyInfo.isForSigning()) { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_SIGN_CSR, tokenInfo, keyInfo); } else { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_AUTH_CSR, tokenInfo, keyInfo); } try { return signerProxyFacade.regenerateCertRequest(csrId, format); } catch (CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Regenerate cert request failed", e); } }
TokenCertificateService { public GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { TokenInfo tokenInfo = tokenService.getTokenForKeyId(keyId); KeyInfo keyInfo = keyService.getKey(tokenInfo, keyId); getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("GENERATE_SIGN_CERT_REQ"); } else { securityHelper.verifyAuthority("GENERATE_AUTH_CERT_REQ"); } if (keyInfo.isForSigning()) { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_SIGN_CSR, tokenInfo, keyInfo); } else { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_AUTH_CSR, tokenInfo, keyInfo); } try { return signerProxyFacade.regenerateCertRequest(csrId, format); } catch (CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Regenerate cert request failed", e); } } }
TokenCertificateService { public GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { TokenInfo tokenInfo = tokenService.getTokenForKeyId(keyId); KeyInfo keyInfo = keyService.getKey(tokenInfo, keyId); getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("GENERATE_SIGN_CERT_REQ"); } else { securityHelper.verifyAuthority("GENERATE_AUTH_CERT_REQ"); } if (keyInfo.isForSigning()) { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_SIGN_CSR, tokenInfo, keyInfo); } else { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_AUTH_CSR, tokenInfo, keyInfo); } try { return signerProxyFacade.regenerateCertRequest(csrId, format); } catch (CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Regenerate cert request failed", e); } } @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 GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { TokenInfo tokenInfo = tokenService.getTokenForKeyId(keyId); KeyInfo keyInfo = keyService.getKey(tokenInfo, keyId); getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("GENERATE_SIGN_CERT_REQ"); } else { securityHelper.verifyAuthority("GENERATE_AUTH_CERT_REQ"); } if (keyInfo.isForSigning()) { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_SIGN_CSR, tokenInfo, keyInfo); } else { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_AUTH_CSR, tokenInfo, keyInfo); } try { return signerProxyFacade.regenerateCertRequest(csrId, format); } catch (CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Regenerate cert request failed", e); } } @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 GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format) throws KeyNotFoundException, CsrNotFoundException, ActionNotPossibleException { TokenInfo tokenInfo = tokenService.getTokenForKeyId(keyId); KeyInfo keyInfo = keyService.getKey(tokenInfo, keyId); getCsr(keyInfo, csrId); if (keyInfo.isForSigning()) { securityHelper.verifyAuthority("GENERATE_SIGN_CERT_REQ"); } else { securityHelper.verifyAuthority("GENERATE_AUTH_CERT_REQ"); } if (keyInfo.isForSigning()) { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_SIGN_CSR, tokenInfo, keyInfo); } else { possibleActionsRuleEngine.requirePossibleKeyAction(PossibleActionEnum.GENERATE_AUTH_CSR, tokenInfo, keyInfo); } try { return signerProxyFacade.regenerateCertRequest(csrId, format); } catch (CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Regenerate cert request failed", e); } } @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);  }