<parent>
<groupId>org.onap.aaf.certservice</groupId>
<artifactId>aaf-certservice</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>aaf-certservice-api</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<name>aaf-certservice-api</name>
<description>AAF Certification Service Api</description>
<packaging>jar</packaging>
major=1
-minor=1
+minor=2
patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}
You need certificate and trust anchors (in JKS format) to connect to CertService API via HTTPS. Information how to generate truststore and keystore files you can find in CertService main README.
-Information how to run you can find in CertService main README and official documentation, see [Read The Docs](https://onap-doc.readthedocs.io/projects/onap-aaf-certservice/en/latest/sections/usage.html)
+Information how to run you can find in CertService main README and official documentation, see [Read The Docs](https://docs.onap.org/projects/onap-aaf-certservice/en/latest/sections/usage.html)
### Logs locally
<parent>
<artifactId>aaf-certservice</artifactId>
<groupId>org.onap.aaf.certservice</groupId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aaf-certservice-client</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<name>aaf-certservice-client</name>
<description>AAF Certification Service Api Client</description>
<packaging>jar</packaging>
PEM("PEM") {
@Override
ArtifactsCreator create(String destPath) {
- return new PemArtifactsCreator(new CertFileWriter(destPath), new PrivateKeyToPemEncoder());
+ return new PemArtifactsCreator(CertFileWriter.createWithDir(destPath), new PrivateKeyToPemEncoder());
}
};
public static ConvertedArtifactsCreator createConverter(String destPath, String fileExtension, String keyStoreType) {
return new ConvertedArtifactsCreator(
- new CertFileWriter(destPath),
+ CertFileWriter.createWithDir(destPath),
new RandomPasswordGenerator(),
new PemConverter(keyStoreType),
fileExtension);
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
private static final Logger LOGGER = LoggerFactory.getLogger(CertFileWriter.class);
private final String destPath;
- public CertFileWriter(String destPath) {
+ private CertFileWriter(String destPath) {
this.destPath = destPath;
}
+ public static CertFileWriter createWithDir(String destPath) {
+ createDirIfNotExists(destPath);
+ return new CertFileWriter(destPath);
+ }
+
public void saveData(byte[] data, String filename) throws CertFileWriterException {
LOGGER.debug("Attempt to save file {} in path {}", filename, destPath);
try (FileOutputStream outputStream = new FileOutputStream(Path.of(destPath, filename).toString())) {
throw new CertFileWriterException(e);
}
}
+
+ private static void createDirIfNotExists(String destPath) {
+ File destFolderPath = new File(destPath);
+ if (!destFolderPath.exists()) {
+ LOGGER.debug("Destination path not exists, subdirectories are created");
+ destFolderPath.mkdirs();
+ }
+ }
}
package org.onap.aaf.certservice.client.certification.writer;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
import java.io.File;
class CertFileWriterTest {
- private static final String RESOURCES_PATH = "src/test/resources";
- private static final String OUTPUT_PATH = RESOURCES_PATH + "/generatedFiles/";
+ private static final String RESOURCES_PATH = "src/test/resources/";
+ private static final String OUTPUT_PATH = RESOURCES_PATH + "generatedFiles/";
+ private static final String NOT_EXISTING_OUTPUT_PATH = OUTPUT_PATH + "directoryDoesNotExist/";
private static final String TRUSTSTORE_P12 = "truststore.p12";
- private static final String ERROR_MESSAGE = "java.io.FileNotFoundException: src/test/resources/generatedFiles/thisPathDoesNotExist/truststore.p12 (No such file or directory)";
-
private File outputDirectory = new File(OUTPUT_PATH);
- @BeforeEach
- void createDirectory() {
- outputDirectory.mkdir();
- }
-
@AfterEach
void cleanUpFiles() {
- List.of(outputDirectory.listFiles()).forEach(f -> f.delete());
- outputDirectory.delete();
+ deleteDirectoryRecursive(outputDirectory);
}
- @Test
- void certFileWriterShouldCreateFilesWithDataInGivenLocation()
+ @ParameterizedTest
+ @ValueSource(strings = {OUTPUT_PATH, NOT_EXISTING_OUTPUT_PATH})
+ void certFileWriterShouldCreateFilesWithDataInGivenLocation(String outputPath)
throws IOException, CertFileWriterException {
// given
+ File truststore = new File(outputPath + TRUSTSTORE_P12);
+ CertFileWriter certFileWriter = CertFileWriter.createWithDir(outputPath);
final byte[] data = new byte[]{-128, 1, 2, 3, 127};
- File truststore = new File(OUTPUT_PATH + TRUSTSTORE_P12);
- CertFileWriter certFileWriter = new CertFileWriter(OUTPUT_PATH);
// when
certFileWriter.saveData(data, TRUSTSTORE_P12);
// then
assertThat(truststore.exists()).isTrue();
- assertThat(Files.readAllBytes(Path.of(OUTPUT_PATH + TRUSTSTORE_P12))).isEqualTo(data);
+ assertThat(Files.readAllBytes(Path.of(outputPath + TRUSTSTORE_P12))).isEqualTo(data);
}
- @Test
- void certFileWriterShouldThrowCertFileWriterExceptionWhenOutputDirectoryDoesNotExist() {
- // given
- final byte[] data = new byte[]{-128, 1, 2, 3, 0};
- CertFileWriter certFileWriter = new CertFileWriter(OUTPUT_PATH + "thisPathDoesNotExist/");
-
- // when then
- assertThatThrownBy(() -> certFileWriter.saveData(data, TRUSTSTORE_P12))
- .isInstanceOf(CertFileWriterException.class).hasMessage(ERROR_MESSAGE);
+ private void deleteDirectoryRecursive(File dirForDeletion) {
+ List.of(dirForDeletion.listFiles()).forEach(file -> {
+ if (file.isDirectory()) {
+ deleteDirectoryRecursive(file);
+ }
+ file.delete();
+ });
+ dirForDeletion.delete();
}
+
}
major=1
-minor=1
+minor=2
patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}
Release Notes
==============
+Version: 1.2.0
+--------------
+
+:Release Date:
+
+**New Features**
+
+ - Client creates subdirectories in given OUTPUT_PATH and place certificate into it.
+
+**Bug Fixes**
+
+ N/A
+
+**Known Issues**
+
+ N/A
+
+**Security Notes**
+
+ N/A
+
+*Fixed Security Issues*
+
+ N/A
+
+*Known Security Issues*
+
+ N/A
+
+*Known Vulnerabilities in Used Modules*
+
+ N/A
+
+**Upgrade Notes**
+
+**Deprecation Notes**
+
+**Other**
+
+===========
+
Version: 1.1.0
--------------
</parent>
<groupId>org.onap.aaf.certservice</groupId>
<artifactId>aaf-certservice</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<name>aaf-certservice</name>
<description>AAF Certification Service</description>
<packaging>pom</packaging>
major=1
-minor=1
+minor=2
patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}