25
26 import jdk.test.lib.process.OutputAnalyzer;
27 import jdk.test.lib.process.ProcessTools;
28 import jdk.test.lib.util.JarUtils;
29
30 import java.io.FileWriter;
31 import java.io.IOException;
32 import java.nio.file.Path;
33 import java.nio.file.Paths;
34
35 /*
36 * @test
37 * @bug 8048362
38 * @summary Tests the doPrivileged with accomplice Generate two jars
39 * (DoPrivTest.jar and DoPrivAccomplice.jar) and grant permission to
40 * DoPrivAccmplice.jar for reading user.name property from a PrivilagedAction.
41 * Run DoPrivTest.jar and try to access user.name property using
42 * DoPrivAccmplice.jar.
43 *
44 * @library /test/lib
45 *
46 * @run main/othervm DoPrivAccompliceTest
47 */
48
49 public class DoPrivAccompliceTest {
50 private static final String ACTION_SOURCE = DoPrivAccomplice.class.getName();
51 private static final String TEST_SOURCE = DoPrivTest.class.getName();
52
53 private static void createPolicyFile(Path jarFile, Path policy) {
54 String codebase = jarFile.toFile().toURI().toString();
55 String quotes = "\"";
56 StringBuilder policyFile = new StringBuilder();
57 policyFile.append("grant codeBase ")
58 .append(quotes).append(codebase).append(quotes)
59 .append("{\n")
60 .append("permission java.util.PropertyPermission ")
61 .append(quotes).append("user.name").append(quotes)
62 .append(",")
63 .append(quotes).append("read").append(quotes)
64 .append(";\n};");
65 try (FileWriter writer = new FileWriter(policy.toFile())) {
|
25
26 import jdk.test.lib.process.OutputAnalyzer;
27 import jdk.test.lib.process.ProcessTools;
28 import jdk.test.lib.util.JarUtils;
29
30 import java.io.FileWriter;
31 import java.io.IOException;
32 import java.nio.file.Path;
33 import java.nio.file.Paths;
34
35 /*
36 * @test
37 * @bug 8048362
38 * @summary Tests the doPrivileged with accomplice Generate two jars
39 * (DoPrivTest.jar and DoPrivAccomplice.jar) and grant permission to
40 * DoPrivAccmplice.jar for reading user.name property from a PrivilagedAction.
41 * Run DoPrivTest.jar and try to access user.name property using
42 * DoPrivAccmplice.jar.
43 *
44 * @library /test/lib
45 * @build jdk.test.lib.util.JarUtils
46 * jdk.test.lib.Utils
47 * jdk.test.lib.Asserts
48 * jdk.test.lib.JDKToolFinder
49 * jdk.test.lib.JDKToolLauncher
50 * jdk.test.lib.Platform
51 * jdk.test.lib.process.*
52 * @run main/othervm DoPrivAccompliceTest
53 */
54
55 public class DoPrivAccompliceTest {
56 private static final String ACTION_SOURCE = DoPrivAccomplice.class.getName();
57 private static final String TEST_SOURCE = DoPrivTest.class.getName();
58
59 private static void createPolicyFile(Path jarFile, Path policy) {
60 String codebase = jarFile.toFile().toURI().toString();
61 String quotes = "\"";
62 StringBuilder policyFile = new StringBuilder();
63 policyFile.append("grant codeBase ")
64 .append(quotes).append(codebase).append(quotes)
65 .append("{\n")
66 .append("permission java.util.PropertyPermission ")
67 .append(quotes).append("user.name").append(quotes)
68 .append(",")
69 .append(quotes).append("read").append(quotes)
70 .append(";\n};");
71 try (FileWriter writer = new FileWriter(policy.toFile())) {
|