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 org.kuali.kfs.authorization;
17:
18: import javax.servlet.http.HttpServletRequest;
19:
20: import org.kuali.bus.auth.AuthorizationService;
21: import org.kuali.core.bo.user.UniversalUser;
22: import org.kuali.core.exceptions.UserNotFoundException;
23: import org.kuali.core.service.UniversalUserService;
24: import org.kuali.core.service.WebAuthenticationService;
25: import org.kuali.kfs.KFSConstants;
26: import org.kuali.kfs.context.SpringContext;
27: import org.kuali.kfs.service.ParameterService;
28: import org.kuali.kfs.service.impl.ParameterConstants;
29:
30: public class ServiceBusAuthorizationService implements
31: AuthorizationService {
32: private ParameterService parameterService;
33:
34: public boolean isAdministrator(HttpServletRequest request) {
35: String networkId = SpringContext.getBean(
36: WebAuthenticationService.class).getNetworkId(request);
37: try {
38: UniversalUser user = SpringContext.getBean(
39: UniversalUserService.class)
40: .getUniversalUserByAuthenticationUserId(networkId);
41: return user
42: .isMember(getParameterService()
43: .getParameterValue(
44: ParameterConstants.FINANCIAL_SYSTEM_ALL.class,
45: KFSConstants.CoreApcParms.SERVICE_BUS_ACCESS_GROUP_PARM));
46: } catch (UserNotFoundException e) {
47: throw new RuntimeException("Failed to fetch user "
48: + networkId, e);
49: }
50: }
51:
52: private ParameterService getParameterService() {
53: if (parameterService == null) {
54: parameterService = SpringContext
55: .getBean(ParameterService.class);
56: }
57: return parameterService;
58: }
59: }
|