FileDocCategorySizeDatePackage
DoubleServer.javaAPI DocExample1262Tue Feb 24 10:23:26 GMT 1998None

DoubleServer

public class DoubleServer extends Object

Fields Summary
Constructors Summary
Methods Summary
public booleanauthenticate(java.io.InputStream inStream)

    DataInputStream in = new DataInputStream(inStream);

    String user = in.readUTF();
    long t1 = in.readLong();
    double q1 = in.readDouble();
    long t2 = in.readLong();
    double q2 = in.readDouble();
    int length = in.readInt();
    byte[] protected2 = new byte[length];
    in.readFully(protected2);

    String password = lookupPassword(user);
    byte[] local1 = Protection.makeDigest(user, password, t1, q1);
    byte[] local2 = Protection.makeDigest(local1, t2, q2);
    return MessageDigest.isEqual(protected2, local2);
  
protected java.lang.StringlookupPassword(java.lang.String user)

 return "buendia"; 
public static voidmain(java.lang.String[] args)

    int port = 7999;
    ServerSocket s = new ServerSocket(port);
    Socket client = s.accept();

    DoubleServer server = new DoubleServer();
    if (server.authenticate(client.getInputStream()))
      System.out.println("Client logged in.");
    else
      System.out.println("Client failed to log in.");

    s.close();