You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by dahepe <pe...@gmx.net> on 2009/12/03 16:47:07 UTC

Using in applet

Hi,

I'm trying to integrate FOP in a client side application that is made
available as applet/java webstart application. The integration works well
but I'm not able to use the &lt;fo:external-graphic ... /&gt; tag to embed
image files into the generated PDF. When trying to embed an image using the
following directive

...
&lt;fo:block&gt;
    &lt;fo:external-graphic content-height="70"
src="url('file:c:///temp/my-image.png')" /&gt;
&lt;/fo:block&gt;
...


I get a

access: access denied (java.io.FilePermission file:c:\temp\my-image.png
read)


on the Java console. Enabling security debug output (Runtime parameter
-Djava.security.debug=access:failure) yielded the following details
(complete output:  http://old.nabble.com/file/p26628106/fop-stacktrace.log
fop-stacktrace.log )

access: access denied (java.io.FilePermission file:c:\temp\my-image.png
read)
java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(Unknown Source)
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkRead(Unknown Source)
	at java.io.File.canRead(Unknown Source)
	...
	at
com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(Unknown
Source)
	at MyXSLTemplate.template$dot$0()
	at MyXSLTemplate.applyTemplates()
	at MyXSLTemplate.applyTemplates()
	at MyXSLTemplate.transform()
	at
com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(Unknown
Source)
        ...
	at
com.transflow.cosa.portal.client.PortalClient$RunThread.run(PortalClient.java:422)
access: access allowed (java.security.SecurityPermission getPolicy)
access: domain that failed ProtectionDomain  (null )

com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl$TransletClassLoader@1573872
 &lt;no principals&gt;
 java.security.Permissions@96d2c2 (
 (java.util.PropertyPermission line.separator read)
 ...
 (java.net.SocketPermission localhost:1024- listen,resolve)
 (java.lang.RuntimePermission stopThread)
)


FEHLER:  'access denied (java.io.FilePermission file:c:\temp\my-image.png
read)'
Fehler in write: java.security.AccessControlException: access denied
(java.io.FilePermission file:c:\temp\my-image.png read)


For me this looks like xalan dynamically generates a class for my XSL
template (MyXSLTemplate) and this class tries to access the external file.
The application is running with a security manager (applet/web start) and
this class does not have the permission to access the file as it is not
signed (unlike the rest of the application).

The file location (locally HD or on a web server) doesn't seem to matter as
the error is always the same...

Is this problem already known and is there a possible solution/workaround
for this? Can't image I'm the first one to try to embed an external graphic
using FOP in an applet context, but search didn't give my any usable
results...

Java version: JRE 1.6.0_17

FOP version: 0.94


Best regards

-- 
View this message in context: http://old.nabble.com/Using-%3Cfo%3Aexternal-graphic-...--%3E-in-applet-tp26628106p26628106.html
Sent from the FOP - Users mailing list archive at Nabble.com.

Re: Using in applet

Posted by dahepe <pe...@gmx.net>.
Hi,

I'm really surprised, that no one else seems to have this problem...

At least we found a workaround to make the templates and the
&lt;external-graphic ... /&gt; work for us. There seem to be two feasible
solutions that don't require too much changes:

  
Implement a custom 
http://java.sun.com/javase/6/docs/api/javax/xml/transform/URIResolver.html
URIResolver , that loads the external references in the template in advance
and make the Transformer use this resolver. As the external references might
also come from included files, you will have to generate the FO first and
than fetch the referenced graphics in the URIResolver.
  
Replace the used SecurityManager by a custom implementation, that allows
access to the requested resources. As the SecurityManager is a system (JVM)
wide setting you should probably replace the SecurityManager after
generation of the PDF again with the one used previously.


Best Regards
-- 
View this message in context: http://old.nabble.com/Using-%3Cfo%3Aexternal-graphic-...--%3E-in-applet-tp26628106p26794599.html
Sent from the FOP - Users mailing list archive at Nabble.com.