FileDocCategorySizeDatePackage
ProtectedServer.javaAPI DocExample1145Tue Feb 24 10:19:48 GMT 1998None

ProtectedServer

public class ProtectedServer 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();
    int length = in.readInt();
    byte[] protected1 = new byte[length];
    in.readFully(protected1);

    String password = lookupPassword(user);
    byte[] local = Protection.makeDigest(user, password, t1, q1);
    return MessageDigest.isEqual(protected1, local);
  
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();

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

    s.close();