1 22 package org.jboss.util; 23 24 import java.security.PrivilegedAction ; 25 import java.security.AccessController ; 26 27 32 class SysPropertyActions 33 { 34 interface SysProps 35 { 36 SysProps NON_PRIVILEDGED = new SysProps() 37 { 38 public String getProperty(final String name, final String defaultValue) 39 { 40 return System.getProperty(name, defaultValue); 41 } 42 }; 43 SysProps PRIVILEDGED = new SysProps() 44 { 45 public String getProperty(final String name, final String defaultValue) 46 { 47 PrivilegedAction action = new PrivilegedAction () 48 { 49 public Object run() 50 { 51 return System.getProperty(name, defaultValue); 52 } 53 }; 54 return (String ) AccessController.doPrivileged(action); 55 } 56 }; 57 String getProperty(String name, String defaultValue); 58 } 59 60 public static String getProperty(String name, String defaultValue) 61 { 62 String prop; 63 if( System.getSecurityManager() == null ) 64 prop = SysProps.NON_PRIVILEDGED.getProperty(name, defaultValue); 65 else 66 prop = SysProps.PRIVILEDGED.getProperty(name, defaultValue); 67 return prop; 68 } 69 } 70 | Popular Tags |