Beispiel #1
0
 public boolean isResponsible(Address address) throws Exception {
   LOG.info("address = " + address);
   Id nodeId = getNodeId(address);
   LOG.info("nodeId = " + nodeId);
   OCPContact contact = getContactFromNodeId(nodeId);
   LOG.info("contact = " + contact);
   LOG.info("is responsible: " + contact.getName().equals(id.toString()));
   return contact.getName().equals(id.toString());
   // return true;
 }
Beispiel #2
0
  public void connect() throws Exception {

    String sId = ds().getProperty("id");
    if (sId == null) {
      id = generateId();
      ds().setProperty("id", id.toString());
    } else {
      id = new Id(sId);
    }
    LOG.info("agent id = " + id);

    try {
      backupNbr = (byte) Integer.parseInt(ds().network.getProperty("backupNbr", "5"));
    } catch (NumberFormatException e) {
      throw new Exception(
          "network property error: backupNbr must be an integer between 1 and 255.");
    }
    if (backupNbr < 1) {
      throw new Exception(
          "network property error: backupNbr must be an integer between 1 and 255.");
    }

    // message digest for hash
    md = MessageDigest.getInstance(ds().network.getProperty("hash", "SHA-1"));

    // all agent must have a PKI
    keyPair = generateKeyPair();
    signatureAlgorithm = ds().network.getProperty("SignatureAlgo", "SHA1withDSA");

    // all users use the same algo for symmetric encryption
    userSecretKeyFactory =
        SecretKeyFactory.getInstance(
            ds().network.getProperty("user.cipher.algo", "PBEWithMD5AndDES"));
    userCipher =
        Cipher.getInstance(ds().network.getProperty("user.cipher.algo", "PBEWithMD5AndDES"));

    if (ds().getProperty("server", "yes").equals("yes")) {
      storage = new Storage(ds());
      storage.attach();
    }
    LOG.info("end");
  }