2 * The Shibboleth License, Version 1.
4 * University Corporation for Advanced Internet Development, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright notice, this
12 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution, if any, must include
17 * the following acknowledgment: "This product includes software developed by
18 * the University Corporation for Advanced Internet Development
19 * <http://www.ucaid.edu>Internet2 Project. Alternately, this acknowledegement
20 * may appear in the software itself, if and wherever such third-party
21 * acknowledgments normally appear.
23 * Neither the name of Shibboleth nor the names of its contributors, nor
24 * Internet2, nor the University Corporation for Advanced Internet Development,
25 * Inc., nor UCAID may be used to endorse or promote products derived from this
26 * software without specific prior written permission. For written permission,
27 * please contact shibboleth@shibboleth.org
29 * Products derived from this software may not be called Shibboleth, Internet2,
30 * UCAID, or the University Corporation for Advanced Internet Development, nor
31 * may Shibboleth appear in their name, without prior written permission of the
32 * University Corporation for Advanced Internet Development.
35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36 * AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
38 * PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED AND THE ENTIRE RISK
39 * OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE.
40 * IN NO EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY
41 * CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC. BE LIABLE FOR ANY DIRECT,
42 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 package edu.internet2.middleware.shibboleth.aa;
53 * Attribute Authority & Release Policy
54 * Resource (or URL) node in the ARP tree.
56 * @author Parviz Dousti (dousti@cmu.edu)
63 import java.security.acl.*;
65 public class ArpResource extends ArpCore implements Serializable{
67 static final long serialVersionUID = 1L;
70 protected String name;
71 protected String comment;
74 protected TName tName;
75 protected Vector attributes;
79 public ArpResource(String name) throws NotOwnerException{
81 tName = new TName(name);
82 attributes = new Vector();
83 makeAcl("resourceAcl");
86 public ArpResource(String name, String comment) throws NotOwnerException{
88 this.comment = comment;
93 public String toString() {
94 return name+" ["+tName+"]";
98 public boolean addAnAttribute(String name, boolean exclude)
99 throws AAPermissionException{
101 if(attributes.contains(new ArpAttribute(name, exclude)))
102 return false; // already there
103 if(! insertPermitted())
104 throw new AAPermissionException("No INSERT right for "+getCaller());
105 attributes.add(new ArpAttribute(name, exclude));
109 public boolean addAnAttribute(ArpAttribute attr)
110 throws AAPermissionException{
111 return addAnAttribute(attr, false);
115 * Adds the given attribute to the attributes for this Resource.
116 * if force flag is true and attribute already exists
117 * then replaces the existing reource otherwise leaves the existing
118 * attribute untouched.
119 * returns false if reource already existed.
121 public boolean addAnAttribute(ArpAttribute attr, boolean force)
122 throws AAPermissionException {
124 if(attributes.contains(attr)){
126 if(! replacePermitted())
127 throw new AAPermissionException("No replace right for "+getCaller());
128 attributes.remove(attr);
129 attributes.add(attr);
131 return false; // already there
133 if(! insertPermitted())
134 throw new AAPermissionException("No INSERT right for "+getCaller());
135 attributes.add(attr);
139 public boolean removeAnAttribute(String name)
140 throws AAPermissionException {
142 if(attributes.contains(new ArpAttribute(name, false))){
143 if(! insertPermitted())
144 throw new AAPermissionException("No DELETE right for "+getCaller());
145 attributes.remove(new ArpAttribute(name, false));
148 return false; // not found
151 public ArpAttribute getAttribute(String name) {
152 Enumeration en = attributes.elements();
153 while(en.hasMoreElements()){
154 ArpAttribute aAttribute = (ArpAttribute)en.nextElement();
155 if(aAttribute.getName().equals(name))
161 public ArpAttribute[] getAttributes() {
162 int len = attributes.size();
163 ArpAttribute[] a = new ArpAttribute[len];
164 for(int i = 0; i < len; i++)
165 a[i] = (ArpAttribute)attributes.get(i);
170 public int fit(String resrcName) {
171 TName tn = new TName(resrcName);
172 return tName.compare(tn);
175 public TName getTName(){
179 public String getName(){
183 public String getComment(){
187 public void setComment(String s){
191 public boolean equals(Object rsrc){
192 return name.equals(((ArpResource)rsrc).getName());
195 } /* end class ArpResource */