001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: /*
017: * Created on Sep 22, 2004
018: *
019: */
020: package org.kuali.module.pdp.service.impl;
021:
022: import java.util.Iterator;
023: import java.util.List;
024:
025: import org.kuali.core.bo.user.KualiGroup;
026: import org.kuali.core.service.KualiConfigurationService;
027: import org.kuali.core.service.KualiGroupService;
028: import org.kuali.module.pdp.PdpConstants;
029: import org.kuali.module.pdp.bo.PdpUser;
030: import org.kuali.module.pdp.service.PdpSecurityService;
031: import org.kuali.module.pdp.service.SecurityRecord;
032: import org.springframework.transaction.annotation.Transactional;
033:
034: /**
035: * @author jsissom
036: */
037: @Transactional
038: public class PdpSecurityServiceImpl implements PdpSecurityService {
039: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
040: .getLogger(PdpSecurityServiceImpl.class);
041:
042: private KualiGroupService groupService;
043: private KualiConfigurationService kualiConfigurationService;
044:
045: public PdpSecurityServiceImpl() {
046: super ();
047: }
048:
049: public void setKualiConfigurationService(
050: KualiConfigurationService kcs) {
051: this .kualiConfigurationService = kcs;
052: }
053:
054: public void setKualiGroupService(KualiGroupService gs) {
055: groupService = gs;
056: }
057:
058: public SecurityRecord getSecurityRecord(PdpUser user) {
059: LOG.debug("getSecurityRecord() started");
060:
061: List groups = groupService.getUsersGroups(user
062: .getUniversalUser());
063:
064: // All of these group names are names in the application settings table.
065: SecurityRecord sr = new SecurityRecord();
066: sr.setCancelRole(groupMember(groups,
067: PdpConstants.Groups.CANCEL_GROUP));
068: sr.setHoldRole(groupMember(groups,
069: PdpConstants.Groups.HOLD_GROUP));
070: sr.setLimitedViewRole(groupMember(groups,
071: PdpConstants.Groups.LIMITEDVIEW_GROUP));
072: sr.setProcessRole(groupMember(groups,
073: PdpConstants.Groups.PROCESS_GROUP));
074: sr.setRangesRole(groupMember(groups,
075: PdpConstants.Groups.RANGES_GROUP));
076: sr.setSubmitRole(groupMember(groups,
077: PdpConstants.Groups.SUBMIT_GROUP));
078: sr.setSysAdminRole(groupMember(groups,
079: PdpConstants.Groups.SYSADMIN_GROUP));
080: sr.setTaxHoldersRole(groupMember(groups,
081: PdpConstants.Groups.TAXHOLDERS_GROUP));
082: sr.setViewAllRole(groupMember(groups,
083: PdpConstants.Groups.VIEWALL_GROUP));
084: sr.setViewIdRole(groupMember(groups,
085: PdpConstants.Groups.VIEWID_GROUP));
086: sr.setViewBankRole(groupMember(groups,
087: PdpConstants.Groups.VIEWBANK_GROUP));
088:
089: return sr;
090: }
091:
092: private boolean groupMember(List groups, String groupName) {
093: for (Iterator iter = groups.iterator(); iter.hasNext();) {
094: KualiGroup element = (KualiGroup) iter.next();
095: if (element.getGroupName().equals(groupName)) {
096: return true;
097: }
098: }
099:
100: return false;
101: }
102: }
|