diff options
author | 2017-04-27 07:53:18 -0400 | |
---|---|---|
committer | 2017-04-27 08:31:27 -0400 | |
commit | 6beb446925c967aca92f5513adf36c5db77c00d6 (patch) | |
tree | 9392057ed0739de2445c5b2a2a8bee6dcdacbcf7 /ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util | |
parent | 246b225194e3e8dc1926294de591a94fd9787fa7 (diff) |
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects
abstraction of components
Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util')
8 files changed, 0 insertions, 815 deletions
diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/CacheManager.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/CacheManager.java deleted file mode 100644 index e26ac884..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/CacheManager.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; - -import org.openecomp.portalsdk.core.objectcache.jcs.JCSCacheManager; -import org.springframework.context.annotation.Configuration; -@Configuration -public class CacheManager extends JCSCacheManager { - public CacheManager() { - - } - - /* The following can be customized for your application to cache the appropriate data upon application startup. The provided - example retrieves a list of sample lookup data and puts the list in the Cache Manager. To retrieve that data, simply call the - Cache Manager's getObject(String key) method which will return an Object instance. To put additional data in the Cache Manager - outside of application startup, call the Cache Manager's putObject(String key, Object objectToCache) method. */ - public void loadLookUpCache() { - /* - List<Role> result = (List<Role>)getDataAccessService().getList(Role.class,null); - - if (result != null) { - putObject("lookupRoles", result); - }*/ - } - -} diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/CipherUtil.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/CipherUtil.java deleted file mode 100644 index 0eec9295..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/CipherUtil.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; - -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.codec.binary.Base64; - -public class CipherUtil { - - private final static String key = "AGLDdG4D04BKm2IxIWEr8o==!"; - - /** - * @param plainText - * @param secretKey - * @return encrypted version of plain text. - * @throws Exception - */ - public static String encrypt(String plainText, String secretKey) throws Exception{ - byte[] rawKey; - String encryptedString; - SecretKeySpec sKeySpec; - byte[] encryptText = plainText.getBytes("UTF-8"); - Cipher cipher; - rawKey = Base64.decodeBase64(secretKey); - sKeySpec = new SecretKeySpec(rawKey, "AES"); - cipher = Cipher.getInstance("AES"); - cipher.init(Cipher.ENCRYPT_MODE, sKeySpec); - encryptedString = Base64.encodeBase64String(cipher.doFinal(encryptText)); - - return encryptedString; - } - - /** - * - * @param plainText - * @return Encrypted Text - * @throws Exception - */ - public static String encrypt(String plainText) throws Exception - { - return CipherUtil.encrypt(plainText,key); - } - - /** - * @param encryptedText - * @param secretKey - * @return plain text version of encrypted text - * @throws Exception - */ - public static String decrypt(String encryptedText, String secretKey) throws Exception { - Cipher cipher; - String encryptedString; - byte[] encryptText = null; - byte[] rawKey; - SecretKeySpec sKeySpec; - - rawKey = Base64.decodeBase64(secretKey); - sKeySpec = new SecretKeySpec(rawKey, "AES"); - encryptText = Base64.decodeBase64(encryptedText.getBytes("UTF-8")); - cipher = Cipher.getInstance("AES"); - cipher.init(Cipher.DECRYPT_MODE, sKeySpec); - encryptedString = new String(cipher.doFinal(encryptText)); - - return encryptedString; - } - - /** - * @param encryptedText - * @return Decrypted Text - * @throws Exception - */ - public static String decrypt(String encryptedText) throws Exception - { - return CipherUtil.decrypt(encryptedText,key); - } - - - public static void main(String[] args) throws Exception { - - String password = "Welcome123"; - String encrypted; - String decrypted; - - if (args.length != 2) { - System.out.println("Default password testing... "); - System.out.println("Plain password: " + password); - encrypted = encrypt(password); - System.out.println("Encrypted password: " + encrypted); - decrypted = decrypt(encrypted); - System.out.println("Decrypted password: " + decrypted); - } else { - String whatToDo = args[0]; - if (whatToDo.equalsIgnoreCase("d")) { - encrypted = args[1]; - System.out.println("Encrypted Text: " + encrypted); - decrypted = decrypt(encrypted); - System.out.println("Decrypted Text: " + decrypted); - } else { - decrypted = args[1]; - System.out.println("Plain Text: " + decrypted); - encrypted = encrypt(decrypted); - System.out.println("Encrypted Text" + encrypted); - } - } - } -} diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/EncDecUtilTest.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/EncDecUtilTest.java deleted file mode 100644 index 46a24533..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/EncDecUtilTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; -import java.security.AlgorithmParameters; -import java.security.SecureRandom; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.codec.binary.Base64; - -public class EncDecUtilTest { - - private static final String password = "test"; - private static final String salt = "r n�HN~��|f��X�" ; - private static int pswdIterations = 65536 ; - private static int keySize = 256; - private byte[] ivBytes; - - public String encrypt(String plainText) throws Exception { - - //get salt - //salt = generateSalt(); - byte[] saltBytes = salt.getBytes("UTF-8"); - - // Derive the key - SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); - PBEKeySpec spec = new PBEKeySpec( - password.toCharArray(), - saltBytes, - pswdIterations, - keySize - ); - - SecretKey secretKey = factory.generateSecret(spec); - SecretKeySpec secret = new SecretKeySpec(secretKey.getEncoded(), "AES"); - - //encrypt the message - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, secret); - AlgorithmParameters params = cipher.getParameters(); - ivBytes = params.getParameterSpec(IvParameterSpec.class).getIV(); - byte[] encryptedTextBytes = cipher.doFinal(plainText.getBytes("UTF-8")); - return new Base64().encodeAsString(encryptedTextBytes); - } - - @SuppressWarnings("static-access") - public String decrypt(String encryptedText) throws Exception { - - byte[] saltBytes = salt.getBytes("UTF-8"); - byte[] encryptedTextBytes = new Base64().decodeBase64(encryptedText); - - // Derive the key - SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); - PBEKeySpec spec = new PBEKeySpec( - password.toCharArray(), - saltBytes, - pswdIterations, - keySize - ); - - SecretKey secretKey = factory.generateSecret(spec); - SecretKeySpec secret = new SecretKeySpec(secretKey.getEncoded(), "AES"); - - // Decrypt the message - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(ivBytes)); - - - byte[] decryptedTextBytes = null; - try { - decryptedTextBytes = cipher.doFinal(encryptedTextBytes); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - } catch (BadPaddingException e) { - e.printStackTrace(); - } - - return new String(decryptedTextBytes); - } - - public String generateSalt() { - SecureRandom random = new SecureRandom(); - byte bytes[] = new byte[20]; - random.nextBytes(bytes); - String s = new String(bytes); - return s; - } -} diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/EncTest.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/EncTest.java deleted file mode 100644 index 865731db..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/EncTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; - -public class EncTest { - - - public static void main(String[] args) { - String secretKey = "AGLDdG4D04BKm2IxIWEr8o=="; - String value1= "AppPassword!1"; - try { - String encryptedValue1= CipherUtil.encrypt(value1, secretKey); - System.out.println(encryptedValue1); - String decryptedValue1 = CipherUtil.decrypt(encryptedValue1, secretKey); - System.out.println(decryptedValue1); - } catch (Exception e) { - // Invalid key would throw an exception. - e.printStackTrace(); - } - - } -} diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/JSONUtil.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/JSONUtil.java deleted file mode 100644 index 6b849e81..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/JSONUtil.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; - -import java.util.HashMap; -import java.util.Map; - -import org.openecomp.portalsdk.core.domain.User; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class JSONUtil { - public static String convertResponseToJSON(String response) throws JsonProcessingException{ - ObjectMapper mapper = new ObjectMapper(); - Map<String, String> responseMap = new HashMap<String, String>(); - responseMap.put("response", response); - response = mapper.writeValueAsString(responseMap); - return response; - } - - public static User mapToDomainUser(User domainUser, User editUser) { - domainUser.setOrgId(editUser.getOrgId()); - domainUser.setManagerId(editUser.getManagerId()); - domainUser.setFirstName(editUser.getFirstName()); - domainUser.setMiddleInitial(editUser.getMiddleInitial()); - domainUser.setLastName(editUser.getLastName()); - domainUser.setPhone(editUser.getPhone()); - domainUser.setEmail(editUser.getEmail()); - domainUser.setHrid(editUser.getHrid()); - domainUser.setOrgUserId(editUser.getOrgUserId()); - domainUser.setOrgCode(editUser.getOrgCode()); - domainUser.setOrgManagerUserId(editUser.getOrgManagerUserId()); - domainUser.setJobTitle(editUser.getJobTitle()); - domainUser.setLoginId(editUser.getLoginId()); - domainUser.setActive(editUser.getActive()); - return domainUser; - } -} diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java deleted file mode 100644 index 8bc6d7a1..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/SystemProperties.java +++ /dev/null @@ -1,279 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; - -import javax.servlet.ServletContext; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; - -/** - * SystemProperties contains a list of constants used throughout portions of the - * application. Populated by Spring from multiple configuration files. - * - * Should be used like this: - * - * <pre> - * - * @Autowired - * SystemProperties systemProperties; - * </pre> - */ -@Configuration -@PropertySource(value = { "${container.classpath:}/WEB-INF/conf/system.properties", - "${container.classpath:}/WEB-INF/fusion/conf/fusion.properties", - "${container.classpath:}/WEB-INF/conf/sql.properties" }) -public class SystemProperties { - - private static Environment environment; - - public SystemProperties() { - } - - protected Environment getEnvironment() { - return environment; - } - - @Autowired - public void setEnvironment(Environment environment) { - SystemProperties.environment = environment; - } - - public ServletContext getServletContext() { - return servletContext; - } - - public void setServletContext(ServletContext servletContext) { - this.servletContext = servletContext; - } - - - public static boolean containsProperty(String key) { - return environment.containsProperty(key); - } - - public static String getProperty(String key) { - if (environment!=null) { - return environment.getRequiredProperty(key); - } else { - return ""; - } - } - - // method created to get around JSTL 1.0 limitation of not being able to - // access a static method of a bean - public String getApplicationName() { - return getProperty(APPLICATION_NAME); - } - - public String getAppDisplayName() { - return getProperty(APP_DISPLAY_NAME); - } - - private ServletContext servletContext; - - // keys used to reference values in the system properties file - public static final String DOMAIN_CLASS_LOCATION = "domain_class_location"; - public static final String DEFAULT_ERROR_MESSAGE = "default_error_message"; - - public static final String AUTHENTICATION_MECHANISM = "authentication_mechanism"; - - public static final String APPLICATION_NAME = "application_name"; - public static final String HIBERNATE_CONFIG_FILE_PATH = "hibernate_config_file_path"; - public static final String APPLICATION_USER_ID = "application_user_id"; - - public static final String POST_INITIAL_CONTEXT_FACTORY = "post_initial_context_factory"; - public static final String POST_PROVIDER_URL = "post_provider_url"; - public static final String POST_SECURITY_PRINCIPAL = "post_security_principal"; - public static final String POST_MAX_RESULT_SIZE = "post_max_result_size"; - public static final String POST_DEFAULT_ROLE_ID = "post_default_role_id"; - - public static final String FILES_PATH = "files_path"; - public static final String TEMP_PATH = "temp_path"; - - public static final String NUM_UPLOAD_FILES = "num_upload_files"; - - public static final String SYS_ADMIN_ROLE_ID = "sys_admin_role_id"; - - public static final String SYS_ADMIN_ROLE_FUNCTION_DELETE_FROM_UI = "sys_admin_role_function_delete_from_ui"; - public static final String USER_NAME = "user_name"; - public static final String FIRST_NAME = "first_name"; - public static final String LAST_NAME = "last_name"; - public static final String APP_DISPLAY_NAME = "app_display_name"; - // Application base URL is a proper prefix of the on-boarding URL - public static final String APP_BASE_URL = "app_base_url"; - - public static final String MENU_PROPERTIES_FILE_LOCATION = "menu_properties_file_location"; - public static final String MENU_QUERY_NAME = "menu_query_name"; - public static final String APPLICATION_MENU_SET_NAME = "application_menu_set_name"; - public static final String APPLICATION_MENU_ATTRIBUTE_NAME = "application_menu_attribute_name"; - public static final String APPLICATION_MENU_PROPERTIES_NAME = "application_menu_properties_name"; - public static final String BUSINESS_DIRECT_MENU_SET_NAME = "business_direct_menu_set_name"; - public static final String BUSINESS_DIRECT_MENU_ATTRIBUTE_NAME = "business_direct_menu_attribute_name"; - public static final String BUSINESS_DIRECT_MENU_PROPERTIES_NAME = "business_direct_menu_properties_name"; - public static final String RAPTOR_CONFIG_FILE_PATH = "raptor_config_file_path"; - public static final String HOMEPAGE_DATA_CALLBACK_CLASS = "homepage_data_callback_class"; - public static final String ERROR_EMAIL_DISTRIBUTION = "error_email_distribution"; - public static final String ERROR_EMAIL_SOURCE_ADDRESS = "error_email_source_address"; - public static final String ERROR_EMAIL_SUBJECT_LINE = "error_email_subject_line"; - public static final String PROFILE_SEARCH_REPORT_ID = "profile_search_report_id"; - public static final String CALLABLE_PROFILE_SEARCH_REPORT_ID = "callable_profile_search_report_id"; - public static final String CLUSTERED = "clustered"; - - public static final String USER_ATTRIBUTE_NAME = "user_attribute_name"; - public static final String ROLES_ATTRIBUTE_NAME = "roles_attribute_name"; - public static final String ROLE_FUNCTIONS_ATTRIBUTE_NAME = "role_functions_attribute_name"; - public static final String CLIENT_DEVICE_ATTRIBUTE_NAME = "client_device_attribute_name"; - public static final String CLIENT_DEVICE_EMULATION = "client_device_emulation"; - public static final String CLIENT_DEVICE_TYPE_TO_EMULATE = "client_device_type_to_emulate"; - // File generation - Document - public static final String TEMPLATES_PATH = "templates_path"; - public static final String DOCUMENT_XML_ENCODING = "document_xml_encoding"; - - // Transaction - public static final String ROUTING_DATASOURCE_KEY = "routing_datasource_key"; - - // Document Library keys - public static final String DOCLIB_ADMIN_ROLE_ID = "doclib_admin_role_id"; - public static final String DOCLIB_USER_ROLE_ID = "doclib_user_role_id"; - - public static final String SYSTEM_PROPERTIES_FILENAME = "system.properties"; - public static final String FUSION_PROPERTIES_FILENAME = "fusion.properties"; - public static final String SUCCESS_TASKS_PROPERTIES_FILENAME = "success_tasks.properties"; - - // login error message keys - public static final String MESSAGE_KEY_LOGIN_ERROR_COOKIE_EMPTY = "login.error.hrid.empty"; - public static final String MESSAGE_KEY_LOGIN_ERROR_HEADER_EMPTY = "login.error.header.empty"; - public static final String MESSAGE_KEY_LOGIN_ERROR_USER_INACTIVE = "login.error.user.inactive"; - public static final String MESSAGE_KEY_LOGIN_ERROR_USER_NOT_FOUND = "login.error.hrid.not-found"; - public static final String MESSAGE_KEY_LOGIN_ERROR_APPLICATION_LOCKED = "login.error.application.locked"; - public static final String MESSAGE_KEY_AUTOLOGIN_NONE = "webphone.autoimport.nouser"; - public static final String MESSAGE_KEY_AUTOLOGIN_MULTIPLE = "webphone.autoimport.multiple"; - - // Application Mobile capability - public static final String MOBILE_ENABLE = "mobile_enable"; - - public static final String DATABASE_TIME_ZONE = "db.time_zone"; - - public static final String AUTO_USER_IMPORT_ENABLE = "auto_user_import_enable"; - public static final String AUTO_USER_IMPORT_ROLE = "auto_user_import_role"; - - public static final String ITRACKER_EMAIL_SOURCE_ADDRESS = "itracker_email_source_address"; - public static final String ITRACKER_EMAIL_DISTRIBUTION = "itracker_email_distribution"; - public static final String ITRACKER_SYSTEM_USER = "itracker_system_user_id"; - - public static final String MAIL_SERVER_HOST = "mail_server_host"; - public static final String MAIL_SERVER_PORT = "mail_server_port"; - - // Routing Data Source keys - public static final String ROUTING_DATASOURCE_KEY_NON_XA = "NON-XA"; - public static final String ROUTING_DATASOURCE_KEY_XA = "XA"; - public static final String QUARTZ_JOB_ENABLED = "quartz_job_enable"; - public static final String WORKFLOW_EMAIL_SENDER = "workflow_email_sender"; - public static final String DROOLS_GUVNOR_HOME = "drools.guvnor.home"; - - // Hibernate Config - public static final String HB_DIALECT = "hb.dialect"; - public static final String HB_SHOW_SQL = "hb.show_sql"; - // DataSource - public static final String DB_DRIVER = "db.driver"; - public static final String DB_CONNECTIONURL = "db.connectionURL"; - public static final String DB_USERNAME = "db.userName"; - public static final String DB_PASSWOR = "db.password"; - public static final String DB_MIN_POOL_SIZE = "db.min_pool_size"; - public static final String DB_MAX_POOL_SIZE = "db.max_pool_size"; - public static final String IDLE_CONNECTION_TEST_PERIOD = "hb.idle_connection_test_period"; - - public static final String MYLOGINS_FEED_CRON = "mylogins_feed_cron"; - public static final String SESSIONTIMEOUT_FEED_CRON = "sessiontimeout_feed_cron"; - public static final String LOG_CRON = "log_cron"; - - public static final String DB_ENCRYPT_FLAG = "db.encrypt_flag"; - - // Decryption Key - public static final String Decryption_Key = "decryption_key"; - - // Logging/Audit Fields - public static final String MDC_APPNAME = "AppName"; - public static final String MDC_REST_PATH = "RestPath"; - public static final String MDC_REST_METHOD = "RestMethod"; - public static final String INSTANCE_UUID = "instance_uuid"; - public static final String MDC_CLASS_NAME = "ClassName"; - public static final String MDC_LOGIN_ID = "LoginId"; - public static final String MDC_TIMER = "Timer"; - public static final String SDK_NAME = "ECOMP_SDK"; - public static final String ECOMP_REQUEST_ID = "X-ECOMP-RequestID"; - public static final String PARTNER_NAME = "PartnerName"; - public static final String FULL_URL = "Full-URL"; - public static final String AUDITLOG_BEGIN_TIMESTAMP = "AuditLogBeginTimestamp"; - public static final String AUDITLOG_END_TIMESTAMP = "AuditLogEndTimestamp"; - public static final String METRICSLOG_BEGIN_TIMESTAMP = "MetricsLogBeginTimestamp"; - public static final String METRICSLOG_END_TIMESTAMP = "MetricsLogEndTimestamp"; - public static final String CLIENT_IP_ADDRESS = "ClientIPAddress"; - public static final String STATUS_CODE = "StatusCode"; - public static final String RESPONSE_CODE = "ResponseCode"; - public static final String TARGET_ENTITY = "TargetEntity"; //Component or sub component name - public static final String TARGET_SERVICE_NAME = "TargetServiceName"; //API or operation name - - // Logging Compliance - public static final String DOUBLE_WHITESPACE_SEPARATOR = " "; - public static final String SINGLE_WHITESPACE_SEPARATOR = " "; - public static final String SINGLE_QUOTE = "'"; - public static final String NA = "N/A"; - public static final String UNKNOWN = "Unknown"; - public static final String SECURITY_LOG_TEMPLATE = "Protocol:{0} Security-Event-Type:{1} Login-ID:{2} {3}"; - public static final String ECOMP_PORTAL_BE = "ECOMP_PORTAL_BE"; - public static final String PROTOCOL = "PROTOCOL"; - public static final String SECURIRY_EVENT_TYPE = "SECURIRY_EVENT_TYPE"; - public static final String LOGIN_ID = "LOGIN_ID"; - public static final String ACCESSING_CLIENT = "ACCESSING_CLIENT"; - public static final String RESULT_STR = "RESULT"; - public static final String ECOMP_PORTAL_FE = "ECOMP_PORTAL_FE"; - public static final String ADDITIONAL_INFO = "ADDITIONAL_INFO"; - public static final String INTERFACE_NAME = "INTERFACE_NAME"; - public static final String USERAGENT_NAME = "user-agent"; - - // Protocols - public static final String HTTP = "HTTP"; - public static final String HTTPS = "HTTPS"; - public static final String SSO_VALUE = "sso"; - - public enum RESULT_ENUM { - SUCCESS, FAILURE - } - - public enum SecurityEventTypeEnum { - FE_LOGIN_ATTEMPT, FE_LOGOUT, SSO_LOGIN_ATTEMPT_PHASE_1, SSO_LOGIN_ATTEMPT_PHASE_2, SSO_LOGOUT, LDAP_PHONEBOOK_USER_SEARCH, INCOMING_REST_MESSAGE, OUTGOING_REST_MESSAGE, REST_AUTHORIZATION_CREDENTIALS_MODIFIED, ECOMP_PORTAL_USER_MODIFIED, ECOMP_PORTAL_USER_ADDED, ECOMP_PORTAL_USER_REMOVED, ECOMP_PORTAL_WIDGET, INCOMING_UEB_MESSAGE, ECOMP_PORTAL_HEALTHCHECK - } - - // Menu - public static final String CONTACT_US_LINK = "contact_us_link"; - - //Left Menu - public static final String LEFT_MENU_PARENT = "parentList"; - public static final String LEFT_MENU_CHILDREND = "childItemList"; - - // URL of the portal site that provides the shared-context REST service - public static final String ECOMP_SHARED_CONTEXT_REST_URL = "ecomp_shared_context_rest_url"; - - public static final String AUTH_USER_SERVER = "authenticate_user_server"; -} diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/UsageUtils.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/UsageUtils.java deleted file mode 100644 index a8cc7fd7..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/UsageUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; - -import javax.servlet.http.HttpSession; - -import org.openecomp.portalsdk.core.command.UserRowBean; -import org.openecomp.portalsdk.core.domain.User; - -public class UsageUtils { - @SuppressWarnings("rawtypes") - public static ArrayList<UserRowBean> getActiveUsers(HashMap activeUsers) { - ArrayList<UserRowBean> rows = new ArrayList<UserRowBean>(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - - for(Iterator i = activeUsers.keySet().iterator(); i.hasNext(); ){ - String sessionId = (String)i.next(); - HttpSession session = (HttpSession)activeUsers.get(sessionId); - User userBean = (User)session.getAttribute("user"); - // - // Not all sessions will be valid logins - // Skip those ones - // - if(null == userBean) - continue; - - UserRowBean userRow = new UserRowBean(); - userRow.setFirstName(userBean.getFirstName()); - userRow.setLastName(userBean.getLastName()); - userRow.setEmail(userBean.getEmail()); - userRow.setId(userBean.getId()); - userRow.setSessionId(sessionId); - userRow.setLoginTime(sdf.format(new Date(session.getCreationTime()))); - userRow.setLastLoginTime(sdf.format(userBean.getLastLoginDate())); - - // - // Calculate the last time and time remaining for these sessions. - // - int sessionLength = session.getMaxInactiveInterval(); - long now = new java.util.Date().getTime(); - long lastAccessed = (now - session.getLastAccessedTime()) / 1000; - long lengthInactive = (now - session.getLastAccessedTime()); - long minutesRemaining = sessionLength - (lengthInactive / 1000); - - userRow.setLastAccess((lastAccessed / 60) + ":" + String.format("%02d", (lastAccessed % 60))); - userRow.setRemaining((minutesRemaining / 60) + ":" + String.format("%02d", (minutesRemaining % 60))); - - rows.add(userRow); - } - - return rows; - } - - @SuppressWarnings("rawtypes") - public static ArrayList<UserRowBean> getActiveUsersAfterDelete(HashMap activeUsers, final java.lang.Object data) { - return getActiveUsers(deleteSession(activeUsers,data)); - - } - - @SuppressWarnings("rawtypes") - private static HashMap deleteSession(HashMap activeUsers, Object data) { - String sessionId = ((UserRowBean)data).getSessionId(); - HttpSession session = (HttpSession)activeUsers.get(sessionId); - session.invalidate(); - activeUsers.remove(sessionId); - - return activeUsers; - } -} diff --git a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/YamlUtils.java b/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/YamlUtils.java deleted file mode 100644 index 58bcb252..00000000 --- a/ecomp-sdk/quantum/src/main/java/org/openecomp/portalsdk/core/util/YamlUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * 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. - * ================================================================================ - */ -package org.openecomp.portalsdk.core.util; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Map; - -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.representer.Representer; - -public class YamlUtils { - - static Yaml yaml; - - static { - - Representer representer = new Representer(); - yaml = new Yaml(representer); - - } - - public static void writeYamlFile(String filePath, String fileName, - Map<String, Object> model) throws IOException { - FileWriter writer = new FileWriter(filePath + File.separator + fileName); - yaml.dump(model, writer); - writer.close(); - } - - public static String returnYaml( - Map<String, Object> model) throws IOException { - - return yaml.dump(model); - - } - - @SuppressWarnings("unchecked") - public static Map<String, Object> readYamlFile( - String filePath, String fileName) throws FileNotFoundException, - IOException { - FileReader reader = new FileReader(filePath + File.separator + fileName); - - Map<String,Object> callFlowBs = (Map<String,Object>)yaml.load(reader); - reader.close(); - return callFlowBs; - } - - -} |