[PATCH] SecurityManager compatibility patch

Jukka Santala jsantala at tml.hut.fi
Thu Aug 2 02:37:20 PDT 2001


This is a fairly straightforward patch to make the default SecurityManager
returned through System.getSecurityManager() to == null. This is
apparently the correct behaviour for compliant classlibs; SecurityManager
is only set by default for applets, and some Java programs will think
they're being ran as applets if they find SecurityManager set, acting
weirdly or refusing to run altogether.

Kaffe's NullSecurityManager permits everything anyway, this makes no
change in security semantics, but allows stuff like JMF 2.1.1 to at least
run. The only non-straightforward change is the mechanism in
Class.getStackClass(), since it's not apparent what should happen if
SecurityManager isn't set. This patch follows the prior behaviour, and
calls defaultSecurityManager's method.

 -Donwulff
-------------- next part --------------
Index: libraries/javalib/java/awt/AWTEvent.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/AWTEvent.java,v
retrieving revision 1.10
diff -u -r1.10 AWTEvent.java
--- libraries/javalib/java/awt/AWTEvent.java	1999/07/24 00:56:10	1.10
+++ libraries/javalib/java/awt/AWTEvent.java	2001/08/02 09:26:44
@@ -161,7 +161,9 @@
 		if ( Defaults.AutoStop ) {
 			// give the SecurityManager a chance to step in before
 			// closing down the Toolkit
-			System.getSecurityManager().checkExit( 0);
+			SecurityManager sm = System.getSecurityManager();
+			if(sm != null)
+				sm.checkExit( 0);
 		
 			Toolkit.terminate();
 			System.exit( 0); // not strictly required (if there are no persistent daemons)
Index: libraries/javalib/java/awt/Window.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/Window.java,v
retrieving revision 1.12
diff -u -r1.12 Window.java
--- libraries/javalib/java/awt/Window.java	1999/10/12 02:29:41	1.12
+++ libraries/javalib/java/awt/Window.java	2001/08/02 09:26:44
@@ -172,10 +172,11 @@
 }
 
 final public String getWarningString() {

-	if (System.getSecurityManager().checkTopLevelWindow(this) == true) {

-		return (null);

-	}

-	return (System.getProperty("awt.appletWarning"));

+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		if (sm.checkTopLevelWindow(this) != true)
+			return (System.getProperty("awt.appletWarning"));

+	return (null);
 }
 
 public void hide() {

Index: libraries/javalib/java/awt/win32/Window.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/win32/Window.java,v
retrieving revision 1.2
diff -u -r1.2 Window.java
--- libraries/javalib/java/awt/win32/Window.java	1999/10/12 02:29:45	1.2
+++ libraries/javalib/java/awt/win32/Window.java	2001/08/02 09:26:44
@@ -141,10 +141,11 @@
 }
 
 final public String getWarningString() {
-	if (System.getSecurityManager().checkTopLevelWindow(this) == true) {
-		return (null);
-	}
-	return (System.getProperty("awt.appletWarning"));
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		if (sm.checkTopLevelWindow(this) != true)
+			return (System.getProperty("awt.appletWarning"));
+	return (null);
 }
 
 public boolean isShowing () {
Index: libraries/javalib/java/beans/Beans.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/beans/Beans.java,v
retrieving revision 1.3
diff -u -r1.3 Beans.java
--- libraries/javalib/java/beans/Beans.java	1999/10/14 19:22:11	1.3
+++ libraries/javalib/java/beans/Beans.java	2001/08/02 09:26:44
@@ -65,12 +65,16 @@
 }
 
 public static void setDesignTime(boolean isDesignTime) throws SecurityException {
-	// System.getSecurityManager().check???
+	// SecurityManager sm = System.getSecurityManager();
+	// if(sm != null)
+	// 	sm.check???
 	designtime = isDesignTime;
 }
 
 public static void setGuiAvailable(boolean isGuiAvailable) throws SecurityException {
-	// System.getSecurityManager().check???
+	// SecurityManager sm = System.getSecurityManager();
+	// if(sm != null)
+	// 	sm.check???
 	guiavailable = isGuiAvailable;
 }
 
