org.ssonet.examples.net
Class TestServer

java.lang.Object
  |
  +--org.ssonet.examples.net.TestServer
All Implemented Interfaces:
CertificateListener, ConnectionListener, SSONETContextFactory, SSONETContextListener

public class TestServer
extends java.lang.Object
implements SSONETContextFactory, SSONETContextListener, CertificateListener, ConnectionListener

This class implements a simple server using the SSONET-library.


Field Summary
(package private)  org.ssonet.net.SSONETContext context
           
static boolean debug
           
 
Fields inherited from interface org.ssonet.net.CertificateListener
INVALID, NOT_TESTED, VALID
 
Fields inherited from interface org.ssonet.net.ConnectionListener
FINISHED_STATE, INIT_STATE, MECHANISMS_NEGOTIATION, NOT_STARTED_STATE, RUNNING_STATE, SECURITY_GOAL_NEGOTIATION
 
Constructor Summary
TestServer()
           
TestServer(int packets)
           
 
Method Summary
 int checkCertificate(org.ssonet.net.SSONETContext context, java.security.cert.X509Certificate cert)
          Method of the implemented listener CertificateListener.
 void connectionStateChanged(org.ssonet.net.SSONETContext context, int currentState)
          When the connection state has changed, this method reports the current state.
 void contextChanged(org.ssonet.net.SSONETContext c)
          Method of the implemented listener SSONETContextListener.
 org.ssonet.net.SSONETContext createContext()
          Method of the implemented SSONETContextFactory.
 boolean decideSecurityGoal(int securityGoal, org.ssonet.net.ActionConfiguration ownConfiguration, org.ssonet.net.SSONETContext context)
          Method of the implemented listener NegotiationListener.
static void main(java.lang.String[] arg)
          The main method of the server.
 void negotiationRequestReceived(org.ssonet.net.SSONETContext context, int negotiationType)
          The method negotiationRequestReceived() is called by SSONETProtocolStream , when a request for a security goal and mechanisms negotiation, or only a mechanisms negotiation was received, but before the negotiation of security parameters starts.
 void replaceContext(org.ssonet.net.SSONETContext o, org.ssonet.net.SSONETContext n)
          Method of the implemented listener SSONETContextListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug

context

org.ssonet.net.SSONETContext context
Constructor Detail

TestServer

public TestServer()

TestServer

public TestServer(int packets)
Parameters:
packets - is not used here
Method Detail

main

public static void main(java.lang.String[] arg)
The main method of the server. It first initializes the server socket, and waits for a connection of a client. When a client has connected, it receives data packets and sends them back to the client.

Parameters:
arg - command line arguments (not used).

createContext

public org.ssonet.net.SSONETContext createContext()
Method of the implemented SSONETContextFactory. It creates a SSONETContext object from the security configuration of the predefined user named "Standardkunde". Further, it registers the listeners, which are implemented by this server, with the created SSONETContext. This server implements all listeners needed to influence SSONET connection establishment according to the servers preferences.

Specified by:
createContext in interface SSONETContextFactory
Returns:
the newly created SSONETContext object.

contextChanged

public void contextChanged(org.ssonet.net.SSONETContext c)
Method of the implemented listener SSONETContextListener. This method is called, if data in the SSONETContext has changed. This listener is particularily usefull, if an application using SSONET has different modules, which need to react to changes in the context data.

Specified by:
contextChanged in interface SSONETContextListener
Parameters:
c - the SSONETContext, which has changed.

replaceContext

public void replaceContext(org.ssonet.net.SSONETContext o,
                           org.ssonet.net.SSONETContext n)
Method of the implemented listener SSONETContextListener. In applications with different modules, the according method in SSONETContext can be called by a module, which want do completely replace a SSONETContext. Other modules may update their SSONETContexts by this method.

Specified by:
replaceContext in interface SSONETContextListener
Parameters:
o - the old SSONETContext
n - the replacement SSONETContext

checkCertificate

public int checkCertificate(org.ssonet.net.SSONETContext context,
                            java.security.cert.X509Certificate cert)
Method of the implemented listener CertificateListener. When a certificate is received from the communication partner, this method is called. It should decide about the validity the the certificate. In SSONETContext, multiple CertificateListeners can be registered. A certificate is considered valid, if no CertificateListener says "invalid" and at least one CertificateListener says "valid".

Specified by:
checkCertificate in interface CertificateListener
Parameters:
context - the SSONETContext object, which requested the certificate check
cert - the certificate to check
Returns:
CertificateListener.VALID if the certificate is valid,
CertificateListener.INVALID if the certificate is invalid,
CertificateListener.NOT_TESTED if this method did not decide about the certificates validity.

decideSecurityGoal

public boolean decideSecurityGoal(int securityGoal,
                                  org.ssonet.net.ActionConfiguration ownConfiguration,
                                  org.ssonet.net.SSONETContext context)
Method of the implemented listener NegotiationListener. If the first round of negotiation of security goals resulted in a conflict, but it was configured to make a new decision in case of a conflict, this method is called. It decides about giving in or not for the conflicting security goal. In SSONETContext, multiple NegotiationListeners can be registered. If at least one listener gives in, i.e. returns true, it is giving in in this conflict.

Specified by:
decideSecurityGoal in interface ConnectionListener
Parameters:
securityGoal - the conflicting security goal
ownConfiguration - the configuration of security goals, which is used for the negotiation
context - the SSONETContext object, which requested the security goal conflict resolution.
Returns:
true, if it is giving in in the conflict,
false, if the decistion about the security goal is not changed.

negotiationRequestReceived

public void negotiationRequestReceived(org.ssonet.net.SSONETContext context,
                                       int negotiationType)
Description copied from interface: ConnectionListener
The method negotiationRequestReceived() is called by SSONETProtocolStream , when a request for a security goal and mechanisms negotiation, or only a mechanisms negotiation was received, but before the negotiation of security parameters starts.

Specified by:
negotiationRequestReceived in interface ConnectionListener
Parameters:
context - the SSONETContext used by the server for this request.
negotiationType - SECURITY_GOAL_NEGOTIATION if the negotiation requested is a security goal (and mechanisms) negotiation,

MECHANISMS_NEGOTIATION if the negotiation requested is only a mechanisms negotiation.


connectionStateChanged

public void connectionStateChanged(org.ssonet.net.SSONETContext context,
                                   int currentState)
Description copied from interface: ConnectionListener
When the connection state has changed, this method reports the current state.

Specified by:
connectionStateChanged in interface ConnectionListener


Copyright © 2003 DRIM Team. All Rights Reserved.