001/** 002 * Copyright 2005-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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 */ 016package org.kuali.rice.krad.demo.uif.authorizer; 017 018import org.kuali.rice.kim.api.identity.Person; 019import org.kuali.rice.krad.inquiry.InquiryViewAuthorizerBase; 020import org.kuali.rice.krad.uif.container.Group; 021import org.kuali.rice.krad.uif.field.DataField; 022import org.kuali.rice.krad.uif.field.Field; 023import org.kuali.rice.krad.uif.view.View; 024import org.kuali.rice.krad.uif.view.ViewModel; 025 026/** 027 * The DemoInquiryViewAuthorizer is used to demonstrate the ability to to control the visibility 028 * and masking of sections and fields based on permission checks. 029 * 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033public class DemoInquiryViewAuthorizer extends InquiryViewAuthorizerBase { 034 035 @Override 036 public boolean canViewField(View view, ViewModel model, Field field, String propertyName, Person user) 037 { 038 //hide travel authorization number from admin 039 if(propertyName.equals("travelAuthorizationDocumentId") && 040 user.getPrincipalName().equals("admin")) { 041 return false; 042 } 043 044 return super.canViewField(view,model,field,propertyName,user); 045 } 046 047 @Override 048 public boolean canViewGroup(View view, ViewModel model, Group group, String groupId, Person user) { 049 050 //hide the estimates section if the user is admin 051 if(groupId.equals("TravelAccount-InquiryView-Costs") && 052 user.getPrincipalName().equals("admin")) { 053 return false; 054 } 055 056 return super.canViewGroup(view,model,group,groupId,user); 057 } 058 059 060 061 062 063}