Index: libraries/javalib/java/io/File.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/io/File.java,v
retrieving revision 1.26
diff -u -r1.26 File.java
--- libraries/javalib/java/io/File.java	2000/05/19 02:03:12	1.26
+++ libraries/javalib/java/io/File.java	2001/08/02 09:26:44
@@ -85,11 +85,15 @@
 native private boolean canWrite0();
 
 private void checkReadAccess() {
-	System.getSecurityManager().checkRead(getPath());
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkRead(getPath());
 }
 
 private void checkWriteAccess() {
-	System.getSecurityManager().checkWrite(getPath());
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkWrite(getPath());
 }
 
 public static File createTempFile(String prefix, String suffix)
@@ -119,7 +123,9 @@
 }
 
 public boolean delete() {
-	System.getSecurityManager().checkDelete(getPath());
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkDelete(getPath());
 
 	return isDirectory0() ? rmdir0() : delete0();
 }
@@ -341,8 +347,11 @@
 }
 
 public boolean renameTo(File dest) {
-	System.getSecurityManager().checkWrite(getPath());
-	System.getSecurityManager().checkWrite(dest.getPath());
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null) {
+		sm.checkWrite(getPath());
+		sm.checkWrite(dest.getPath());
+	}
 
 	return renameTo0(dest);
 }
Index: libraries/javalib/java/io/FileInputStream.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/io/FileInputStream.java,v
retrieving revision 1.9
diff -u -r1.9 FileInputStream.java
--- libraries/javalib/java/io/FileInputStream.java	1999/11/08 22:16:44	1.9
+++ libraries/javalib/java/io/FileInputStream.java	2001/08/02 09:26:44
@@ -26,12 +26,16 @@
 }
 
 public FileInputStream(FileDescriptor fdObj) {
-	System.getSecurityManager().checkRead(fdObj);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkRead(fdObj);
 	fd=fdObj;
 }
 
 public FileInputStream(String name) throws FileNotFoundException {
-	System.getSecurityManager().checkRead(name);		
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkRead(name);		
 	try {
 		open(name);
 	} catch (IOException e) {
Index: libraries/javalib/java/io/FileOutputStream.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/io/FileOutputStream.java,v
retrieving revision 1.5
diff -u -r1.5 FileOutputStream.java
--- libraries/javalib/java/io/FileOutputStream.java	1999/10/28 18:31:25	1.5
+++ libraries/javalib/java/io/FileOutputStream.java	2001/08/02 09:26:44
@@ -28,7 +28,9 @@
 
 public FileOutputStream(FileDescriptor fdObj)
 	{
-	System.getSecurityManager().checkWrite(fdObj);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkWrite(fdObj);
 	fd = fdObj;
 }
 
@@ -39,7 +41,9 @@
 
 public FileOutputStream(String name, boolean append) throws FileNotFoundException
 {
-	System.getSecurityManager().checkWrite(name);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkWrite(name);
 	if (append == false) {
 		open(name);		
 	}
Index: libraries/javalib/java/io/RandomAccessFile.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/io/RandomAccessFile.java,v
retrieving revision 1.15
diff -u -r1.15 RandomAccessFile.java
--- libraries/javalib/java/io/RandomAccessFile.java	1999/11/11 19:54:39	1.15
+++ libraries/javalib/java/io/RandomAccessFile.java	2001/08/02 09:26:44
@@ -29,9 +29,11 @@
 	else if (mode.equalsIgnoreCase("rw")) writable=true;
 	else throw new IllegalArgumentException();
 
-	System.getSecurityManager().checkRead(name);
-	if (writable) {
-		System.getSecurityManager().checkWrite(name);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null) {
+		sm.checkRead(name);
+		if (writable)
+			sm.checkWrite(name);
 	}
 
 	open(name, writable);
Index: libraries/javalib/java/lang/Class.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/Class.java,v
retrieving revision 1.28
diff -u -r1.28 Class.java
--- libraries/javalib/java/lang/Class.java	2001/04/21 19:03:56	1.28
+++ libraries/javalib/java/lang/Class.java	2001/08/02 09:26:44
@@ -118,7 +118,9 @@
 	Vector v = new Vector();
 	Class clazz = this;
 	while (clazz != null) {
-		System.getSecurityManager().checkMemberAccess(clazz, Member.PUBLIC);
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkMemberAccess(clazz, Member.PUBLIC);
 		Class[] classes = clazz.getClasses0(true);
 
 		for (int i = 0; i < classes.length; i++) {
@@ -138,7 +140,9 @@
 
 public Constructor getConstructor(Class parameterTypes[]) throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.PUBLIC);
 	return (getConstructor0(parameterTypes, false));
 }
 
@@ -146,7 +150,9 @@
 
 public Constructor[] getConstructors() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.PUBLIC);
 	return (getConstructors0(false));
 }
 
@@ -162,49 +168,65 @@
  */
 public Class[] getDeclaredClasses() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.DECLARED);
 	return (getClasses0(true));
 }
 
 public Constructor getDeclaredConstructor(Class parameterTypes[]) throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.DECLARED);
 	return (getConstructor0(parameterTypes, true));
 }
 
 public Constructor[] getDeclaredConstructors() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.DECLARED);
 	return (getConstructors0(true));
 }
 
 public Field getDeclaredField(String name) throws NoSuchFieldException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.DECLARED);
 	return (getField0(name, true));
 }
 
 public Field[] getDeclaredFields() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.DECLARED);
 	return (getFields0(true));
 }
 
 public Method getDeclaredMethod(String name, Class parameterTypes[]) throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.DECLARED);
 	return (getMethod0(name, parameterTypes, true));
 }
 
 public Method[] getDeclaredMethods() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.DECLARED);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.DECLARED);
 	return (getMethods0(true));
 }
 
 public Field getField(String name) throws NoSuchFieldException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.PUBLIC);
 	return (getField0(name, false));
 }
 
