aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/security/Permissions.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/security/Permissions.java')
-rw-r--r--libjava/java/security/Permissions.java113
1 files changed, 61 insertions, 52 deletions
diff --git a/libjava/java/security/Permissions.java b/libjava/java/security/Permissions.java
index d44341c947a..b603dedcf86 100644
--- a/libjava/java/security/Permissions.java
+++ b/libjava/java/security/Permissions.java
@@ -1,5 +1,5 @@
/* Permissions.java -- a collection of permission collections
- Copyright (C) 1998, 2001, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,8 +53,8 @@ import java.util.NoSuchElementException;
* collection type which stores its permissions in a hash table will be
* used.
*
- * @author Aaron M. Renn <arenn@urbanophile.com>
- * @author Eric Blake <ebb9@email.byu.edu>
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Eric Blake (ebb9@email.byu.edu)
* @since 1.1
*/
public final class Permissions extends PermissionCollection
@@ -188,58 +188,67 @@ public final class Permissions extends PermissionCollection
}
};
}
-} // class Permissions
-
-/**
- * Implements the permission collection for all permissions without one of
- * their own, and obeys serialization of JDK.
- *
- * @author Eric Blake <ebb9@email.byu.edu>
- */
-class PermissionsHash extends PermissionCollection
-{
- /**
- * Compatible with JDK 1.1+.
- */
- private static final long serialVersionUID = -8491988220802933440L;
-
- /**
- * Hashtable where we store permissions.
- *
- * @serial the stored permissions, both as key and value
- */
- private final Hashtable perms = new Hashtable();
-
- /**
- * Add a permission. We don't need to check for read-only, as this
- * collection is never exposed outside of Permissions, which has already
- * done that check.
- *
- * @param perm the permission to add
- */
- public void add(Permission perm)
- {
- perms.put(perm, perm);
- }
-
- /**
- * Returns true if perm is in the collection.
- *
- * @param perm the permission to check
- * @return true if it is implied
- */
- public boolean implies(Permission perm)
- {
- return perms.get(perm) != null;
- }
/**
- * Return the elements.
+ * Implements the permission collection for all permissions without one of
+ * their own, and obeys serialization of JDK.
*
- * @return the elements
+ * @author Eric Blake (ebb9@email.byu.edu)
*/
- public Enumeration elements()
+ private static final class PermissionsHash extends PermissionCollection
{
- return perms.elements();
- }
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -8491988220802933440L;
+
+ /**
+ * Hashtable where we store permissions.
+ *
+ * @serial the stored permissions, both as key and value
+ */
+ private final Hashtable perms = new Hashtable();
+
+ /**
+ * Add a permission. We don't need to check for read-only, as this
+ * collection is never exposed outside of Permissions, which has already
+ * done that check.
+ *
+ * @param perm the permission to add
+ */
+ public void add(Permission perm)
+ {
+ perms.put(perm, perm);
+ }
+
+ /**
+ * Returns true if perm is in the collection.
+ *
+ * @param perm the permission to check
+ * @return true if it is implied
+ */
+ // FIXME: Should this method be synchronized?
+ public boolean implies(Permission perm)
+ {
+ Enumeration elements = elements();
+
+ while (elements.hasMoreElements())
+ {
+ Permission p = (Permission)elements.nextElement();
+ if (p.implies(perm))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return the elements.
+ *
+ * @return the elements
+ */
+ public Enumeration elements()
+ {
+ return perms.elements();
+ }
+ } // class PermissionsHash
} // class Permissions