equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
70 SecurityManager sm = System.getSecurityManager(); |
70 SecurityManager sm = System.getSecurityManager(); |
71 if (sm != null) { |
71 if (sm != null) { |
72 sm.checkPermission(new AudioPermission("record")); |
72 sm.checkPermission(new AudioPermission("record")); |
73 } |
73 } |
74 } |
74 } |
75 |
|
76 static String getProperty(final String propertyName) { |
|
77 String propertyValue; |
|
78 if (hasSecurityManager()) { |
|
79 if(Printer.debug) Printer.debug("using JDK 1.2 security to get property"); |
|
80 try{ |
|
81 PrivilegedAction<String> action = new PrivilegedAction<String>() { |
|
82 public String run() { |
|
83 try { |
|
84 return System.getProperty(propertyName); |
|
85 } catch (Throwable t) { |
|
86 return null; |
|
87 } |
|
88 } |
|
89 }; |
|
90 propertyValue = AccessController.doPrivileged(action); |
|
91 } catch( Exception e ) { |
|
92 if(Printer.debug) Printer.debug("not using JDK 1.2 security to get properties"); |
|
93 propertyValue = System.getProperty(propertyName); |
|
94 } |
|
95 } else { |
|
96 if(Printer.debug) Printer.debug("not using JDK 1.2 security to get properties"); |
|
97 propertyValue = System.getProperty(propertyName); |
|
98 } |
|
99 return propertyValue; |
|
100 } |
|
101 |
|
102 |
75 |
103 /** Load properties from a file. |
76 /** Load properties from a file. |
104 This method tries to load properties from the filename give into |
77 This method tries to load properties from the filename give into |
105 the passed properties object. |
78 the passed properties object. |
106 If the file cannot be found or something else goes wrong, |
79 If the file cannot be found or something else goes wrong, |