@@ -212,7 +234,9 @@
 
 public Field[] getFields() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.PUBLIC);
 	return (getFields0(false));
 }
 
@@ -222,7 +246,9 @@
 
 public Method getMethod(String name, Class parameterTypes[]) throws NoSuchMethodException, SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC );
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.PUBLIC );
 	return (getMethod0(name, parameterTypes, false));
 }
 
@@ -230,7 +256,9 @@
 
 public Method[] getMethods() throws SecurityException
 {
-	System.getSecurityManager().checkMemberAccess( this, Member.PUBLIC);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkMemberAccess( this, Member.PUBLIC);
 	return (getMethods0(false));
 }
 
@@ -327,7 +355,12 @@
  * Returns null if not found.
  */
 static Class getStackClass(int frame) {
-	Class[] classStack = System.getSecurityManager().getClassContext();
+	Class[] classStack;
+	SecurityManager sm = System.getSecurityManager();
+	if (sm != null)
+		classStack = sm.getClassContext();
+	else
+		classStack = System.defaultSecurityManager.getClassContext();
 	frame += 3;
 	if (frame >= 0 && frame < classStack.length)
 		return classStack[frame];
Index: libraries/javalib/java/lang/ClassLoader.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/ClassLoader.java,v
retrieving revision 1.22
diff -u -r1.22 ClassLoader.java
--- libraries/javalib/java/lang/ClassLoader.java	1999/12/13 09:21:47	1.22
+++ libraries/javalib/java/lang/ClassLoader.java	2001/08/02 09:26:44
@@ -51,7 +51,9 @@
 }
 
 protected ClassLoader(ClassLoader parent) {
-	System.getSecurityManager().checkCreateClassLoader();
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkCreateClassLoader();
 	this.parent = parent;
 }
 
