自签名录音机小程序中的安全例外 [英] Security Exception in self signed sound recorder Applet

查看:22
本文介绍了自签名录音机小程序中的安全例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个用于录制声音的小程序.当我尝试打开数据线时,它会引发异常.

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

TargetDataLine.open()

java.security.AccessControlException:访问被拒绝(javax.sound.sampled.AudioPermission 记录)

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

我的小程序是自签名的,所有其他 jar 文件都是自签名的.

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

以前我使用不同的线程来启动 TargetDataLine 并关闭该行.之后,我没有创建另一个线程,而是切换到 Executorservice.它适用于线程,但使用 ExecutorService 抛出上述异常.

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.

推荐答案

由于执行器服务在有 javascript 调用时会启动一个新线程,因此线程的安全级别设置为 javascript 线程的安全级别.

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.

所以使用 AccessControl.doPrivilaged 有助于解决问题.此处说明了如何操作.

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

这篇关于自签名录音机小程序中的安全例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