source: trunk/src/gcc/libjava/java/security/UnresolvedPermission.java@ 192

Last change on this file since 192 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 6.4 KB
Line 
1/* UnresolvedPermission.java -- Placeholder for unresolved permissions.
2 Copyright (C) 1998, 2001 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38package java.security;
39
40import java.io.Serializable;
41// All uses of Certificate in this file refer to this class.
42import java.security.cert.Certificate;
43
44/**
45 * This class is used to hold instances of all permissions that cannot
46 * be resolved to available permission classes when the security
47 * <code>Policy</code> object is instantiated. This may happen when the
48 * necessary security class has not yet been downloaded from the network.
49 * <p>
50 * Instances of this class are re-resolved when <code>AccessController</code>
51 * check is done. At that time, a scan is made of all existing
52 * <code>UnresolvedPermission</code> objects and they are converted to
53 * objects of the appropriate permission type if the class for that type
54 * is then available.
55 *
56 * @version 0.0
57 *
58 * @author Aaron M. Renn ([email protected])
59 */
60public final class UnresolvedPermission
61 extends Permission
62 implements Serializable
63{
64
65 /**
66 * The list of actions associated with this permission object
67 */
68 private String actions;
69
70 /**
71 * The list of <code>Certificates</code> associated with this object
72 */
73 private Certificate[] certs;
74
75 /**
76 * The name of the class this object should be resolved to.
77 */
78 private String type;
79
80 /**
81 * This method initializes a new instance of <code>UnresolvedPermission</code>
82 * with all the information necessary to resolve it to an instance of the
83 * proper class at a future time.
84 *
85 * @param type The name of the desired class this permission should be resolved to
86 * @param name The name of this permission
87 * @param actions The action list for this permission
88 * @param certs The list of certificates this permission's class was signed with
89 */
90 public UnresolvedPermission(String type, String name, String actions,
91 Certificate[] certs)
92 {
93 super(name);
94
95 this.type = type;
96 this.actions = actions;
97 this.certs = certs;
98 }
99
100 /**
101 * This method returns the list of actions associated with this
102 * permission.
103 *
104 * @return The action list
105 */
106 public String getActions()
107 {
108 return (actions);
109 }
110
111 /**
112 * This method returns <code>false</code> always to indicate that this
113 * permission does not imply the specified permission. An
114 * <code>UnresolvedPermission</code> never grants any permissions.
115 *
116 * @param perm The <code>Permission</code> object to test against - ignored by this class
117 *
118 * @return <code>false</code> to indicate this permission does not imply the specified permission.
119 */
120 public boolean implies(Permission perm)
121 {
122 return (false);
123 }
124
125 /**
126 * This method tests this permission for equality against the specified
127 * <code>Object</code>. This will be true if and only if the following
128 * conditions are met:
129 * <p>
130 * <ul>
131 * <li>The specified <code>Object</code> is an instance of
132 * <code>UnresolvedPermission</code>, or a subclass.
133 * <li>The specified permission has the same type (i.e., desired class name)
134 * as this permission.
135 * <li>The specified permission has the same name as this one.
136 * <li>The specified permissoin has the same action list as this one.
137 * <li>The specified permission has the same certificate list as this one.
138 * </ul>
139 *
140 * @param obj The <code>Object</code> to test for equality
141 *
142 * @return <code>true</code> if the specified object is equal to this one, <code>false</code> otherwise.
143 */
144 public boolean equals(Object obj)
145 {
146 if (!(obj instanceof UnresolvedPermission))
147 return (false);
148
149 UnresolvedPermission up = (UnresolvedPermission) obj;
150
151 if (!getName().equals(up.getName()))
152 return (false);
153
154 if (!getActions().equals(up.getActions()))
155 return (false);
156
157 if (!type.equals(up.type))
158 return (false);
159
160 if (!certs.equals(up.certs))
161 return (false);
162
163 return (true);
164 }
165
166 /**
167 * Returns a hash code value for this object.
168 *
169 * @return A hash value
170 */
171 public int hashCode()
172 {
173 return (System.identityHashCode(this));
174 }
175
176 /**
177 * This method returns a <code>String</code> representation of this
178 * class. The format is: '(unresolved "ClassName "name" "actions")'
179 *
180 * @return A <code>String</code> representation of this object
181 */
182 public String toString()
183 {
184 return "(unresolved " + type + " " + getName() + " " + getActions() + ")";
185 }
186
187 /**
188 * This class returns a <code>PermissionCollection</code> object that can
189 * be used to store instances of <code>UnresolvedPermission</code>. If
190 * <code>null</code> is returned, the caller is free to use any desired
191 * <code>PermissionCollection</code>.
192 *
193 * @return A new <code>PermissionCollection</code>.
194 */
195 public PermissionCollection newPermissionCollection()
196 {
197 return (null);
198 }
199}
Note: See TracBrowser for help on using the repository browser.