mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
Merge remote branch 'oss/master' into jdk7
Conflicts: makefile
This commit is contained in:
21
classpath/java/lang/RuntimePermission.java
Normal file
21
classpath/java/lang/RuntimePermission.java
Normal file
@ -0,0 +1,21 @@
|
||||
/* Copyright (c) 2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.lang;
|
||||
|
||||
import java.security.BasicPermission;
|
||||
|
||||
public class RuntimePermission extends BasicPermission {
|
||||
|
||||
public RuntimePermission(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
}
|
@ -17,12 +17,15 @@ import java.io.BufferedOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileDescriptor;
|
||||
import java.util.Map;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class System {
|
||||
private static final long NanoTimeBaseInMillis = currentTimeMillis();
|
||||
|
||||
private static Property properties;
|
||||
private static Map<String, String> environment;
|
||||
|
||||
private static SecurityManager securityManager;
|
||||
// static {
|
||||
@ -145,4 +148,37 @@ public abstract class System {
|
||||
this.next = next;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getenv(String name) throws NullPointerException,
|
||||
SecurityException {
|
||||
if (getSecurityManager() != null) { // is this allowed?
|
||||
getSecurityManager().
|
||||
checkPermission(new RuntimePermission("getenv." + name));
|
||||
}
|
||||
return getenv().get(name);
|
||||
}
|
||||
|
||||
public static Map<String, String> getenv() throws SecurityException {
|
||||
if (getSecurityManager() != null) { // is this allowed?
|
||||
getSecurityManager().checkPermission(new RuntimePermission("getenv.*"));
|
||||
}
|
||||
|
||||
if (environment == null) { // build environment table
|
||||
String[] vars = getEnvironment();
|
||||
environment = new Hashtable<String, String>(vars.length);
|
||||
for (String var : vars) { // parse name-value pairs
|
||||
int equalsIndex = var.indexOf('=');
|
||||
// null names and values are forbidden
|
||||
if (equalsIndex != -1 && equalsIndex < var.length() - 1) {
|
||||
environment.put(var.substring(0, equalsIndex),
|
||||
var.substring(equalsIndex + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return environment;
|
||||
}
|
||||
|
||||
/** Returns the native process environment. */
|
||||
private static native String[] getEnvironment();
|
||||
}
|
||||
|
Reference in New Issue
Block a user