summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util')
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/CipherUtil.java125
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java65
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiProperties.java102
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOFilter.java75
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java46
5 files changed, 0 insertions, 413 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/CipherUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/CipherUtil.java
deleted file mode 100644
index e376cd4c..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/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.onboarding.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/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java
deleted file mode 100644
index 087d03d5..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiConstants.java
+++ /dev/null
@@ -1,65 +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.onboarding.util;
-
-public interface PortalApiConstants {
- public static final String API_PREFIX = "/api/v2";
- public static final String PORTAL_JSESSION_ID = "PORTAL_JSESSION_ID";
- public static final String PORTAL_JSESSION_BIND = "PORTAL_JSESSION_BIND";
- public static final String ACTIVE_USERS_NAME = "activeUsers";
-
- /** Portal service cookie name */
- public static final String EP_SERVICE = "EPService";
-
- public static final String GLOBAL_SESSION_MAX_IDLE_TIME = "global_session_max_idle_time";
- public static final String PORTAL_SESSION_SLOT_CHECK = "portal_session_slot_check";
- public static final String SESSION_PREVIOUS_ACCESS_TIME = "session_previous_access_time";
- public static final String MAX_IDLE_TIME = "max.idle.time";
-
- // Names of keys in the portal.properties file
- public static final String PORTAL_API_IMPL_CLASS = "portal.api.impl.class";
- public static final String ECOMP_REDIRECT_URL = "ecomp_redirect_url";
- public static final String ECOMP_REST_URL = "ecomp_rest_url";
- public static final String ROLE_ACCESS_CENTRALIZED = "role_access_centralized";
- public static final String CSP_COOKIE_NAME = "csp_cookie_name";
- public static final String CSP_GATE_KEEPER_PROD_KEY = "csp_gate_keeper_prod_key";
-
- // UEB related
- public static final String UEB_URL_LIST = "ueb_url_list"; // In properties file
- public static final String ECOMP_PORTAL_INBOX_NAME = "ecomp_portal_inbox_name";
- public static final String ECOMP_DEFAULT_MSG_ID = "0";
- public static final String ECOMP_GENERAL_UEB_PARTITION = "EPGeneralPartition";
- public static final String UEB_LISTENERS_ENABLE = "ueb_listeners_enable";
- public static final String UEB_APP_INBOUND_MAILBOX_NAME = "ueb_app_mailbox_name";
- public static final String UEB_APP_CONSUMER_GROUP_NAME = "ueb_app_consumer_group_name";
-
- // UebManager generates a consumer group name for special token {UUID}
- public static final String UEB_APP_CONSUMER_GROUP_NAME_GENERATOR = "{UUID}";
- public static final String UEB_APP_KEY = "ueb_app_key";
- public static final String UEB_APP_SECRET = "ueb_app_secret";
- public static final String ECOMP_UEB_INVALID_MSG = "100: Invalid Message format.";
- public static final String ECOMP_UEB_TIMEOUT_ERROR = "101: Timeout";
- public static final String ECOMP_UEB_UNKNOWN_PUBLISH_ERROR = "102: Unknown error during publish";
- public static final String ECOMP_UEB_UNKNOWN_CONSUME_ERROR = "103: Unknown error during consume";
- public static final String USE_REST_FOR_FUNCTIONAL_MENU = "use_rest_for_functional_menu";
-
- public static final String EXT_REQUEST_CONNECTION_TIMEOUT = "ext_req_connection_timeout";
- public static final String EXT_REQUEST_READ_TIMEOUT = "ext_req_read_timeout";
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiProperties.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiProperties.java
deleted file mode 100644
index 93572ee9..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/PortalApiProperties.java
+++ /dev/null
@@ -1,102 +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.onboarding.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Singleton Class representing portal properties. Searches the classpath for
- * the file "portal.properties".
- *
- * To put the file "portal.properties" on the classpath, it can be in the same
- * directory where the first package folder is - 'myClasses' folder in the
- * following case as an example:
- *
- */
-public class PortalApiProperties {
-
- private static final Log logger = LogFactory.getLog(PortalApiProperties.class);
-
- private static Properties properties;
- private static String propertyFileName = "portal.properties";
-
- /**
- * Constructor is private.
- */
- private PortalApiProperties() {
- }
-
- /**
- * Gets the property value for the specified key. If a value is found,
- * leading and trailing space is trimmed.
- *
- * @param property
- * @return Value for the named property; null if the property file was not
- * loaded or the key was not found.
- */
- public static String getProperty(String property) {
- if (properties == null) {
- synchronized (propertyFileName) {
- try {
- if (!initialize()) {
- logger.error("Failed to read property file " + propertyFileName);
- return null;
- }
- } catch (IOException e) {
- logger.error("Failed to read property file " + propertyFileName, e);
- return null;
- }
- }
- }
- String value = properties.getProperty(property);
- if (value != null)
- value = value.trim();
- return value;
- }
-
- /**
- * Reads properties from a portal.properties file on the classpath.
- *
- * Clients do NOT need to call this method. Clients MAY call this method to
- * test whether the properties file can be loaded successfully.
- *
- * @return True if properties were successfully loaded, else false.
- * @throws IOException
- */
- public static boolean initialize() throws IOException {
- if (properties != null)
- return true;
- InputStream in = PortalApiProperties.class.getClassLoader().getResourceAsStream(propertyFileName);
- if (in == null)
- return false;
- properties = new Properties();
- try {
- properties.load(in);
- } finally {
- in.close();
- }
- return true;
- }
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOFilter.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOFilter.java
deleted file mode 100644
index 1d8a9620..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOFilter.java
+++ /dev/null
@@ -1,75 +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.onboarding.util;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.openecomp.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy;
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
-
-public class SSOFilter implements Filter {
-
- private final Log logger = LogFactory.getLog(getClass());
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
- throws java.io.IOException, ServletException {
-
- try {
- if (PortalRestAPIProxy.getPortalRestApiServiceImpl().getUserId((HttpServletRequest) request) == null) {
- String redirectURL = SSOUtil.getECOMPSSORedirectURL(((HttpServletRequest) request),
- ((HttpServletResponse) response),
- (((HttpServletRequest) request).getRequestURI()
- .substring(((HttpServletRequest) request).getContextPath().length() + 1)
- + (((HttpServletRequest) request).getQueryString() != null
- ? ("?" + ((HttpServletRequest) request).getQueryString()) : "")));
-
- ((HttpServletResponse) response).sendRedirect(redirectURL);
-
- } else {
- // Pass request back down the filter chain
- chain.doFilter(request, response);
-
- }
- } catch (PortalAPIException e) {
- logger.error("Issue calling getUserId method ");
- throw new ServletException(e);
- }
-
- }
-
- public void destroy() {
-
- }
-
- public void init(FilterConfig arg0) throws ServletException {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java
deleted file mode 100644
index 87134d3c..00000000
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/openecomp/portalsdk/core/onboarding/util/SSOUtil.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.openecomp.portalsdk.core.onboarding.util;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class SSOUtil {
-
- private static final Log logger = LogFactory.getLog(SSOUtil.class);
-
- /**
- * Constructs a path for this server, this app's context, etc.
- *
- * @param request
- * HttpServletRequest
- * @param response
- * HttpServletResponse
- * @param forwardPath
- * Path to forward user
- * @return Redirect URL
- */
- public static String getECOMPSSORedirectURL(HttpServletRequest request, HttpServletResponse response,
- String forwardPath) {
- String appURL = (request.isSecure() ? "https://" : "http://") + request.getServerName() + ":"
- + request.getServerPort() + request.getContextPath() + "/" + forwardPath;
- String encodedAppURL = null;
- try {
- encodedAppURL = URLEncoder.encode(appURL, "UTF-8");
- } catch (UnsupportedEncodingException ex) {
- logger.error("getECOMPSSORedirectURL: Failed to encode app URL " + appURL);
- }
- String portalURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
- if (portalURL == null || portalURL.length() == 0) {
- logger.error("getECOMPSSORedirectURL: Failed to get property " + PortalApiConstants.ECOMP_REDIRECT_URL);
- return null;
- }
- String redirectURL = portalURL + "?redirectUrl=" + encodedAppURL;
- return redirectURL;
- }
-
-}