Index: libraries/javalib/java/lang/Runtime.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/Runtime.java,v
retrieving revision 1.15
diff -u -r1.15 Runtime.java
--- libraries/javalib/java/lang/Runtime.java	2000/05/10 22:34:22	1.15
+++ libraries/javalib/java/lang/Runtime.java	2001/08/02 09:26:44
@@ -69,7 +69,9 @@
 
 public Process exec(String[] cmdarray, String[] envp, File dir)
 		throws IOException {
-	System.getSecurityManager().checkExec(cmdarray[0]);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkExec(cmdarray[0]);
 	return execInternal(cmdarray, envp, dir);
 }
 
@@ -77,7 +79,9 @@
 	throws IOException;
 
 public void exit(int status) {
-	System.getSecurityManager().checkExit(status);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkExit(status);
 	// Handle application extensions - if this thread is part of an
 	// application then we exit that rather than the whole thing.
 	if (kaffe.lang.Application.exit(status) == false) {
@@ -121,7 +125,9 @@
 }
 
 void loadLibrary(String libname, ClassLoader loader) {
-	System.getSecurityManager().checkLink(libname);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkLink(libname);
 	String errmsg = libname + ": not found";
 	String filename;
 	String[] names;
@@ -146,7 +152,9 @@
 }
 
 void load(String filename, ClassLoader loader) {
-	System.getSecurityManager().checkLink(filename);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkLink(filename);
 	new NativeLibrary(filename, loader);
 }
 
Index: libraries/javalib/java/lang/System.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/System.java,v
retrieving revision 1.21
diff -u -r1.21 System.java
--- libraries/javalib/java/lang/System.java	2001/04/13 00:35:34	1.21
+++ libraries/javalib/java/lang/System.java	2001/08/02 09:26:45
@@ -42,8 +42,6 @@
 static {
 	// XXX what are the constraints on the initialization order in here?
 
-	security = defaultSecurityManager;
-
 	props = initProperties(new Properties());
 	// Load any system properties from the system.properties resource
 	InputStream sin = ClassLoader.getSystemResourceAsStream("system.properties");
@@ -92,7 +90,9 @@
 	int src_position, Object dst, int dst_position, int length);
 
 private static void checkPropertyAccess() {
-	getSecurityManager().checkPropertiesAccess();
+	SecurityManager sm = getSecurityManager();
+	if(sm != null)
+		sm.checkPropertiesAccess();
 }
 
 native public static long currentTimeMillis();
@@ -193,7 +193,7 @@
 }
 
 public static void setSecurityManager(SecurityManager s) {
-	if (security != defaultSecurityManager) {
+	if (security != null) {
 		throw new SecurityException();
 	}
 	if (s != null) {
Index: libraries/javalib/java/lang/Thread.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/Thread.java,v
retrieving revision 1.34
diff -u -r1.34 Thread.java
--- libraries/javalib/java/lang/Thread.java	2000/06/21 07:05:08	1.34
+++ libraries/javalib/java/lang/Thread.java	2001/08/02 09:26:45
@@ -139,7 +139,9 @@
 }
 
 public void checkAccess() {
-	System.getSecurityManager().checkAccess(this);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkAccess(this);
 }
 
 native public int countStackFrames();
Index: libraries/javalib/java/lang/ThreadGroup.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/lang/ThreadGroup.java,v
retrieving revision 1.12
diff -u -r1.12 ThreadGroup.java
--- libraries/javalib/java/lang/ThreadGroup.java	2001/04/18 09:30:49	1.12
+++ libraries/javalib/java/lang/ThreadGroup.java	2001/08/02 09:26:45
@@ -108,7 +108,9 @@
 }
 
 final public void checkAccess() {
-	System.getSecurityManager().checkAccess(this);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkAccess(this);
 }
 
 final public synchronized void destroy() {
Index: libraries/javalib/java/net/DatagramSocket.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/net/DatagramSocket.java,v
retrieving revision 1.9
diff -u -r1.9 DatagramSocket.java
--- libraries/javalib/java/net/DatagramSocket.java	1999/10/15 04:23:41	1.9
+++ libraries/javalib/java/net/DatagramSocket.java	2001/08/02 09:26:45
@@ -32,7 +32,9 @@
 }
 
 public DatagramSocket(int port, InetAddress bindAddr) throws SocketException {
-	System.getSecurityManager().checkListen(port);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkListen(port);
 	if (bindAddr == null) {
 		bindAddr = InetAddress.getAnyAddress();
 	}
@@ -112,7 +114,9 @@
 		while (true) {
 			impl.receive(p);
 			if (this.address == null) {
-				System.getSecurityManager().checkAccept(
+				SecurityManager sm = System.getSecurityManager();
+				if(sm != null)
+					sm.checkAccept(
 				    p.getAddress().getHostName(), p.getPort());
 				break;
 			} else if (this.address.equals(p.getAddress())
@@ -146,9 +150,13 @@
 
 private void checkRemote(InetAddress addr, int port) {
 	if (addr.isMulticastAddress()) {
-		System.getSecurityManager().checkMulticast(addr);
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkMulticast(addr);
 	} else {
-		System.getSecurityManager().checkConnect(addr.getHostName(), port);
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkConnect(addr.getHostName(), port);
 	}
 }
 
Index: libraries/javalib/java/net/InetAddress.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/net/InetAddress.java,v
retrieving revision 1.8
diff -u -r1.8 InetAddress.java
--- libraries/javalib/java/net/InetAddress.java	1999/07/05 20:50:52	1.8
+++ libraries/javalib/java/net/InetAddress.java	2001/08/02 09:26:45
@@ -147,7 +147,9 @@
 public static InetAddress getLocalHost() throws UnknownHostException {
 	try {
 		String name = impl.getLocalHostName();
-		System.getSecurityManager().checkConnect(name, 0);
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkConnect(name, 0);
 		return (getByName(name));
 	}
 	catch (SecurityException se) {
Index: libraries/javalib/java/net/ServerSocket.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/net/ServerSocket.java,v
retrieving revision 1.10
diff -u -r1.10 ServerSocket.java
--- libraries/javalib/java/net/ServerSocket.java	2000/12/26 14:02:41	1.10
+++ libraries/javalib/java/net/ServerSocket.java	2001/08/02 09:26:45
@@ -43,7 +43,9 @@
  * @param bindAddr 	the local InetAddress the server will bind to
  */
 public ServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException {
-	System.getSecurityManager().checkListen(port);
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkListen(port);
 
 	if (bindAddr == null) {
 		bindAddr = InetAddress.getAnyAddress();
@@ -72,7 +74,9 @@
 
 protected final void implAccept(Socket s) throws IOException {
 	impl.accept(s.impl);
-	System.getSecurityManager().checkAccept(s.getInetAddress().getHostName(), s.getPort());
+	SecurityManager sm = System.getSecurityManager();
+	if(sm != null)
+		sm.checkAccept(s.getInetAddress().getHostName(), s.getPort());
 }
 
 public void close() throws IOException {
Index: libraries/javalib/java/net/URL.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/net/URL.java,v
retrieving revision 1.26
diff -u -r1.26 URL.java
--- libraries/javalib/java/net/URL.java	2000/06/13 14:31:53	1.26
+++ libraries/javalib/java/net/URL.java	2001/08/02 09:26:45
@@ -134,7 +134,9 @@
 
 	// User-supplied handler?
 	if (handler != null) {
-		System.getSecurityManager().checkPermission(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkPermission(
 		    new NetPermission("specifyStreamHandler"));
 		this.handler = handler;
 		return;
@@ -268,7 +270,9 @@
 
 public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory fac) {
 	if (factory == null) {
-		System.getSecurityManager().checkSetFactory();
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkSetFactory();
 		factory = fac;
 	}
 	else {
Index: libraries/javalib/java/security/Permission.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/Permission.java,v
retrieving revision 1.1
diff -u -r1.1 Permission.java
--- libraries/javalib/java/security/Permission.java	1999/07/22 02:12:05	1.1
+++ libraries/javalib/java/security/Permission.java	2001/08/02 09:26:45
@@ -25,7 +25,9 @@
 	}
 
 	public void checkGuard(Object object) throws SecurityException {
-		System.getSecurityManager().checkPermission(this);
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkPermission(this);
 	}
 
 	public abstract boolean implies(Permission permission);
Index: libraries/javalib/java/security/Provider.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/Provider.java,v
retrieving revision 1.1
diff -u -r1.1 Provider.java
--- libraries/javalib/java/security/Provider.java	1999/07/22 02:12:05	1.1
+++ libraries/javalib/java/security/Provider.java	2001/08/02 09:26:45
@@ -51,7 +51,9 @@
 	}
 
 	public void clear() {
-		System.getSecurityManager().checkSecurityAccess(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkSecurityAccess(
 			"clearProviderProperties." + name);
 		super.clear();
 	}
@@ -77,13 +79,17 @@
 	}
 
 	public Object put(Object key, Object value) {
-		System.getSecurityManager().checkSecurityAccess(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkSecurityAccess(
 			"putProviderProperty." + name);
 		return super.put(key, value);
 	}
 
 	public Object remove(Object key) {
-		System.getSecurityManager().checkSecurityAccess(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkSecurityAccess(
 			"removeProviderProperty." + name);
 		return super.remove(key);
 	}
Index: libraries/javalib/java/security/SecureClassLoader.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/SecureClassLoader.java,v
retrieving revision 1.1
diff -u -r1.1 SecureClassLoader.java
--- libraries/javalib/java/security/SecureClassLoader.java	1999/08/06 23:56:20	1.1
+++ libraries/javalib/java/security/SecureClassLoader.java	2001/08/02 09:26:45
@@ -19,7 +19,9 @@
 	private ClassLoader parent;
 
 	protected SecureClassLoader(ClassLoader parent) {
-		System.getSecurityManager().checkCreateClassLoader();
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkCreateClassLoader();
 		this.parent = parent;
 	}
 
Index: libraries/javalib/java/security/Security.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/security/Security.java,v
retrieving revision 1.6
diff -u -r1.6 Security.java
--- libraries/javalib/java/security/Security.java	1999/10/27 23:18:23	1.6
+++ libraries/javalib/java/security/Security.java	2001/08/02 09:26:45
@@ -96,7 +96,9 @@
 	}
 
 	public static int insertProviderAt(Provider provider, int position) {
-		System.getSecurityManager().checkSecurityAccess(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkSecurityAccess(
 		    "insertProvider." + provider.getName());
 		if (--position < 0) {
 			throw new IllegalArgumentException();
@@ -116,7 +118,9 @@
 	}
 
 	public static int addProvider(Provider provider) {
-		System.getSecurityManager().checkSecurityAccess(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkSecurityAccess(
 		    "insertProvider." + provider.getName());
 		synchronized (providers) {
 			if (findProvider(provider.getName()) >= 0) {
@@ -127,7 +131,9 @@
 	}
 
 	public static void removeProvider(String name) {
-		System.getSecurityManager().checkSecurityAccess(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkSecurityAccess(
 		    "removeProvider." + name);
 		synchronized (providers) {
 			int posn = findProvider(name);
@@ -156,7 +162,9 @@
 	}
 
 	public static String getProperty(String key) {
-		System.getSecurityManager().checkPermission(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkPermission(
 		    new SecurityPermission("getProperty." + key));
 		synchronized (props) {
 			return (String)props.get(key);
@@ -164,7 +172,9 @@
 	}
 
 	public static void setProperty(String key, String value) {
-		System.getSecurityManager().checkPermission(
+		SecurityManager sm = System.getSecurityManager();
+		if(sm != null)
+			sm.checkPermission(
 		    new SecurityPermission("setProperty." + key));
 		synchronized (props) {
 			props.put(key, value);


More information about the kaffe mailing list