From 28f7d9d05ad70afad626d4bc54c633d31eb7430a Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Wed, 25 Apr 2001 16:45:15 +0100 Subject: decl.c (init_decl_processing): Add new class "protectionDomain" field. gcc/java: 2001-04-25 Bryce McKinlay * decl.c (init_decl_processing): Add new class "protectionDomain" field. * class.c (make_class_data): Set initial value for "protectionDomain". libjava: 2001-04-25 Bryce McKinlay java.security merge and ClassLoader compliance fixes. * java/lang/Class.h (Class): Include ProtectionDomain.h. New protectionDomain field. (forName): Add initialize parameter. Fixes declaration to comply with JDK spec. * java/lang/natClass.cc (forName): Correct declaration of the three-arg variant. Honour "initialize" flag. (getProtectionDomain0): New method. * java/lang/Class.java: Fix forName() declaration. (getPackage): New method based on Classpath implementation. (getProtectionDomain0): New native method decl. (getProtectionDomain): New method. * java/lang/ClassLoader.java (getParent): Now final. (definedPackages): New field. (getPackage): New. (defineClass): New variant with protectionDomain argument. (definePackage): New. (getPackages): New. (findSystemClass): Now final. (getSystemResourceAsStream): Remove redundant "final" modifier. (getSystemResource): Remove redundant "final" modifier. (getResources): Now final. (protectionDomainPermission): New static field. (unknownProtectionDomain): Ditto. (defaultProtectionDomain): Ditto. (getSystemClassLoader): Now non-native. * java/util/ResourceBundle.java (tryGetSomeBundle): Use the correct arguments for Class.forName(). * java/lang/Package.java: New file. * gnu/gcj/runtime/VMClassLoader.java (getVMClassLoader): Removed. (instance): Static initialize singleton. (findClass): Override this, not findSystemClass. * java/lang/natClassLoader.cc (defineClass0): Set class's protectionDomain field as specified. (getSystemClassLoader): Removed. (findClass): Renamed from findSystemClass. Call the interpreter via URLClassLoader.findClass if loading class via dlopen fails. * java/security/*.java: java.security import/merge with Classpath. * java/security/acl/*.java: Likewise. * java/security/interfaces/*.java: Likewise. * java/security/spec/*.java: Likewise. * java/net/NetPermission.java: Likewise. * java/net/SocketPermission.java: Likewise. * gnu/java/security/provider/DefaultPolicy.java: Likewise. * Makefile.am: Add new classes. * Makefile.in: Rebuilt. * gcj/javaprims.h: CNI namespace rebuild. From-SVN: r41543 --- libjava/java/security/PermissionCollection.java | 306 ++++++++++-------------- 1 file changed, 131 insertions(+), 175 deletions(-) (limited to 'libjava/java/security/PermissionCollection.java') diff --git a/libjava/java/security/PermissionCollection.java b/libjava/java/security/PermissionCollection.java index 08a9c49..f709a0a 100644 --- a/libjava/java/security/PermissionCollection.java +++ b/libjava/java/security/PermissionCollection.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -24,184 +24,140 @@ resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ - package java.security; import java.io.Serializable; import java.util.Enumeration; -/** - * This class models a group of Java permissions. It has convenient - * methods for determining whether or not a given permission is implied - * by any of the permissions in this collection. - *

- * Some care must be taken in storing permissions. First, a collection of - * the appropriate type must be created. This is done by calling the - * newPermissionCollection method on an object of the - * permission class you wish to add to the collection. If this method - * returns null, any type of PermissionCollection - * can be used to store permissions of that type. However, if a - * PermissionCollection collection object is returned, that - * type must be used. - *

- * The PermissionCollection's returned - * by the newPermissionCollection instance in a subclass of - * Permission is a homogeneous collection. It only will - * hold permissions of one specified type - instances of the class that - * created it. Not all PermissionCollection subclasses - * have to hold permissions of only one type however. For example, - * the Permissions class holds permissions of many types. - *

