当前位置: 技术问答>java相关
applet怎么读写本地文件
来源: 互联网 发布时间:2015-05-18
本文导语: 好象用signed applet 但是看不明白,请高人指点 最好有源码 谢谢! 毕业设计用 | 如果是想在本地的.java.policy像底下足够 // JMFPolicySection // Note: Use jdk1.2.2 or later // Due to jdk bug 4189625, whe...
好象用signed applet
但是看不明白,请高人指点
最好有源码
谢谢!
毕业设计用
但是看不明白,请高人指点
最好有源码
谢谢!
毕业设计用
|
如果是想在本地的.java.policy像底下足够
// JMFPolicySection
// Note: Use jdk1.2.2 or later
// Due to jdk bug 4189625, when using an applet, you will get
// "SecurityException: Access denied to ThreadGroup not owned by applet"
// This bug has been fixed in jdk1.2.2
grant {
//////////////////////////////////////////////////////
// Needed to play file: protocol
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "user.home", "read";
permission java.util.PropertyPermission "java.home", "read";
permission java.util.PropertyPermission "java.class.path", "read";
permission java.util.PropertyPermission "user.name", "read"; // for RTP
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
permission java.lang.RuntimePermission "accessClassInPackage.sun.audio";
permission java.lang.RuntimePermission "modifyThread";
permission java.lang.RuntimePermission "modifyThreadGroup";
permission java.lang.RuntimePermission "loadLibrary.*";
permission java.io.FilePermission "", "read";
// Note: If write permission for jmf.log is not there, you can still play
// file:, but the jmf.log won't be written.
permission java.io.FilePermission "${user.dir}${/}jmf.log", "write";
permission java.io.FilePermission "${user.home}${/}.JMStudioCfg", "write";
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// For http, ftp protocol
// You need 'accept' permission for rtp
permission java.net.SocketPermission "*", "connect,accept";
// JMFPolicyCacheDir
permission java.io.FilePermission "C:\WINNT\TEMP\*", "write";
permission java.io.FilePermission "C:\WINNT\TEMP\*", "delete";
/////////////////////////////////////////////////////
permission java.awt.AWTPermission "showWindowWithoutWarningBanner";
permission javax.sound.sampled.AudioPermission "record";
permission java.net.SocketPermission "-", "listen";
permission java.net.SocketPermission "-", "accept";
permission java.net.SocketPermission "-", "connect";
permission java.net.SocketPermission "-", "resolve";
permission java.security.AllPermission;
};
grant SignedBy "saili" {
permission java.net.SocketPermission "-", "listen";
permission java.net.SocketPermission "-", "accept";
permission java.net.SocketPermission "-", "connect";
permission java.net.SocketPermission "-", "resolve";
permission java.security.AllPermission;
};
如果想数字签名搜索本论坛吧。
// JMFPolicySection
// Note: Use jdk1.2.2 or later
// Due to jdk bug 4189625, when using an applet, you will get
// "SecurityException: Access denied to ThreadGroup not owned by applet"
// This bug has been fixed in jdk1.2.2
grant {
//////////////////////////////////////////////////////
// Needed to play file: protocol
permission java.util.PropertyPermission "user.dir", "read";
permission java.util.PropertyPermission "user.home", "read";
permission java.util.PropertyPermission "java.home", "read";
permission java.util.PropertyPermission "java.class.path", "read";
permission java.util.PropertyPermission "user.name", "read"; // for RTP
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
permission java.lang.RuntimePermission "accessClassInPackage.sun.audio";
permission java.lang.RuntimePermission "modifyThread";
permission java.lang.RuntimePermission "modifyThreadGroup";
permission java.lang.RuntimePermission "loadLibrary.*";
permission java.io.FilePermission "", "read";
// Note: If write permission for jmf.log is not there, you can still play
// file:, but the jmf.log won't be written.
permission java.io.FilePermission "${user.dir}${/}jmf.log", "write";
permission java.io.FilePermission "${user.home}${/}.JMStudioCfg", "write";
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// For http, ftp protocol
// You need 'accept' permission for rtp
permission java.net.SocketPermission "*", "connect,accept";
// JMFPolicyCacheDir
permission java.io.FilePermission "C:\WINNT\TEMP\*", "write";
permission java.io.FilePermission "C:\WINNT\TEMP\*", "delete";
/////////////////////////////////////////////////////
permission java.awt.AWTPermission "showWindowWithoutWarningBanner";
permission javax.sound.sampled.AudioPermission "record";
permission java.net.SocketPermission "-", "listen";
permission java.net.SocketPermission "-", "accept";
permission java.net.SocketPermission "-", "connect";
permission java.net.SocketPermission "-", "resolve";
permission java.security.AllPermission;
};
grant SignedBy "saili" {
permission java.net.SocketPermission "-", "listen";
permission java.net.SocketPermission "-", "accept";
permission java.net.SocketPermission "-", "connect";
permission java.net.SocketPermission "-", "resolve";
permission java.security.AllPermission;
};
如果想数字签名搜索本论坛吧。
|
一般在applet中需要进行数字签名才有权限访问本地资源,如果不进行数字签名也可以直接修改本地的java策略文件.java.policy
http://www.csdn.net/expert/topic/476/476203.xml?temp=.8232233
http://www.csdn.net/expert/topic/476/476203.xml?temp=.8232233
|
one way is modified policy file(this file mostly is uder %user%.java - if you have installed java plug-in). but the way is only used since you have installed java plug-in.
the other way is sign your applet. this way is more complex relatively. because java 1.1 & java 1.2 has different means, ie and netscape also has different way.
with the second way, if you'll signed at ie. please check microsoft sdk 4.0 to find answer. if you'll signed at nc. please check nescape sign tools 1.3 to find, too.
the other way is sign your applet. this way is more complex relatively. because java 1.1 & java 1.2 has different means, ie and netscape also has different way.
with the second way, if you'll signed at ie. please check microsoft sdk 4.0 to find answer. if you'll signed at nc. please check nescape sign tools 1.3 to find, too.