Examples of PublicKeyManager


Examples of org.hive2hive.core.network.data.PublicKeyManager

  public void testReadWriteMetaData() throws IOException, ClassNotFoundException {
    String fileName = "test-file";
    File file = new File(root, fileName);
    FileUtils.writeStringToFile(file, NetworkTestUtil.randomString());

    PublicKeyManager publicKeyManager = new PublicKeyManager("user", EncryptionUtil.generateRSAKeyPair(),
        null);
    DownloadManager downloadManager = new DownloadManager(null, null, publicKeyManager, null);
    FileUtil.writePersistentMetaData(root.toPath(), publicKeyManager, downloadManager);
    PersistentMetaData persistentMetaData = FileUtil.readPersistentMetaData(root.toPath());
    Map<String, byte[]> fileTree = persistentMetaData.getFileTree();
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

  public static void createKeyPairs(List<NetworkManager> network) throws NoPeerConnectionException {
    for (NetworkManager node : network) {
      KeyPair keyPair = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
      UserCredentials userCredentials = generateRandomCredentials();
      UserProfileManager profileManager = new UserProfileManager(node.getDataManager(), userCredentials);
      PublicKeyManager keyManager = new PublicKeyManager(userCredentials.getUserId(), keyPair, node.getDataManager());
      IFileConfiguration config = FileConfiguration.createDefault();
      DownloadManager downloadManager = new DownloadManager(node.getDataManager(), node.getMessageManager(),
          keyManager, config);
      File root = new File(System.getProperty("java.io.tmpdir"), NetworkTestUtil.randomString());
      H2HSession session;
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

  public static void createSameKeyPair(List<NetworkManager> network) throws NoPeerConnectionException {
    KeyPair keyPair = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
    UserCredentials userCredentials = generateRandomCredentials();
    for (NetworkManager node : network) {
      UserProfileManager profileManager = new UserProfileManager(node.getDataManager(), userCredentials);
      PublicKeyManager keyManager = new PublicKeyManager(userCredentials.getUserId(), keyPair, node.getDataManager());
      IFileConfiguration config = FileConfiguration.createDefault();
      DownloadManager downloadManager = new DownloadManager(node.getDataManager(), node.getMessageManager(),
          keyManager, config);
      File root = new File(System.getProperty("java.io.tmpdir"), NetworkTestUtil.randomString());
      H2HSession session;
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

  public void testPutGet() throws IOException, NoPeerConnectionException {
    String userId = NetworkTestUtil.randomString();
    TestUserProfileTask userProfileTask = new TestUserProfileTask();
    KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
    NetworkManager node = network.get(random.nextInt(networkSize));
    PublicKeyManager publicKeyManager = new PublicKeyManager(userId, key, node.getDataManager());
    node.setSession(new H2HSession(new UserProfileManager(node.getDataManager(), new UserCredentials(userId, "password",
        "pin")), publicKeyManager, new DownloadManager(node.getDataManager(), node.getMessageManager(),
        publicKeyManager, config), config, FileTestUtil.getTempDirectory().toPath()));

    SimpleGetUserProfileTaskContext context = new SimpleGetUserProfileTaskContext();
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

  public void testPutGetRollback() throws IOException, NoPeerConnectionException {
    String userId = NetworkTestUtil.randomString();
    TestUserProfileTask userProfileTask = new TestUserProfileTask();
    KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
    NetworkManager node = network.get(random.nextInt(networkSize));
    PublicKeyManager publicKeyManager = new PublicKeyManager(userId, key, node.getDataManager());
    node.setSession(new H2HSession(new UserProfileManager(node.getDataManager(), new UserCredentials(userId, "password",
        "pin")), publicKeyManager, new DownloadManager(node.getDataManager(), node.getMessageManager(),
        publicKeyManager, config), config, FileTestUtil.getTempDirectory().toPath()));

    SimpleGetUserProfileTaskContext context = new SimpleGetUserProfileTaskContext();
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

  public void testPutGetRemove() throws NoPeerConnectionException, IOException {
    String userId = NetworkTestUtil.randomString();
    TestUserProfileTask userProfileTask = new TestUserProfileTask();
    KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
    NetworkManager node = network.get(random.nextInt(networkSize));
    PublicKeyManager publicKeyManager = new PublicKeyManager(userId, key, node.getDataManager());
    node.setSession(new H2HSession(new UserProfileManager(node.getDataManager(), new UserCredentials(userId, "password",
        "pin")), publicKeyManager, new DownloadManager(node.getDataManager(), node.getMessageManager(),
        publicKeyManager, config), config, FileTestUtil.getTempDirectory().toPath()));

    SimpleGetUserProfileTaskContext context = new SimpleGetUserProfileTaskContext();
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

      NoPeerConnectionException {
    String userId = NetworkTestUtil.randomString();
    TestUserProfileTask userProfileTask = new TestUserProfileTask();
    KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
    NetworkManager node = network.get(random.nextInt(networkSize));
    PublicKeyManager publicKeyManager = new PublicKeyManager(userId, key, node.getDataManager());
    node.setSession(new H2HSession(new UserProfileManager(node.getDataManager(), new UserCredentials(userId, "password",
        "pin")), publicKeyManager, new DownloadManager(node.getDataManager(), node.getMessageManager(),
        publicKeyManager, config), config, FileTestUtil.getTempDirectory().toPath()));

    // IGetUserProfileTaskContext context = new SimpleGetUserProfileTaskContext();
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

      InvalidCipherTextException, IllegalBlockSizeException, BadPaddingException, InterruptedException, IOException,
      NoPeerConnectionException {
    String userId = NetworkTestUtil.randomString();
    NetworkManager node = network.get(random.nextInt(networkSize));
    KeyPair key = EncryptionUtil.generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
    PublicKeyManager publicKeyManager = new PublicKeyManager(userId, key, node.getDataManager());
    node.setSession(new H2HSession(new UserProfileManager(node.getDataManager(), new UserCredentials(userId, "password",
        "pin")), publicKeyManager, new DownloadManager(node.getDataManager(), node.getMessageManager(),
        publicKeyManager, config), config, FileTestUtil.getTempDirectory().toPath()));

    // create some tasks
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

    try {
      // get the persistently cached items
      PersistentMetaData metaData = FileUtil.readPersistentMetaData(params.getRoot());

      // create the key manager
      PublicKeyManager keyManager = new PublicKeyManager(userProfile.getUserId(),
          userProfile.getEncryptionKeys(), networkManager.getDataManager());

      // read eventually cached keys and add them to the key manager
      Map<String, PublicKey> publicKeyCache = metaData.getPublicKeyCache();
      for (String userId : publicKeyCache.keySet()) {
        keyManager.putPublicKey(userId, publicKeyCache.get(userId));
      }
      params.setKeyManager(keyManager);

      // create the download manager
      DownloadManager downloadManager = new DownloadManager(networkManager.getDataManager(),
View Full Code Here

Examples of org.hive2hive.core.network.data.PublicKeyManager

    this.messageManager = networkManager.getMessageManager();
  }

  @Override
  protected void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
    PublicKeyManager keyManager;
    try {
      keyManager = networkManager.getSession().getKeyManager();
    } catch (NoSessionException e) {
      throw new ProcessExecutionException("No session yet");
    }

    Locations locations = context.consumeLocations();
    waitForResponses = new CountDownLatch(locations.getPeerAddresses().size());
    if (!locations.getPeerAddresses().isEmpty()) {
      for (PeerAddress address : locations.getPeerAddresses()) {
        // contact all other clients (exclude self)
        if (!address.equals(networkManager.getConnection().getPeer().getPeerAddress())) {
          String evidence = UUID.randomUUID().toString();
          evidences.put(address, evidence);

          ContactPeerMessage message = new ContactPeerMessage(address, evidence);
          message.setCallBackHandler(this);

          // TODO this is blocking, should be parallel (asynchronous)
          boolean success = messageManager.sendDirect(message, keyManager.getOwnPublicKey());
          if (!success) {
            responses.put(address, false);
          }
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.