29package com.jogamp.common.util;
31import java.security.*;
32import java.util.HashSet;
42 static final HashSet<String> trustedPrefixes;
43 static final HashSet<String> trusted;
46 trustedPrefixes =
new HashSet<String>();
51 trusted =
new HashSet<String>();
52 trusted.add(
"sun.java2d.opengl");
53 trusted.add(
"sun.java2d.noddraw");
54 trusted.add(
"sun.java2d.d3d");
55 trusted.add(
"sun.awt.noerasebackground");
62 protected static final void addTrustedPrefix(
final String prefix)
throws AccessControlException {
64 trustedPrefixes.add(prefix);
67 public static final boolean isTrusted(
final String propertyKey) {
68 final int dot1 = propertyKey.indexOf(
'.');
70 return trustedPrefixes.contains(propertyKey.substring(0, dot1+1)) || trusted.contains(propertyKey);
77 public static final int getIntProperty(
final String property,
final boolean jnlpAlias,
final int defaultValue) {
82 i = Integer.parseInt(sv);
84 }
catch (
final NumberFormatException nfe) {}
89 public static final long getLongProperty(
final String property,
final boolean jnlpAlias,
final long defaultValue) {
94 l = Long.parseLong(sv);
96 }
catch (
final NumberFormatException nfe) {}
106 public static final boolean getBooleanProperty(
final String property,
final boolean jnlpAlias,
final boolean defaultValue) {
109 return Boolean.valueOf(valueS).booleanValue();
138 public static final String
getProperty(
final String propertyKey,
final boolean jnlpAlias)
139 throws SecurityException, NullPointerException, IllegalArgumentException {
140 if(
null == propertyKey) {
141 throw new NullPointerException(
"propertyKey is NULL");
143 if(0 == propertyKey.length()) {
144 throw new IllegalArgumentException(
"propertyKey is empty");
150 s = getTrustedPropKey(propertyKey);
153 s = System.getProperty(propertyKey);
155 if(
null == s && jnlpAlias ) {
167 public static final String
getProperty(
final String propertyKey,
final boolean jnlpAlias,
final String defaultValue)
168 throws SecurityException, NullPointerException, IllegalArgumentException {
177 private static final String getTrustedPropKey(
final String propertyKey) {
180 public String run() {
182 return System.getProperty(propertyKey);
183 }
catch (
final SecurityException se) {
184 throw new SecurityException(
"Could not access trusted property '"+propertyKey+
"'", se);
Helper routines for accessing properties.
static final boolean getBooleanProperty(final String property, final boolean jnlpAlias)
static final boolean getBooleanProperty(final String property, final boolean jnlpAlias, final boolean defaultValue)
static final String javaws_prefix
trusted build-in property prefix 'javaws.
static final boolean isPropertyDefined(final String property, final boolean jnlpAlias)
static final String jnlp_prefix
trusted build-in property prefix 'jnlp.
static final void addTrustedPrefix(final String prefix)
static final boolean isTrusted(final String propertyKey)
static final long getLongProperty(final String property, final boolean jnlpAlias, final long defaultValue)
static final String getProperty(final String propertyKey, final boolean jnlpAlias)
Query the property with the name propertyKey.
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< 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...