summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common/src/main/java/org/onap
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/src/main/java/org/onap
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/src/main/java/org/onap')
-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
2 files changed, 90 insertions, 2 deletions
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;
+ }
+
+}