29import java.security.*;
30import java.util.HashSet;
32import org.jau.sec.SecurityUtil;
42 static final HashSet<String> trustedPrefixes;
43 static final HashSet<String> trusted;
46 trustedPrefixes =
new HashSet<String>();
49 trustedPrefixes.add(
"jau.");
52 trusted =
new HashSet<String>();
53 trusted.add(
"sun.java2d.opengl");
54 trusted.add(
"sun.java2d.noddraw");
55 trusted.add(
"sun.java2d.d3d");
56 trusted.add(
"sun.awt.noerasebackground");
63 protected static final void addTrustedPrefix(
final String prefix)
throws SecurityException {
65 trustedPrefixes.add(prefix);
68 public static final boolean isTrusted(
final String propertyKey) {
69 final int dot1 = propertyKey.indexOf(
'.');
71 return trustedPrefixes.contains(propertyKey.substring(0, dot1+1)) || trusted.contains(propertyKey);
78 public static final int getIntProperty(
final String property,
final boolean jnlpAlias,
final int defaultValue) {
83 i = Integer.parseInt(sv);
85 }
catch (
final NumberFormatException nfe) {}
90 public static final long getLongProperty(
final String property,
final boolean jnlpAlias,
final long defaultValue) {
95 l = Long.parseLong(sv);
97 }
catch (
final NumberFormatException nfe) {}
107 public static final boolean getBooleanProperty(
final String property,
final boolean jnlpAlias,
final boolean defaultValue) {
110 return Boolean.valueOf(valueS).booleanValue();
139 public static final String
getProperty(
final String propertyKey,
final boolean jnlpAlias)
140 throws SecurityException, NullPointerException, IllegalArgumentException {
141 if(
null == propertyKey) {
142 throw new NullPointerException(
"propertyKey is NULL");
144 if(0 == propertyKey.length()) {
145 throw new IllegalArgumentException(
"propertyKey is empty");
151 s = getTrustedPropKey(propertyKey);
154 s = System.getProperty(propertyKey);
156 if(
null == s && jnlpAlias ) {
168 public static final String
getProperty(
final String propertyKey,
final boolean jnlpAlias,
final String defaultValue)
169 throws SecurityException, NullPointerException, IllegalArgumentException {
178 private static final String getTrustedPropKey(
final String propertyKey) {
181 public String run() {
183 return System.getProperty(propertyKey);
184 }
catch (
final SecurityException se) {
185 throw new SecurityException(
"Could not access trusted property '"+propertyKey+
"'", se);
static< T > T doPrivileged(final PrivilegedAction< T > o)
Call wrapper for java.security.AccessController#doPrivileged(PrivilegedAction).
static final void checkAllPermissions()
Throws an SecurityException if an installed SecurityManager does not permit the requested AllPermissi...
Helper routines for accessing properties.
static final boolean isTrusted(final String propertyKey)
static final void addTrustedPrefix(final String prefix)
static final long getLongProperty(final String property, final boolean jnlpAlias, final long defaultValue)
static final String javaws_prefix
trusted build-in property prefix 'javaws.
static final String getProperty(final String propertyKey, final boolean jnlpAlias)
Query the property with the name propertyKey.
static final boolean getBooleanProperty(final String property, final boolean jnlpAlias)
static final String jnlp_prefix
trusted build-in property prefix 'jnlp.
static final boolean getBooleanProperty(final String property, final boolean jnlpAlias, final boolean defaultValue)
static final String getProperty(final String propertyKey, final boolean jnlpAlias, final String defaultValue)
See getProperty(String, boolean), additionally allows a defaultValue if property value is null.
static final int getIntProperty(final String property, final boolean jnlpAlias, final int defaultValue)
static final boolean isPropertyDefined(final String property, final boolean jnlpAlias)