From 60da43c2d8a8b229678209276080bf06dc44f0f8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 11 Aug 2011 06:18:49 +0200 Subject: Enclose file IO access in priviledged block --- .../font/typecast/TypecastFontConstructor.java | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java index cb0d1a372..126328ad7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java @@ -30,6 +30,8 @@ package jogamp.graph.font.typecast; import java.io.File; import java.io.IOException; import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.media.opengl.GLException; @@ -54,16 +56,27 @@ public class TypecastFontConstructor implements FontConstructor { return null; } - public Font create(URL furl) throws IOException { - final File tf = File.createTempFile( "joglfont", ".ttf"); - final int len = IOUtil.copyURL2File(furl, tf); - if(len==0) { - tf.delete(); - throw new GLException("Font of stream "+furl+" was zero bytes"); - } - final Font f = create(tf); - tf.delete(); - return f; + public Font create(final URL furl) throws IOException { + return (Font) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + File tf = null; + int len=0; + Font f = null; + try { + tf = File.createTempFile( "joglfont", ".ttf"); + len = IOUtil.copyURL2File(furl, tf); + if(len==0) { + tf.delete(); + throw new GLException("Font of stream "+furl+" was zero bytes"); + } + f = create(tf); + tf.delete(); + } catch (IOException e) { + e.printStackTrace(); + } + return f; + } + }); } -} \ No newline at end of file +} -- cgit v1.2.3