aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2024-04-02 13:15:58 +0100
committerSimon Steiner <ssteiner@apache.org>2024-04-02 13:15:58 +0100
commit64846a5c4ccdf0d900058fef60c2232926dbd6ad (patch)
tree4c7e0ebc14e0bfd97009e78de24bd3a33848abb4
parentde9d1b17e9cb89fb6f239e591d3092d98a251a2f (diff)
downloadxmlgraphics-fop-64846a5c4ccdf0d900058fef60c2232926dbd6ad.tar.gz
xmlgraphics-fop-64846a5c4ccdf0d900058fef60c2232926dbd6ad.zip
FOP-3174: Allow sections which need security permissions to be run when AllPermission denied in caller code
-rw-r--r--fop-core/src/main/java/org/apache/fop/apps/FopFactory.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java b/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java
index 0c57d2643..3b90614b4 100644
--- a/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java
+++ b/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java
@@ -164,9 +164,26 @@ public final class FopFactory implements ImageContext {
* @throws SAXException
* @throws IOException
*/
- public static FopFactory newInstance(URI baseURI, InputStream confStream) throws SAXException,
+ public static FopFactory newInstance(final URI baseURI, final InputStream confStream) throws SAXException,
IOException {
- return new FopConfParser(confStream, baseURI).getFopFactoryBuilder().build();
+ Object action = AccessController.doPrivileged(
+ new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ return new FopConfParser(confStream, baseURI).getFopFactoryBuilder().build();
+ } catch (SAXException | IOException e) {
+ return e;
+ }
+ }
+ }
+ );
+ if (action instanceof SAXException) {
+ throw (SAXException) action;
+ }
+ if (action instanceof IOException) {
+ throw (IOException) action;
+ }
+ return (FopFactory) action;
}
/**