Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

security problem

 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.security.AccessControlException: access denied (java.io.FilePermission c:\one.txt read)

this massage comes when i try to run my applet into my under constracting project i am tring to load file to my server,

by the way applet viewer can run this applet and it work, policy tool i have put permission for this appelt but i do not know if it work or not.

thanks

if you need my applet to test it here is it.
to run it type location of your file.

// TestApplet.java
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.border.*;

public class TestApplet extends JApplet implements ActionListener {

private JPanel pane = null;
private JScrollPane scrolling = null;
private JTextPane fileBox = null;
private JTextField tfFilename = null;
private JButton butLoad = null;
private final String LOAD = "load";

public void init() {
try {
jbInit();
} catch(Exception e) {
e.printStackTrace();
}
}


// method which will read data from file, and return it in
// String

public String readFile(String fn) {
String thisLine, ret = "";
try {
FileInputStream fin = new FileInputStream(fn);
BufferedReader myInput = new BufferedReader
(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null) {
ret += thisLine + "\n";
}
} catch (Exception e) {
ret = e + "Cannot load, exception!";
}
return ret;
}

private void jbInit() throws Exception {
pane = new JPanel();
pane.setBounds(new Rectangle(0, 0, 500, 325));
pane.setLayout(null);
pane.setBorder(BorderFactory.createEtchedBorder(
EtchedBorder.LOWERED));
pane.setBackground(new Color(221, 194, 219));

fileBox = new JTextPane();
fileBox.setText("");
fileBox.setEditable(false);
scrolling = new JScrollPane(fileBox);
scrolling.setBounds(new Rectangle(16, 65, 295, 225));

tfFilename = new JTextField();
tfFilename.setText("");
tfFilename.setBounds(new Rectangle(16, 23, 206, 29));

butLoad = new JButton();
butLoad.setBounds(new Rectangle(231, 23, 80, 30));
butLoad.setText("Load");
butLoad.setActionCommand(LOAD);
butLoad.addActionListener(this);

pane.add(scrolling);
pane.add(tfFilename);
pane.add(butLoad);

setContentPane(pane);
}

public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(LOAD)) {
fileBox.setText(readFile(tfFilename.getText()));
}
}
}
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More interesting than the applet code would be the policy file you're using. Here is some more information on that subject.
[ October 19, 2006: Message edited by: Ulf Dittmer ]
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
answer for this is in this site
you can made your applete to access your resource

http://personal.vsnl.com/sureshms/javasign1.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic