📄 sslconnectionserver.java
字号:
package SOMA.security.net.ssl;
/*
This is the SSL-protected version of StringLengthServer.java.
StringLengthServer.java (and SSL_StringLengthServer.java) do
these steps:
1. Listen for connections from clients.
2. Return the length of incoming strings.
*/
import java.net.*;
import java.io.*;
import java.security.*;
import java.security.cert.X509Certificate;
import iaik.security.ssl.*;
import iaik.asn1.structures.Name;
import com.entrust.security.provider.*;
import com.entrust.toolkit.*;
import com.entrust.util.*;
import com.entrust.x509.directory.*;
import SOMA.security.infrastructure.*;
import SOMA.network.connection.*;
public class SSLConnectionServer extends ConnectionServer implements SSLControlCaller
{
// Infrastruttura di riferimento.
Infrastructure infrastructure = null;
// profilo utente per la connessione.
ProfileManager profile = null;
int controlCaller = ControlCaller_ON;
Thread myServerDaemon = null;
ServerSocket myServerSocket = null;
ConnectionFactory myConnectionFactory = null;
Object status = OFF;
String ErrorDescription = "";
int port = 0;
int backlog = 50;
/*
Thread myServerDaemon = null;
ServerSocket myServerSocket = null;
ConnectionFactory myConnectionFactory = null;
int status = OFF;
String ErrorDescription = "";
int port = 0;
int backlog = 50;
*/
public SSLConnectionServer (int port, int backlog, ConnectionFactory myConnectionFactory )
{
super ( port, backlog, myConnectionFactory );
this.port = port;
this.backlog = backlog;
this.myConnectionFactory = myConnectionFactory;
}
public SSLConnectionServer (int port, int backlog, ConnectionFactory myConnectionFactory, ProfileManager profile, int controlCaller)
{
super ( port, backlog, myConnectionFactory );
this.infrastructure = profile.getEntrustInfrastructure();
this.profile = profile;
this.controlCaller = controlCaller;
this.port = port;
this.backlog = backlog;
this.myConnectionFactory = myConnectionFactory;
}
public void setInfrastructure(Infrastructure infrastructure)
{
this.infrastructure = infrastructure;
}
public void setProfile(ProfileManager profile)
{
this.profile = profile;
}
public void setControlCaller(int controlCaller) throws SSLException
{
if (this.status != ON)
this.controlCaller = controlCaller;
else
throw new SSLException( "Server already ON" );
}
public int getControlCaller()
{
return this.controlCaller;
}
/** Restituisce lo stato.
* Metodo ereditato. */
// public int getStatus()
/* Rappresentazione in stringa dello stato del server. */
public String toString()
{
return "<SSLConnectionServer: " + this +
": ControlCaller = " +
(this.controlCaller == ControlCaller_ON ? "ON" : "OFF") +
"\\n " + super.toString() + ">";
}
/** Avvia il server. */
public synchronized void start() throws IOException, ConnectionServerException
{
if( status != ON )
{
try
{
myServerSocket = init();
myServerDaemon = new Thread( this, toString() );
status = ON;
myServerDaemon.start();
}
catch( Exception e )
{
status = ERROR;
ErrorDescription = e.toString();
// throw( e );
}
}
else
throw new ConnectionServerException( "Server already ON" );
}
/** Arresta il server.
* Attenzione: questo metodo potrebbe non essere riscritto;
* lo si riscrive solo per poter ridefinire l'eccezione
* che viene chiamata in caso di stato diverso da OFF.
**/
public synchronized void stop() throws IOException, ConnectionServerException
{
if( status != OFF )
{
try
{
status = OFF;
if( myServerSocket != null )
myServerSocket.close();
// Vedo se cos
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -