decl.c (init_decl_processing): Add new class "protectionDomain" field.
gcc/java: 2001-04-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz> * 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 <bryce@albatross.co.nz> 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
This commit is contained in:
parent
744cfa53c3
commit
28f7d9d05a
115 changed files with 11887 additions and 1549 deletions
|
@ -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.
|
||||
* <p>
|
||||
* Some care must be taken in storing permissions. First, a collection of
|
||||
* the appropriate type must be created. This is done by calling the
|
||||
* <code>newPermissionCollection</code> method on an object of the
|
||||
* permission class you wish to add to the collection. If this method
|
||||
* returns <code>null</code>, any type of <code>PermissionCollection</code>
|
||||
* can be used to store permissions of that type. However, if a
|
||||
* <code>PermissionCollection</code> collection object is returned, that
|
||||
* type must be used.
|
||||
* <p>
|
||||
* The <code>PermissionCollection</code>'s returned
|
||||
* by the <code>newPermissionCollection</code> instance in a subclass of
|
||||
* <code>Permission</code> is a homogeneous collection. It only will
|
||||
* hold permissions of one specified type - instances of the class that
|
||||
* created it. Not all <code>PermissionCollection</code> subclasses
|
||||
* have to hold permissions of only one type however. For example,
|
||||
* the <code>Permissions</code> class holds permissions of many types.
|
||||
* <p>
|
||||
* Since the <code>newPermissionCollection</code> in <code>Permission</code>
|
||||
* itself returns <code>null</code>, 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
|
||||
/**
|
||||
* 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.
|
||||
* <p>
|
||||
* Some care must be taken in storing permissions. First, a collection of
|
||||
* the appropriate type must be created. This is done by calling the
|
||||
* <code>newPermissionCollection</code> method on an object of the
|
||||
* permission class you wish to add to the collection. If this method
|
||||
* returns <code>null</code>, any type of <code>PermissionCollection</code>
|
||||
* can be used to store permissions of that type. However, if a
|
||||
* <code>PermissionCollection</code> collection object is returned, that
|
||||
* type must be used.
|
||||
* <p>
|
||||
* The <code>PermissionCollection</code>'s returned
|
||||
* by the <code>newPermissionCollection</code> instance in a subclass of
|
||||
* <code>Permission</code> is a homogeneous collection. It only will
|
||||
* hold permissions of one specified type - instances of the class that
|
||||
* created it. Not all <code>PermissionCollection</code> subclasses
|
||||
* have to hold permissions of only one type however. For example,
|
||||
* the <code>Permissions</code> class holds permissions of many types.
|
||||
* <p>
|
||||
* Since the <code>newPermissionCollection</code> in <code>Permission</code>
|
||||
* itself returns <code>null</code>, 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";
|
||||
}
|
||||
|
||||
/*
|
||||
* Class Variables
|
||||
*/
|
||||
/**
|
||||
* Indicates whether or not this collection is read only.
|
||||
*/
|
||||
private boolean readOnly;
|
||||
|
||||
public static final String linesep = null;
|
||||
/**
|
||||
* This method initializes a new instance of <code>PermissionCollection</code>.
|
||||
* This is provided only as a default constructor and does nothing in this
|
||||
* class.
|
||||
*/
|
||||
public PermissionCollection()
|
||||
{
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
String linesep = System.getProperty("line.separator");
|
||||
if (linesep == null);
|
||||
linesep = "\n";
|
||||
/**
|
||||
* This method tests whether or not this <code>PermissionCollection</code>
|
||||
* object is read only.
|
||||
*
|
||||
* @return <code>true</code> if this collection is read only, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isReadOnly()
|
||||
{
|
||||
return (readOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets this <code>PermissionCollection</code> 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 <code>Permission</code> object to the collection.
|
||||
*
|
||||
* @param perm The <code>Permission</code> 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 <code>Enumeration</code> of all the objects in
|
||||
* this collection.
|
||||
*
|
||||
* @return An <code>Enumeration</code> of this collection's objects.
|
||||
*/
|
||||
public abstract Enumeration elements();
|
||||
|
||||
/**
|
||||
* This method tests whether the specified <code>Permission</code> object is
|
||||
* implied by this collection of <code>Permission</code> objects.
|
||||
*
|
||||
* @param perm The <code>Permission</code> object to test.
|
||||
*
|
||||
* @return <code>true</code> if the specified <code>Permission</code> is implied by this collection, <code>false</code> otherwise.
|
||||
*/
|
||||
public abstract boolean implies(Permission perm);
|
||||
|
||||
/**
|
||||
* This method returns a <code>String</code> representation of this
|
||||
* collection. It will print the class name and has code in the same
|
||||
* manner as <code>Object.toString()</code> then print a listing of all
|
||||
* the <code>Permission</code> objects contained.
|
||||
*
|
||||
* @return A <code>String</code> 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 Variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* Indicates whether or not this collection is read only.
|
||||
*/
|
||||
private boolean readOnly;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method initializes a new instance of <code>PermissionCollection</code>.
|
||||
* This is provided only as a default constructor and does nothing in this
|
||||
* class.
|
||||
*/
|
||||
public
|
||||
PermissionCollection()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method tests whether or not this <code>PermissionCollection</code>
|
||||
* object is read only.
|
||||
*
|
||||
* @return <code>true</code> if this collection is read only, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean
|
||||
isReadOnly()
|
||||
{
|
||||
return(readOnly);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method sets this <code>PermissionCollection</code> 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 <code>Permission</code> object to the collection.
|
||||
*
|
||||
* @param perm The <code>Permission</code> 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 <code>Enumeration</code> of all the objects in
|
||||
* this collection.
|
||||
*
|
||||
* @return An <code>Enumeration</code> of this collection's objects.
|
||||
*/
|
||||
public abstract Enumeration
|
||||
elements();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method tests whether the specified <code>Permission</code> object is
|
||||
* implied by this collection of <code>Permission</code> objects.
|
||||
*
|
||||
* @param perm The <code>Permission</code> object to test.
|
||||
*
|
||||
* @return <code>true</code> if the specified <code>Permission</code> is implied by this collection, <code>false</code> otherwise.
|
||||
*/
|
||||
public abstract boolean
|
||||
implies(Permission perm);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns a <code>String</code> representation of this
|
||||
* collection. It will print the class name and has code in the same
|
||||
* manner as <code>Object.toString()</code> then print a listing of all
|
||||
* the <code>Permission</code> objects contained.
|
||||
*
|
||||
* @return A <code>String</code> 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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue