<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ================================================================================
+ Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+ ============LICENSE_END=========================================================
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
<releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
<stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/oom/cert-service/${project.artifactId}/${project.version}</sitePath>
+ <sitePath>/content/sites/site/org/onap/oom/platform/cert-service/${project.artifactId}/${project.version}</sitePath>
<java.version>11</java.version>
<springdoc-openapi-maven-plugin.apiDocsUrl>http://localhost:8080/v3/api-docs.yaml</springdoc-openapi-maven-plugin.apiDocsUrl>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>aaf-certservice</artifactId>
- <groupId>org.onap.aaf.certservice</groupId>
+ <artifactId>oom-certservice</artifactId>
+ <groupId>org.onap.oom.platform.cert-service</groupId>
<version>1.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
import org.onap.oom.truststoremerger.certification.file.EnvProvider;
import org.onap.oom.truststoremerger.certification.file.TruststoresPathsProvider;
import org.onap.oom.truststoremerger.configuration.MergerConfiguration;
-import org.onap.oom.truststoremerger.configuration.MergerConfigurationException;
import org.onap.oom.truststoremerger.configuration.MergerConfigurationFactory;
import org.onap.oom.truststoremerger.certification.file.PathValidator;
--- /dev/null
+/*============LICENSE_START=======================================================
+ * oom-truststore-merger
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.oom.truststoremerger.api;
+
+public class ConfigurationEnvs {
+
+ public static final String TRUSTSTORES_ENV = "TRUSTSTORES";
+ public static final String TRUSTSTORES_PASSWORDS_ENV = "TRUSTSTORES_PASSWORDS";
+}
package org.onap.oom.truststoremerger.certification.file;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_ENV;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PASSWORDS_ENV;
+
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
public class TruststoresPathsProvider {
- static final String TRUSTSTORES_ENV = "TRUSTSTORES";
- static final String TRUSTSTORES_PASSWORDS_ENV = "TRUSTSTORES_PASSWORDS";
private static final String DELIMITER = ":";
private static final int NEGATIVE_SPLIT_LIMIT = -1;
public List<String> getTruststores() throws TruststoresPathsProviderException {
return envProvider.getEnv(TRUSTSTORES_ENV)
- .filter(Predicate.not(String::isEmpty))
- .map(this::splitToList)
- .filter(this::validateTruststores)
- .orElseThrow(() -> new TruststoresPathsProviderException("TRUSTSTORES environment variable does not contain valid truststores paths"));
+ .filter(Predicate.not(String::isEmpty))
+ .map(this::splitToList)
+ .filter(this::validateTruststores)
+ .orElseThrow(() -> new TruststoresPathsProviderException(
+ TRUSTSTORES_ENV + " environment variable does not contain valid truststores paths"));
}
public List<String> getTruststoresPasswords() throws TruststoresPathsProviderException {
return envProvider.getEnv(TRUSTSTORES_PASSWORDS_ENV)
- .map(this::splitToList)
- .filter(this::validateTruststoresPasswords)
- .orElseThrow(() -> new TruststoresPathsProviderException("TRUSTSTORES_PASSWORDS environment variable does not contain valid passwords paths"));
+ .map(this::splitToList)
+ .filter(this::validateTruststoresPasswords)
+ .orElseThrow(() -> new TruststoresPathsProviderException(
+ TRUSTSTORES_PASSWORDS_ENV + " environment variable does not contain valid passwords paths"));
}
private boolean validateTruststores(List<String> truststores) {
return truststores.stream()
- .allMatch(pathValidator::isTruststorePathValid);
+ .allMatch(pathValidator::isTruststorePathValid);
}
private boolean validateTruststoresPasswords(List<String> truststoresPasswords) {
return truststoresPasswords.stream()
- .allMatch(pathValidator::isTruststorePasswordPathValid);
+ .allMatch(pathValidator::isTruststorePasswordPathValid);
}
private List<String> splitToList(String stringToSplit) {
import org.onap.oom.truststoremerger.certification.file.TruststoresPathsProvider;
import org.onap.oom.truststoremerger.certification.file.TruststoresPathsProviderException;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_ENV;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PASSWORDS_ENV;
+
import java.util.List;
public class MergerConfigurationFactory {
this.pathsProvider = pathsProvider;
}
- public MergerConfiguration createConfiguration() throws MergerConfigurationException, TruststoresPathsProviderException {
+ public MergerConfiguration createConfiguration()
+ throws MergerConfigurationException, TruststoresPathsProviderException {
List<String> truststores = pathsProvider.getTruststores();
List<String> truststoresPasswords = pathsProvider.getTruststoresPasswords();
if (truststores.size() != truststoresPasswords.size()) {
- throw new MergerConfigurationException("Size of TRUSTSTORES does not match size of TRUSTSTORES_PASSWORDS environment variables");
+ throw new MergerConfigurationException(
+ "Size of " + TRUSTSTORES_ENV
+ + " does not match size of " + TRUSTSTORES_PASSWORDS_ENV + " environment variables");
}
return new MergerConfiguration(truststores, truststoresPasswords);
AppExitHandler appExitHandler;
@Test
- void shouldExitWithMergeConfigurationExceptionDueToMissingEnvs() {
+ void shouldExitWithTruststoresPathsProviderExceptionDueToMissingTrustoresPathEnvs() {
new TrustStoreMerger(appExitHandler).run();
- verify(appExitHandler).exit(ExitStatus.MERGER_CONFIGURATION_EXCEPTION);
+ verify(appExitHandler).exit(ExitStatus.TRUSTSTORES_PATHS_PROVIDER_EXCEPTION);
}
}
+/*============LICENSE_START=======================================================
+ * oom-truststore-merger
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.oom.truststoremerger.certification.file;
import org.junit.jupiter.api.BeforeEach;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.when;
-import static org.onap.oom.truststoremerger.certification.file.TruststoresPathsProvider.TRUSTSTORES_ENV;
-import static org.onap.oom.truststoremerger.certification.file.TruststoresPathsProvider.TRUSTSTORES_PASSWORDS_ENV;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_ENV;
+import static org.onap.oom.truststoremerger.api.ConfigurationEnvs.TRUSTSTORES_PASSWORDS_ENV;
+
@ExtendWith(MockitoExtension.class)
class TruststoresPathsProviderTest {