1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.base.web;
17
18 import javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
21 import org.apache.log4j.Logger;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionForward;
24 import org.apache.struts.action.ActionMapping;
25 import org.apache.struts.action.ActionRedirect;
26 import org.kuali.hr.time.util.TKContext;
27 import org.kuali.hr.time.util.TKUser;
28 import org.kuali.hr.time.util.TkConstants;
29 import org.kuali.rice.kns.web.struts.action.KualiAction;
30 import org.kuali.rice.krad.UserSession;
31 import org.kuali.rice.krad.exception.AuthorizationException;
32 import org.kuali.rice.krad.util.GlobalVariables;
33
34 public class TkAction extends KualiAction {
35
36 private static final Logger LOG = Logger.getLogger(TkAction.class);
37
38
39 protected void checkTKAuthorization(ActionForm form, String methodToCall) throws AuthorizationException {
40 }
41
42 @Override
43 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
44 try {
45 String methodToCall = null;
46 if (form instanceof TkForm) {
47 methodToCall = ((TkForm)form).getMethodToCall();
48 }
49 checkTKAuthorization(form, methodToCall);
50 } catch (AuthorizationException e) {
51 LOG.error("User: " + TKContext.getPrincipalId() + " Target: " + TKContext.getTargetPrincipalId(), e);
52 return mapping.findForward("unauthorized");
53 }
54
55
56
57
58 return super.execute(mapping, form, request, response);
59 }
60
61 public ActionForward userLogout(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
62 TKContext.clear();
63 request.getSession().invalidate();
64 ActionRedirect redirect = new ActionRedirect();
65 redirect.setPath("portal.do");
66 return redirect;
67 }
68
69 }