Initial
This commit is contained in:
109
test/Proto.java
Normal file
109
test/Proto.java
Normal file
@@ -0,0 +1,109 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.applet.Applet.*;
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import com.ms.security.*;
|
||||
|
||||
public class Proto extends java.applet.Applet
|
||||
{
|
||||
private SocketControl mSocketControl;
|
||||
// private SocketPermission mSocketPermission;
|
||||
// ConnectionManager mConnectionManager;
|
||||
String mStrAddress=null;
|
||||
SocketControl socketControl=null;
|
||||
private Label mLabelMessage;
|
||||
private Button mButtonEvaluate;
|
||||
|
||||
public void init()
|
||||
{
|
||||
mStrAddress=new String("209.139.139.200");
|
||||
performLayout();
|
||||
try{if(Class.forName("com.ms.security.PolicyEngine") != null)
|
||||
{
|
||||
mLabelMessage.setText("asserting permissions");
|
||||
PolicyEngine.assertPermission(PermissionID.NETIO);}
|
||||
}
|
||||
catch(Throwable cnfe){mLabelMessage.setText("policy assertion failed");return;}
|
||||
|
||||
// SecurityManager securityManager=System.getSecurityManager();
|
||||
// try{securityManager.checkConnect(mStrAddress,1024);}
|
||||
// catch(SecurityException securityException){mLabelMessage.setText("checkConnect failed");return;}
|
||||
|
||||
try{mSocketControl=new SocketControl(mStrAddress,1024);}
|
||||
catch(SecurityExceptionEx exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
mLabelMessage.setText("SecurityExceptionEx");
|
||||
return;
|
||||
};
|
||||
catch(IOException ioException){mLabelMessage.setText("java.io.IOException");return;}
|
||||
try{mSocketControl.closeSocket();}
|
||||
catch(IOException ioException){mLabelMessage.setText("java.io.IOException");return;}
|
||||
mLabelMessage.setText("Success!");
|
||||
|
||||
|
||||
|
||||
// try{if(Class.forName("com.ms.security.PolicyEngine") != null)PolicyEngine.assertPermission(PermissionID.NETIO);}
|
||||
// catch(Throwable cnfe){;}
|
||||
// mSocketPermission=new SocketPermission("192.168.1.2","connect");
|
||||
// performLayout();
|
||||
// mLabelMessage.setText("attempting connection...");
|
||||
|
||||
// try{SocketControl socketControl=new SocketControl("209.139.139.200",1024);}
|
||||
// catch(IOException ioException){mLabelMessage.setText("java.io.IOException");}
|
||||
|
||||
// try{socketControl.closeSocket();}
|
||||
// catch(IOException ioException){mLabelMessage.setText("IOException closing socket");}
|
||||
|
||||
// public SocketControl(String strHost,int port)throws IOException
|
||||
|
||||
// try{mSocketControl=new SocketControl("209.139.139.200",1024);}
|
||||
// catch(IOException ioException){mLabelMessage.setText("java.io.IOException");}
|
||||
// catch(SecurityException exception){mLabelMessage.setText("security exception");}
|
||||
// try{mSocketControl.closeSocket();}
|
||||
// catch(IOException ioException){;}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if(!mSocketControl.isConnected())mLabelMessage.setText("Connection failed.");
|
||||
else
|
||||
{
|
||||
mLabelMessage.setText("Connected...");
|
||||
String strLine=new String();
|
||||
strLine=mSocketControl.readLine();
|
||||
if(null==strLine)mLabelMessage.setText("nothing received.");
|
||||
else mLabelMessage.setText(strLine);
|
||||
try{mSocketControl.closeSocket();}
|
||||
catch(IOException ioException){mLabelMessage.setText("java.io.Exception");}
|
||||
}
|
||||
*/
|
||||
}
|
||||
public void update(Graphics graphics)
|
||||
{
|
||||
}
|
||||
public void paint(Graphics graphics)
|
||||
{
|
||||
}
|
||||
public void performLayout()
|
||||
{
|
||||
GridBagLayout layout=new GridBagLayout();
|
||||
GridBagConstraints constraints=new GridBagConstraints();
|
||||
setFont(new Font("Arial",Font.PLAIN,12));
|
||||
setLayout(layout);
|
||||
constraints.gridwidth=1;
|
||||
constraints.fill=GridBagConstraints.BOTH;
|
||||
constraints.weightx=0.25;
|
||||
mButtonEvaluate=new Button("Evaluate");
|
||||
constraints.gridwidth=GridBagConstraints.REMAINDER;
|
||||
layout.setConstraints(mButtonEvaluate,constraints);
|
||||
add(mButtonEvaluate);
|
||||
|
||||
mLabelMessage=new Label("Ready.",Label.LEFT);
|
||||
constraints.gridwidth=GridBagConstraints.REMAINDER;
|
||||
layout.setConstraints(mLabelMessage,constraints);
|
||||
add(mLabelMessage);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user