@Test public void generateInternalTlsKeyAndCertificateFail() throws Exception { internalTlsCertificateService.setGenerateCertScriptPath(MOCK_FAIL_SCRIPT); try { internalTlsCertificateService.generateInternalTlsKeyAndCertificate(); } catch (DeviationAwareRuntimeException e) { assertEquals(KEY_CERT_GENERATION_FAILED, e.getErrorDeviation().getCode()); } }
public void generateInternalTlsKeyAndCertificate() throws InterruptedException { try { externalProcessRunner.executeAndThrowOnFailure(generateCertScriptPath, generateCertScriptArgs.split("\\s+")); } catch (ProcessNotExecutableException | ProcessFailedException e) { log.error("Failed to generate internal TLS key and cert", e); throw new DeviationAwareRuntimeException(e, new ErrorDeviation(KEY_CERT_GENERATION_FAILED)); } X509Certificate generatedCert = internalTlsCertificateRepository.getInternalTlsCertificate(); auditDataHelper.putCertificateHash(generatedCert); }
InternalTlsCertificateService { public void generateInternalTlsKeyAndCertificate() throws InterruptedException { try { externalProcessRunner.executeAndThrowOnFailure(generateCertScriptPath, generateCertScriptArgs.split("\\s+")); } catch (ProcessNotExecutableException | ProcessFailedException e) { log.error("Failed to generate internal TLS key and cert", e); throw new DeviationAwareRuntimeException(e, new ErrorDeviation(KEY_CERT_GENERATION_FAILED)); } X509Certificate generatedCert = internalTlsCertificateRepository.getInternalTlsCertificate(); auditDataHelper.putCertificateHash(generatedCert); } }
InternalTlsCertificateService { public void generateInternalTlsKeyAndCertificate() throws InterruptedException { try { externalProcessRunner.executeAndThrowOnFailure(generateCertScriptPath, generateCertScriptArgs.split("\\s+")); } catch (ProcessNotExecutableException | ProcessFailedException e) { log.error("Failed to generate internal TLS key and cert", e); throw new DeviationAwareRuntimeException(e, new ErrorDeviation(KEY_CERT_GENERATION_FAILED)); } X509Certificate generatedCert = internalTlsCertificateRepository.getInternalTlsCertificate(); auditDataHelper.putCertificateHash(generatedCert); } @Autowired  InternalTlsCertificateService(InternalTlsCertificateRepository internalTlsCertificateRepository,
            ExternalProcessRunner externalProcessRunner,
            @Value("${script.generate-certificate.path}") String generateCertScriptPath,
            @Value("${script.generate-certificate.args}") String generateCertScriptArgs,
            AuditDataHelper auditDataHelper); }
InternalTlsCertificateService { public void generateInternalTlsKeyAndCertificate() throws InterruptedException { try { externalProcessRunner.executeAndThrowOnFailure(generateCertScriptPath, generateCertScriptArgs.split("\\s+")); } catch (ProcessNotExecutableException | ProcessFailedException e) { log.error("Failed to generate internal TLS key and cert", e); throw new DeviationAwareRuntimeException(e, new ErrorDeviation(KEY_CERT_GENERATION_FAILED)); } X509Certificate generatedCert = internalTlsCertificateRepository.getInternalTlsCertificate(); auditDataHelper.putCertificateHash(generatedCert); } @Autowired  InternalTlsCertificateService(InternalTlsCertificateRepository internalTlsCertificateRepository,
            ExternalProcessRunner externalProcessRunner,
            @Value("${script.generate-certificate.path}") String generateCertScriptPath,
            @Value("${script.generate-certificate.args}") String generateCertScriptArgs,
            AuditDataHelper auditDataHelper); X509Certificate getInternalTlsCertificate(); byte[] exportInternalTlsCertificate(); void generateInternalTlsKeyAndCertificate(); X509Certificate importInternalTlsCertificate(byte[] certificateBytes); }
InternalTlsCertificateService { public void generateInternalTlsKeyAndCertificate() throws InterruptedException { try { externalProcessRunner.executeAndThrowOnFailure(generateCertScriptPath, generateCertScriptArgs.split("\\s+")); } catch (ProcessNotExecutableException | ProcessFailedException e) { log.error("Failed to generate internal TLS key and cert", e); throw new DeviationAwareRuntimeException(e, new ErrorDeviation(KEY_CERT_GENERATION_FAILED)); } X509Certificate generatedCert = internalTlsCertificateRepository.getInternalTlsCertificate(); auditDataHelper.putCertificateHash(generatedCert); } @Autowired  InternalTlsCertificateService(InternalTlsCertificateRepository internalTlsCertificateRepository,
            ExternalProcessRunner externalProcessRunner,
            @Value("${script.generate-certificate.path}") String generateCertScriptPath,
            @Value("${script.generate-certificate.args}") String generateCertScriptArgs,
            AuditDataHelper auditDataHelper); X509Certificate getInternalTlsCertificate(); byte[] exportInternalTlsCertificate(); void generateInternalTlsKeyAndCertificate(); X509Certificate importInternalTlsCertificate(byte[] certificateBytes); static final String KEY_CERT_GENERATION_FAILED; static final String IMPORT_INTERNAL_CERT_FAILED; }