3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * Copyright (c) 2021 Nokia. All rights reserved.
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=========================================================
25 package org.onap.blueprintgenerator.service.common;
27 import org.onap.blueprintgenerator.constants.Constants;
28 import org.onap.blueprintgenerator.model.common.ExternalTlsInfo;
29 import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
30 import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Service;
34 import java.util.HashMap;
38 * @author : Ravi Mantena
39 * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add External TLS
43 public class ExternalTlsInfoFactoryService extends ExternalCertificateDataFactoryService {
46 private ExternalCertificateParametersFactoryService externalCertificateParametersFactoryService;
49 private BlueprintHelperService blueprintHelperService;
52 * Creates External TLS Info from Component Spec
54 * @param cs ComponentSpec
57 public ExternalTlsInfo createFromComponentSpec(OnapComponentSpec cs) {
58 ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo();
59 Map<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
61 externalTlsInfoBp.setExternalCertDirectory(
62 (String) tlsInfoCs.get(Constants.CERT_DIRECTORY_FIELD));
64 .setUseExternalTls(createPrefixedGetInput(Constants.USE_EXTERNAL_TLS_FIELD));
65 externalTlsInfoBp.setCaName(createPrefixedGetInput(Constants.CA_NAME_FIELD));
66 externalTlsInfoBp.setCertType(createPrefixedGetInput(Constants.CERT_TYPE_FIELD));
67 externalTlsInfoBp.setExternalCertificateParameters(
68 externalCertificateParametersFactoryService.create());
70 return externalTlsInfoBp;
74 * Creates Input List for External TLS Info from Component Spec
76 * @param cs ComponentSpec
79 public Map<String, Map<String, Object>> createInputListFromComponentSpec(
80 OnapComponentSpec cs) {
82 Map<String, Map<String, Object>> retInputs = new HashMap<>();
84 Map<String, Object> externalTlsInfoCs = cs.getAuxilary().getTls_info();
85 Map<String, Object> useTlsFlagInput =
86 blueprintHelperService.createBooleanInput(
87 "Flag to indicate external tls enable/disable.",
88 externalTlsInfoCs.get(Constants.USE_EXTERNAL_TLS_FIELD));
89 retInputs.put(addPrefix(Constants.USE_EXTERNAL_TLS_FIELD), useTlsFlagInput);
91 Map<String, Object> caNameInputMap =
92 blueprintHelperService.createStringInput(
93 "Name of Certificate Authority configured on CertService side.",
94 Constants.DEFAULT_CA);
95 retInputs.put(addPrefix(Constants.CA_NAME_FIELD), caNameInputMap);
97 Map<String, Object> certTypeInputMap =
98 blueprintHelperService.createStringInput(
99 "Format of provided certificates", Constants.DEFAULT_CERT_TYPE);
100 retInputs.put(addPrefix(Constants.CERT_TYPE_FIELD), certTypeInputMap);
102 retInputs.putAll(externalCertificateParametersFactoryService.createInputList());