JDK-8096432 : WebView rendering of Web Fonts requires unacceptable 'AllPermissions' granted by Security Manager
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8u25
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2014-11-12
  • Updated: 2015-06-12
  • Resolved: 2014-11-13
Related Reports
Relates :  
Description
In 8u25, it seems that if our application ClassLoader is involved in the Permission check of a web font, then we need to grant  "AllPermissions" to our application code to get this to work with the security manager on. It it not acceptable for us to grant this to the code that launches the WebView.

For example, go here "http://fortawesome.github.io/Font-Awesome/icons/"

The web font works fine with security manager off; but it shows the wrong font when the security manager is on (unless we add grant AllPermissions to our appliction).

Here is the security manager debug; we are told that we need to add entry for our "testTest.jar" module which launches the browser (this is an unacceptable thing for us to add to our application):

access: access denied ("java.security.AllPermission" "<all permissions>" "<all actions>")
java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(Thread.java:1329)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:447)
	at java.security.AccessController.checkPermission(AccessController.java:884)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at com.sun.javafx.application.PlatformImpl.isSupported(PlatformImpl.java:481)
	at javafx.application.Platform.isSupported(Platform.java:166)
	at javafx.scene.Scene.<init>(Scene.java:329)
	at javafx.scene.Scene.<init>(Scene.java:181)
	at test.workbench.SimpleSwingBrowser$2.run(SimpleSwingBrowser.java:201)
	at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
	at com.sun.javafx.application.PlatformImpl$$Lambda$107/605914852.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
	at com.sun.javafx.application.PlatformImpl$$Lambda$106/677804791.run(Unknown Source)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
	at com.sun.glass.ui.win.WinApplication$$Lambda$98/1683068293.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:745)
access: access allowed ("java.security.SecurityPermission" "getPolicy")
access: access allowed ("java.io.FilePermission" "D:\niagara\r40\niagara_home\modules\testTest.jar" "read")
access: domain that failed ProtectionDomain  (file:/d:/niagara/r40/niagara_home/modules/testTest.jar <no signer certificates>)
 com.tridium.sys.module.ModuleClassLoader for testTest-Tridium-4.0.1 [sc798w]
 <no principals>
 java.security.Permissions@177667e5 (
 ("java.io.FilePermission" "C:\Users\e333930\AppData\Local\Temp\\-" "read,write,delete")
 ("java.io.FilePermission" "<<ALL FILES>>" "read,write")
 (unresolved java.lang.NetPermission getCookieHandler null)
 ("java.net.SocketPermission" "localhost:0" "listen,resolve")
 ("java.net.SocketPermission" "*:1-100000" "connect,resolve")
 ("java.util.logging.LoggingPermission" "control")
 ("java.util.PropertyPermission" "java.specification.version" "read")
 ("java.util.PropertyPermission" "java.version" "read")
 ("java.util.PropertyPermission" "os.arch" "read")
 ("java.util.PropertyPermission" "java.specification.vendor" "read")
 ("java.util.PropertyPermission" "java.vm.specification.name" "read")
 ("java.util.PropertyPermission" "*" "read")
 ("java.util.PropertyPermission" "java.vm.vendor" "read")
 ("java.util.PropertyPermission" "path.separator" "read")
 ("java.util.PropertyPermission" "os.version" "read")
 ("java.util.PropertyPermission" "file.separator" "read")
 ("java.util.PropertyPermission" "line.separator" "read")
 ("java.util.PropertyPermission" "java.vm.specification.vendor" "read")
 ("java.util.PropertyPermission" "java.specification.name" "read")
 ("java.util.PropertyPermission" "java.vendor.url" "read")
 ("java.util.PropertyPermission" "java.vendor" "read")
 ("java.util.PropertyPermission" "java.vm.version" "read")
 ("java.util.PropertyPermission" "java.vm.name" "read")
 ("java.util.PropertyPermission" "java.vm.specification.version" "read")
 ("java.util.PropertyPermission" "os.name" "read")
 ("java.util.PropertyPermission" "java.class.version" "read")
 ("java.lang.RuntimePermission" "accessDeclaredMembers")
 ("java.lang.RuntimePermission" "accessClassInPackage.sun.util.logging.resources")
 ("java.lang.RuntimePermission" "exitVM.0")
 ("java.lang.RuntimePermission" "stopThread")
 ("java.awt.AWTPermission" "accessClipboard")
 ("java.awt.AWTPermission" "showWindowWithoutWarningBanner")
)




Comments
I filed RT-39384 to track adding fine-grained privileges to FX.
13-11-2014

Understood. Thanks very much for taking a look.
13-11-2014

We had an open JIRA to use finer-graned permissions, but there wasn't enough interest in doing this, nor support in the deployment dialogs to present such an option to users (so applets and web start apps have no choice but to request all permissions). Currently we use AllPermissions for this and other features (transparent windows, keyboard input in FullScreen mode, etc) that require permission. You could file a JIRA to request that we add fine-grained permissions as an enhancement, but we are unlikely to do this before JDK 9 at the earliest (and I can't promise that we will do it for 9).
13-11-2014

Could it at least be restricted to a specific type of permission? The required permission is AllPermission so in order for any application to load a font, it likewise has to be granted AllPermission - there is no other option.
13-11-2014

This was an intentional change, so I am closing this bug as "Won't fix". This is now documented in the loadFont method: * If the application does not have the proper permission then this method * will return the default system font with the specified font size. Perhaps we could document this more clearly, but we will not change the behavior.
13-11-2014

Here is the stack trace that applies specifically to fonts: access: access denied ("java.security.AllPermission" "<all permissions>" "<all actions>") java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1329) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:447) at java.security.AccessController.checkPermission(AccessController.java:884) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at com.sun.javafx.font.PrismFontFactory.hasPermission(PrismFontFactory.java:1773) at com.sun.javafx.font.PrismFontFactory.loadEmbeddedFont(PrismFontFactory.java:1417) at com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:92) at javafx.scene.text.Font.loadFont(Font.java:408) {our code's stack trace starts here}
12-11-2014