コード例 #1
0
  public void sendSignedMessageForTallier(byte[] message) {
    try {
      Socket tallier_socket = sslManager.connectSocket("localhost", TALLIER_PORT_NUMBER);
      ObjectOutputStream oosbm = new ObjectOutputStream(tallier_socket.getOutputStream());
      oosbm.writeObject(message);
      vLogger.info("Signed message sent to tallier for validation and registration");

      // reads the response
      ObjectInputStream oisbm = new ObjectInputStream(tallier_socket.getInputStream());
      Boolean response = (Boolean) oisbm.readObject();

      if (response.booleanValue()) vLogger.info("Vote successfully registered!");
      else vLogger.error("Vote could NOT be registered!");

      oosbm.flush();

      // closing connection
      tallier_socket.close();

    } catch (IOException exception) {
      vLogger.error("Error sending the signed message to tallier :" + exception.getMessage());
    } catch (ClassNotFoundException exception) {
      vLogger.error("Error sending the signed message to tallier :" + exception.getMessage());
    }
  }
コード例 #2
0
  public VotingProcess(String ksPath, char[] ksPass) {
    try {
      sslManager = new SSLManager(ksPath, ksPass);
      validator_socket = sslManager.connectSocket("localhost", VALIDATOR_PORT_NUMBER);
      voterIsEligible = false;
      vLogger = Logger.getLogger("VotingLogger");
      X509Certificate[] serverCertificates =
          (X509Certificate[]) (((SSLSocket) validator_socket).getSession()).getPeerCertificates();
      pbK = serverCertificates[0].getPublicKey();

    } catch (IOException exception) {
      vLogger.error("Error intializing the client :" + exception.getMessage());
    } catch (Exception e) {
      vLogger.error("Error intializing the client :" + e.getMessage());
    }
  }