Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Granting AWTPermission  RSS feed

 
Jyothi Pathuri
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Is there any way to grant AWTPermission to a component programmatically(other than through grant command).

Regards,
Jyothi.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean from within the code that required the permission? No, because that would amount to the code granting itself the permission to execute, which would be a breach of the security model.
 
Jyothi Pathuri
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you ULf for your immediate response. In my code, I am trying to implement copy/paste feature for a component which is developed from scratch. Copy is working fine, because i am able to view the copied contents through clipboard. but when i am trying to paste the contents in the component it is throwing
"Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)".

Please help me how to solve this problem programmatically.

Regards,
Jyothi.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of application is this - an applet, a desktop application or a WebStart application?
 
Jyothi Pathuri
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is an applet.

The error i am getting is

Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)
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.checkSystemClipboardAccess(Unknown Source)
at sun.awt.windows.WToolkit.getSystemClipboard(Unknown Source)
at ChoicePlus.keyPressed(ChoicePlus.java:739)
at java.awt.Component.processKeyEvent(Unknown Source)
at EditPlus.processKeyEvent(EditPlus.java:2209)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Please please help to solve this problem.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jyothi Pathuri:


Is there any way to grant AWTPermission to a component programmatically


Its like issuing yourself a driving license.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to sign the applet. See here: HowCanAnAppletReadFilesOnTheLocalFileSystem
 
Madhu Menda
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:You need to sign the applet. See here: HowCanAnAppletReadFilesOnTheLocalFileSystem



permission java.awt.AWTPermission "accessClipboard";
permission java.awt.AWTPermission "accessEventQueue";
permission java.awt.AWTPermission "showWindowWithoutWarningBanner";

add these in java.policy file
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!