001 /**
002 * Copyright 2005-2012 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 */
016 package org.kuali.rice.krms.impl.authorization;
017
018 import org.kuali.rice.kim.api.permission.PermissionService;
019 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
020 import org.kuali.rice.krad.util.GlobalVariables;
021 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
022 import org.kuali.rice.krms.impl.repository.ContextBoService;
023 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
024
025 import java.util.HashMap;
026 import java.util.Map;
027
028 public class AgendaAuthorizationServiceImpl implements AgendaAuthorizationService {
029
030 static final String NAMESPACE_CODE = "namespaceCode";
031
032 @Override
033 public boolean isAuthorized(String permissionName, String contextId) {
034 String namespace = "";
035 if (contextId != null) {
036 ContextDefinition context = getContextBoService().getContextByContextId(contextId);
037 namespace = context.getNamespace();
038 }
039
040 Map qualification = new HashMap<String, String>();
041 boolean isAuthorized = getPermissionService().isAuthorized(
042 GlobalVariables.getUserSession().getPrincipalId(),
043 namespace,
044 permissionName,
045 qualification,
046 new HashMap<String, String>());
047 return isAuthorized;
048 }
049
050 /**
051 * return the contextBoService
052 */
053 private ContextBoService getContextBoService() {
054 return KrmsRepositoryServiceLocator.getContextBoService();
055 }
056
057 /**
058 * returns the permissionService
059 */
060 private PermissionService getPermissionService() {
061 return KimApiServiceLocator.getPermissionService();
062 }
063 }