- * Since the newPermissionCollection in Permission - * itself returns null, by default a permission can be stored - * in any type of collection unless it overrides that method to create its - * own collection type. - * - * @version 0.0 - * - * @author Aaron M. Renn (arenn@urbanophile.com) - */ -public abstract class PermissionCollection extends Object implements Serializable -{ - -/*************************************************************************/ - -/* - * Class Variables - */ - -public static final String linesep = null; - -static -{ - String linesep = System.getProperty("line.separator"); - if (linesep == null); - linesep = "\n"; -} - -/*************************************************************************/ - -/* - * Instance Variables - */ - -/** - * Indicates whether or not this collection is read only. - */ -private boolean readOnly; - -/*************************************************************************/ - -/* - * Constructors - */ - -/** - * This method initializes a new instance of PermissionCollection. - * This is provided only as a default constructor and does nothing in this - * class. - */ -public -PermissionCollection() + /** + * This class models a group of Java permissions. It has convenient + * methods for determining whether or not a given permission is implied + * by any of the permissions in this collection. + *

+ * Some care must be taken in storing permissions. First, a collection of + * the appropriate type must be created. This is done by calling the + * newPermissionCollection method on an object of the + * permission class you wish to add to the collection. If this method + * returns null, any type of PermissionCollection + * can be used to store permissions of that type. However, if a + * PermissionCollection collection object is returned, that + * type must be used. + *

+ * The PermissionCollection's returned + * by the newPermissionCollection instance in a subclass of + * Permission is a homogeneous collection. It only will + * hold permissions of one specified type - instances of the class that + * created it. Not all PermissionCollection subclasses + * have to hold permissions of only one type however. For example, + * the Permissions class holds permissions of many types. + *

+ * Since the newPermissionCollection in Permission + * itself returns null, by default a permission can be stored + * in any type of collection unless it overrides that method to create its + * own collection type. + * + * @version 0.0 + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public abstract class PermissionCollection extends Object implements + Serializable { - ; + public static final String linesep = null; + + static + { + String linesep = System.getProperty("line.separator"); + if (linesep == null); + linesep = "\n"; + } + + /** + * Indicates whether or not this collection is read only. + */ + private boolean readOnly; + + /** + * This method initializes a new instance of PermissionCollection. + * This is provided only as a default constructor and does nothing in this + * class. + */ + public PermissionCollection() + { + } + + /** + * This method tests whether or not this PermissionCollection + * object is read only. + * + * @return true if this collection is read only, false otherwise + */ + public boolean isReadOnly() + { + return (readOnly); + } + + /** + * This method sets this PermissionCollection object to be + * read only. No further permissions can be added to it after calling this + * method. + */ + public void setReadOnly() + { + readOnly = true; + } + + /** + * This method adds a new Permission object to the collection. + * + * @param perm The Permission to add. + * + * @exception SecurityException If the collection is marked read only. + * @exception IllegalArgumentException If a permission of the specified type cannot be added + */ + public abstract void + add(Permission perm) throws SecurityException, IllegalArgumentException; + + /** + * This method returns an Enumeration of all the objects in + * this collection. + * + * @return An Enumeration of this collection's objects. + */ + public abstract Enumeration elements(); + + /** + * This method tests whether the specified Permission object is + * implied by this collection of Permission objects. + * + * @param perm The Permission object to test. + * + * @return true if the specified Permission is implied by this collection, false otherwise. + */ + public abstract boolean implies(Permission perm); + + /** + * This method returns a String representation of this + * collection. It will print the class name and has code in the same + * manner as Object.toString() then print a listing of all + * the Permission objects contained. + * + * @return A String representing this object. + */ + public String toString() + { + StringBuffer sb = new StringBuffer(""); + + sb.append(super.toString() + " (" + linesep); + Enumeration e = elements(); + while (e.hasMoreElements()) + { + Object obj = e.nextElement(); + if (obj instanceof Permission) + sb.append(((Permission) obj).toString() + linesep); + } + + sb.append(")" + linesep); + return (sb.toString()); + } } - -/*************************************************************************/ - -/* - * Instance Methods - */ - -/** - * This method tests whether or not this PermissionCollection - * object is read only. - * - * @return true if this collection is read only, false otherwise - */ -public boolean -isReadOnly() -{ - return(readOnly); -} - -/*************************************************************************/ - -/** - * This method sets this PermissionCollection object to be - * read only. No further permissions can be added to it after calling this - * method. - */ -public void -setReadOnly() -{ - readOnly = true; -} - -/*************************************************************************/ - -/** - * This method adds a new Permission object to the collection. - * - * @param perm The Permission to add. - * - * @exception SecurityException If the collection is marked read only. - * @exception IllegalArgumentException If a permission of the specified type cannot be added - */ -public abstract void -add(Permission perm) throws SecurityException, IllegalArgumentException; - -/*************************************************************************/ - -/** - * This method returns an Enumeration of all the objects in - * this collection. - * - * @return An Enumeration of this collection's objects. - */ -public abstract Enumeration -elements(); - -/*************************************************************************/ - -/** - * This method tests whether the specified Permission object is - * implied by this collection of Permission objects. - * - * @param perm The Permission object to test. - * - * @return true if the specified Permission is implied by this collection, false otherwise. - */ -public abstract boolean -implies(Permission perm); - -/*************************************************************************/ - -/** - * This method returns a String representation of this - * collection. It will print the class name and has code in the same - * manner as Object.toString() then print a listing of all - * the Permission objects contained. - * - * @return A String representing this object. - */ -public String -toString() -{ - StringBuffer sb = new StringBuffer(""); - - sb.append(super.toString() + " (" + linesep); - Enumeration e = elements(); - while (e.hasMoreElements()) - { - Object obj = e.nextElement(); - if (obj instanceof Permission) - sb.append(((Permission)obj).toString() + linesep); - } - - sb.append(")" + linesep); - return(sb.toString()); -} - -} // class PermissionCollection - -- cgit v1.1