View Javadoc

1   /**
2    * Copyright 2005-2011 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.rice.krms.impl.authorization;
17  
18  import org.kuali.rice.kim.api.identity.Person;
19  import org.kuali.rice.krad.document.MaintenanceDocument;
20  import org.kuali.rice.krad.document.authorization.MaintenanceDocumentAuthorizer;
21  import org.kuali.rice.krad.document.authorization.DocumentAuthorizerBase;
22  import org.kuali.rice.krms.api.KrmsConstants;
23  import org.kuali.rice.krms.impl.repository.AgendaBo;
24  import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
25  import org.kuali.rice.krms.impl.ui.AgendaEditor;
26  
27  import java.util.HashSet;
28  import java.util.Set;
29  
30  public class AgendaEditorAuthorizer extends DocumentAuthorizerBase implements MaintenanceDocumentAuthorizer {
31  
32      @Override
33      public boolean canCreate(Class boClass, Person user) {
34          return getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, null);
35      }
36  
37      @Override
38      public boolean canMaintain(Object dataObject, Person user) {
39          AgendaEditor agendaEditor = (AgendaEditor) dataObject;
40          return getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agendaEditor.getAgenda().getContextId());
41      }
42  
43      @Override
44      public boolean canCreateOrMaintain(MaintenanceDocument maintenanceDocument, Person user) {
45          AgendaEditor agendaEditor = (AgendaEditor) maintenanceDocument.getOldMaintainableObject().getDataObject();
46          return getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agendaEditor.getAgenda().getContextId());
47      }
48  
49      @Override
50      public Set<String> getSecurePotentiallyReadOnlySectionIds() {
51          return new HashSet<String>();
52      }
53  
54      @Override
55      public Set<String> getSecurePotentiallyHiddenSectionIds() {
56          return new HashSet<String>();
57      }
58  
59      private AgendaAuthorizationService getAgendaAuthorizationService() {
60          return KrmsRepositoryServiceLocator.getAgendaAuthorizationService();
61      }
62  }