/** * @param s newly connected socket from (hopefully) a client * @param callback object which will be called asynchonously as messages come in * @param pass password hash to authenticate with * @throws IOException */ public ClientConnection(SSLSocket s, IServer callback, PasswordHash pass) throws IOException { if (pass == null) throw new NullPointerException("Seibert LIED TO ME!"); /** unique id for this client connection */ ID = claimID(); pw = pass; server = callback; out = s.getOutputStream(); InputStream in = s.getInputStream(); /** authenticate */ byte[] clientPwHash = new byte[20]; NetUtils.readFully(in, clientPwHash, 0, 20); if (!(new PasswordHash(clientPwHash).equals(pw))) throw new SecurityException("Incorrect password recieved"); ccct = new ClientConnectionCallbackThread(in, server, this, ID); /** start up the callback thread */ new Thread(ccct).start(); }