Merge
This commit is contained in:
commit
d4cfd27ff7
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
@ -37,6 +37,7 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.ObjectStreamField;
|
import java.io.ObjectStreamField;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.lang.RuntimePermission;
|
||||||
import java.lang.module.Configuration;
|
import java.lang.module.Configuration;
|
||||||
import java.lang.module.ModuleDescriptor;
|
import java.lang.module.ModuleDescriptor;
|
||||||
import java.lang.module.ModuleFinder;
|
import java.lang.module.ModuleFinder;
|
||||||
@ -45,7 +46,11 @@ import java.lang.module.ModuleReader;
|
|||||||
import java.lang.reflect.Layer;
|
import java.lang.reflect.Layer;
|
||||||
import java.lang.reflect.Module;
|
import java.lang.reflect.Module;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
|
import java.security.CodeSigner;
|
||||||
|
import java.security.CodeSource;
|
||||||
|
import java.security.PermissionCollection;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
import java.security.ProtectionDomain;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -177,6 +182,7 @@ public final class TemplatesImpl implements Templates, Serializable {
|
|||||||
_loadedExternalExtensionFunctions = mapEF;
|
_loadedExternalExtensionFunctions = mapEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class<?> loadClass(String name) throws ClassNotFoundException {
|
public Class<?> loadClass(String name) throws ClassNotFoundException {
|
||||||
Class<?> ret = null;
|
Class<?> ret = null;
|
||||||
// The _loadedExternalExtensionFunctions will be empty when the
|
// The _loadedExternalExtensionFunctions will be empty when the
|
||||||
@ -196,6 +202,10 @@ public final class TemplatesImpl implements Templates, Serializable {
|
|||||||
Class defineClass(final byte[] b) {
|
Class defineClass(final byte[] b) {
|
||||||
return defineClass(null, b, 0, b.length);
|
return defineClass(null, b, 0, b.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Class defineClass(final byte[] b, ProtectionDomain pd) {
|
||||||
|
return defineClass(null, b, 0, b.length, pd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -482,16 +492,24 @@ public final class TemplatesImpl implements Templates, Serializable {
|
|||||||
|
|
||||||
// the module needs access to runtime classes
|
// the module needs access to runtime classes
|
||||||
Module thisModule = TemplatesImpl.class.getModule();
|
Module thisModule = TemplatesImpl.class.getModule();
|
||||||
|
// the module also needs permission to access each package
|
||||||
|
// that is exported to it
|
||||||
|
PermissionCollection perms =
|
||||||
|
new RuntimePermission("*").newPermissionCollection();
|
||||||
Arrays.asList(Constants.PKGS_USED_BY_TRANSLET_CLASSES).forEach(p -> {
|
Arrays.asList(Constants.PKGS_USED_BY_TRANSLET_CLASSES).forEach(p -> {
|
||||||
thisModule.addExports(p, m);
|
thisModule.addExports(p, m);
|
||||||
|
perms.add(new RuntimePermission("accessClassInPackage." + p));
|
||||||
});
|
});
|
||||||
|
|
||||||
// java.xml needs to instanitate the translet class
|
CodeSource codeSource = new CodeSource(null, (CodeSigner[])null);
|
||||||
|
ProtectionDomain pd = new ProtectionDomain(codeSource, perms,
|
||||||
|
loader, null);
|
||||||
|
|
||||||
|
// java.xml needs to instantiate the translet class
|
||||||
thisModule.addReads(m);
|
thisModule.addReads(m);
|
||||||
|
|
||||||
for (int i = 0; i < classCount; i++) {
|
for (int i = 0; i < classCount; i++) {
|
||||||
_class[i] = loader.defineClass(_bytecodes[i]);
|
_class[i] = loader.defineClass(_bytecodes[i], pd);
|
||||||
final Class superClass = _class[i].getSuperclass();
|
final Class superClass = _class[i].getSuperclass();
|
||||||
|
|
||||||
// Check if this is the main class
|
// Check if this is the main class
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,6 +24,7 @@
|
|||||||
package transform;
|
package transform;
|
||||||
|
|
||||||
import static jaxp.library.JAXPTestUtilities.getSystemProperty;
|
import static jaxp.library.JAXPTestUtilities.getSystemProperty;
|
||||||
|
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -217,7 +218,7 @@ public class TransformerTest {
|
|||||||
* @summary Test for JDK-6272879
|
* @summary Test for JDK-6272879
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testBug6272879() throws IOException, TransformerException {
|
public final void testBug6272879() throws Exception {
|
||||||
final String xsl =
|
final String xsl =
|
||||||
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + LINE_SEPARATOR +
|
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + LINE_SEPARATOR +
|
||||||
"<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" + LINE_SEPARATOR +
|
"<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" + LINE_SEPARATOR +
|
||||||
@ -274,9 +275,11 @@ public class TransformerTest {
|
|||||||
|
|
||||||
System.out.println("Result after transformation:");
|
System.out.println("Result after transformation:");
|
||||||
System.out.println("============================");
|
System.out.println("============================");
|
||||||
OutputFormat format = new OutputFormat();
|
tryRunWithTmpPermission(() -> {
|
||||||
format.setIndenting(true);
|
OutputFormat format = new OutputFormat();
|
||||||
new XMLSerializer(System.out, format).serialize(document);
|
format.setIndenting(true);
|
||||||
|
new XMLSerializer(System.out, format).serialize(document);
|
||||||
|
}, new RuntimePermission("accessClassInPackage.com.sun.org.apache.xml.internal.serialize"));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("Node content for element valeur2:");
|
System.out.println("Node content for element valeur2:");
|
||||||
@ -529,7 +532,7 @@ public class TransformerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() throws IOException, TransformerException {
|
public void run() throws Exception {
|
||||||
printSnippet("Source:", sourceXml);
|
printSnippet("Source:", sourceXml);
|
||||||
|
|
||||||
printSnippet("Stylesheet:", xsl);
|
printSnippet("Stylesheet:", xsl);
|
||||||
@ -545,9 +548,11 @@ public class TransformerTest {
|
|||||||
|
|
||||||
System.out.println("Result after transformation:");
|
System.out.println("Result after transformation:");
|
||||||
System.out.println("============================");
|
System.out.println("============================");
|
||||||
OutputFormat format = new OutputFormat();
|
tryRunWithTmpPermission(() -> {
|
||||||
format.setIndenting(true);
|
OutputFormat format = new OutputFormat();
|
||||||
new XMLSerializer(System.out, format).serialize(document);
|
format.setIndenting(true);
|
||||||
|
new XMLSerializer(System.out, format).serialize(document);
|
||||||
|
}, new RuntimePermission("accessClassInPackage.com.sun.org.apache.xml.internal.serialize"));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
checkNodeNS(document.getElementsByTagName("test1").item(0), "ns2", "ns2", null);
|
checkNodeNS(document.getElementsByTagName("test1").item(0), "ns2", "ns2", null);
|
||||||
@ -566,9 +571,7 @@ public class TransformerTest {
|
|||||||
* definitions to reset the default namespace
|
* definitions to reset the default namespace
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testBug8162598() throws IOException,
|
public final void testBug8162598() throws Exception {
|
||||||
TransformerException
|
|
||||||
{
|
|
||||||
new Test8162598().run();
|
new Test8162598().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user