[PORTAL-7] Rebase
[portal.git] / ecomp-portal-BE-os / src / main / java / org / openecomp / portalapp / controller / ONAPLoginController.java
1 /*-\r
2  * ================================================================================\r
3  * ECOMP Portal SDK\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ================================================================================\r
19  */\r
20 package org.openecomp.portalapp.controller;\r
21 \r
22 import java.util.HashMap;\r
23 import java.util.Map;\r
24 \r
25 import javax.servlet.http.HttpServletRequest;\r
26 import javax.servlet.http.HttpServletResponse;\r
27 \r
28 import org.openecomp.portalsdk.core.auth.LoginStrategy;\r
29 import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;\r
30 import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler;\r
31 import org.openecomp.portalsdk.core.service.LoginService;\r
32 import org.openecomp.portalsdk.core.service.ProfileService;\r
33 import org.openecomp.portalsdk.core.web.support.AppUtils;\r
34 import org.springframework.beans.factory.annotation.Autowired;\r
35 import org.springframework.stereotype.Controller;\r
36 import org.springframework.web.bind.annotation.RequestMapping;\r
37 import org.springframework.web.bind.annotation.RequestMethod;\r
38 import org.springframework.web.servlet.ModelAndView;\r
39 \r
40 @Controller\r
41 @RequestMapping("/")\r
42 public class ONAPLoginController extends UnRestrictedBaseController {\r
43         @Autowired\r
44         ProfileService service;\r
45         @Autowired\r
46         private LoginService loginService;\r
47         @Autowired\r
48         private LoginStrategy loginStrategy;\r
49         String viewName;\r
50 \r
51         @RequestMapping(value = { "/doLogin" }, method = RequestMethod.GET)\r
52         public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {\r
53                 return loginStrategy.doLogin(request, response);\r
54         }\r
55 \r
56         public String getJessionId(HttpServletRequest request) {\r
57                 return request.getSession().getId();\r
58         }\r
59 \r
60         protected void initateSessionMgtHandler(HttpServletRequest request) {\r
61                 String jSessionId = getJessionId(request);\r
62                 PortalTimeoutHandler.sessionCreated(jSessionId, jSessionId, AppUtils.getSession(request));\r
63         }\r
64 \r
65         public String getViewName() {\r
66                 return viewName;\r
67         }\r
68 \r
69         public void setViewName(String viewName) {\r
70                 this.viewName = viewName;\r
71         }\r
72 \r
73         public LoginService getLoginService() {\r
74                 return loginService;\r
75         }\r
76 \r
77         public void setLoginService(LoginService loginService) {\r
78                 this.loginService = loginService;\r
79         }\r
80 \r
81 }\r