Beispiel #1
0
 public static boolean checkSecurity() {
   SecurityManager security = System.getSecurityManager();
   if (security != null) {
     try {
       security.checkPropertyAccess("user.dir");
       security.checkPropertyAccess("file.separator");
     } catch (SecurityException e) {
       System.out.println("SecurityManager restricts session recording.");
       return false;
     }
   }
   return true;
 }
Beispiel #2
0
 public static JvmInfo jvmInfo() {
   SecurityManager sm = System.getSecurityManager();
   if (sm != null) {
     sm.checkPermission(new ManagementPermission("monitor"));
     sm.checkPropertyAccess("*");
   }
   return INSTANCE;
 }
  /**
   * Retrieve the value of the named environment property.
   *
   * @param key The name of the requested property.
   * @return The value of the requested property, or <code>null</code> if the property is undefined.
   */
  public String getProperty(String key) {
    SecurityManager sm = System.getSecurityManager();

    if (sm != null) {
      sm.checkPropertyAccess(key);
    }

    return (framework.getProperty(key));
  }
Beispiel #4
0
  /**
   * Gets the system property indicated by the specified key.
   *
   * <p>First, if there is a security manager, its <code>checkPropertyAccess</code> method is called
   * with the <code>key</code> as its argument.
   *
   * <p>If there is no current set of system properties, a set of system properties is first created
   * and initialized in the same manner as for the <code>getProperties</code> method.
   *
   * @param key the name of the system property.
   * @param def a default value.
   * @return the string value of the system property, or the default value if there is no property
   *     with that key.
   * @exception SecurityException if a security manager exists and its <code>checkPropertyAccess
   *     </code> method doesn't allow access to the specified system property.
   * @exception NullPointerException if <code>key</code> is <code>null</code>.
   * @exception IllegalArgumentException if <code>key</code> is empty.
   * @see #setProperty
   * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
   * @see java.lang.System#getProperties()
   */
  public static String getProperty(String key, String def) {
    checkKey(key);
    SecurityManager sm = getSecurityManager();
    if (sm != null) {
      sm.checkPropertyAccess(key);
    }

    return props.getProperty(key, def);
  }
 @Override
 public void checkPropertyAccess(final String pKey) {
   if (finalSecurityManager != null) finalSecurityManager.checkPropertyAccess(pKey);
 }
 @Override
 public void checkPropertyAccess(final String key) {
   if (securityManager != null) securityManager.checkPropertyAccess(key);
 }