|
Ok I'm having this issue with my applet here. I compile it and run it and it always throws an exception. 'java.security.AccessControlException: access denied (java.net.SocketPermission asylym-mud.org connect, resolve)'
I've looked up many different possible solutions and the bulk of them state that I need to genereate a certificate for it and assign it via the 'grant' code to the 'jre/lib/security/java.policy' file. I've done all this and it still gives me the same exception. Any ideas anyone?
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.TextField.*;
import java.lang.*;
import java.util.*;
public class AMClient extends JApplet implements ActionListener{
static public Socket localSocket;
static final long serialVersionUID = 42L;
static public PrintWriter out;
static public InputStream in;
static public JFrame fAMClient;
static public JPanel nPanel,cPanel,sPanel;
static public JButton btnConnect;
static public JTextField tfInput;
static public JTextArea taMud;
public void init()
{
try
{
System.out.println("1");
System.getSecurityManager().checkPermission(new SocketPermission("asylum-mud.org", "connect"));
localSocket = new Socket("asylum-mud.org", 6715);
System.out.println("2");
in = new BufferedInputStream(localSocket.getInputStream());
System.out.println("3");
out= new PrintWriter(localSocket.getOutputStream(),true);
}
catch(Exception e)
{
System.out.println(e);
}
tfInput= new JTextField(30);
btnConnect = new JButton("Connect");
taMud = new JTextArea(30,50);
add(btnConnect);
add(taMud);
add(tfInput);
btnConnect.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == btnConnect)
{
btnConnect.enable(false);
}
try
{
taMud.append("6");
String stdInn;
taMud.append("7");
stdInn = slurp(in,4122 );
taMud.append("8");
taMud.append(stdInn);
taMud.append("9");
out.flush();
}
catch(Exception ioe)
{
System.out.println(ioe.getMessage());
}
}
public static void main( String[] args )
{
try
{
System.out.println("1");
localSocket = new Socket("asylum-mud.org", 6715);
System.out.println("2");
in = new BufferedInputStream(localSocket.getInputStream());
System.out.println("3");
out= new PrintWriter(localSocket.getOutputStream(),true);
}
catch(Exception e)
{
System.out.println(e);
}
fAMClient = new JFrame();
System.out.println("init 1");
JApplet aAMClient = new JApplet();
aAMClient.init();
fAMClient.getContentPane().add(aAMClient);
fAMClient.setSize(1200, 1200);
fAMClient.setVisible(true);
fAMClient.setTitle("AbsentMirage Client");
aAMClient.start();
}
public static String slurp(final InputStream is, final int bufferSize)
{
final char[] buffer = new char[bufferSize];
final StringBuilder slurpOut = new StringBuilder();
taMud.append("slurp1");
try
{
taMud.append("slurp2");
final Reader slurpIn = new InputStreamReader(is, "UTF-8");
taMud.append("slurp3");
try
{
final int rsz = slurpIn.read(buffer, 0, buffer.length);
slurpOut.append(buffer, 0, rsz);
}
catch (IOException ex)
{
System.out.println(ex);
}
finally
{
try
{
in.close();
}
catch (IOException ex)
{
System.out.println(ex);
}
}
}
catch (UnsupportedEncodingException ex)
{
System.out.println(ex);
}
return out.toString();
}
}
|
|
|
|
|
ok I think I've figured out what it is... I haven't uploaded my applet to asylum-mud.org yet and have been trying to test it locally on my machine.
|
|
|
|