summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKotta, Shireesha (sk434m) <sk434m@att.com>2018-09-20 15:29:26 -0400
committerKotta, Shireesha (sk434m) <sk434m@att.com>2018-09-21 12:21:52 -0400
commit50ab57604bd752ca886acdea66c475ea4baa7b05 (patch)
tree08d125f5ff6634bed73cf48790bff39b9258ddd4
parentcddbf4178c451ed6ff7a0eb3aaf0655176107221 (diff)
Null UserId while login into sdk3.0.2-ONAPrelease-2.4.0casablanca
Issue-ID: PORTAL-390, PORTAL-393 Added changes to get uid from session Change-Id: I1ac4da2679bc243408d1ae5f8ef1a3d9ad93274e Signed-off-by: Kotta, Shireesha (sk434m) <sk434m@att.com>
-rw-r--r--ecomp-sdk/epsdk-app-os/README.md2
-rw-r--r--ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/controller/OnapLoginController.java73
-rw-r--r--ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java45
-rw-r--r--ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/jsp/login.jsp2
-rw-r--r--ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/InMemoryRestServer.java49
5 files changed, 154 insertions, 17 deletions
diff --git a/ecomp-sdk/epsdk-app-os/README.md b/ecomp-sdk/epsdk-app-os/README.md
index c61ebe63..1c127630 100644
--- a/ecomp-sdk/epsdk-app-os/README.md
+++ b/ecomp-sdk/epsdk-app-os/README.md
@@ -14,6 +14,8 @@ https://www.eclipse.org/m2e-wtp/
## Release Notes
Version 2.3.0
- PORTAL 254 ECOMP AAF jar
+- portal 390 Null UserId while login into sdk in centralized mode
+- portal 393 InMemoryRestServer.java - Apache-2.0 (incomplete license statement)
Version 2.2.0
- PORTAL 136 Junits for SDK
diff --git a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/controller/OnapLoginController.java b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/controller/OnapLoginController.java
new file mode 100644
index 00000000..9e0ab54a
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/controller/OnapLoginController.java
@@ -0,0 +1,73 @@
+/*
+ * ============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.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.onap.portalsdk.core.auth.LoginStrategy;
+import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
+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.servlet.ModelAndView;
+
+@Controller
+@RequestMapping("/")
+public class OnapLoginController extends UnRestrictedBaseController {
+
+ @Autowired
+ private LoginStrategy loginStrategy;
+
+ private String viewName;
+
+ public String getViewName() {
+ return viewName;
+ }
+
+ public void setViewName(String viewName) {
+ this.viewName = viewName;
+ }
+
+ @RequestMapping(value = { "/do_login_external" }, method = RequestMethod.POST)
+ public ModelAndView doexternalLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ return loginStrategy.doLogin(request, response);
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java
index 074311dc..c06e282a 100644
--- a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java
+++ b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java
@@ -38,16 +38,27 @@
package org.onap.portalapp.login;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.onap.portalsdk.core.auth.LoginStrategy;
+import org.onap.portalsdk.core.command.LoginBean;
+import org.onap.portalsdk.core.domain.RoleFunction;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.menu.MenuProperties;
import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.service.LoginService;
+import org.onap.portalsdk.core.service.RoleService;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
/**
@@ -58,13 +69,45 @@ public class LoginStrategyImpl extends LoginStrategy {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LoginStrategyImpl.class);
+ @Autowired
+ private RoleService roleService;
+
+ @Autowired
+ private LoginService loginService;
+
/**
* login for open source is same as external login in the non-open-source
* version.
*/
@Override
public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {
- return doExternalLogin(request, response);
+ invalidateExistingSession(request);
+
+ LoginBean commandBean = new LoginBean();
+ String loginId = request.getParameter("loginId");
+ String password = request.getParameter("password");
+ commandBean.setLoginId(loginId);
+ commandBean.setLoginPwd(password);
+ commandBean.setUserid(loginId);
+ commandBean = loginService.findUser(commandBean,
+ (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), new HashMap());
+ List<RoleFunction> roleFunctionList = roleService.getRoleFunctions(loginId);
+
+ if (commandBean.getUser() == null) {
+ String loginErrorMessage = (commandBean.getLoginErrorMessage() != null) ? commandBean.getLoginErrorMessage()
+ : "login.error.external.invalid";
+ Map<String, String> model = new HashMap<>();
+ model.put("error", loginErrorMessage);
+ return new ModelAndView("login_external", "model", model);
+ } else {
+ // store the currently logged in user's information in the session
+ UserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(),
+ commandBean.getBusinessDirectMenu(),
+ SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_BACKDOOR), roleFunctionList);
+ initateSessionMgtHandler(request);
+ // user has been authenticated, now take them to the welcome page
+ return new ModelAndView("redirect:welcome.htm");
+ }
}
@Override
diff --git a/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/jsp/login.jsp b/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/jsp/login.jsp
index a91a3a9b..6c30088a 100644
--- a/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/jsp/login.jsp
+++ b/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/jsp/login.jsp
@@ -100,7 +100,7 @@
<%=appDisplayName%>
</h2>
<br />
- <form action="login_external" method="POST">
+ <form action="do_login_external" method="POST">
<label for="loginId">Login ID:</label>
<input id="loginId" name="loginId" type="text" style="width: 140px;height:25px;border-radius:7px;font-size:18px;padding-left:5px;" maxlength="30">
<br/>
diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/InMemoryRestServer.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/InMemoryRestServer.java
index 2c37e214..beddc7e2 100644
--- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/InMemoryRestServer.java
+++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/InMemoryRestServer.java
@@ -1,20 +1,39 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+/*
+ * ============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
- *
- * https://github.com/mp911de/rest-api-test
- *
- * Embedded InMemory REST server for RESTEasy. Usage:
- * <ul>
- * <li>InMemoryRestServer srv = InMemoryRestServer.create(...) passing your resources and provider classes</li>
- * <li>srv.baseUri() for BaseUrl</li>
- * <li>srv.newRequest("/relative/resource/path") to issue requests</li>
- * <li>srv.close() to stop</li>
- * </ul>
*
+ * 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.portalsdk.fw.test;