Пример #1
0
  public MixServerRMI(String filename)
      throws InvalidPropertiesFormatException, FileNotFoundException, IOException, JSONException,
          NotBoundException {
    super();
    settings = new MixServerSettings(filename);

    // output = new OutputHandlerRMI(server.getId(), serverRegistry, hostname_to_registry);
    mix = new MixServer(this, this);
    mix.setRepetitions(settings.getRepetitions());

    new Thread(mix).start();
    bind(settings.getName());

    for (String v : settings.getVerifyServers()) {
      while (true) {
        try {
          VerifyServerInterface veri = (VerifyServerInterface) Naming.lookup(v);
          veri.addVerificationListener(this);
          break;
        } catch (Exception ex) {
          try {
            Thread.sleep(5000);
          } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    }
  }
Пример #2
0
  @Override
  public boolean putCryptoCollection(CryptoMessageCollection collection, EncryptionLayer layer) {
    if (isLast()) {
      System.out.println("# Result after " + layer + " encryption stage");
      int i = 0;
      for (CryptoMessage msg : collection.getList())
        System.out.println("[" + i++ + "] " + msg.getMessage());
    }

    try {
      System.out.println("<-- Sending collection to " + settings.getNext());
      MixServerInterface node = (MixServerInterface) Naming.lookup(settings.getNext());

      for (String v : settings.getVerifyServers()) {
        System.out.println("<-- Sending to verifier " + v);
        VerifyServerInterface veri = (VerifyServerInterface) Naming.lookup(v);
        veri.putCryptoCollection(collection);
        /*
        RemoteHandler veri = info.getRemote();
        ((org.juddholm.mixnet.verifyserver.rmi.RMIInput) veri.getInputHandler()).putCryptoCollection(collection);
        */
      }

      if (!(isLast() && layer == EncryptionLayer.FINAL)) {
        node.putCryptoCollection(collection);
      }

    } catch (RemoteException | MalformedURLException | NotBoundException e) {
      return false;
    }

    return true;
  }