diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
commit | 3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 (patch) | |
tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/java/security/AccessControlContext.java | |
parent | 7e55c49d7d91ef9f09e93c1100119b1ab3652446 (diff) | |
download | gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.tar.gz |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/security/AccessControlContext.java')
-rw-r--r-- | libjava/classpath/java/security/AccessControlContext.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/libjava/classpath/java/security/AccessControlContext.java b/libjava/classpath/java/security/AccessControlContext.java index 9a6ad208144..3b51e94125b 100644 --- a/libjava/classpath/java/security/AccessControlContext.java +++ b/libjava/classpath/java/security/AccessControlContext.java @@ -77,14 +77,23 @@ public final class AccessControlContext /** * Construct a new AccessControlContext with the specified - * ProtectionDomains and DomainCombiner + * {@link ProtectionDomain}s and {@link DomainCombiner}. * + * <p>Code calling this constructor must have a {@link + * SecurityPermission} of <i>createAccessControlContext</i>.</p> + * + * @throws SecurityException If the caller does not have permission + * to create an access control context. * @since 1.3 */ public AccessControlContext(AccessControlContext acc, DomainCombiner combiner) { - // XXX check permission to call this. + SecurityManager sm = System.getSecurityManager (); + if (sm != null) + { + sm.checkPermission (new SecurityPermission ("createAccessControlContext")); + } AccessControlContext acc2 = AccessController.getContext(); protectionDomains = combiner.combine (acc2.protectionDomains, acc.protectionDomains); @@ -119,10 +128,20 @@ public final class AccessControlContext public void checkPermission(Permission perm) throws AccessControlException { if (protectionDomains.length == 0) - throw new AccessControlException ("permission not granted"); + throw new AccessControlException ("permission " + + perm + + " not granted: no protection domains"); + for (int i = 0; i < protectionDomains.length; i++) - if (!protectionDomains[i].implies(perm)) - throw new AccessControlException ("permission not granted"); + { + final ProtectionDomain domain = protectionDomains[i]; + if (!domain.implies(perm)) + throw new AccessControlException ("permission " + + perm + + " not granted: " + + domain + + " does not imply it."); + } } /** @@ -173,4 +192,9 @@ public final class AccessControlContext return h; } + + ProtectionDomain[] getProtectionDomains () + { + return protectionDomains; + } } |