use of java.security.Permission in project jdk8u_jdk by JetBrains.
the class JmxMBeanServer method checkMBeanPermission.
// SECURITY CHECKS
//----------------
private static void checkMBeanPermission(String classname, String member, ObjectName objectName, String actions) throws SecurityException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Permission perm = new MBeanPermission(classname, member, objectName, actions);
sm.checkPermission(perm);
}
}
use of java.security.Permission in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method checkMBeanPermission.
private static void checkMBeanPermission(String classname, String member, ObjectName objectName, String actions) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Permission perm = new MBeanPermission(classname, member, objectName, actions);
sm.checkPermission(perm);
}
}
use of java.security.Permission in project jdk8u_jdk by JetBrains.
the class MBeanServerFactory method checkPermission.
private static void checkPermission(String action) throws SecurityException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Permission perm = new MBeanServerPermission(action);
sm.checkPermission(perm);
}
}
use of java.security.Permission in project jdk8u_jdk by JetBrains.
the class TokenStore method checkPerm.
private static void checkPerm(PolicyFile p, ProtectionDomain pd) throws Exception {
boolean foundIt = false;
Enumeration perms = p.getPermissions(pd).elements();
while (perms.hasMoreElements()) {
Permission perm = (Permission) perms.nextElement();
if (!(perm instanceof AllPermission)) {
throw new SecurityException("expected AllPermission");
} else {
foundIt = true;
}
}
if (!foundIt) {
throw new SecurityException("expected AllPermission");
}
}
use of java.security.Permission in project jdk8u_jdk by JetBrains.
the class Proc method start.
// Starts the proc
public Proc start() throws IOException {
List<String> cmd = new ArrayList<>();
if (launcher != null) {
cmd.add(launcher);
} else {
cmd.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getPath());
}
cmd.add("-cp");
StringBuilder cp = new StringBuilder();
for (URL url : ((URLClassLoader) Proc.class.getClassLoader()).getURLs()) {
if (cp.length() != 0) {
cp.append(File.pathSeparatorChar);
}
cp.append(url.getFile());
}
cmd.add(cp.toString());
for (Entry<String, String> e : prop.entrySet()) {
cmd.add("-D" + e.getKey() + "=" + e.getValue());
}
if (!perms.isEmpty()) {
Path p = Files.createTempFile(Paths.get(".").toAbsolutePath(), "policy", null);
StringBuilder sb = new StringBuilder();
sb.append("grant {\n");
for (Permission perm : perms) {
// Sometimes a permission has no name or actions.
// but it's safe to use an empty string.
String s = String.format("%s \"%s\", \"%s\"", perm.getClass().getCanonicalName(), perm.getName().replace("\\", "\\\\").replace("\"", "\\\""), perm.getActions());
sb.append(" permission ").append(s).append(";\n");
}
sb.append("};\n");
Files.write(p, sb.toString().getBytes());
cmd.add("-Djava.security.policy=" + p.toString());
}
cmd.add(clazz);
for (String s : args) {
cmd.add(s);
}
if (debug != null) {
System.out.println("PROC: " + debug + " cmdline: " + cmd);
}
ProcessBuilder pb = new ProcessBuilder(cmd);
for (Entry<String, String> e : env.entrySet()) {
pb.environment().put(e.getKey(), e.getValue());
}
if (inheritIO) {
pb.inheritIO();
} else if (noDump) {
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
} else {
pb.redirectError(ProcessBuilder.Redirect.appendTo(new File(DFILE)));
}
p = pb.start();
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
return this;
}
Aggregations