Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 83659 invoked from network); 25 Jul 2004 00:57:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 25 Jul 2004 00:57:03 -0000 Received: (qmail 70233 invoked by uid 500); 25 Jul 2004 00:57:03 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 70139 invoked by uid 500); 25 Jul 2004 00:57:02 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@geronimo.apache.org Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 70125 invoked by uid 500); 25 Jul 2004 00:57:01 -0000 Delivered-To: apmail-incubator-geronimo-cvs@apache.org Received: (qmail 70122 invoked by uid 99); 25 Jul 2004 00:57:01 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Sat, 24 Jul 2004 17:57:01 -0700 Received: (qmail 83647 invoked by uid 1751); 25 Jul 2004 00:57:00 -0000 Date: 25 Jul 2004 00:57:00 -0000 Message-ID: <20040725005700.83646.qmail@minotaur.apache.org> From: adc@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/specs/j2ee-jacc/src/java/javax/security/jacc EJBMethodPermissionCollection.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N adc 2004/07/24 17:57:00 Modified: specs/j2ee-jacc/src/java/javax/security/jacc EJBMethodPermissionCollection.java Log: Changed WILDCARD to String. Revision Changes Path 1.4 +168 -148 incubator-geronimo/specs/j2ee-jacc/src/java/javax/security/jacc/EJBMethodPermissionCollection.java Index: EJBMethodPermissionCollection.java =================================================================== RCS file: /home/cvs/incubator-geronimo/specs/j2ee-jacc/src/java/javax/security/jacc/EJBMethodPermissionCollection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- EJBMethodPermissionCollection.java 10 Mar 2004 09:59:53 -0000 1.3 +++ EJBMethodPermissionCollection.java 25 Jul 2004 00:57:00 -0000 1.4 @@ -21,151 +21,171 @@ // DO NOT add / change / or delete method signatures! // -package javax.security.jacc; - -import java.security.PermissionCollection; -import java.security.Permission; -import java.util.LinkedList; -import java.util.HashMap; -import java.util.Enumeration; -import java.util.Collections; - - -/** - * - * @version $Revision$ $Date$ - */ -public final class EJBMethodPermissionCollection extends PermissionCollection { - - private LinkedList collection = new LinkedList(); - private HashMap permissions = new HashMap(); - private static final Object WILDCARD = new Object(); - - /** - * Adds a permission object to the current collection of permission objects. - * - * @param permission the Permission object to add. - * - * @exception SecurityException - if this PermissionCollection object - * has been marked readonly - */ - public void add(Permission permission) { - if (isReadOnly()) throw new IllegalArgumentException("Read only collection"); - - if (!(permission instanceof EJBMethodPermission)) throw new IllegalArgumentException("Wrong permission type"); - - if (collection.contains(permission)) return; - else collection.add(permission); - - EJBMethodPermission p = (EJBMethodPermission)permission; - EJBMethodPermission.MethodSpec spec = p.methodSpec; - Object test = permissions.get(p.getName()); - - if (test instanceof Boolean) return; - - if (spec.methodName == null && spec.methodInterface == null && spec.methodParams == null) { - permissions.put(p.getName(), new Boolean(true)); - return; - } - - HashMap methods = (HashMap)test; - if (methods == null) { - methods = new HashMap(); - permissions.put(p.getName(), methods); - } - - Object methodKey = (spec.methodName == null || spec.methodName.length() == 0? WILDCARD:spec.methodName); - HashMap interfaces = (HashMap)methods.get(methodKey); - if (interfaces == null) { - interfaces = new HashMap(); - methods.put(methodKey, interfaces); - } - - Object interfaceKey = (spec.methodInterface == null || spec.methodInterface.length() == 0? WILDCARD:spec.methodInterface); - HashMap parameters = (HashMap)interfaces.get(interfaceKey); - if (parameters == null) { - parameters = new HashMap(); - interfaces.put(interfaceKey, parameters); - } - - // an empty string for a parameter spec indicates a method w/ no parameters - Object parametersKey = (spec.methodParams == null? WILDCARD:spec.methodParams); - Object parameter = parameters.get(parametersKey); - if (parameter == null) { - parameter = new Boolean(true); - parameters.put(parametersKey, parameter); - } - } - - /** - * Checks to see if the specified permission is implied by - * the collection of Permission objects held in this PermissionCollection. - * - * @param permission the Permission object to compare. - * - * @return true if "permission" is implied by the permissions in - * the collection, false if not. - */ - public boolean implies(Permission permission) { - if (!(permission instanceof EJBMethodPermission)) return false; - - EJBMethodPermission p = (EJBMethodPermission)permission; - - EJBMethodPermission.MethodSpec spec = p.methodSpec; - Object test = permissions.get(p.getName()); - - if (test == null) return false; - if (test instanceof Boolean) return true; - - HashMap methods = (HashMap)test; - - Object methodKey = (spec.methodName == null || spec.methodName.length() == 0? WILDCARD:spec.methodName); - HashMap interfaces = (HashMap)methods.get(methodKey); - - if (methodImplies(interfaces, spec)) return true; - if (methodKey != WILDCARD) { - return methodImplies((HashMap)methods.get(WILDCARD), spec); - } - - return false; - } - - protected boolean methodImplies(HashMap interfaces, EJBMethodPermission.MethodSpec spec) { - if (interfaces == null) return false; - - Object interfaceKey = (spec.methodInterface == null || spec.methodInterface.length() == 0? WILDCARD:spec.methodInterface); - HashMap parameters = (HashMap)interfaces.get(interfaceKey); - - if (interfaceImplies(parameters, spec)) return true; - if (interfaceKey != WILDCARD) { - return interfaceImplies((HashMap)interfaces.get(WILDCARD), spec); - } - - return false; - } - - protected boolean interfaceImplies(HashMap parameters, EJBMethodPermission.MethodSpec spec) { - if (parameters == null) return false; - - // An empty string for a parameter spec indicates a method w/ no parameters - // so we won't convert an empty string to a wildcard. - Object parametersKey = (spec.methodParams == null? WILDCARD:spec.methodParams); - Object parameter = parameters.get(parametersKey); - - if (parameter != null) return true; - if (parametersKey != WILDCARD) { - return parameters.containsKey(WILDCARD); - } - - return false; - } - - /** - * Returns an enumeration of all the Permission objects in the collection. - * - * @return an enumeration of all the Permissions. - */ - public Enumeration elements() { - return Collections.enumeration(collection); - } -} +package javax.security.jacc; + +import java.security.PermissionCollection; + +import java.security.Permission; + +import java.util.LinkedList; + +import java.util.HashMap; + +import java.util.Enumeration; + +import java.util.Collections; + + +/** + * + * @version $Revision$ $Date$ + */ +public final class EJBMethodPermissionCollection extends PermissionCollection { + + private LinkedList collection = new LinkedList(); + private HashMap permissions = new HashMap(); + private static final String WILDCARD = new String(); + + /** + * Adds a permission object to the current collection of permission objects. + * + * @param permission the Permission object to add. + * + * @exception SecurityException - if this PermissionCollection object + * has been marked readonly + */ + + public void add(Permission permission) { + + if (isReadOnly()) throw new IllegalArgumentException("Read only collection"); + + if (!(permission instanceof EJBMethodPermission)) throw new IllegalArgumentException("Wrong permission type"); + + if (collection.contains(permission)) return; + else collection.add(permission); + + EJBMethodPermission p = (EJBMethodPermission)permission; + EJBMethodPermission.MethodSpec spec = p.methodSpec; + Object test = permissions.get(p.getName()); + + if (test instanceof Boolean) return; + + if (spec.methodName == null && spec.methodInterface == null && spec.methodParams == null) { + permissions.put(p.getName(), new Boolean(true)); + return; + } + + HashMap methods = (HashMap)test; + if (methods == null) { + methods = new HashMap(); + permissions.put(p.getName(), methods); + } + + Object methodKey = (spec.methodName == null || spec.methodName.length() == 0? WILDCARD:spec.methodName); + HashMap interfaces = (HashMap)methods.get(methodKey); + if (interfaces == null) { + interfaces = new HashMap(); + methods.put(methodKey, interfaces); + } + + Object interfaceKey = (spec.methodInterface == null || spec.methodInterface.length() == 0? WILDCARD:spec.methodInterface); + HashMap parameters = (HashMap)interfaces.get(interfaceKey); + if (parameters == null) { + parameters = new HashMap(); + interfaces.put(interfaceKey, parameters); + } + + + + // an empty string for a parameter spec indicates a method w/ no parameters + Object parametersKey = (spec.methodParams == null? WILDCARD:spec.methodParams); + Object parameter = parameters.get(parametersKey); + if (parameter == null) { + parameter = new Boolean(true); + parameters.put(parametersKey, parameter); + } + + } + + /** + * Checks to see if the specified permission is implied by + * the collection of Permission objects held in this PermissionCollection. + * + * @param permission the Permission object to compare. + * + * @return true if "permission" is implied by the permissions in + * the collection, false if not. + */ + public boolean implies(Permission permission) { + + if (!(permission instanceof EJBMethodPermission)) return false; + + EJBMethodPermission p = (EJBMethodPermission)permission; + + EJBMethodPermission.MethodSpec spec = p.methodSpec; + Object test = permissions.get(p.getName()); + + if (test == null) return false; + if (test instanceof Boolean) return true; + + HashMap methods = (HashMap)test; + + Object methodKey = (spec.methodName == null || spec.methodName.length() == 0? WILDCARD:spec.methodName); + HashMap interfaces = (HashMap)methods.get(methodKey); + + if (methodImplies(interfaces, spec)) return true; + if (methodKey != WILDCARD) { + return methodImplies((HashMap)methods.get(WILDCARD), spec); + } + + return false; + } + + + + protected boolean methodImplies(HashMap interfaces, EJBMethodPermission.MethodSpec spec) { + + if (interfaces == null) return false; + + Object interfaceKey = (spec.methodInterface == null || spec.methodInterface.length() == 0? WILDCARD:spec.methodInterface); + HashMap parameters = (HashMap)interfaces.get(interfaceKey); + + if (interfaceImplies(parameters, spec)) return true; + if (interfaceKey != WILDCARD) { + return interfaceImplies((HashMap)interfaces.get(WILDCARD), spec); + } + + return false; + } + + + + protected boolean interfaceImplies(HashMap parameters, EJBMethodPermission.MethodSpec spec) { + + if (parameters == null) return false; + + // An empty string for a parameter spec indicates a method w/ no parameters + // so we won't convert an empty string to a wildcard. + Object parametersKey = (spec.methodParams == null? WILDCARD:spec.methodParams); + Object parameter = parameters.get(parametersKey); + + if (parameter != null) return true; + if (parametersKey != WILDCARD) { + return parameters.containsKey(WILDCARD); + } + + return false; + } + + + + /** + * Returns an enumeration of all the Permission objects in the collection. + * + * @return an enumeration of all the Permissions. + */ + public Enumeration elements() { + return Collections.enumeration(collection); + } +} +