From c1cca55d6fe8df3d80afce7f88843c4046c35903 Mon Sep 17 00:00:00 2001 From: bryce Date: Fri, 24 May 2002 11:57:40 +0000 Subject: Merge JDK 1.4 java.security changes from classpath. * java/security/AccessControlException.java: Merge from Classpath. * java/security/AccessController.java: Likewise. * java/security/AllPermission.java: Likewise. * java/security/BasicPermission.java: Likewise. * java/security/Certificate.java: Likewise. * java/security/CodeSource.java: Likewise. * java/security/DigestException.java: Likewise. * java/security/DigestOutputStream.java: Likewise. * java/security/DomainCombiner.java: Likewise. * java/security/GeneralSecurityException.java: Likewise. * java/security/Guard.java: Likewise. * java/security/GuardedObject.java: Likewise. * java/security/InvalidAlgorithmParameterException.java: Likewise. * java/security/InvalidKeyException.java: Likewise. * java/security/InvalidParameterException.java: Likewise. * java/security/Key.java: Likewise. * java/security/KeyException.java: Likewise. * java/security/KeyManagementException.java: Likewise. * java/security/KeyStoreException.java: Likewise. * java/security/MessageDigest.java: Likewise. * java/security/NoSuchAlgorithmException.java: Likewise. * java/security/NoSuchProviderException.java: Likewise. * java/security/Permission.java: Likewise. * java/security/PermissionCollection.java: Likewise. * java/security/Permissions.java: Likewise. * java/security/Policy.java: Likewise. * java/security/Principal.java: Likewise. * java/security/PrivateKey.java: Likewise. * java/security/PrivilegedAction.java: Likewise. * java/security/PrivilegedActionException.java: Likewise. * java/security/PrivilegedExceptionAction.java: Likewise. * java/security/ProtectionDomain.java: Likewise. * java/security/ProviderException.java: Likewise. * java/security/PublicKey.java: Likewise. * java/security/SecureClassLoader.java: Likewise. * java/security/SecurityPermission.java: Likewise. * java/security/SignatureException.java: Likewise. * java/security/UnrecoverableKeyException.java: Likewise. * java/security/UnresolvedPermission.java: Likewise. * java/security/acl/AclNotFoundException.java: Likewise. * java/security/acl/LastOwnerException.java: Likewise. * java/security/acl/NotOwnerException.java: Likewise. * java/security/cert/CRLException.java: Likewise. * java/security/cert/CertificateEncodingException.java: Likewise. * java/security/cert/CertificateException.java: Likewise. * java/security/cert/CertificateExpiredException.java: Likewise. * java/security/cert/CertificateFactory.java: Likewise. * java/security/cert/CertificateNotYetValidException.java: Likewise. * java/security/cert/CertificateParsingException.java: Likewise. * java/security/spec/InvalidKeySpecException.java: Likewise. * java/security/spec/InvalidParameterSpecException.java: Likewise. * java/security/cert/CertPath.java: New file. * java/security/cert/CertPathBuilderException.java: New file. * java/security/cert/CertPathValidatorException.java: New file. * java/security/cert/CertStoreException.java: New file. * Makefile.am: Add new CertPath classes. * Makefile.in: Rebuilt. * gnu/java/util/EmptyEnumeration: New file from classpath. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53837 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/security/BasicPermission.java | 309 +++++++++++++++++------------ 1 file changed, 179 insertions(+), 130 deletions(-) (limited to 'libjava/java/security/BasicPermission.java') diff --git a/libjava/java/security/BasicPermission.java b/libjava/java/security/BasicPermission.java index 7e7d09db8e5..25630fb798b 100644 --- a/libjava/java/security/BasicPermission.java +++ b/libjava/java/security/BasicPermission.java @@ -1,5 +1,5 @@ -/* BasicPermission.java -- Implements a simple named permission. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. +/* BasicPermission.java -- implements a simple named permission + Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,90 +44,94 @@ import java.util.Enumeration; /** * This class implements a simple model for named permissions without an * associated action list. That is, either the named permission is granted - * or it is not. - *

- * It also supports trailing wildcards to allow the - * easy granting of permissions in a hierarchical fashion. (For example, - * the name "org.gnu.*" might grant all permissions under the "org.gnu" - * permissions hierarchy). The only valid wildcard character is a '*' - * which matches anything. It must be the rightmost element in the - * permission name and must follow a '.' or else the Permission name must - * consist of only a '*'. Any other occurrence of a '*' is not valid. - *

- * This class ignores the action list. Subclasses can choose to implement - * actions on top of this class if desired. + * or it is not. + * + *

It also supports trailing wildcards to allow the easy granting of + * permissions in a hierarchical fashion. (For example, the name "org.gnu.*" + * might grant all permissions under the "org.gnu" permissions hierarchy). + * The only valid wildcard character is a '*' which matches anything. It + * must be the rightmost element in the permission name and must follow a + * '.' or else the Permission name must consist of only a '*'. Any other + * occurrence of a '*' is not valid. * - * @version 0.1 + *

This class ignores the action list. Subclasses can choose to implement + * actions on top of this class if desired. * - * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Aaron M. Renn + * @author Eric Blake + * @see Permission + * @see Permissions + * @see PermissionCollection + * @see RuntimePermission + * @see SecurityPermission + * @see PropertyPermission + * @see AWTPermission + * @see NetPermission + * @see SecurityManager + * @since 1.1 + * @status updated to 1.4 */ public abstract class BasicPermission extends java.security.Permission implements Serializable - // FIXME extends with fully qualified classname as workaround for gcj 3.0.4 + // FIXME extends with fully qualified classname is workaround for gcj 3.0.4. { /** - * This method initializes a new instance of BasicPermission - * with the specified name. If the name contains an illegal wildcard - * character, an exception is thrown. - * - * @param name The name of this permission. + * Compatible with JDK 1.1+. + */ + private static final long serialVersionUID = 6279438298436773498L; + + /** + * Create a new instance with the specified permission name. If the name + * is empty, or contains an illegal wildcard character, an exception is + * thrown. * - * @exception IllegalArgumentException If the name contains an invalid wildcard character - * @exception NullPointerException If the name is null + * @param name the name of this permission + * @throws NullPointerException if name is null + * @throws IllegalArgumentException if name is invalid */ - public BasicPermission(String name) - throws IllegalArgumentException, NullPointerException + public BasicPermission(String name) { super(name); - if (name.indexOf("*") != -1) { - if (!name.endsWith(".*") && !name.equals("*")) - throw new IllegalArgumentException("Bad wildcard: " + name); - - if (name.indexOf("*") != name.lastIndexOf("*")) - throw new IllegalArgumentException("Bad wildcard: " + name); + if ((! name.endsWith(".*") && ! name.equals("*")) + || name.indexOf("*") != name.lastIndexOf("*")) + throw new IllegalArgumentException("Bad wildcard: " + name); } + if ("".equals(name)) + throw new IllegalArgumentException("Empty name"); } /** - * This method initializes a new instance of BasicPermission - * with the specified name. If the name contains an illegal wildcard - * character, an exception is thrown. The action list passed to this - * form of the constructor is ignored. - * - * @param name The name of this permission. - * @param actions The list of actions for this permission - ignored in this class. + * Create a new instance with the specified permission name. If the name + * is empty, or contains an illegal wildcard character, an exception is + * thrown. The actions parameter is ignored. * - * @exception IllegalArgumentException If the name contains an invalid wildcard character - * @exception NullPointerException If the name is null + * @param name the name of this permission + * @param actions ignored + * @throws NullPointerException if name is null + * @throws IllegalArgumentException if name is invalid */ - public BasicPermission(String name, String actions) - throws IllegalArgumentException, NullPointerException + public BasicPermission(String name, String actions) { - // ignore actions this(name); } /** - * This method tests to see if the specified permission is implied by - * this permission. This will be true if the following conditions are met: - *

- *