8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 import jdk.test.lib.process.OutputAnalyzer;
27 import jdk.test.lib.process.ProcessTools;
28 import jdk.testlibrary.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 /lib/testlibrary
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};");
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
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};");
|