From 7376425b24b3fbc1e37f46129143fdd152a3f8aa Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Sun, 15 Aug 2010 14:47:45 +0200 Subject: [PATCH] dummy SecurityManager and related classes added --- classpath/java/lang/SecurityManager.java | 30 +++++++++++++++++++ classpath/java/lang/System.java | 9 ++++++ classpath/java/security/AccessController.java | 6 +++- classpath/java/security/AllPermission.java | 8 ++++- classpath/java/security/BasicPermission.java | 19 ++++++++++++ classpath/java/security/Permission.java | 16 ++++++++++ .../java/security/SecurityPermission.java | 19 ++++++++++++ 7 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 classpath/java/lang/SecurityManager.java create mode 100644 classpath/java/security/BasicPermission.java create mode 100644 classpath/java/security/SecurityPermission.java diff --git a/classpath/java/lang/SecurityManager.java b/classpath/java/lang/SecurityManager.java new file mode 100644 index 0000000000..0b522c5bfb --- /dev/null +++ b/classpath/java/lang/SecurityManager.java @@ -0,0 +1,30 @@ +/* Copyright (c) 2010, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +package java.lang; + +import java.security.AccessController; +import java.security.Permission; +import java.security.SecurityPermission; + +public class SecurityManager { + + public SecurityManager() { + } + + public void checkPermission(Permission perm) { + AccessController.checkPermission(perm); + } + + public void checkSecurityAccess(String target) { + checkPermission(new SecurityPermission(target)); + } + +} diff --git a/classpath/java/lang/System.java b/classpath/java/lang/System.java index ac3ee11b3a..c060493e7c 100644 --- a/classpath/java/lang/System.java +++ b/classpath/java/lang/System.java @@ -22,6 +22,7 @@ import java.util.Properties; public abstract class System { private static Property properties; + private static SecurityManager securityManager; // static { // loadLibrary("natives"); // } @@ -118,6 +119,14 @@ public abstract class System { public static void exit(int code) { Runtime.getRuntime().exit(code); } + + public static SecurityManager getSecurityManager() { + return securityManager; + } + + public static void setSecurityManager(SecurityManager securityManager) { + System.securityManager = securityManager; + } private static class Property { public final String name; diff --git a/classpath/java/security/AccessController.java b/classpath/java/security/AccessController.java index 804dfe70a7..b219e450ae 100644 --- a/classpath/java/security/AccessController.java +++ b/classpath/java/security/AccessController.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, Avian Contributors +/* Copyright (c) 2008, 2010 Avian Contributors Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided @@ -21,5 +21,9 @@ public class AccessController { public static Object doPrivileged (PrivilegedAction action) { return action.run(); } + + public static void checkPermission(Permission perm) throws AccessControlException { + + } } diff --git a/classpath/java/security/AllPermission.java b/classpath/java/security/AllPermission.java index 6bc99d53e8..b35004f609 100644 --- a/classpath/java/security/AllPermission.java +++ b/classpath/java/security/AllPermission.java @@ -10,4 +10,10 @@ package java.security; -public class AllPermission extends Permission { } +public class AllPermission extends Permission { + public AllPermission() { + super(""); + } + + +} diff --git a/classpath/java/security/BasicPermission.java b/classpath/java/security/BasicPermission.java new file mode 100644 index 0000000000..756e70139d --- /dev/null +++ b/classpath/java/security/BasicPermission.java @@ -0,0 +1,19 @@ +/* Copyright (c) 2010, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +package java.security; + +public class BasicPermission extends Permission { + + public BasicPermission(String name) { + super(name); + } + +} diff --git a/classpath/java/security/Permission.java b/classpath/java/security/Permission.java index bc6c438e18..528795a127 100644 --- a/classpath/java/security/Permission.java +++ b/classpath/java/security/Permission.java @@ -11,6 +11,22 @@ package java.security; public abstract class Permission { + + protected String name; + + public Permission(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '['+name+']'; + } + public PermissionCollection newPermissionCollection() { return null; } diff --git a/classpath/java/security/SecurityPermission.java b/classpath/java/security/SecurityPermission.java new file mode 100644 index 0000000000..22660f6111 --- /dev/null +++ b/classpath/java/security/SecurityPermission.java @@ -0,0 +1,19 @@ +/* Copyright (c) 2010, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +package java.security; + +public class SecurityPermission extends BasicPermission { + + public SecurityPermission(String name) { + super(name); + } + +}