Package org.hive2hive.core.security

Examples of org.hive2hive.core.security.UserCredentials


  }

  @Test(expected = NoSessionException.class)
  public void testInvalidPin() throws NoSessionException, InvalidProcessStateException, NoPeerConnectionException,
      ProcessExecutionException {
    UserCredentials wrongCredentials = new UserCredentials(userCredentials.getUserId(), userCredentials.getPassword(),
        NetworkTestUtil.randomString());

    loginAndWaitToFail(wrongCredentials);
  }
View Full Code Here


  }

  @Test(expected = NoSessionException.class)
  public void testInvalidUserId() throws NoSessionException, InvalidProcessStateException, NoPeerConnectionException,
      ProcessExecutionException {
    UserCredentials wrongCredentials = new UserCredentials(NetworkTestUtil.randomString(),
        userCredentials.getPassword(), userCredentials.getPin());

    loginAndWaitToFail(wrongCredentials);
  }
View Full Code Here

  public void setup() throws NoPeerConnectionException {
    super.beforeMethod();

    // network
    network = NetworkTestUtil.createNetwork(2);
    UserCredentials credentials = NetworkTestUtil.generateRandomCredentials();

    root = FileTestUtil.getTempDirectory();
    UseCaseTestUtil.registerAndLogin(credentials, network.get(0), root);
  }
View Full Code Here

  public void testRegisterProcessSuccess() throws InvalidProcessStateException, ClassNotFoundException,
      IOException, GetFailedException, NoPeerConnectionException {
    NetworkManager client = network.get(0);
    NetworkManager otherClient = network.get(1);

    UserCredentials credentials = NetworkTestUtil.generateRandomCredentials();
    UseCaseTestUtil.register(credentials, client);

    // verify put user profile
    UserProfile getUserProfile = UseCaseTestUtil.getUserProfile(otherClient, credentials);

    assertNotNull(getUserProfile);
    assertEquals(credentials.getUserId(), getUserProfile.getUserId());

    // verify put locations
    FutureGet getLocations = otherClient.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getUserId()).setContentKey(
            H2HConstants.USER_LOCATIONS));
    getLocations.awaitUninterruptibly();
    getLocations.getFutureRequests().awaitUninterruptibly();
    Locations locations = (Locations) getLocations.getData().object();

    assertNotNull(locations);
    assertEquals(credentials.getUserId(), locations.getUserId());
    assertTrue(locations.getPeerAddresses().isEmpty());

    // verify put user public key
    FutureGet getKey = otherClient.getDataManager().getUnblocked(
        new Parameters().setLocationKey(credentials.getUserId()).setContentKey(
            H2HConstants.USER_PUBLIC_KEY));
    getKey.awaitUninterruptibly();
    getKey.getFutureRequests().awaitUninterruptibly();
    UserPublicKey publicKey = (UserPublicKey) getKey.getData().object();
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

  private boolean register() throws NoPeerConnectionException, InvalidProcessStateException,
      InterruptedException {

    IUserManager userManager = menus.getNodeMenu().getNode().getUserManager();
    UserCredentials userCredentials = menus.getUserMenu().getUserCredentials();

    if (userManager.isRegistered(userCredentials.getUserId())) {
      return true;
    } else {
      H2HConsoleMenuItem
          .printPrecondition("You are not registered to the network. This will now happen automatically.");
      IProcessComponent registerProcess = userManager.register(userCredentials);
View Full Code Here

TOP

Related Classes of org.hive2hive.core.security.UserCredentials

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.