From 161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:14:21 -0800 Subject: Second part of onap rename This is the second commit of the rename. The folder structure is renamed for appc-adapters and appc-config in this commit. Change-Id: Iaa2b8c937ff1ca1b5d1178128961fb115ee65d9b Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../encryptiontool/EncryptionToolActivator.java | 55 +++++++ .../appc/encryptiontool/wrapper/Constants.java | 33 ++++ .../appc/encryptiontool/wrapper/DbServiceUtil.java | 72 +++++++++ .../encryptiontool/wrapper/EncryptionTool.java | 168 +++++++++++++++++++++ .../wrapper/EncryptionToolDGWrapper.java | 79 ++++++++++ .../wrapper/WrapperEncryptionTool.java | 129 ++++++++++++++++ .../encryptiontool/EncryptionToolActivator.java | 55 ------- .../appc/encryptiontool/wrapper/Constants.java | 33 ---- .../appc/encryptiontool/wrapper/DbServiceUtil.java | 72 --------- .../encryptiontool/wrapper/EncryptionTool.java | 168 --------------------- .../wrapper/EncryptionToolDGWrapper.java | 79 ---------- .../wrapper/WrapperEncryptionTool.java | 129 ---------------- .../appc/encryptiontool/TestEncryptionTool.java | 75 +++++++++ .../appc/encryptiontool/TestEncryptionTool.java | 75 --------- 14 files changed, 611 insertions(+), 611 deletions(-) create mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/EncryptionToolActivator.java create mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/Constants.java create mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/DbServiceUtil.java create mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionTool.java create mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java create mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java delete mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/EncryptionToolActivator.java delete mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/Constants.java delete mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/DbServiceUtil.java delete mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionTool.java delete mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java delete mode 100644 appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/WrapperEncryptionTool.java create mode 100644 appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestEncryptionTool.java delete mode 100644 appc-config/appc-encryption-tool/provider/src/test/java/org/openecomp/appc/encryptiontool/TestEncryptionTool.java (limited to 'appc-config/appc-encryption-tool') diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/EncryptionToolActivator.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/EncryptionToolActivator.java new file mode 100644 index 000000000..9942ef5ee --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/EncryptionToolActivator.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.appc.encryptiontool; + +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class EncryptionToolActivator implements BundleActivator { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(EncryptionToolActivator.class); + private List registrations = new LinkedList(); + + @Override + public void start(BundleContext ctx) throws Exception { + EncryptionToolDGWrapper encryptionToolWrapper = new EncryptionToolDGWrapper(); + log.info("Registering service-- " + encryptionToolWrapper.getClass().getName()); + registrations.add(ctx.registerService(encryptionToolWrapper.getClass().getName(), encryptionToolWrapper, null)); + + } + + @Override + public void stop(BundleContext arg0) throws Exception { + for (ServiceRegistration registration : registrations) { + registration.unregister(); + registration = null; + } + } +} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/Constants.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/Constants.java new file mode 100644 index 000000000..9289b1be5 --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/Constants.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.appc.encryptiontool.wrapper; + +public class Constants +{ + + public static final String DBLIB_SERVICE = "org.openecomp.sdnctl.sli.resource.dblib.DBResourceManager"; + public static final String DEVICE_AUTHENTICATION="DEVICE_AUTHENTICATION"; + public static final String SCHEMA_SDNCTL="SDNCTL"; + + private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; + + public static final String APPC_CONFIG_DIR="/opt/app/bvc/properties"; +} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/DbServiceUtil.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/DbServiceUtil.java new file mode 100644 index 000000000..5e5d37e66 --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/DbServiceUtil.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.appc.encryptiontool.wrapper; + +import java.io.File; +import java.net.URL; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import javax.sql.rowset.CachedRowSet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.dblib.DbLibService; + +public class DbServiceUtil +{ + private static final Logger log = LoggerFactory + .getLogger(DbServiceUtil.class); + + private static Properties props; + private static DBResourceManager jdbcDataSource = null; + + public static boolean updateDB(String tableName, ArrayList inputArgs, + String scema, String whereClause, String setCluase) throws SQLException + { + String updatePasswordString = "update " + tableName + " set " + setCluase + " where " + whereClause ; + boolean result = jdbcDataSource.writeData(updatePasswordString, inputArgs,Constants.SCHEMA_SDNCTL); + return result; + } + + public static CachedRowSet getData(String tableName, ArrayList argList, String schema, + String getselectData, String getDataClasue ) throws SQLException + { + String selectQuery = "select " + getselectData + "from " + tableName + " where " + getDataClasue ; + CachedRowSet data = jdbcDataSource.getData(selectQuery, argList, schema); + return data; + } + + + public static DBResourceManager initDbLibService() throws Exception + { + props = new Properties(); + File file = new File("/opt/app/bvc/properties/dblib.properties"); + URL propURL = file.toURI().toURL(); + props.load(propURL.openStream()); + jdbcDataSource = new DBResourceManager(props); + return jdbcDataSource; + } + +} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionTool.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionTool.java new file mode 100644 index 000000000..d05a99be8 --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionTool.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ +package org.onap.appc.encryptiontool.wrapper; + +import java.security.Provider; +import java.security.Provider.Service; +import java.security.Security; + +import org.jasypt.contrib.org.apache.commons.codec_1_3.binary.Base64; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class is used to encapsulate the encryption and decryption support in one place and to + * provide a utility to encrypt and decrypt data. + */ +public class EncryptionTool { + + /** + * The prefix we insert onto any data we encrypt so that we can tell if it is encrpyted later and + * therefore decrypt it + */ + public static final String ENCRYPTED_VALUE_PREFIX = "enc:"; + + /** + * The instance of the encryption utility object + */ + private static EncryptionTool instance = null; + + /** + * The logger for this class. + */ + private static final Logger LOG = LoggerFactory.getLogger(EncryptionTool.class); + + /** + * The secret passphrase (PBE) that we use to perform encryption and decryption. The algorithm we + * are using is a symmetrical cipher. + */ + private static char[] secret = {'C', '_', 'z', 'l', '!', 'K', '!', '4', '?', 'O', 'z', 'E', 'K', 'E', '>', 'U', 'R', + '/', '%', 'Y', '\\', 'f', 'b', '"', 'e', 'n', '{', '"', 'l', 'U', 'F', '+', 'E', '\'', 'R', 'T', 'p', '1', + 'V', '4', 'l', 'a', '9', 'w', 'v', '5', 'Z', '#', 'i', 'V', '"', 'd', 'l', '!', 'L', 'M', 'g', 'L', 'Q', + '{', 'v', 'v', 'K', 'V'}; + + + + /** + * Get an instance of the EncryptionTool + * + * @return The encryption tool to be used + */ + public static final synchronized EncryptionTool getInstance() { + if (instance == null) { + instance = new EncryptionTool(); + } + return instance; + } + + /** + * Create the EncryptionTool instance + */ + private EncryptionTool() { + + StringBuilder sb = new StringBuilder("Found the following security algorithms:"); + for (Provider p : Security.getProviders()) { + for (Service s : p.getServices()) { + String algo = s.getAlgorithm(); + sb.append(String.format("%n -Algorithm [ %s ] in provider [ %s ] and service [ %s ]", algo, p.getName(), + s.getClassName())); + } + } + if (LOG.isDebugEnabled()) { + LOG.debug(sb.toString()); + } + } + + /** + * Decrypt the provided encrypted text + * + * @param cipherText THe cipher text to be decrypted. If the ciphertext is not encrypted, then it is + * returned as is. + * @return the clear test of the (possibly) encrypted value. The original value if the string is not + * encrypted. + */ + public synchronized String decrypt(String cipherText) { + if (isEncrypted(cipherText)) { + String encValue = cipherText.substring(ENCRYPTED_VALUE_PREFIX.length()); + byte[] plainByte = Base64.decodeBase64(encValue.getBytes()); + byte[] decryptByte = xorWithSecret(plainByte); + return new String(decryptByte); + } else { + return cipherText; + } + + } + + /** + * Encrypt the provided clear text + * + * @param clearText The clear text to be encrypted + * @return the encrypted text. If the clear text is empty (null or zero length), then an empty + * string is returned. If the clear text is already encrypted, it is not encrypted again and + * is returned as is. Otherwise, the clear text is encrypted and returned. + */ + public synchronized String encrypt(String clearText) { + if (clearText != null) { + byte[] encByte = xorWithSecret(clearText.getBytes()); + String encryptedValue = new String(Base64.encodeBase64(encByte)); + return ENCRYPTED_VALUE_PREFIX + encryptedValue; + } else { + return null; + } + } + + /** + * Is a value encrypted? A value is considered to be encrypted if it begins with the + * {@linkplain #ENCRYPTED_VALUE_PREFIX encrypted value prefix}. + * + * @param value the value to check. + * @return true/false; + */ + private static boolean isEncrypted(final String value) { + return value != null && value.startsWith(ENCRYPTED_VALUE_PREFIX); + } + + /** + * XORs the input byte array with the secret key, padding 0x0 to the end of the secret key if the + * input is longer and returns a byte array the same size as input + * + * @param inp The byte array to be XORed with secret + * @return A byte array the same size as inp or null if input is null. + */ + private byte[] xorWithSecret(byte[] inp) { + if (inp == null) { + return new byte[0]; + } + + byte[] secretBytes = new String(secret).getBytes(); + int size = inp.length; + + byte[] out = new byte[size]; + for (int i = 0; i < size; i++) { + out[i] = (byte) ((inp[i]) ^ (secretBytes[i % secretBytes.length])); + } + return out; + } + +} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java new file mode 100644 index 000000000..c30f05033 --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.encryptiontool.wrapper; + +import java.util.Map; + +import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class EncryptionToolDGWrapper implements SvcLogicJavaPlugin { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(EncryptionToolDGWrapper.class); + + public void runEncryption(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + String userName = inParams.get("userName"); + String password = inParams.get("password"); + String vnfType = inParams.get("vnf_type"); + + try { + if (StringUtils.isBlank(userName) || StringUtils.isBlank(password) || StringUtils.isBlank(vnfType)) { + throw new SvcLogicException("username or Password is missing"); + } + + String[] input = new String[] {vnfType, userName, password}; + WrapperEncryptionTool.main(input); + + } catch (Exception e) { + throw new SvcLogicException(e.getMessage()); + } + + } + + public void getProperty(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + String responsePrefix = inParams.get("prefix"); + String propertyName = inParams.get("propertyName"); + + try { + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : ""; + PropertiesConfiguration conf = + new PropertiesConfiguration(Constants.APPC_CONFIG_DIR + "/appc_southbound.properties"); + conf.setBasePath(null); + EncryptionTool et = EncryptionTool.getInstance(); + + ctx.setAttribute(responsePrefix + "propertyName", et.decrypt(conf.getProperty(propertyName).toString())); + } catch (Exception e) { + ctx.setAttribute(responsePrefix + "status", "failure"); + ctx.setAttribute(responsePrefix + "error-message", e.getMessage()); + log.info("Caught exception", e); + throw new SvcLogicException(e.getMessage()); + } + } +} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java new file mode 100644 index 000000000..9cc322259 --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/main/java/org/onap/appc/encryptiontool/wrapper/WrapperEncryptionTool.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.encryptiontool.wrapper; + +import java.util.ArrayList; + +import javax.sql.rowset.CachedRowSet; + +import org.apache.commons.configuration.PropertiesConfiguration; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WrapperEncryptionTool { + + private static final Logger log = LoggerFactory.getLogger(WrapperEncryptionTool.class); + + public static void main(String[] args) { + int rowCount = 0; + String vnfType = args[0]; + String user = args[1]; + String password = args[2]; + String action = args[3]; + String port = args[4]; + String url = args[5]; + + if ("".equals(vnfType)) { + log.info("ERROR-VNF_TYPE can not be null"); + return; + } + if ("".equals(user)) { + log.info("ERROR-USER can not be null"); + return; + } + if ("".equals(password)) { + log.info("ERROR-PASSWORD can not be null"); + return; + } + + EncryptionTool et = EncryptionTool.getInstance(); + String enPass = et.encrypt(password); + + if (action != null && !action.isEmpty()) { + updateProperties(user, vnfType, enPass, action, port, url); + return; + } + + ArrayList argList = new ArrayList<>(); + argList.add(vnfType); + argList.add(user); + String clause = " vnfType = ? and user_name = ? "; + String setClause = " password = ? "; + String getselectData = " * "; + DBResourceManager dbResourceManager = null; + try { + dbResourceManager = DbServiceUtil.initDbLibService(); + CachedRowSet data = DbServiceUtil.getData(Constants.DEVICE_AUTHENTICATION, argList,Constants.SCHEMA_SDNCTL, getselectData, clause); + + while (data.next()) { + rowCount++; + } + if (rowCount == 0) + log.info("APPC-MESSAGE: ERROR - No record Found for VNF_TYPE: %, User % ", vnfType, user); + else { + argList.clear(); + argList.add(enPass); + argList.add(vnfType); + argList.add(user); + DbServiceUtil.updateDB(Constants.DEVICE_AUTHENTICATION, argList, Constants.SCHEMA_SDNCTL, clause, + setClause); + log.info("APPC-MESSAGE: Password Updated Successfully"); + } + } catch (Exception e) { + log.info("Caught exception", e); + log.info("APPC-MESSAGE:" + e.getMessage()); + } finally { + if (dbResourceManager != null) { + dbResourceManager.cleanUp(); + } + } + } + + private static void updateProperties(String user, String vnfType, String password, String action, String port, + String url) { + + log.info("Received Inputs User:%s vnfType:%s action:%s", user, vnfType, action); + String property = vnfType + "." + action + "."; + + + try { + PropertiesConfiguration conf = + new PropertiesConfiguration(Constants.APPC_CONFIG_DIR + "/appc_southbound.properties"); + conf.setProperty(property + "user", user); + if (port != null && !port.isEmpty()) + conf.setProperty(property + "port", port); + if (password != null && !password.isEmpty()) + conf.setProperty(property + "password", password); + if (url != null && !url.isEmpty()) + conf.setProperty(property + "url", url); + + conf.save(); + + } catch (Exception e) { + log.info("Caught Exception", e); + } + } +} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/EncryptionToolActivator.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/EncryptionToolActivator.java deleted file mode 100644 index 9942ef5ee..000000000 --- a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/EncryptionToolActivator.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.appc.encryptiontool; - -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class EncryptionToolActivator implements BundleActivator { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(EncryptionToolActivator.class); - private List registrations = new LinkedList(); - - @Override - public void start(BundleContext ctx) throws Exception { - EncryptionToolDGWrapper encryptionToolWrapper = new EncryptionToolDGWrapper(); - log.info("Registering service-- " + encryptionToolWrapper.getClass().getName()); - registrations.add(ctx.registerService(encryptionToolWrapper.getClass().getName(), encryptionToolWrapper, null)); - - } - - @Override - public void stop(BundleContext arg0) throws Exception { - for (ServiceRegistration registration : registrations) { - registration.unregister(); - registration = null; - } - } -} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/Constants.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/Constants.java deleted file mode 100644 index 9289b1be5..000000000 --- a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/Constants.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.appc.encryptiontool.wrapper; - -public class Constants -{ - - public static final String DBLIB_SERVICE = "org.openecomp.sdnctl.sli.resource.dblib.DBResourceManager"; - public static final String DEVICE_AUTHENTICATION="DEVICE_AUTHENTICATION"; - public static final String SCHEMA_SDNCTL="SDNCTL"; - - private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; - - public static final String APPC_CONFIG_DIR="/opt/app/bvc/properties"; -} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/DbServiceUtil.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/DbServiceUtil.java deleted file mode 100644 index 5e5d37e66..000000000 --- a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/DbServiceUtil.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.appc.encryptiontool.wrapper; - -import java.io.File; -import java.net.URL; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Properties; - -import javax.sql.rowset.CachedRowSet; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.onap.ccsdk.sli.core.dblib.DbLibService; - -public class DbServiceUtil -{ - private static final Logger log = LoggerFactory - .getLogger(DbServiceUtil.class); - - private static Properties props; - private static DBResourceManager jdbcDataSource = null; - - public static boolean updateDB(String tableName, ArrayList inputArgs, - String scema, String whereClause, String setCluase) throws SQLException - { - String updatePasswordString = "update " + tableName + " set " + setCluase + " where " + whereClause ; - boolean result = jdbcDataSource.writeData(updatePasswordString, inputArgs,Constants.SCHEMA_SDNCTL); - return result; - } - - public static CachedRowSet getData(String tableName, ArrayList argList, String schema, - String getselectData, String getDataClasue ) throws SQLException - { - String selectQuery = "select " + getselectData + "from " + tableName + " where " + getDataClasue ; - CachedRowSet data = jdbcDataSource.getData(selectQuery, argList, schema); - return data; - } - - - public static DBResourceManager initDbLibService() throws Exception - { - props = new Properties(); - File file = new File("/opt/app/bvc/properties/dblib.properties"); - URL propURL = file.toURI().toURL(); - props.load(propURL.openStream()); - jdbcDataSource = new DBResourceManager(props); - return jdbcDataSource; - } - -} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionTool.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionTool.java deleted file mode 100644 index d05a99be8..000000000 --- a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionTool.java +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ -package org.onap.appc.encryptiontool.wrapper; - -import java.security.Provider; -import java.security.Provider.Service; -import java.security.Security; - -import org.jasypt.contrib.org.apache.commons.codec_1_3.binary.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class is used to encapsulate the encryption and decryption support in one place and to - * provide a utility to encrypt and decrypt data. - */ -public class EncryptionTool { - - /** - * The prefix we insert onto any data we encrypt so that we can tell if it is encrpyted later and - * therefore decrypt it - */ - public static final String ENCRYPTED_VALUE_PREFIX = "enc:"; - - /** - * The instance of the encryption utility object - */ - private static EncryptionTool instance = null; - - /** - * The logger for this class. - */ - private static final Logger LOG = LoggerFactory.getLogger(EncryptionTool.class); - - /** - * The secret passphrase (PBE) that we use to perform encryption and decryption. The algorithm we - * are using is a symmetrical cipher. - */ - private static char[] secret = {'C', '_', 'z', 'l', '!', 'K', '!', '4', '?', 'O', 'z', 'E', 'K', 'E', '>', 'U', 'R', - '/', '%', 'Y', '\\', 'f', 'b', '"', 'e', 'n', '{', '"', 'l', 'U', 'F', '+', 'E', '\'', 'R', 'T', 'p', '1', - 'V', '4', 'l', 'a', '9', 'w', 'v', '5', 'Z', '#', 'i', 'V', '"', 'd', 'l', '!', 'L', 'M', 'g', 'L', 'Q', - '{', 'v', 'v', 'K', 'V'}; - - - - /** - * Get an instance of the EncryptionTool - * - * @return The encryption tool to be used - */ - public static final synchronized EncryptionTool getInstance() { - if (instance == null) { - instance = new EncryptionTool(); - } - return instance; - } - - /** - * Create the EncryptionTool instance - */ - private EncryptionTool() { - - StringBuilder sb = new StringBuilder("Found the following security algorithms:"); - for (Provider p : Security.getProviders()) { - for (Service s : p.getServices()) { - String algo = s.getAlgorithm(); - sb.append(String.format("%n -Algorithm [ %s ] in provider [ %s ] and service [ %s ]", algo, p.getName(), - s.getClassName())); - } - } - if (LOG.isDebugEnabled()) { - LOG.debug(sb.toString()); - } - } - - /** - * Decrypt the provided encrypted text - * - * @param cipherText THe cipher text to be decrypted. If the ciphertext is not encrypted, then it is - * returned as is. - * @return the clear test of the (possibly) encrypted value. The original value if the string is not - * encrypted. - */ - public synchronized String decrypt(String cipherText) { - if (isEncrypted(cipherText)) { - String encValue = cipherText.substring(ENCRYPTED_VALUE_PREFIX.length()); - byte[] plainByte = Base64.decodeBase64(encValue.getBytes()); - byte[] decryptByte = xorWithSecret(plainByte); - return new String(decryptByte); - } else { - return cipherText; - } - - } - - /** - * Encrypt the provided clear text - * - * @param clearText The clear text to be encrypted - * @return the encrypted text. If the clear text is empty (null or zero length), then an empty - * string is returned. If the clear text is already encrypted, it is not encrypted again and - * is returned as is. Otherwise, the clear text is encrypted and returned. - */ - public synchronized String encrypt(String clearText) { - if (clearText != null) { - byte[] encByte = xorWithSecret(clearText.getBytes()); - String encryptedValue = new String(Base64.encodeBase64(encByte)); - return ENCRYPTED_VALUE_PREFIX + encryptedValue; - } else { - return null; - } - } - - /** - * Is a value encrypted? A value is considered to be encrypted if it begins with the - * {@linkplain #ENCRYPTED_VALUE_PREFIX encrypted value prefix}. - * - * @param value the value to check. - * @return true/false; - */ - private static boolean isEncrypted(final String value) { - return value != null && value.startsWith(ENCRYPTED_VALUE_PREFIX); - } - - /** - * XORs the input byte array with the secret key, padding 0x0 to the end of the secret key if the - * input is longer and returns a byte array the same size as input - * - * @param inp The byte array to be XORed with secret - * @return A byte array the same size as inp or null if input is null. - */ - private byte[] xorWithSecret(byte[] inp) { - if (inp == null) { - return new byte[0]; - } - - byte[] secretBytes = new String(secret).getBytes(); - int size = inp.length; - - byte[] out = new byte[size]; - for (int i = 0; i < size; i++) { - out[i] = (byte) ((inp[i]) ^ (secretBytes[i % secretBytes.length])); - } - return out; - } - -} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java deleted file mode 100644 index c30f05033..000000000 --- a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/EncryptionToolDGWrapper.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.encryptiontool.wrapper; - -import java.util.Map; - -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.commons.lang.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class EncryptionToolDGWrapper implements SvcLogicJavaPlugin { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(EncryptionToolDGWrapper.class); - - public void runEncryption(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - String userName = inParams.get("userName"); - String password = inParams.get("password"); - String vnfType = inParams.get("vnf_type"); - - try { - if (StringUtils.isBlank(userName) || StringUtils.isBlank(password) || StringUtils.isBlank(vnfType)) { - throw new SvcLogicException("username or Password is missing"); - } - - String[] input = new String[] {vnfType, userName, password}; - WrapperEncryptionTool.main(input); - - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - - } - - public void getProperty(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - String responsePrefix = inParams.get("prefix"); - String propertyName = inParams.get("propertyName"); - - try { - responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : ""; - PropertiesConfiguration conf = - new PropertiesConfiguration(Constants.APPC_CONFIG_DIR + "/appc_southbound.properties"); - conf.setBasePath(null); - EncryptionTool et = EncryptionTool.getInstance(); - - ctx.setAttribute(responsePrefix + "propertyName", et.decrypt(conf.getProperty(propertyName).toString())); - } catch (Exception e) { - ctx.setAttribute(responsePrefix + "status", "failure"); - ctx.setAttribute(responsePrefix + "error-message", e.getMessage()); - log.info("Caught exception", e); - throw new SvcLogicException(e.getMessage()); - } - } -} diff --git a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/WrapperEncryptionTool.java b/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/WrapperEncryptionTool.java deleted file mode 100644 index 9cc322259..000000000 --- a/appc-config/appc-encryption-tool/provider/src/main/java/org/openecomp/appc/encryptiontool/wrapper/WrapperEncryptionTool.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.encryptiontool.wrapper; - -import java.util.ArrayList; - -import javax.sql.rowset.CachedRowSet; - -import org.apache.commons.configuration.PropertiesConfiguration; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WrapperEncryptionTool { - - private static final Logger log = LoggerFactory.getLogger(WrapperEncryptionTool.class); - - public static void main(String[] args) { - int rowCount = 0; - String vnfType = args[0]; - String user = args[1]; - String password = args[2]; - String action = args[3]; - String port = args[4]; - String url = args[5]; - - if ("".equals(vnfType)) { - log.info("ERROR-VNF_TYPE can not be null"); - return; - } - if ("".equals(user)) { - log.info("ERROR-USER can not be null"); - return; - } - if ("".equals(password)) { - log.info("ERROR-PASSWORD can not be null"); - return; - } - - EncryptionTool et = EncryptionTool.getInstance(); - String enPass = et.encrypt(password); - - if (action != null && !action.isEmpty()) { - updateProperties(user, vnfType, enPass, action, port, url); - return; - } - - ArrayList argList = new ArrayList<>(); - argList.add(vnfType); - argList.add(user); - String clause = " vnfType = ? and user_name = ? "; - String setClause = " password = ? "; - String getselectData = " * "; - DBResourceManager dbResourceManager = null; - try { - dbResourceManager = DbServiceUtil.initDbLibService(); - CachedRowSet data = DbServiceUtil.getData(Constants.DEVICE_AUTHENTICATION, argList,Constants.SCHEMA_SDNCTL, getselectData, clause); - - while (data.next()) { - rowCount++; - } - if (rowCount == 0) - log.info("APPC-MESSAGE: ERROR - No record Found for VNF_TYPE: %, User % ", vnfType, user); - else { - argList.clear(); - argList.add(enPass); - argList.add(vnfType); - argList.add(user); - DbServiceUtil.updateDB(Constants.DEVICE_AUTHENTICATION, argList, Constants.SCHEMA_SDNCTL, clause, - setClause); - log.info("APPC-MESSAGE: Password Updated Successfully"); - } - } catch (Exception e) { - log.info("Caught exception", e); - log.info("APPC-MESSAGE:" + e.getMessage()); - } finally { - if (dbResourceManager != null) { - dbResourceManager.cleanUp(); - } - } - } - - private static void updateProperties(String user, String vnfType, String password, String action, String port, - String url) { - - log.info("Received Inputs User:%s vnfType:%s action:%s", user, vnfType, action); - String property = vnfType + "." + action + "."; - - - try { - PropertiesConfiguration conf = - new PropertiesConfiguration(Constants.APPC_CONFIG_DIR + "/appc_southbound.properties"); - conf.setProperty(property + "user", user); - if (port != null && !port.isEmpty()) - conf.setProperty(property + "port", port); - if (password != null && !password.isEmpty()) - conf.setProperty(property + "password", password); - if (url != null && !url.isEmpty()) - conf.setProperty(property + "url", url); - - conf.save(); - - } catch (Exception e) { - log.info("Caught Exception", e); - } - } -} diff --git a/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestEncryptionTool.java b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestEncryptionTool.java new file mode 100644 index 000000000..5c1d2d17c --- /dev/null +++ b/appc-config/appc-encryption-tool/provider/src/test/java/org/onap/appc/encryptiontool/TestEncryptionTool.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.encryptiontool; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.onap.appc.encryptiontool.wrapper.DbServiceUtil; +import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper; +import org.onap.appc.encryptiontool.wrapper.WrapperEncryptionTool; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +public class TestEncryptionTool { + + @Test + public void testEncryptionTool() throws Exception{ + String [] input = new String[] {"testVnf_Type","testUser","testPassword11", "testAction1", "8080", "http://localhost:8080/restconf/healthcheck"}; + WrapperEncryptionTool.main(input); + + } +// @Test(expected=Exception.class) + public void testgetPropertyDG() throws Exception{ + EncryptionToolDGWrapper et = new EncryptionToolDGWrapper(); + SvcLogicContext ctx = new SvcLogicContext(); + Map inParams = new HashMap(); + inParams.put("prefix", "test"); + inParams.put("propertyName", "testVnf_Type.testAction1.url"); + et.getProperty(inParams, ctx); + } + @Test(expected=Exception.class) + public void testgetData() throws Exception + { + DbServiceUtil d = new DbServiceUtil(); + ArrayList argList = null; + String schema ="sdnctl"; + String tableName ="dual"; + String getselectData ="123"; + String getDataClasue="123='123'"; + d.getData(tableName, argList, schema, getselectData, getDataClasue); + } + @Test(expected=Exception.class) + public void testupdateDB() throws Exception + { + DbServiceUtil d = new DbServiceUtil(); + String setCluase = null; + String schema ="sdnctl"; + String tableName ="dual"; + ArrayList inputArgs = null; + String whereClause="123='123'"; + d.updateDB(tableName, inputArgs, schema, whereClause, setCluase); + } +} diff --git a/appc-config/appc-encryption-tool/provider/src/test/java/org/openecomp/appc/encryptiontool/TestEncryptionTool.java b/appc-config/appc-encryption-tool/provider/src/test/java/org/openecomp/appc/encryptiontool/TestEncryptionTool.java deleted file mode 100644 index 5c1d2d17c..000000000 --- a/appc-config/appc-encryption-tool/provider/src/test/java/org/openecomp/appc/encryptiontool/TestEncryptionTool.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.encryptiontool; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import org.onap.appc.encryptiontool.wrapper.DbServiceUtil; -import org.onap.appc.encryptiontool.wrapper.EncryptionToolDGWrapper; -import org.onap.appc.encryptiontool.wrapper.WrapperEncryptionTool; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -public class TestEncryptionTool { - - @Test - public void testEncryptionTool() throws Exception{ - String [] input = new String[] {"testVnf_Type","testUser","testPassword11", "testAction1", "8080", "http://localhost:8080/restconf/healthcheck"}; - WrapperEncryptionTool.main(input); - - } -// @Test(expected=Exception.class) - public void testgetPropertyDG() throws Exception{ - EncryptionToolDGWrapper et = new EncryptionToolDGWrapper(); - SvcLogicContext ctx = new SvcLogicContext(); - Map inParams = new HashMap(); - inParams.put("prefix", "test"); - inParams.put("propertyName", "testVnf_Type.testAction1.url"); - et.getProperty(inParams, ctx); - } - @Test(expected=Exception.class) - public void testgetData() throws Exception - { - DbServiceUtil d = new DbServiceUtil(); - ArrayList argList = null; - String schema ="sdnctl"; - String tableName ="dual"; - String getselectData ="123"; - String getDataClasue="123='123'"; - d.getData(tableName, argList, schema, getselectData, getDataClasue); - } - @Test(expected=Exception.class) - public void testupdateDB() throws Exception - { - DbServiceUtil d = new DbServiceUtil(); - String setCluase = null; - String schema ="sdnctl"; - String tableName ="dual"; - ArrayList inputArgs = null; - String whereClause="123='123'"; - d.updateDB(tableName, inputArgs, schema, whereClause, setCluase); - } -} -- cgit 1.2.3-korg