Package org.hive2hive.core.model

Examples of org.hive2hive.core.model.UserProfile


          FileUtils.readFileToString(synchronizedFile));
    }
  }

  private static void checkIndex(Path relativePath) throws GetFailedException, NoSessionException {
    UserProfile userProfileA = nodeA.getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    Index indexA = userProfileA.getFileByPath(relativePath);

    UserProfile userProfileB = nodeB.getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    Index indexB = userProfileB.getFileByPath(relativePath);

    // check if userA's content protection keys are other ones
    Assert.assertFalse(indexA.getProtectionKeys().getPrivate()
        .equals(userProfileA.getProtectionKeys().getPrivate()));
    Assert.assertFalse(indexA.getProtectionKeys().getPublic()
View Full Code Here


    NetworkManager client = network.get(1); // where the user profile is stored

    // create the needed objects
    UserCredentials credentials = NetworkTestUtil.generateRandomCredentials();

    UserProfile testProfile = new UserProfile(credentials.getUserId());
    IConsumeUserProfile context = new ConsumeProfileContext(testProfile);

    // initialize the process and the one and only step to test
    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);

    // decrypt it using the same password as set above
    SecretKey decryptionKeys = PasswordUtil.generateAESKeyFromPassword(credentials.getPassword(),
        credentials.getPin(), H2HConstants.KEYLENGTH_USER_PROFILE);
    UserProfile decrypted = (UserProfile) H2HEncryptionUtil.decryptAES(found, decryptionKeys);

    // verify if both objects are the same
    Assert.assertEquals(credentials.getUserId(), decrypted.getUserId());
  }
View Full Code Here

    NetworkManager proxy = network.get(1); // where the user profile is stored
    proxy.getConnection().getPeer().getPeerBean().storage(new DenyingPutTestStorage());

    // create the needed objects
    UserCredentials credentials = NetworkTestUtil.generateRandomCredentials();
    UserProfile testProfile = new UserProfile(credentials.getUserId());
    IConsumeUserProfile context = new ConsumeProfileContext(testProfile);

    // initialize the process and the one and only step to test
    PutUserProfileStep step = new PutUserProfileStep(credentials, context, putter.getDataManager());
    TestProcessComponentListener listener = new TestProcessComponentListener();
View Full Code Here

    // upload the new version
    UseCaseTestUtil.uploadNewVersion(uploader, file);

    // download the file and check if version is newer
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(downloader, userCredentials);
    Index index = userProfile.getFileByPath(file, uploaderRoot);
    File downloaded = UseCaseTestUtil.downloadFile(downloader, index.getFilePublicKey());

    // new content should be latest one
    Assert.assertEquals(newContent, FileUtils.readFileToString(downloaded));
View Full Code Here

    do {
      waiter.tickASecond();
    } while (!listener.hasFailed());

    // verify if the md5 hash did not change
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(downloader, userCredentials);
    FileIndex fileNode = (FileIndex) userProfile.getFileByPath(file, uploaderRoot);
    Assert.assertTrue(H2HEncryptionUtil.compareMD5(file, fileNode.getMD5()));

    // verify that only one version was created
    MetaFileSmall metaDocument = (MetaFileSmall) UseCaseTestUtil.getMetaFile(downloader,
        fileNode.getFileKeys());
View Full Code Here

    // update the file
    FileUtils.write(file, "bla", false);
    UseCaseTestUtil.uploadNewVersion(uploader, file);

    // verify that only one version is online
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(downloader, userCredentials);
    Index fileNode = userProfile.getFileByPath(file, uploaderRoot);
    MetaFileSmall metaFileSmall = (MetaFileSmall) UseCaseTestUtil.getMetaFile(downloader,
        fileNode.getFileKeys());
    Assert.assertEquals(1, metaFileSmall.getVersions().size());
  }
View Full Code Here

    FileUtils.write(file, NetworkTestUtil.randomString(), true);

    UseCaseTestUtil.uploadNewVersion(uploader, file);

    // verify that only one version is online
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(downloader, userCredentials);
    Index fileNode = userProfile.getFileByPath(file, uploaderRoot);
    MetaFileSmall metaFileSmall = (MetaFileSmall) UseCaseTestUtil.getMetaFile(downloader,
        fileNode.getFileKeys());
    Assert.assertEquals(1, metaFileSmall.getVersions().size());
  }
View Full Code Here

    NetworkManager putter = network.get(0); // where the process runs

    // create the needed objects
    UserCredentials credentials = NetworkTestUtil.generateRandomCredentials();

    UserProfile testProfile = new UserProfile(credentials.getUserId());

    // add them already to the DHT
    SecretKey encryptionKeys = PasswordUtil.generateAESKeyFromPassword(credentials.getPassword(), credentials.getPin(),
        H2HConstants.KEYLENGTH_USER_PROFILE);
    EncryptedNetworkContent encrypted = H2HEncryptionUtil.encryptAES(testProfile, encryptionKeys);
    FuturePut putGlobal = putter.getDataManager().putUnblocked(
        new Parameters().setLocationKey(credentials.getProfileLocationKey())
            .setContentKey(H2HConstants.USER_PROFILE).setData(encrypted));
    putGlobal.awaitUninterruptibly();

    UserProfile profile = UseCaseTestUtil.getUserProfile(putter, credentials);

    // verify if both objects are the same
    Assert.assertEquals(credentials.getUserId(), profile.getUserId());
  }
View Full Code Here

      InterruptedException, NoPeerConnectionException, NoSessionException, InvalidProcessStateException {
    File file = FileTestUtil.createFileRandomContent(3, root, CHUNK_SIZE);
    UseCaseTestUtil.uploadNewFile(client, file);

    // store the keys of the meta file to verify them later
    UserProfile userProfileBeforeDeletion = UseCaseTestUtil.getUserProfile(client, userCredentials);
    KeyPair metaKeyPair = userProfileBeforeDeletion.getFileByPath(file, root).getFileKeys();
    MetaFileSmall metaDocumentBeforeDeletion = (MetaFileSmall) UseCaseTestUtil.getMetaFile(client,
        metaKeyPair);
    Assert.assertNotNull(metaDocumentBeforeDeletion);

    // delete the file
    UseCaseTestUtil.deleteFile(client, file);

    // check if the file is still in the DHT
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Assert.assertNull(userProfile.getFileById(metaKeyPair.getPublic()));

    MetaFile metaDocument = UseCaseTestUtil.getMetaFile(client, metaKeyPair, false);
    Assert.assertNull(metaDocument);

    for (FileVersion version : metaDocumentBeforeDeletion.getVersions()) {
View Full Code Here

    File folder = new File(root, NetworkTestUtil.randomString());
    folder.mkdir();
    UseCaseTestUtil.uploadNewFile(client, folder);

    // store some keys before deletion
    UserProfile userProfileBeforeDeletion = UseCaseTestUtil.getUserProfile(client, userCredentials);
    KeyPair metaKeyPair = userProfileBeforeDeletion.getFileByPath(folder, root).getFileKeys();

    // delete the folder
    UseCaseTestUtil.deleteFile(client, folder);

    // check if the folder is still in the DHT
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Assert.assertNull(userProfile.getFileById(metaKeyPair.getPublic()));
  }
View Full Code Here

TOP

Related Classes of org.hive2hive.core.model.UserProfile

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.