edu.internet2.middleware.grouper.ui.UiPermissions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grouper-ui Show documentation
Show all versions of grouper-ui Show documentation
Internet2 Groups Management User Interface
The newest version!
/*******************************************************************************
* Copyright 2012 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
/*
Copyright 2004-2007 University Corporation for Advanced Internet Development, Inc.
Copyright 2004-2007 The University Of Bristol
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package edu.internet2.middleware.grouper.ui;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import edu.internet2.middleware.grouper.Group;
import edu.internet2.middleware.grouper.GroupFinder;
import edu.internet2.middleware.grouper.GrouperHelper;
import edu.internet2.middleware.grouper.GrouperSession;
import edu.internet2.middleware.grouper.exception.GroupNotFoundException;
import edu.internet2.middleware.subject.Subject;
/**
* New in 1.2.1, a general means of specifying UI privileges. Initially implemented to allow
* selection of menu items, but hopefully will have wider application. Configured through
* resources/grouper/ui-permissions.xml (if present)
*
<ui-permissions>
<virtual-groups>
<virtual-group name="HighlyPrivileged">
<group name="qsuob:admins"/>
</virtual-group>
</virtual-groups>
<permissions>
<permission can="view" target="ManageGroups" if-member-of="HighlyPrivileged"
is="false"/>
</permissions>
</ui-permissions>
*
* if-member-of can be an actual group name. If using virtual groups, if-member-of evaluates to true
* if the current Subject is a member of any of the nested groups. In the example shown, members of qsuob:admins
* do not get the Manage Groups menu item. Manage Groups does not currently scale well for a Subject
* who has privileges over thousands of groups.
*
* NB. The format above is illustrative. In the case shown it is not necessary to use a virtual group.
* The following would have worked just as well:
*
<ui-permissions>
<permissions>
<permission can="view" target="ManageGroups" if-member-of="qsuob:admins"
is="false"/>
</permissions>
</ui-permissions>
*
*
*
*
*
* @author Gary Brown.
* @version $Id: UiPermissions.java,v 1.4 2009-08-12 04:52:14 mchyzer Exp $
*/
public class UiPermissions implements Serializable {
Map vGroups = new HashMap();
Map targets = new HashMap();
public UiPermissions(GrouperSession s,Document doc) {
NodeList nl = doc.getElementsByTagName("virtual-group");
Element el;
VirtualGroup vGroup = null;
String group;
NodeList groups;
Element elGroup;
for(int i=0;i