summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common
diff options
context:
space:
mode:
authorMuni Mohan Kunchi <munmohan@att.com>2020-02-06 13:51:45 -0500
committerMuni Mohan Kunchi <munmohan@att.com>2020-02-06 13:54:22 -0500
commite3636b96e9938cb89bb90672cf70fff3ae790186 (patch)
tree89dd47a4a95150f70e83556a3280cf4cd02daf89 /ecomp-sdk/epsdk-app-common
parent35d028274a61ce8e77a9fa409877d93d0fce05a8 (diff)
adding sdk changes
adding sdk changes Issue-ID: PORTAL-830 Signed-off-by: Muni Mohan Kunchi <munmohan@att.com> Change-Id: I0c99d3ab15fcf4c3b34d84658b64114dadbe2577
Diffstat (limited to 'ecomp-sdk/epsdk-app-common')
-rw-r--r--ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_3_0_to_2_6_Common.sql1
-rw-r--r--ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_6_to_3_0_Common.sql42
-rw-r--r--ecomp-sdk/epsdk-app-common/pom.xml4
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java38
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/model/EPServiceCookie.java54
-rw-r--r--ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java34
6 files changed, 156 insertions, 17 deletions
diff --git a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_3_0_to_2_6_Common.sql b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_3_0_to_2_6_Common.sql
index 4afb501e..f0a228df 100644
--- a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_3_0_to_2_6_Common.sql
+++ b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Rollback_3_0_to_2_6_Common.sql
@@ -24,5 +24,6 @@ UPDATE fn_menu
SET ACTION='admin#/admin_menu_edit'
WHERE LABEL='Menus';
+delete FROM fn_restricted_url WHERE RESTRICTED_URL='V2';
commit; \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_6_to_3_0_Common.sql b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_6_to_3_0_Common.sql
index 5982363b..4139a7a5 100644
--- a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_6_to_3_0_Common.sql
+++ b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkMySql_Upgrade_2_6_to_3_0_Common.sql
@@ -3,20 +3,34 @@ use ecomp_sdk;
SET FOREIGN_KEY_CHECKS=0;
UPDATE fn_menu
-SET ACTION='v2/admin/role_function_list'
-WHERE LABEL='Role Functions';
+SET ACTION='welcome'
+WHERE LABEL='Home';
+UPDATE fn_menu
+SET ACTION='v2/userProfile'
+WHERE LABEL='Search';
UPDATE fn_menu
-SET ACTION='v2/admin/usage_list'
-WHERE LABEL='Usage';
+SET ACTION='v2/userProfile/post_search'
+WHERE LABEL='Import from WEBPHONE';
+UPDATE fn_menu
+SET ACTION='v2/userProfile/self_profile'
+WHERE LABEL='Self';
UPDATE fn_menu
SET ACTION='v2/admin/admin'
WHERE LABEL='Roles';
UPDATE fn_menu
+SET ACTION='v2/admin/role_function_list'
+WHERE LABEL='Role Functions';
+
+UPDATE fn_menu
+SET ACTION='v2/admin/usage_list'
+WHERE LABEL='Usage';
+
+UPDATE fn_menu
SET ACTION='v2/admin/cache_admin'
WHERE LABEL='Cache Admin';
@@ -24,13 +38,25 @@ UPDATE fn_menu
SET ACTION='v2/admin/admin_menu_edit'
WHERE LABEL='Menus';
+
+-- fn_menu - update menu icon
+UPDATE fn_menu
+SET `IMAGE_SRC`='icon ion-ios-home'
+WHERE `LABEL`='Home';
+
+UPDATE fn_menu
+SET `IMAGE_SRC`='icon ion-md-pie'
+WHERE `LABEL`='Reports';
+
UPDATE fn_menu
-SET ACTION='v2/report-list'
-WHERE LABEL='All Reports';
+SET `IMAGE_SRC`='ion-md-person'
+WHERE `LABEL`='Profile';
UPDATE fn_menu
-SET ACTION='v2/create'
-WHERE LABEL='Create Reports';
+SET `IMAGE_SRC`='icon ion-md-star'
+WHERE `LABEL`='Admin';
+-- Added new update for fn_restricted_url -
+insert into fn_restricted_url values ('v2','menu_home');
commit; \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-common/pom.xml b/ecomp-sdk/epsdk-app-common/pom.xml
index 2d0bf371..21a56f01 100644
--- a/ecomp-sdk/epsdk-app-common/pom.xml
+++ b/ecomp-sdk/epsdk-app-common/pom.xml
@@ -128,7 +128,7 @@
<dependency>
<groupId>com.att.eelf</groupId>
<artifactId>eelf-core</artifactId>
- <version>1.0.0-oss</version>
+ <version>1.0.0</version>
</dependency>
<!-- Mapper -->
<dependency>
@@ -192,7 +192,7 @@
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
- <version>2.2.1</version>
+ <version>2.3.2</version>
<exclusions>
<!-- exclude 0.9.1.1 to avoid dupe of com.mchange:c3p0:0.9.2.1 -->
<exclusion>
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java
index 3e23fed8..d04acc8d 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java
@@ -37,6 +37,7 @@
*/
package org.onap.portalapp.controller.core;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
@@ -50,6 +51,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
+import org.onap.portalapp.model.EPServiceCookie;
import org.onap.portalsdk.core.auth.LoginStrategy;
import org.onap.portalsdk.core.command.LoginBean;
import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
@@ -69,9 +71,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
@Controller
@RequestMapping("/")
public class SingleSignOnController extends UnRestrictedBaseController {
@@ -86,6 +93,9 @@ public class SingleSignOnController extends UnRestrictedBaseController {
@Autowired
private RoleService roleService;
+
+
+ private RestTemplate restTemplate = new RestTemplate();
private String viewName;
private String welcomeView;
@@ -233,9 +243,33 @@ public class SingleSignOnController extends UnRestrictedBaseController {
PortalTimeoutHandler.sessionCreated(portalJSessionId, jSessionId, AppUtils.getSession(request));
}
- public boolean isLoginCookieExist(HttpServletRequest request) {
+ public boolean isLoginCookieExist(HttpServletRequest request) throws JsonParseException, JsonMappingException, IOException {
Cookie ep = WebUtils.getCookie(request, LoginStrategy.EP_SERVICE);
- return ep != null;
+ if(ep!=null) {
+ return validateEPServiceCookie(ep.getValue());
+ }
+ return false;
+ }
+
+ //This method is validating EPService cookie in portal
+ public boolean validateEPServiceCookie(String cookieValue) throws JsonParseException, JsonMappingException, IOException{
+ Boolean result = false;
+ try{
+ //Create json Request for REST call
+ final String uri = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String,String> valueMap = mapper.readValue(URLDecoder.decode(cookieValue, "UTF-8"),HashMap.class);
+
+ EPServiceCookie epServiceCookie = new EPServiceCookie();
+ epServiceCookie.setValue(valueMap);
+ //Call portal service to validate
+ result = restTemplate.postForObject( uri+"/v3/validateCookie", epServiceCookie, Boolean.class);
+ logger.info(EELFLoggerDelegate.applicationLogger,"Epservice cookie validation result:: "+result);
+ }catch(Exception e){
+ logger.error(EELFLoggerDelegate.errorLogger,"Error in calling service :: "+e.getMessage());
+ }
+
+ return result;
}
public String getPortalJSessionId(HttpServletRequest request) {
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/model/EPServiceCookie.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/model/EPServiceCookie.java
new file mode 100644
index 00000000..2fa58530
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/model/EPServiceCookie.java
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.portalapp.model;
+
+import java.util.Map;
+
+
+public class EPServiceCookie {
+ Map<String, String> value;
+
+ public Map<String, String> getValue() {
+ return value;
+ }
+
+ public void setValue(Map<String, String> value) {
+ this.value = value;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java
index 75b31c97..f3c72c6b 100644
--- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java
+++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java
@@ -71,6 +71,7 @@ import org.onap.portalsdk.core.web.support.UserUtils;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
@@ -93,6 +94,9 @@ public class SingleSignOnControllerTest {
@Mock
URLDecoder uRLDecoder;
+
+ @Mock
+ RestTemplate restTemplate;
@Before
public void setup() {
@@ -133,6 +137,9 @@ public class SingleSignOnControllerTest {
Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY)).thenReturn("uebkey");
Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL))
.thenReturn("http://test.com/roles");
+
+
+
ModelAndView expectedResults = singleSignOnController.singleSignOnLogin(mockedRequest);
assertEquals(expectedResults.getViewName(),
"redirect:http://test.com/process_csp?uebAppKey=uebkey&redirectUrl=http%3A%2F%2FTestUrl%2FTest");
@@ -164,12 +171,15 @@ public class SingleSignOnControllerTest {
PowerMockito.mockStatic(URLDecoder.class);
PowerMockito.mockStatic(SystemProperties.class);
PowerMockito.mockStatic(WebUtils.class);
+ PowerMockito.mockStatic(PortalApiProperties.class);
Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com");
Mockito.when(mockedRequest.getParameter("redirectToPortal")).thenReturn(null);
Mockito.when(SystemProperties.containsProperty(SystemProperties.APP_BASE_URL)).thenReturn(true);
Mockito.when(SystemProperties.getProperty(SystemProperties.APP_BASE_URL)).thenReturn("http://TestUrl");
Mockito.when(SystemProperties.getProperty(SystemProperties.COOKIE_DOMAIN)).thenReturn("Test.com");
- Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test"));
+ Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}"));
+ Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl");
+ Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true);
User user = new User();
user.setOrgUserId("test12");
Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user);
@@ -185,14 +195,19 @@ public class SingleSignOnControllerTest {
Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com");
PowerMockito.mockStatic(URLDecoder.class);
PowerMockito.mockStatic(WebUtils.class);
+ PowerMockito.mockStatic(PortalApiProperties.class);
PowerMockito.mockStatic(SystemProperties.class);
Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com");
- Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test"));
+ Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}"));
+ Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl");
+ Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true);
Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user);
Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("testauth");
Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234");
Mockito.when(mockedRequest.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY)).thenReturn("test");
+ Mockito.when(mockedRequest.getRequestURL()).thenReturn(new StringBuffer("test"));
+
LoginBean commandBean = new LoginBean();
commandBean.setUserid("test1234");
commandBean.setUser(null);
@@ -211,11 +226,14 @@ public class SingleSignOnControllerTest {
Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com");
PowerMockito.mockStatic(URLDecoder.class);
PowerMockito.mockStatic(WebUtils.class);
+ PowerMockito.mockStatic(PortalApiProperties.class);
PowerMockito.mockStatic(SystemProperties.class);
PowerMockito.mockStatic(UserUtils.class);
Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com");
- Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test"));
+ Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}"));
+ Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl");
+ Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true);
Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user);
Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("testauth");
Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234");
@@ -240,11 +258,14 @@ public class SingleSignOnControllerTest {
Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com");
PowerMockito.mockStatic(URLDecoder.class);
PowerMockito.mockStatic(WebUtils.class);
+ PowerMockito.mockStatic(PortalApiProperties.class);
PowerMockito.mockStatic(SystemProperties.class);
PowerMockito.mockStatic(UserUtils.class);
Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com");
- Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test"));
+ Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}"));
+ Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl");
+ Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true);
Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user);
Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn(null);
Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234");
@@ -273,10 +294,13 @@ public class SingleSignOnControllerTest {
Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com");
PowerMockito.mockStatic(URLDecoder.class);
PowerMockito.mockStatic(WebUtils.class);
+ PowerMockito.mockStatic(PortalApiProperties.class);
PowerMockito.mockStatic(SystemProperties.class);
PowerMockito.mockStatic(UserUtils.class);
Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com");
- Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test"));
+ Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}"));
+ Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl");
+ Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true);
Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user);
Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("CSP");
Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234");