从Java脚本安全问题调用签名的Java Applet

时间:2015-06-20 22:51:08

标签: java javascript security applet

我有一个签名的Java Applet,它有以下方法:

public Boolean SaveToFile(String text)
{
File file = new File("c:\\myFile.txt");

// if file doesnt exists, then create it 
if ( ! file.exists( ) )
{
    file.createNewFile( );
}

file.setReadable(true);
file.setWritable(true);
FileWriter fw = new FileWriter( file.getAbsoluteFile( ) );
BufferedWriter bw = new BufferedWriter( fw );
bw.write( text );
bw.close( );
return true;

}

当我从applet中的按钮调用此方法时,它会毫无问题地创建文件。

问题是当我从java脚本调用此方法时,我有以下异常:

access denied (java.io.FilePermission c:\myFile.txt read)

如何修复此异常?

1 个答案:

答案 0 :(得分:0)

使用 Dim image As System.Drawing.Image = System.Drawing.Image.FromFile("C:\carl\addAccount.png") Dim buttonAdd As New RepositoryItemButtonEdit buttonAdd.TextEditStyle = TextEditStyles.HideTextEditor buttonAdd.Buttons(0).Kind = ButtonPredefines.Glyph buttonAdd.Buttons(0).Image = image AddHandler buttonAdd.Click, AddressOf Me.Button_Click Dim unbColumn As GridColumn = gvView.Columns.AddField("Button") unbColumn.VisibleIndex = gvgvView.Columns.Count unbColumn.ColumnEdit = buttonAdd gvView.OptionsView.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowAlways 解决了问题:

AccessController