From e09b853ebea2bf2f17379213e230ea811c476f4f Mon Sep 17 00:00:00 2001 From: "samskivert@gmail.com" Date: Wed, 2 Mar 2005 04:24:14 +0000 Subject: [PATCH] Allow the preferences to be used on behalf of unsigned code if the samskivert code is signed. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1604 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/Config.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/Config.java b/projects/samskivert/src/java/com/samskivert/util/Config.java index 612aab26..f3147b5c 100644 --- a/projects/samskivert/src/java/com/samskivert/util/Config.java +++ b/projects/samskivert/src/java/com/samskivert/util/Config.java @@ -23,6 +23,8 @@ package com.samskivert.util; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.security.AccessControlException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.io.FileNotFoundException; import java.io.IOException; @@ -142,10 +144,18 @@ public class Config * supplied properties, rooted at the specified path in the * preferences hieriarchy. */ - public Config (String path, Properties props) + public Config (final String path, Properties props) { _props = props; - _prefs = Preferences.userRoot().node(path); + + // even if we're called from unprivileged code we want to allow + // access to preferences + AccessController.doPrivileged(new PrivilegedAction() { + public Object run () { + _prefs = Preferences.userRoot().node(path); + return null; + } + }); } /**