org.ssonet.examples.net
Class TestClient

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

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

The client of a simple example implementation for a network connection using the SSONET library. Immediately after starting, the client reads its security configuration form the predefined user named "Client". Then it connects to the TestServer-Server and establishes a connection. The established connection is used to send some data to the server. The client implements all listeners needed to influence SSONET connection establishment according to the clients preferences.


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
TestClient()
           
TestClient(int connectionCount)
           
 
Method Summary
 int checkCertificate(org.ssonet.net.SSONETContext context, java.security.cert.X509Certificate certificate)
          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 listener SSONETContextListener.
 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.
 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

TestClient

public TestClient()

TestClient

public TestClient(int connectionCount)
Method Detail

main

public static void main(java.lang.String[] arg)
The main method. It sets up the SSONET connection and sends some data to the server.


createContext

public org.ssonet.net.SSONETContext createContext()
Method of the implemented listener SSONETContextListener. When a new SSONETClientSocket is created by the SSONETClientSocketFactory, a SSONETContext is requested for use in the SSONETClientSocket by using this method.

Specified by:
createContext in interface SSONETContextFactory
Returns:
a SSONETContext for use in the newly created SSONETClientSocket.

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 certificate)
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
certificate - 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.