2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.appc.encryptiontool.wrapper;
25 import org.apache.commons.configuration.PropertiesConfiguration;
26 import org.apache.commons.lang.StringUtils;
28 import com.att.eelf.configuration.EELFLogger;
29 import com.att.eelf.configuration.EELFManager;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
34 public class EncryptionToolDGWrapper implements SvcLogicJavaPlugin {
36 private static final EELFLogger log = EELFManager.getInstance().getLogger(EncryptionToolDGWrapper.class);
38 public void runEncryption(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException
40 String responsePrefix = inParams.get("prefix");
41 String userName = inParams.get("userName");
42 String password = inParams.get("password");
43 String vnf_type = inParams.get("vnf_type");
46 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "" ;
47 if(StringUtils.isBlank(userName) || StringUtils.isBlank(password) || StringUtils.isBlank(vnf_type)){
48 throw new Exception("username or Password is missing");
51 String [] input = new String[] {vnf_type,userName,password};
52 WrapperEncryptionTool.main(input);
56 throw new SvcLogicException(e.getMessage());
60 public void getProperty(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException
62 String responsePrefix = inParams.get("prefix");
63 String propertyName = inParams.get("propertyName");
66 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "" ;
67 PropertiesConfiguration conf = new PropertiesConfiguration(Constants.APPC_CONFIG_DIR + "/appc_southbound.properties");
68 conf.setBasePath(null);
69 EncryptionTool et = EncryptionTool.getInstance();
71 ctx.setAttribute(responsePrefix + "propertyName", et.decrypt(conf.getProperty(propertyName).toString()));
74 ctx.setAttribute(responsePrefix + "status", "failure");
75 ctx.setAttribute(responsePrefix + "error-message", e.getMessage());
77 throw new SvcLogicException(e.getMessage());