210 * Initialize a ExecPermission object. Common to all constructors. 211 * Also called during de-serialization. 212 */ 213 private void init(String path) { 214 this.fp = new FilePermission(path, "execute"); 215 } 216 217 /** 218 * A ExecPermissionCollection stores a collection 219 * of ExecPermission permissions. ExecPermission objects 220 * must be stored in a manner that allows them to be inserted in any 221 * order, but enable the implies function to evaluate the implies 222 * method in an efficient (and consistent) manner. 223 * 224 * @serial include 225 */ 226 private static class ExecPermissionCollection 227 extends PermissionCollection 228 implements java.io.Serializable 229 { 230 private Vector permissions; 231 232 private static final long serialVersionUID = -3352558508888368273L; 233 234 /** 235 * Create an empty ExecPermissionCollection. 236 */ 237 public ExecPermissionCollection() { 238 permissions = new Vector(); 239 } 240 241 /** 242 * Adds a permission to the collection. 243 * 244 * @param permission the Permission object to add. 245 * 246 * @exception IllegalArgumentException - if the permission is not a 247 * ExecPermission 248 * 249 * @exception SecurityException - if this ExecPermissionCollection 250 * object has been marked readonly 251 */ 252 public void add(Permission permission) 253 { 254 if (! (permission instanceof ExecPermission)) 255 throw new IllegalArgumentException("invalid permission: "+ 256 permission); 257 if (isReadOnly()) 258 throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection"); 259 260 permissions.addElement(permission); 261 } 262 263 /** 264 * Check and see if this set of permissions implies the permissions 265 * expressed in "permission". 266 * 267 * @param p the Permission object to compare 268 * 269 * @return true if "permission" is a proper subset of a permission in 270 * the set, false if not. 271 */ 272 public boolean implies(Permission permission) 273 { 274 if (! (permission instanceof ExecPermission)) 275 return false; 276 277 Enumeration e = permissions.elements(); 278 279 while (e.hasMoreElements()) { 280 ExecPermission x = (ExecPermission) e.nextElement(); 281 if (x.implies(permission)) { 282 return true; 283 } 284 } 285 return false; 286 } 287 288 /** 289 * Returns an enumeration of all the ExecPermission objects in the 290 * container. 291 * 292 * @return an enumeration of all the ExecPermission objects. 293 */ 294 public Enumeration elements() 295 { 296 return permissions.elements(); 297 } 298 } 299 } | 210 * Initialize a ExecPermission object. Common to all constructors. 211 * Also called during de-serialization. 212 */ 213 private void init(String path) { 214 this.fp = new FilePermission(path, "execute"); 215 } 216 217 /** 218 * A ExecPermissionCollection stores a collection 219 * of ExecPermission permissions. ExecPermission objects 220 * must be stored in a manner that allows them to be inserted in any 221 * order, but enable the implies function to evaluate the implies 222 * method in an efficient (and consistent) manner. 223 * 224 * @serial include 225 */ 226 private static class ExecPermissionCollection 227 extends PermissionCollection 228 implements java.io.Serializable 229 { 230 private Vector<Permission> permissions; 231 232 private static final long serialVersionUID = -3352558508888368273L; 233 234 /** 235 * Create an empty ExecPermissionCollection. 236 */ 237 public ExecPermissionCollection() { 238 permissions = new Vector<Permission>(); 239 } 240 241 /** 242 * Adds a permission to the collection. 243 * 244 * @param permission the Permission object to add. 245 * 246 * @exception IllegalArgumentException - if the permission is not a 247 * ExecPermission 248 * 249 * @exception SecurityException - if this ExecPermissionCollection 250 * object has been marked readonly 251 */ 252 public void add(Permission permission) 253 { 254 if (! (permission instanceof ExecPermission)) 255 throw new IllegalArgumentException("invalid permission: "+ 256 permission); 257 if (isReadOnly()) 258 throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection"); 259 260 permissions.addElement(permission); 261 } 262 263 /** 264 * Check and see if this set of permissions implies the permissions 265 * expressed in "permission". 266 * 267 * @param p the Permission object to compare 268 * 269 * @return true if "permission" is a proper subset of a permission in 270 * the set, false if not. 271 */ 272 public boolean implies(Permission permission) 273 { 274 if (! (permission instanceof ExecPermission)) 275 return false; 276 277 Enumeration<Permission> e = permissions.elements(); 278 279 while (e.hasMoreElements()) { 280 ExecPermission x = (ExecPermission)e.nextElement(); 281 if (x.implies(permission)) { 282 return true; 283 } 284 } 285 return false; 286 } 287 288 /** 289 * Returns an enumeration of all the ExecPermission objects in the 290 * container. 291 * 292 * @return an enumeration of all the ExecPermission objects. 293 */ 294 public Enumeration<Permission> elements() 295 { 296 return permissions.elements(); 297 } 298 } 299 } |