01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package edu.sampleu.travel.rice;
17:
18: import javax.servlet.http.HttpServletRequest;
19:
20: import org.kuali.bus.auth.AuthorizationService;
21:
22: import edu.iu.uis.eden.KEWServiceLocator;
23: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
24: import edu.iu.uis.eden.web.session.UserSession;
25: import edu.iu.uis.eden.workgroup.GroupNameId;
26:
27: /**
28: * Implementation of the ksb AuthorizationService which returns true if the authenticated user is
29: * a member of WorkflowAdmin.
30: *
31: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
32: *
33: */
34: public class TravelAuthorizationService implements AuthorizationService {
35:
36: /**
37: * This overridden method ...
38: *
39: * @see org.kuali.bus.auth.AuthorizationService#isAdministrator()
40: */
41: public boolean isAdministrator(HttpServletRequest request) {
42: UserSession userSession = UserSession.getAuthenticatedUser();
43: if (userSession == null) {
44: throw new RuntimeException(
45: "Could not determine authenticated user. UserSession was null.");
46: }
47: if (userSession.getWorkflowUser() == null) {
48: throw new RuntimeException(
49: "Could not determine authenticated user. UserSession.getWorkflowUser was null.");
50: }
51: try {
52: return KEWServiceLocator.getWorkgroupService()
53: .isUserMemberOfGroup(
54: new GroupNameId("WorkflowAdmin"),
55: userSession.getWorkflowUser());
56: } catch (EdenUserNotFoundException e) {
57: throw new RuntimeException(e);
58: }
59: }
60:
61: }
|