summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2010-12-25 18:38:49 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2010-12-25 18:38:49 +0000
commitfece38543cd6be7efd42bcde0b471a794c071e7a (patch)
treef01348a94b8e6b816ec211bf5a64575da12b8384
parent44bc36797efb004b85bef4e540caae998ede7fc1 (diff)
downloadclasspath-fece38543cd6be7efd42bcde0b471a794c071e7a.tar.gz
PR classpath/42390: Throw SecurityException when adding and removing LogManager PropertyChangeListeners.
2010-12-25 Andrew John Hughes <ahughes@redhat.com> PR classpath/42390 * java/util/logging/LogManager.java: (addPropertyChangeListener(PropertyChangeListener)): Document fully. Throw NPE in a clearer way. Add SecurityException. (removePropertyChangeListener(PropertyChangeListener)): Document fully. Add SecurityException.
-rw-r--r--ChangeLog10
-rw-r--r--java/util/logging/LogManager.java27
2 files changed, 34 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e8c56c183..2d9c17694 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,16 @@
2010-12-25 Andrew John Hughes <ahughes@redhat.com>
PR classpath/42390
+ * java/util/logging/LogManager.java:
+ (addPropertyChangeListener(PropertyChangeListener)):
+ Document fully. Throw NPE in a clearer way. Add
+ SecurityException.
+ (removePropertyChangeListener(PropertyChangeListener)):
+ Document fully. Add SecurityException.
+
+2010-12-25 Andrew John Hughes <ahughes@redhat.com>
+
+ PR classpath/42390
* java/io/ObjectOutputStream.java:
(ObjectOutputStream(OutputStream)): Add
required security check.
diff --git a/java/util/logging/LogManager.java b/java/util/logging/LogManager.java
index dffa44d9c..f8c6c3393 100644
--- a/java/util/logging/LogManager.java
+++ b/java/util/logging/LogManager.java
@@ -211,11 +211,21 @@ public class LogManager
/**
* Registers a listener which will be notified when the
* logging properties are re-read.
+ *
+ * @param listener the event listener to register.
+ * @throws NullPointerException if the listener is {@code null}.
+ * @throws SecurityException if a security manager exists and the
+ * calling code does not have the permission
+ * {@code LoggingPermission("control")}.
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
{
- /* do not register null. */
- listener.getClass();
+ if (listener == null)
+ throw new NullPointerException("Attempt to add null property change listener");
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new LoggingPermission("control", null));
pcs.addPropertyChangeListener(listener);
}
@@ -226,11 +236,22 @@ public class LogManager
* If <code>listener</code> has not been registered previously,
* nothing happens. Also, no exception is thrown if
* <code>listener</code> is <code>null</code>.
+ *
+ * @param listener the listener to remove.
+ * @throws SecurityException if a security manager exists and the
+ * calling code does not have the permission
+ * {@code LoggingPermission("control")}.
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
{
if (listener != null)
- pcs.removePropertyChangeListener(listener);
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(new LoggingPermission("control", null));
+
+ pcs.removePropertyChangeListener(listener);
+ }
}
/**