1 /*
2 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
266 * {@link #MBeanServerFileAccessController(String,MBeanServer)}
267 * constructors to specify a file from which the entries are read,
268 * the file is re-read.</p>
269 *
270 * <p>If this instance was created using the
271 * {@link #MBeanServerFileAccessController(Properties)} or
272 * {@link #MBeanServerFileAccessController(Properties,MBeanServer)}
273 * constructors then a new copy of the <code>Properties</code> object
274 * is made.</p>
275 *
276 * @exception IOException if the file does not exist, is a
277 * directory rather than a regular file, or for some other
278 * reason cannot be opened for reading.
279 *
280 * @exception IllegalArgumentException if any of the supplied access
281 * level values differs from "readonly" or "readwrite".
282 */
283 public synchronized void refresh() throws IOException {
284 Properties props;
285 if (accessFileName == null)
286 props = (Properties) originalProps;
287 else
288 props = propertiesFromFile(accessFileName);
289 parseProperties(props);
290 }
291
292 private static Properties propertiesFromFile(String fname)
293 throws IOException {
294 FileInputStream fin = new FileInputStream(fname);
295 try {
296 Properties p = new Properties();
297 p.load(fin);
298 return p;
299 } finally {
300 fin.close();
301 }
302 }
303
304 private synchronized void checkAccess(AccessType requiredAccess, String arg) {
305 final AccessControlContext acc = AccessController.getContext();
306 final Subject s =
|
1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
266 * {@link #MBeanServerFileAccessController(String,MBeanServer)}
267 * constructors to specify a file from which the entries are read,
268 * the file is re-read.</p>
269 *
270 * <p>If this instance was created using the
271 * {@link #MBeanServerFileAccessController(Properties)} or
272 * {@link #MBeanServerFileAccessController(Properties,MBeanServer)}
273 * constructors then a new copy of the <code>Properties</code> object
274 * is made.</p>
275 *
276 * @exception IOException if the file does not exist, is a
277 * directory rather than a regular file, or for some other
278 * reason cannot be opened for reading.
279 *
280 * @exception IllegalArgumentException if any of the supplied access
281 * level values differs from "readonly" or "readwrite".
282 */
283 public synchronized void refresh() throws IOException {
284 Properties props;
285 if (accessFileName == null)
286 props = originalProps;
287 else
288 props = propertiesFromFile(accessFileName);
289 parseProperties(props);
290 }
291
292 private static Properties propertiesFromFile(String fname)
293 throws IOException {
294 FileInputStream fin = new FileInputStream(fname);
295 try {
296 Properties p = new Properties();
297 p.load(fin);
298 return p;
299 } finally {
300 fin.close();
301 }
302 }
303
304 private synchronized void checkAccess(AccessType requiredAccess, String arg) {
305 final AccessControlContext acc = AccessController.getContext();
306 final Subject s =
|