问题
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