3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * ================================================================================
8 * * Licensed under the Apache License, Version 2.0 (the "License");
9 * * you may not use this file except in compliance with the License.
10 * * You may obtain a copy of the License at
12 * * http://www.apache.org/licenses/LICENSE-2.0
14 * * Unless required by applicable law or agreed to in writing, software
15 * * distributed under the License is distributed on an "AS IS" BASIS,
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * * See the License for the specific language governing permissions and
18 * * limitations under the License.
19 * * ============LICENSE_END=========================================================
24 package org.onap.blueprintgenerator.service.common;
26 import org.onap.blueprintgenerator.constants.Constants;
27 import org.onap.blueprintgenerator.model.common.ExternalTlsInfo;
28 import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
29 import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Service;
33 import java.util.HashMap;
34 import java.util.LinkedHashMap;
38 * @author : Ravi Mantena
40 * Application: ONAP - Blueprint Generator
41 * Common ONAP Service used by ONAP and DMAAP Blueprint to add External TLS Info
46 public class ExternalTlsInfoFactoryService extends ExternalCertificateDataFactoryService {
49 private ExternalCertificateParametersFactoryService externalCertificateParametersFactoryService;
52 private BlueprintHelperService blueprintHelperService;
54 //Method to create External TLS Info from Component Spec
55 public ExternalTlsInfo createFromComponentSpec(OnapComponentSpec cs) {
56 ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo();
57 Map<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
59 externalTlsInfoBp.setExternalCertDirectory((String) tlsInfoCs.get(Constants.CERT_DIRECTORY_FIELD));
60 externalTlsInfoBp.setUseExternalTls(createPrefixedGetInput(Constants.USE_EXTERNAL_TLS_FIELD));
61 externalTlsInfoBp.setCaName(createPrefixedGetInput(Constants.CA_NAME_FIELD));
62 externalTlsInfoBp.setCertType(createPrefixedGetInput(Constants.CERT_TYPE_FIELD));
63 externalTlsInfoBp.setExternalCertificateParameters(externalCertificateParametersFactoryService.create());
65 return externalTlsInfoBp;
68 //Method to create Input List for External TLS Info from Component Spec
69 public Map<String, LinkedHashMap<String, Object>> createInputListFromComponentSpec(OnapComponentSpec cs) {
71 Map<String, LinkedHashMap<String, Object>> retInputs = new HashMap<>();
73 Map<String, Object> externalTlsInfoCs = cs.getAuxilary().getTls_info();
74 LinkedHashMap<String, Object> useTlsFlagInput = blueprintHelperService.createBooleanInput("Flag to indicate external tls enable/disable.",externalTlsInfoCs.get(Constants.USE_EXTERNAL_TLS_FIELD));
75 retInputs.put(addPrefix(Constants.USE_EXTERNAL_TLS_FIELD), useTlsFlagInput);
77 LinkedHashMap<String, Object> caNameInputMap = blueprintHelperService.createStringInput("Name of Certificate Authority configured on CertService side.",Constants.DEFAULT_CA);
78 retInputs.put(addPrefix(Constants.CA_NAME_FIELD), caNameInputMap);
80 LinkedHashMap<String, Object> certTypeInputMap = blueprintHelperService.createStringInput("Format of provided certificates",Constants.DEFAULT_CERT_TYPE);
81 retInputs.put(addPrefix(Constants.CERT_TYPE_FIELD), certTypeInputMap);
83 retInputs.putAll(externalCertificateParametersFactoryService.createInputList());