[kaffe] PATCH: implement AccessController.getContext
Casey Marshall
csm at gnu.org
Sun May 30 07:10:03 PDT 2004
Hi.
Attached is a patch that attempts to implement AccessController, and
fixes a few inconsistencies in other classes along the way.
The relevant details of this patch include:
* The stack inspection is implemented in VMAccessController, which
simply has to provide three methods: pushing a privileged action
context, popping it off, and getting an AccessControlContext.
Fetching the actual stack is done in native code that works nearly
identically to ThreadStack.getClassStack, but returns the method
names alongside the classes. I couldn't find any existing code
that did what I wanted (and believe this class needs), so I had to
end up with some code duplication.
This VM* split seems somewhat superfluous to me, but maybe it is
worth it. A similar implementation for libgcj should be trivial to
write, and maybe for other VMs too.
* PrimordialClassLoader will set the default ProtectionDomain to one
that contains a single AllPermission object. I think this is the
right behavior, to allow "system" classes full permissions.
* Permission checking (with a PolicyFile enabled) will work for some
permission types, but other Permission objects have some clear
bugs that prevent proper checks. So far PropertyPermission and
RuntimePermission seem to work ok.
* There are some bugs in Classpath's security classes, some of which
are fixed here. I will propagate these back to Classpath.
* I wasn't entirely sure how to update the build system properly, so
the Makefile diffs may be wrong.
Comments welcome. Clearly this isn't a complete implementation of the
security architecture, but hopefully this is a start.
--
Casey Marshall || csm at gnu.org
-------------- next part --------------
2004-05-29 Casey Marshall <csm at gnu.org>
* include/Makefile.am: added java_security_VMAccessController.h.
* include/Makefile.in: updated.
* libraries/clib/native/AccessController.c: new file.
* libraries/clib/native/Makefile.am: add AccessController.c.
* libraries/clib/native/Makefile.in: updated.
* libraries/javalib/bootstrap.classlist: add java.security
classes.
* libraries/javalib/essential.files: add java.security classes.
* libraries/javalib/gnu/java/security/PolicyFile.java
(debug): don't check `DEBUG' here. Changed all calls to check
`DEBUG' before calling `debug'.
* libraries/javalib/java/lang/SecurityManager.java
(getSecurityContext): return AccessController.getContext().
(checkPermission): call AccessController.checkPermission().
(checkPermission(Permission,Object)): call checkPermission of
`context' if it is an AccessControlContext.
(checkRead): likewise.
(checkConnect): likewise.
* libraries/javalib/java/net/SocketPermission.java
(implies): check `actions' list properly.
* libraries/javalib/java/security/AccessControlContext.java:
Use Classpath's version as base.
(<init>): copy ProtectionDomains properly.
(checkPermission): only succeed if the permission is implied by
every domain in the list.
* libraries/javalib/java/security/AccessController.java:
Use Classpath's version as base.
(doPrivileged): call VMAccessController.pushContext and
VMAccessController.popContext if a context is supplied.
(getContext): implemented.
* libraries/javalib/java/security/IntersectingDomainCombiner.java:
new file.
* libraries/javalib/java/security/ProtectionDomain.java
(<init>): set statically bound to `true' in the two-argument
version.
* libraries/javalib/java/security/SecureClassLoader.java
Use Classpath's version as base.
(getPermissions): call `Policy.getCurrentPolicy' to bypass
security check.
* libraries/javalib/java/security/VMAccessController.java: new
file.
* libraries/javalib/java/util/PropertyPermissionCollection.java
(implies): avoid infinite loop.
* libraries/javalib/kaffe/lang/PrimordialClassLoader.java
(DEFAULT_PROTECTION_DOMAIN): set permissions to `AllPermissions'.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: access.patch
Type: text/x-patch
Size: 181362 bytes
Desc: not available
Url : http://pogo.kaffe.org/pipermail/kaffe/attachments/20040530/27582f87/access.bin
More information about the kaffe
mailing list