Package org.hive2hive.core.network.data.parameters

Examples of org.hive2hive.core.network.data.parameters.Parameters


    Map<String, PublicKey> publicKeys = new HashMap<String, PublicKey>();
    for (int i = 0; i < random.nextInt(10); i++) {
      String userId = NetworkTestUtil.randomString();
      KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
      UserPublicKey userPublicKey = new UserPublicKey(key.getPublic());
      Parameters parameters = new Parameters().setLocationKey(userId)
          .setContentKey(H2HConstants.USER_PUBLIC_KEY).setData(userPublicKey);
      network.get(random.nextInt(networkSize)).getDataManager().putUnblocked(parameters)
          .awaitUninterruptibly();
      publicKeys.put(userId, key.getPublic());
    }
View Full Code Here


    Map<String, PublicKey> publicKeys = new HashMap<String, PublicKey>();
    for (int i = 0; i < random.nextInt(5); i++) {
      String userId = NetworkTestUtil.randomString();
      KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
      UserPublicKey userPublicKey = new UserPublicKey(key.getPublic());
      Parameters parameters = new Parameters().setLocationKey(userId)
          .setContentKey(H2HConstants.USER_PUBLIC_KEY).setData(userPublicKey);
      network.get(random.nextInt(networkSize)).getDataManager().putUnblocked(parameters)
          .awaitUninterruptibly();
      publicKeys.put(userId, key.getPublic());
    }

    for (String userId : publicKeys.keySet()) {
      assertEquals(publicKeys.get(userId), publicKeyManager.getPublicKey(userId));

      // remove the public keys from network, the manager shouldn't do any get request
      Parameters parameters = new Parameters().setLocationKey(userId).setContentKey(
          H2HConstants.USER_PUBLIC_KEY);
      network.get(random.nextInt(networkSize)).getDataManager().removeUnblocked(parameters)
          .awaitUninterruptibly();

      // the public key manager should use his cache
View Full Code Here

    PublicKeyManager publicKeyManager = new PublicKeyManager(loggedInUserId, loggedInUserKeys,
        node.getDataManager());

    String otherUser = NetworkTestUtil.randomString();
    H2HTestData noPublicKey = new H2HTestData("public key");
    Parameters parameters = new Parameters().setLocationKey(otherUser)
        .setContentKey(H2HConstants.USER_PUBLIC_KEY).setData(noPublicKey);
    network.get(random.nextInt(networkSize)).getDataManager().putUnblocked(parameters)
        .awaitUninterruptibly();

    try {
View Full Code Here

    Map<String, PublicKey> publicKeys = new HashMap<String, PublicKey>();
    for (int i = 0; i < 5; i++) {
      String userId = NetworkTestUtil.randomString();
      KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
      UserPublicKey userPublicKey = new UserPublicKey(key.getPublic());
      Parameters parameters = new Parameters().setLocationKey(userId)
          .setContentKey(H2HConstants.USER_PUBLIC_KEY).setData(userPublicKey);
      network.get(random.nextInt(networkSize)).getDataManager().putUnblocked(parameters)
          .awaitUninterruptibly();
      publicKeys.put(userId, key.getPublic());
    }
View Full Code Here

  }

  @Override
  public boolean putUserProfileTask(String userId, Number160 contentKey, NetworkContent content,
      KeyPair protectionKey) {
    IParameters parameters = new Parameters().setLocationKey(userId).setContentKey(contentKey)
        .setDomainKey(H2HConstants.USER_PROFILE_TASK_DOMAIN).setData(content)
        .setProtectionKeys(protectionKey).setTTL(content.getTimeToLive());
    FuturePut putFuture = putUnblocked(parameters);
    if (putFuture == null) {
      return false;
View Full Code Here

    return listener.awaitAndGet();
  }

  @Override
  public NetworkContent getUserProfileTask(String userId) {
    IParameters parameters = new Parameters().setLocationKey(userId).setDomainKey(
        H2HConstants.USER_PROFILE_TASK_DOMAIN);

    FutureGet futureGet = getPeer()
        .get(parameters.getLKey())
        .from(new Number640(parameters.getLKey(), parameters.getDKey(), Number160.ZERO,
View Full Code Here

    return listener.await();
  }

  @Override
  public boolean removeUserProfileTask(String userId, Number160 contentKey, KeyPair protectionKey) {
    IParameters parameters = new Parameters().setLocationKey(userId)
        .setDomainKey(H2HConstants.USER_PROFILE_TASK_DOMAIN).setContentKey(contentKey)
        .setProtectionKeys(protectionKey);
    FutureRemove futureRemove = removeUnblocked(parameters);
    FutureRemoveListener listener = new FutureRemoveListener(parameters, true, this);
    futureRemove.addListener(listener);
View Full Code Here

    newLocations.addPeerAddress(getter.getConnection().getPeer().getPeerAddress());

    // put the locations to the DHT
    proxy.getDataManager()
        .putUnblocked(
            new Parameters().setLocationKey(userId).setContentKey(H2HConstants.USER_LOCATIONS)
                .setData(newLocations)).awaitUninterruptibly();

    GetLocationsContext context = new GetLocationsContext();
    GetUserLocationsStep step = new GetUserLocationsStep(userId, context, getter.getDataManager());
    UseCaseTestUtil.executeProcess(step);
View Full Code Here

    PutUserProfileStep step = new PutUserProfileStep(credentials, context, putter.getDataManager());
    UseCaseTestUtil.executeProcess(step);

    // get the user profile which should be stored at the proxy
    FutureGet global = client.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getProfileLocationKey()).setContentKey(
            H2HConstants.USER_PROFILE));
    global.awaitUninterruptibly();
    global.getFutureRequests().awaitUninterruptibly();
    EncryptedNetworkContent found = (EncryptedNetworkContent) global.getData().object();
    Assert.assertNotNull(found);
View Full Code Here

    UseCaseTestUtil.waitTillFailed(listener, 20);

    // get the locations which should be stored at the proxy --> they should be null
    FutureGet futureGet = proxy.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getProfileLocationKey()).setContentKey(
            H2HConstants.USER_LOCATIONS));
    futureGet.awaitUninterruptibly();
    assertNull(futureGet.getData());
  }
View Full Code Here

TOP

Related Classes of org.hive2hive.core.network.data.parameters.Parameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.