[PORTAL-7] Rebase
[portal.git] / ecomp-portal-BE-os / src / main / java / org / openecomp / portalapp / controller / ONAPWelcomeController.java
1 /*-
2  * ================================================================================
3  * ECOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 package org.openecomp.portalapp.controller;
21
22 import java.security.Principal;
23 import java.util.Set;
24
25 import javax.annotation.Resource;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28
29 import org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority;
30 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
31 import org.springframework.context.annotation.EnableAspectJAutoProxy;
32 import org.springframework.stereotype.Controller;
33 import org.springframework.ui.Model;
34 import org.springframework.web.bind.annotation.RequestMapping;
35 import org.springframework.web.bind.annotation.RequestMethod;
36 import org.springframework.web.servlet.ModelAndView;
37
38 @Controller
39 @RequestMapping("/")
40 @org.springframework.context.annotation.Configuration
41 @EnableAspectJAutoProxy
42 @EPAuditLog
43 public class ONAPWelcomeController extends EPRestrictedBaseController{
44         String viewName;
45                 
46         @RequestMapping(value = "/index.htm", method = RequestMethod.GET)
47     public String getIndexPage(HttpServletRequest request) {
48                 return "/index";
49     }
50         
51         @RequestMapping(value = {"/applicationsHome", "/dashboard", "/widgetsHome", "/kpidash*", "/admins", "/users", "/portalAdmins", "/applications", "/widgets", "/functionalMenu", "/contactUs", "/getAccess","/appCatalog" }, method = RequestMethod.GET)
52     public String getEcompSinglePage(HttpServletRequest request, HttpServletResponse response) {
53                 return "forward:/index.html";
54     }
55         
56         protected String getViewName() {
57                 return viewName;
58         }
59         
60         protected void setViewName(String viewName) {
61                 this.viewName = viewName;
62         }
63         
64         
65         @Resource(name = "namedAdmins")
66         private Set<SubjectIssuerGrantedAuthority> admins;
67         
68         @RequestMapping("/user")
69         public String user(Principal p) {
70                 return "oid-user";
71         }
72
73         @RequestMapping("/admin")
74         public String admin(Model model, Principal p) {
75
76                 model.addAttribute("admins", admins);
77
78                 return "oid-admin";
79         }
80         @RequestMapping("/oid-login")
81         public ModelAndView login(Principal p) {                
82                 return new ModelAndView("openIdLogin");
83         }       
84 }