package assign3; import submission.Demo.*; import simnet.*; import java.io.*; import org.bouncycastle.crypto.params.DHParameters; import org.bouncycastle.crypto.params.DHPublicKeyParameters; import java.security.SecureRandom; import java.math.BigInteger; import java.sql.Timestamp; /** * Shows how an implimented Authentication message works that * implements: CryptographicAuthenticationMessage, Serializable, and Cloneable. * You might need to change some varable names. * DHPublicKeyParetersWrappers is based on Dr.Brenos DHParamaters class */ public class MyAuthenticationMessage implements CryptographicAuthenticationMessage, Serializable, Cloneable { // DATA MEMBERS String SenderName; //name of the node sending message DHPublicKeyParametersWrapper AlgorithmSpecsWrapper; // a DHPublicKeyParametersWrapper stroing th public key of the sendor java.sql.Timestamp timestamp; // The time this message was created and sent Object[] arguments = new Object[1]; // the other agruments of the message example g^x mod p and g^y mod p String SessionID; // the session id string of the message DHPublicKeyParametersWrapper PubKeyClientwrapper1 = new DHPublicKeyParametersWrapper(); /** * Creates the authenticatio message useing the following parameters * @param SenderNamein * @param AlgorithmSpecsin * @param Timestampin * @param argumentsin * @param SessionIDin */ public MyAuthenticationMessage(String SenderNamein, DHPublicKeyParametersWrapper AlgorithmSpecsin, java.sql.Timestamp Timestampin ,Object[] argumentsin, String SessionIDin) { // Sets the SenderName for the input parameter SenderName = SenderNamein; // Sets the Algorithms specs by copying inputed object AlgorithmSpecsWrapper = new DHPublicKeyParametersWrapper(); AlgorithmSpecsWrapper = AlgorithmSpecsin; // Sets the TimeStamp timestamp = new java.sql.Timestamp(Timestampin.getTime() ); // Set the Message Arguments arguments[0] = argumentsin[0]; // Associates the SessionID to the one inputted SessionID = SessionIDin; } /** *This is how to use the implimented clone. *The command to create clones **/ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Implementation of CryptographicAuthenticationMessage right below * From inside your server and client you call each of these functions to use. * IE=> B = ((DHPublicKeyParameters) IN.getAlgorithmSpecs()) */ public String getSenderName() { return SenderName; } public Object getAlgorithmSpecs() { return ( (Object) AlgorithmSpecsWrapper.getDHPublicKeyParameters() ); } public java.sql.Timestamp getTimestamp() { return timestamp; } public Object[] getArguments() { return arguments; } public String getSessionID() { return SessionID; } }