1 /** 2 * Copyright 2004-2013 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 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.hr.time.authorization; 17 18 import org.apache.commons.lang.StringUtils; 19 import org.kuali.hr.time.roles.UserRoles; 20 import org.kuali.hr.time.util.TKContext; 21 import org.kuali.hr.time.util.TKUser; 22 import org.kuali.hr.time.util.TkConstants; 23 24 public class AuthorizationValidationUtils { 25 26 /** 27 * Indicates whether or not the current user can wildcard the work area 28 * of the specified DepartmentalRule. 29 * 30 * @param dr The DepartmentalRule we are investigating. 31 * 32 * @return true if you can wildcard the WorkArea, false otherwise. 33 */ 34 public static boolean canWildcardWorkArea(DepartmentalRule dr) { 35 // Sysadmins and (Departmental OrgAdmins for their Department) 36 if (TKUser.isSystemAdmin()) 37 return true; 38 39 String dept = dr.getDept(); 40 if (StringUtils.equals(dept, TkConstants.WILDCARD_CHARACTER)) { 41 // Only system administrators can wildcard the work area if the 42 // department also has a wildcard. 43 return TKUser.isSystemAdmin(); 44 } else { 45 return TKUser.getDepartmentAdminAreas().contains(dept); 46 } 47 } 48 49 /** 50 * Can the current user use a wildcard for the department? 51 * 52 * @param dr The DepartmentalRule we are examining. 53 * 54 * @return true if so, false otherwise. 55 */ 56 public static boolean canWildcardDepartment(DepartmentalRule dr) { 57 return TKUser.isSystemAdmin(); 58 } 59 }