Security Exception in self signed sound recorder Applet

廉价感情. 提交于 2019-12-24 06:44:21

问题


I have created an applet for recording sound. It throws an exception when I try to open a dataline.

TargetDataLine.open()

java.security.AccessControlException: access denied (javax.sound.sampled.AudioPermission record)

My applet is self signed, all other jar files are self signed.

Previously I was using a different thread to start the TargetDataLine and close the line. Afterwords instead of creating another thread, I switched to Executorservice. It works fine with thread but throws above exception with ExecutorService.


回答1:


Since the executor service starts a new thread when there is call from javascript, the security level of the thread is set to that of javascript thread.

So using AccessControl.doPrivilaged helps to solve the problem.Explained here how to do it.



来源:https://stackoverflow.com/questions/7709377/security-exception-in-self-signed-sound-recorder-applet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!