]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-3174: Allow sections which need security permissions to be run when AllPermission...
authorSimon Steiner <ssteiner@apache.org>
Tue, 2 Apr 2024 12:15:58 +0000 (13:15 +0100)
committerSimon Steiner <ssteiner@apache.org>
Tue, 2 Apr 2024 12:15:58 +0000 (13:15 +0100)
fop-core/src/main/java/org/apache/fop/apps/FopFactory.java

index 0c57d264316cf1357ff77283099d848f0cd9a918..3b90614b42ad0bd934cef00b48a000dbc5cf933f 100644 (file)
@@ -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;
     }
 
     /**