View Javadoc
1   /**
2    * Copyright 2011-2014 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.mobility.auth.controllers;
17  
18  import org.slf4j.Logger;
19  import org.slf4j.LoggerFactory;
20  import org.kuali.mobility.auth.service.AuthService;
21  import org.kuali.mobility.shared.Constants;
22  import org.springframework.stereotype.Controller;
23  import org.springframework.ui.Model;
24  import org.springframework.web.bind.annotation.PathVariable;
25  import org.springframework.web.bind.annotation.RequestMapping;
26  import org.springframework.web.bind.annotation.RequestMethod;
27  
28  import javax.annotation.Resource;
29  import javax.servlet.http.HttpServletRequest;
30  import java.util.Properties;
31  
32  /**
33   * Controller for Auth
34   * @author Kuali Mobility Team (mobility.collab@kuali.org)
35   * @since 3.2.0-SNAPSHOT
36   */
37  @Controller
38  @RequestMapping("/auth")
39  public class AuthControllerImpl {
40  
41  	/** 
42  	 * A reference to a Logger 
43  	 */
44  	private static final Logger LOG = LoggerFactory.getLogger( AuthControllerImpl.class );
45  
46  	@Resource(name="authService")
47  	private AuthService service;
48  
49      @Resource(name="kmeProperties")
50      private Properties kmeProperties;
51  
52      /**
53  	 * Controller to load the index page for this tool
54  	 */
55  	@RequestMapping(method = RequestMethod.GET)
56  	public String index(HttpServletRequest request, Model uiModel) {
57          String viewName = null;
58  
59          if( "3".equalsIgnoreCase( getKmeProperties().getProperty("kme.uiVersion","classic") ) ) {
60              viewName = "ui3/auth/index";
61          } else {
62              viewName = "auth/index";
63          }
64  
65          return viewName;
66  	}
67  
68      @RequestMapping(value="/templates/{key}")
69      public String getAngularTemplates(
70          @PathVariable("key") String key,
71                  HttpServletRequest request,
72          Model uiModel ) {
73          return "ui3/auth/templates/"+key;
74      }
75  
76      @RequestMapping(value = "/js/{key}.js")
77      public String getJavaScript(
78          @PathVariable("key") String key,
79          HttpServletRequest request,
80          Model uiModel) {
81          return "ui3/auth/js/"+key;
82      }
83  
84      @RequestMapping(value="logout")
85      public String logout(HttpServletRequest request, Model uiModel) {
86          return "ui3/auth/logout";
87      }
88  
89      @RequestMapping(value="logoutConfirm")
90      public String logoutConfirm(HttpServletRequest request, Model uiModel) {
91          request.getSession().setAttribute(Constants.KME_MOCK_USER_KEY, null);
92          request.getSession().setAttribute(Constants.KME_USER_KEY, null);
93          return "redirect:/home";
94      }
95  
96      /**
97  	 * Sets the reference to the <code>AuthService</code>
98  	 */
99  	public void setService(AuthService service) {
100 		this.service = service;
101 	}
102 
103     /**
104      * A reference to the <code>AuthService</code>
105      */
106     public AuthService getService() {
107         return service;
108     }
109 
110     public Properties getKmeProperties() {
111         return kmeProperties;
112     }
113 
114     public void setKmeProperties(Properties kmeProperties) {
115         this.kmeProperties = kmeProperties;
116     }
117 }