Package org.hive2hive.core

Examples of org.hive2hive.core.H2HSession


      public int getChunkSize() {
        return H2HConstants.DEFAULT_CHUNK_SIZE;
      }
    };

    H2HSession session = uploader.getSession();
    H2HSession newSession = new H2HSession(session.getProfileManager(), session.getKeyManager(),
        session.getDownloadManager(), limitingConfig, session.getRoot());
    uploader.setSession(newSession);

    // update the file
    FileUtils.write(file, "bla", false);
View Full Code Here


      public int getChunkSize() {
        return H2HConstants.DEFAULT_CHUNK_SIZE;
      }
    };

    H2HSession session = uploader.getSession();
    H2HSession newSession = new H2HSession(session.getProfileManager(), session.getKeyManager(),
        session.getDownloadManager(), limitingConfig, session.getRoot());
    uploader.setSession(newSession);

    // update the file (append some data)
    FileUtils.write(file, NetworkTestUtil.randomString(), true);
View Full Code Here

    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

    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

    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

    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();
    // HybridEncryptedContent encrypted = H2HEncryptionUtil.encryptHybrid(userProfileTask,
View Full Code Here

      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
    List<TestUserProfileTask> tasks = new ArrayList<TestUserProfileTask>();
View Full Code Here

 
  @Override
  public IProcessComponent add(File file) throws NoSessionException, NoPeerConnectionException,
      IllegalFileLocation {
    // verify the argument
    H2HSession session = networkManager.getSession();
    if (file == null) {
      throw new IllegalArgumentException("File cannot be null.");
    } else if (!file.exists()) {
      throw new IllegalArgumentException("File does not exist.");
    } else if (session.getRoot().toFile().equals(file)) {
      throw new IllegalArgumentException("Root cannot be added.");
    } else if (!FileUtil.isInH2HDirectory(file, session)) {
      throw new IllegalFileLocation();
    }
View Full Code Here

    if (!folder.isDirectory())
      throw new IllegalArgumentException("File has to be a folder.");
    if (!folder.exists())
      throw new IllegalFileLocation("Folder does not exist.");

    H2HSession session = networkManager.getSession();
    Path root = session.getRoot();

    // folder must be in the given root directory
    if (!folder.toPath().toString().startsWith(root.toString()))
      throw new IllegalFileLocation("Folder must be in root of the H2H directory.");
View Full Code Here

  @Override
  public void run() {
    logger.debug("Received request for a chunk from peer {}", senderAddress);

    // search user profile for this file
    H2HSession session = null;
    try {
      session = networkManager.getSession();
    } catch (NoSessionException e) {
      logger.error("Cannot answer because session is invalid");
      sendDirectResponse(createResponse(null));
      return;
    }

    UserProfile userProfile;
    try {
      UserProfileManager profileManager = session.getProfileManager();
      userProfile = profileManager.getUserProfile(messageID, false);
    } catch (GetFailedException e) {
      logger.error("Cannot get the user profile", e);
      sendDirectResponse(createResponse(null));
      return;
    }

    // find file in user profile
    Index index = userProfile.getFileById(fileKey);
    if (index == null || index.isFolder()) {
      logger.info("File not found in the user profile, cannot return a chunk");
      sendDirectResponse(createResponse(null));
      return;
    }

    // check if file is on disk
    Path path = FileUtil.getPath(session.getRoot(), index);
    if (path == null || !path.toFile().exists()) {
      logger.info("File not found on disk, cannot return a chunk");
      sendDirectResponse(createResponse(null));
      return;
    }
View Full Code Here

TOP

Related Classes of org.hive2hive.core.H2HSession

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.