D
Darren
No i've edited the global java.policy file and added the entry
permission java.io.Filepermission
"/usr/local/apache2/htdocs/hello.html","read";
permission java.net.SocketPermission ":80","connect,resolve,accept";
Then i made sure rmiregistry is running then i run my applet
and i still get
thread applet-Helloserver.class[1] > java.security.AccessControlException:
access denied (java.net.SocketPermission 10.0.0.254:80 connect,resolve)
on the line
BufferedReader in = new BufferedReader(new
InputStreamReader(location.openStream()));
Does anyone know why and how i can fix it?
I've included the full script below
Thanks in advance
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import java.security.*;
public class Helloserver extends Applet
{
private String hostname = "10.0.0.254";
private String protocol = "http://";
private String port="80";
private URL location;
private Object content;
private String getStr = "GET / HTTP/1.1";
public void init()
{
hello();
}
public void paint(Graphics g)
{
g.drawString(hostname, 50, 60 );
}
/**
* Method hello
*
*
* @return
*
*/
protected boolean hello()
{
String host=hostname+":"+port;
hostname = host;
String str,buf,server;
buf="";
try
{
location=new URL(protocol+hostname);
server=location.getHost();
server=server+"/hello.html";
System.out.println(server);
SocketPermission sp = new SocketPermission (server, "connect,resolve");
FilePermission fp = new FilePermission ("<<ALL FILES>>","read");
BufferedReader in = new BufferedReader(new
InputStreamReader(location.openStream()));
while ((str = in.readLine()) != null)
{
buf=buf+str;
}
in.close();
System.out.println(buf);
}
catch(MalformedURLException u)
{
hostname=u.getMessage();
}
catch(IOException u)
{
hostname=u.getMessage();
}
return true;
}
}
permission java.io.Filepermission
"/usr/local/apache2/htdocs/hello.html","read";
permission java.net.SocketPermission ":80","connect,resolve,accept";
Then i made sure rmiregistry is running then i run my applet
and i still get
thread applet-Helloserver.class[1] > java.security.AccessControlException:
access denied (java.net.SocketPermission 10.0.0.254:80 connect,resolve)
on the line
BufferedReader in = new BufferedReader(new
InputStreamReader(location.openStream()));
Does anyone know why and how i can fix it?
I've included the full script below
Thanks in advance
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import java.security.*;
public class Helloserver extends Applet
{
private String hostname = "10.0.0.254";
private String protocol = "http://";
private String port="80";
private URL location;
private Object content;
private String getStr = "GET / HTTP/1.1";
public void init()
{
hello();
}
public void paint(Graphics g)
{
g.drawString(hostname, 50, 60 );
}
/**
* Method hello
*
*
* @return
*
*/
protected boolean hello()
{
String host=hostname+":"+port;
hostname = host;
String str,buf,server;
buf="";
try
{
location=new URL(protocol+hostname);
server=location.getHost();
server=server+"/hello.html";
System.out.println(server);
SocketPermission sp = new SocketPermission (server, "connect,resolve");
FilePermission fp = new FilePermission ("<<ALL FILES>>","read");
BufferedReader in = new BufferedReader(new
InputStreamReader(location.openStream()));
while ((str = in.readLine()) != null)
{
buf=buf+str;
}
in.close();
System.out.println(buf);
}
catch(MalformedURLException u)
{
hostname=u.getMessage();
}
catch(IOException u)
{
hostname=u.getMessage();
}
return true;
}
}