package org.onap.aaf.certservice.client.api;
public abstract class ExitableException extends Exception {
- public ExitableException(Throwable e) {
- super(e);
+ public ExitableException(Throwable cause) {
+ super(cause);
}
public ExitableException(String message) {
LOGGER.info("Creation of CSR has been started with following parameters: {}", configuration.toString());
String csrParameters = getMandatoryParameters().append(getOptionalParameters()).toString();
X500Principal subject = new X500Principal(csrParameters);
- PKCS10CertificationRequest request = createPKCS10Csr(subject, keyPair);
+ PKCS10CertificationRequest request = createPkcs10Csr(subject, keyPair);
LOGGER.info("Creation of CSR has been completed successfully");
- return convertPKCS10CsrToPem(request);
+ return convertPkcs10CsrToPem(request);
}
private StringBuilder getMandatoryParameters() {
return optionalParameters.toString();
}
- private PKCS10CertificationRequest createPKCS10Csr(X500Principal subject, KeyPair keyPair) throws CsrGenerationException {
+ private PKCS10CertificationRequest createPkcs10Csr(X500Principal subject, KeyPair keyPair) throws CsrGenerationException {
JcaPKCS10CertificationRequestBuilder builder = new JcaPKCS10CertificationRequestBuilder(subject, keyPair.getPublic());
if (isParameterPresent(configuration.getSans())) {
return contentSigner;
}
- private String convertPKCS10CsrToPem(PKCS10CertificationRequest request) throws CsrGenerationException {
+ private String convertPkcs10CsrToPem(PKCS10CertificationRequest request) throws CsrGenerationException {
final StringWriter stringWriter = new StringWriter();
try (JcaPEMWriter pemWriter = new JcaPEMWriter(stringWriter)) {
LOGGER.info("Conversion of CSR to PEM has been started");
public class CertFileWriterException extends ExitableException {
- public CertFileWriterException(Throwable e) {
- super(e);
+ public CertFileWriterException(Throwable cause) {
+ super(cause);
}
@Override
public class CsrGenerationException extends ExitableException {
private static final ExitStatus EXIT_STATUS = ExitStatus.CSR_GENERATION_EXCEPTION;
- public CsrGenerationException(Throwable e) {
- super(e);
+ public CsrGenerationException(Throwable cause) {
+ super(cause);
}
public ExitStatus applicationExitStatus() {
public class PemConversionException extends ExitableException {
private static final ExitStatus EXIT_STATUS = ExitStatus.PEM_CONVERSION_EXCEPTION;
- public PemConversionException(Throwable e) {
- super(e);
+ public PemConversionException(Throwable cause) {
+ super(cause);
}
public PemConversionException(String message) {
public class PkEncodingException extends ExitableException {
private static final ExitStatus EXIT_STATUS = ExitStatus.PK_TO_PEM_ENCODING_EXCEPTION;
- public PkEncodingException(Throwable e) {
- super(e);
+ public PkEncodingException(Throwable cause) {
+ super(cause);
}
public ExitStatus applicationExitStatus() {
String truststorePassword = envsForTls.getTruststorePassword()
.orElseThrow(() -> new TlsConfigurationException(createEnvMissingMessage(TlsConfigurationEnvs.TRUSTSTORE_PASSWORD)));
- return createSSLContext(keystorePath, keystorePassword, truststorePath, truststorePassword);
+ return createSslContext(keystorePath, keystorePassword, truststorePath, truststorePassword);
}
private String createEnvMissingMessage(TlsConfigurationEnvs keystorePath) {
return keyStore;
}
- private SSLContext createSSLContext(String keystorePath, String keystorePassword, String truststorePath, String truststorePassword) throws TlsConfigurationException {
+ private SSLContext createSslContext(String keystorePath, String keystorePassword, String truststorePath, String truststorePassword) throws TlsConfigurationException {
try {
KeyStore identityKeystore = setupKeystore(keystorePath, keystorePassword);
KeyStore trustKeystore = setupKeystore(truststorePath, truststorePassword);
public class HttpClientException extends ExitableException {
private static final ExitStatus EXIT_STATUS = ExitStatus.HTTP_CLIENT_EXCEPTION;
- public HttpClientException(Throwable e) {
- super(e);
+ public HttpClientException(Throwable cause) {
+ super(cause);
}
@Override
}
@Test
- void certFileWriterShouldThrowPemToPKCS12ConverterExceptionWhenOutputDirectoryDoesNotExist() {
+ void certFileWriterShouldThrowCertFileWriterExceptionWhenOutputDirectoryDoesNotExist() {
// given
final byte[] data = new byte[]{-128, 1, 2, 3, 0};
CertFileWriter certFileWriter = new CertFileWriter(OUTPUT_PATH + "thisPathDoesNotExist/");
}
@Test
- void shouldReturnSystemEnvOUVariableWhenItWasDefined() {
+ void shouldReturnSystemEnvOuVariableWhenItWasDefined() {
// given
when(envsForCsr.readEnv(CsrConfigurationEnvs.ORGANIZATION_UNIT)).thenReturn(Optional.of(TEST_ENV));
}
@Test
- public void shouldReportThatSystemEnvOUVariableIsNotPresentWhenItWasNotDefined() {
+ public void shouldReportThatSystemEnvOuVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForCsr.getOrganizationUnit();
}
@Test
- void shouldReturnSystemEnvSANSVariableWhenItWasDefined() {
+ void shouldReturnSystemEnvSansVariableWhenItWasDefined() {
// given
when(envsForCsr.readEnv(CsrConfigurationEnvs.SANS)).thenReturn(Optional.of(TEST_ENV));
}
@Test
- public void shouldReportThatSystemEnvSANSVariableIsNotPresentWhenItWasNotDefined() {
+ public void shouldReportThatSystemEnvSansVariableIsNotPresentWhenItWasNotDefined() {
// when
final Optional<String> testEnv = envsForCsr.getSubjectAlternativesName();
private CsrConfigurationFactory testedFactory;
private Condition<CsrConfigurationException> expectedExitCodeCondition = new Condition<>("Correct exit code") {
@Override
- public boolean matches(CsrConfigurationException e) {
- return e.applicationExitStatus() == CSR_CONFIGURATION_EXCEPTION;
+ public boolean matches(CsrConfigurationException exception) {
+ return exception.applicationExitStatus() == CSR_CONFIGURATION_EXCEPTION;
}
};
}
@Test
- public void shouldReturnSSLContext() throws TlsConfigurationException {
+ public void shouldReturnSslContext() throws TlsConfigurationException {
// Given
String keystorePath = getResourcePath(VALID_KEYSTORE_NAME);
String truststorePath = getResourcePath(VALID_TRUSTSTORE_NAME);