2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.aai.modelloader.config;
26 import org.eclipse.jetty.util.security.Password;
27 import org.openecomp.sdc.api.consumer.IConfiguration;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.Properties;
33 public class ModelLoaderConfig implements IConfiguration {
35 // Configuration file structure
36 public static final String PREFIX_MODEL_LOADER_CONFIG = "ml";
37 public static final String PREFIX_DISTRIBUTION_CLIENT =
38 PREFIX_MODEL_LOADER_CONFIG + ".distribution.";
39 public static final String PREFIX_AAI = PREFIX_MODEL_LOADER_CONFIG + ".aai.";
40 public static final String PREFIX_DEBUG = PREFIX_MODEL_LOADER_CONFIG + ".debug.";
42 // Configuration file properties
43 protected static final String PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH =
44 PREFIX_DISTRIBUTION_CLIENT + "ACTIVE_SERVER_TLS_AUTH";
45 protected static final String PROP_ML_DISTRIBUTION_ASDC_ADDRESS = PREFIX_DISTRIBUTION_CLIENT
47 protected static final String PROP_ML_DISTRIBUTION_CONSUMER_GROUP = PREFIX_DISTRIBUTION_CLIENT
49 protected static final String PROP_ML_DISTRIBUTION_CONSUMER_ID = PREFIX_DISTRIBUTION_CLIENT
51 protected static final String PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME = PREFIX_DISTRIBUTION_CLIENT
53 protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD = PREFIX_DISTRIBUTION_CLIENT
54 + "KEYSTORE_PASSWORD";
55 protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_FILE = PREFIX_DISTRIBUTION_CLIENT
57 protected static final String PROP_ML_DISTRIBUTION_PASSWORD = PREFIX_DISTRIBUTION_CLIENT
59 protected static final String PROP_ML_DISTRIBUTION_POLLING_INTERVAL = PREFIX_DISTRIBUTION_CLIENT
61 protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT
63 protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER";
64 protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT
66 protected static final String PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP =
67 PREFIX_DISTRIBUTION_CLIENT + "USE_HTTPS_WITH_DMAAP";
69 protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL";
70 protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + "KEYSTORE_FILE";
71 protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + "KEYSTORE_PASSWORD";
72 protected static final String PROP_AAI_MODEL_RESOURCE_URL = PREFIX_AAI + "MODEL_URL";
73 protected static final String PROP_AAI_NAMED_QUERY_RESOURCE_URL = PREFIX_AAI + "NAMED_QUERY_URL";
74 protected static final String PROP_AAI_VNF_IMAGE_RESOURCE_URL = PREFIX_AAI + "VNF_IMAGE_URL";
75 protected static final String PROP_AAI_AUTHENTICATION_USER = PREFIX_AAI + "AUTH_USER";
76 protected static final String PROP_AAI_AUTHENTICATION_PASSWORD = PREFIX_AAI + "AUTH_PASSWORD";
78 protected static final String PROP_DEBUG_INGEST_SIMULATOR = PREFIX_DEBUG + "INGEST_SIMULATOR";
80 private Properties modelLoaderProperties = null;
82 private String certLocation = ".";
84 private List<String> artifactTypes = null;
87 * This is the class constructor.
89 * @param modelLoaderProperties properties needed to be configured for the model loader
90 * @param certLocation location of the certificate
92 public ModelLoaderConfig(Properties modelLoaderProperties, String certLocation) {
93 this.modelLoaderProperties = modelLoaderProperties;
94 this.certLocation = certLocation;
96 // Get list of artifacts
97 artifactTypes = new ArrayList<String>();
98 if (modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) != null) {
99 String[] artTypeList = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES)
101 for (String artType : artTypeList) {
102 artifactTypes.add(artType);
108 public boolean activateServerTLSAuth() {
109 String value = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH);
110 return value == null ? false : Boolean.parseBoolean(value);
114 public String getAsdcAddress() {
115 return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ASDC_ADDRESS);
119 public String getConsumerGroup() {
120 return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_GROUP);
124 public String getConsumerID() {
125 return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_ID);
129 public String getEnvironmentName() {
130 return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME);
134 public String getKeyStorePassword() {
136 .deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD));
140 public String getKeyStorePath() {
141 return certLocation + modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_FILE);
145 public String getPassword() {
146 return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_PASSWORD));
150 public int getPollingInterval() {
152 .parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_INTERVAL));
156 public int getPollingTimeout() {
158 .parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_TIMEOUT));
162 public List<String> getRelevantArtifactTypes() {
163 return artifactTypes;
167 public String getUser() {
168 return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_USER);
172 public boolean isFilterInEmptyResources() {
177 public Boolean isUseHttpsWithDmaap() {
178 String useHTTPS = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP);
179 return useHTTPS == null ? false : Boolean.valueOf(useHTTPS);
182 public String getAaiKeyStorePath() {
183 return certLocation + "/" + modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE);
186 public String getAaiKeyStorePassword() {
187 return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_PASSWORD));
190 public String getAaiBaseUrl() {
191 return modelLoaderProperties.getProperty(PROP_AAI_BASE_URL);
194 public String getAaiModelUrl(String version) {
195 return modelLoaderProperties.getProperty(PROP_AAI_MODEL_RESOURCE_URL).replace("v*", version);
198 public String getAaiNamedQueryUrl(String version) {
199 return modelLoaderProperties.getProperty(PROP_AAI_NAMED_QUERY_RESOURCE_URL).replace("v*", version);
202 public String getAaiVnfImageUrl() {
203 return modelLoaderProperties.getProperty(PROP_AAI_VNF_IMAGE_RESOURCE_URL);
206 public String getAaiAuthenticationUser() {
207 return modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_USER);
211 * @return password for AAI authentication that has been reverse-engineered
212 * from its obfuscated form.
214 public String getAaiAuthenticationPassword() {
215 String password = Password
216 .deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_PASSWORD));
218 if ((password != null) && (password.equals(""))) {
226 * @return a boolean value indicating whether the simulator is enabled.
228 public boolean getIngestSimulatorEnabled() {
229 String propValue = modelLoaderProperties.getProperty(PROP_DEBUG_INGEST_SIMULATOR);
231 if (propValue == null) {
235 if (propValue.compareToIgnoreCase("enabled") == 0) {