diff options
| author | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
|---|---|---|
| committer | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
| commit | 8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch) | |
| tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/java/security/AccessControlContext.java | |
| parent | 02e549bfaaec38f68307e7f34e46ea57ea1809af (diff) | |
| download | gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.gz | |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
From-SVN: r107049
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; + } } |
