From ffde862e033a0825e1e9972a89c0f1f80b261a8e Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 14 Aug 2006 23:12:35 +0000 Subject: 2006-08-14 Mark Wielaard Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/classpath/java/security/Provider.java | 92 ++++++++++++++++----------- 1 file changed, 54 insertions(+), 38 deletions(-) (limited to 'libjava/classpath/java/security/Provider.java') diff --git a/libjava/classpath/java/security/Provider.java b/libjava/classpath/java/security/Provider.java index 4ffaa55bcb1..ea1dd9d3ff2 100644 --- a/libjava/classpath/java/security/Provider.java +++ b/libjava/classpath/java/security/Provider.java @@ -1,5 +1,5 @@ /* Provider.java -- Security provider information - Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2002, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,20 +41,19 @@ import java.io.Serializable; import java.util.Properties; /** - * This class represents a Java security architecture service provider. - * The services provided by a such a provider can range from security - * algorithms to key generation. + * This class represents a Java security architecture service provider. The + * services provided by a such a provider can range from security algorithms to + * key generation. *

- * Providers are installed by name and version number. There is one - * standard provider supplied with the class library. This is the - * "GNU" provider, which can also be accessed by the alias "SUN" for - * compatibility with the JDK. - * - * @version 0.0 - * + * Providers are installed by name and version number. See the static + * initializer of the {@link java.security.Security} class for the default + * security providers installed by this class library. + * * @author Aaron M. Renn (arenn@urbanophile.com) */ -public abstract class Provider extends Properties implements Serializable +public abstract class Provider + extends Properties + implements Serializable { private static final long serialVersionUID = -4298000515446427739L; @@ -119,36 +118,34 @@ public abstract class Provider extends Properties implements Serializable } /** - * Sets the key property to have the specified value. + * Maps a key property to a designated value. *

- * NOT IMPLEMENTED YET[ - * First, if there is a security manager, its checkSecurityAccess - * method is called with the string "putProviderProperty."+name, where name is - * the provider name, to see if it's ok to set this provider's property - * values. - * If the default implementation of checkSecurityAccess is used - * (that is, that method is not overriden), then this results in a call to the - * security manager's checkPermission method with a - * SecurityPermission("putProviderProperty."+name) - * permission.
] - * + * If there is an installed {@link SecurityManager} object in the underlying + * VM, its {@link SecurityManager#checkSecurityAccess(String)} method is + * called with the string "putProviderProperty." + name, where + * name is this provider's name. For the default implementation + * this translates into a {@link SecurityManager#checkPermission(Permission)} + * for a SecurityPermission("putProviderProperty." + name). + * * @param key The property key. * @param value The property value. - * * @return The previous value of the specified property (key), * or null if it did not have one. - * @throws SecurityException If a security manager exists and its - * {@link java.lang.SecurityManager.checkSecurityAccess(java.lang.String)} - * method denies access to set property values. + * @throws SecurityException If a security manager is installed and its + * {@link SecurityManager#checkSecurityAccess(String)} method + * disallows adding properties at run-time. * @since Classpath 0.4+cvs, JDK 1.2 - * @see java.lang.Object.equals(Object) - * @see java.util.Hashtable.get(Object) + * @see java.lang.Object#equals(Object) + * @see java.util.Hashtable#get(Object) */ public Object put(Object key, Object value) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkSecurityAccess("putProviderProperty." + this.name); return super.put(toCanonicalKey(key), value); } - + // overrides same in java.util.Hashtable public Object get(Object key) { @@ -157,25 +154,45 @@ public abstract class Provider extends Properties implements Serializable /** * This method removes the specified key entry (and its associated value) - * from the property mapping list. + * from the property mapping collection. + *

+ * If there is an installed {@link SecurityManager} object in the underlying + * VM, its {@link SecurityManager#checkSecurityAccess(String)} method is + * called with the string "removeProviderProperty." + name, where + * name is this provider's name. For the default implementation + * this translates into a {@link SecurityManager#checkPermission(Permission)} + * for a SecurityPermission("removeProviderProperty." + name). * * @param key The key to remove - * * @return The previous value for this key, or null if no * previous value. */ public Object remove(Object key) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkSecurityAccess("removeProviderProperty." + this.name); return super.remove(toCanonicalKey(key)); } /** - * This method clears the entire property list such that it no longer + * This method clears the entire property collection such that it no longer * contains the properties used to look up the services provided by - * the Provider. + * this Provider. + *

+ * If there is an installed {@link SecurityManager} object in the underlying + * VM, its {@link SecurityManager#checkSecurityAccess(String)} method is + * called with the string "clearProviderProperties." + name, + * where name is this provider's name. For the default + * implementation this translates into a + * {@link SecurityManager#checkPermission(Permission)} for a + * SecurityPermission("clearProviderProperties." + name). */ public void clear() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkSecurityAccess("clearProviderProperties." + this.name); super.clear(); } @@ -191,12 +208,11 @@ public abstract class Provider extends Properties implements Serializable return (getClass().getName() + ": name=" + getName() + " version=" + version); } - + private Object toCanonicalKey(Object key) { if (key.getClass().isAssignableFrom(String.class)) // is it ours? return ((String) key).toUpperCase(); // use default locale - else - return key; + return key; } } -- cgit v1.2.1