Package org.waveprotocol.box.server.account

Examples of org.waveprotocol.box.server.account.AccountData


      throws RobotRegistrationException, PersistenceException {
    Preconditions.checkNotNull(robotId);
    Preconditions.checkNotNull(location);
    Preconditions.checkArgument(!location.isEmpty());

    AccountData account = accountStore.getAccount(robotId);
    if (account != null) {
      throwExceptionIfNotRobot(account);
      RobotAccountData robotAccount = account.asRobot();
      if (robotAccount.getUrl().equals(location)) {
        return robotAccount;
      } else {
        removeRobotAccount(robotAccount);
      }
View Full Code Here


      LOG.info("Participant id invalid", e);
      resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      return;
    }

    AccountData account;
    try {
      account = accountStore.getAccount(participant);
    } catch (PersistenceException e) {
      LOG.severe("Failed to retrieve account data for " + participant, e);
      resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          "An unexpected error occured while trying to retrieve account data for "
              + participant.getAddress());
      return;
    }
    if (account == null || !account.isRobot()) {
      LOG.info("The account for robot named " + participant + " does not exist");
      resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      return;
    }

    OAuthConsumer consumer =
        new OAuthConsumer(null, participant.getAddress(), account.asRobot().getConsumerSecret(),
            oauthServiceProvider);
    OAuthAccessor accessor = new OAuthAccessor(consumer);

    processOpsRequest(req, resp, message, accessor, participant);
  }
View Full Code Here

  public final void testRoundtripHumanAccount() throws Exception {
    AccountStore accountStore = newAccountStore();

    HumanAccountDataImpl account = new HumanAccountDataImpl(HUMAN_ID);
    accountStore.putAccount(account);
    AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID);
    assertEquals(account, retrievedAccount);
  }
View Full Code Here

  public final void testRoundtripHumanAccountWithPassword() throws Exception {
    AccountStore accountStore = newAccountStore();
   
    accountStore.putAccount(
        new HumanAccountDataImpl(HUMAN_ID, new PasswordDigest("internet".toCharArray())));
    AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID);
    assertTrue(retrievedAccount.asHuman().getPasswordDigest().verify("internet".toCharArray()));
  }
View Full Code Here

  public final void testRoundtripRobotAccount() throws Exception {
    AccountStore accountStore = newAccountStore();

    accountStore.putAccount(robotAccount);
    AccountData retrievedAccount = accountStore.getAccount(ROBOT_ID);
    assertEquals(robotAccount, retrievedAccount);
  }
View Full Code Here

  public final void testPutAccountOverrides() throws Exception {
    AccountStore accountStore = newAccountStore();

    accountStore.putAccount(robotAccount);
    AccountData account = accountStore.getAccount(ROBOT_ID);
    assertEquals(robotAccount, account);

    accountStore.putAccount(updatedRobotAccount);
    AccountData updatedAccount = accountStore.getAccount(ROBOT_ID);
    assertEquals(updatedRobotAccount, updatedAccount);
  }
View Full Code Here

  public final void testPutAccountCanChangeType() throws Exception {
    AccountStore accountStore = newAccountStore();

    accountStore.putAccount(robotAccount);
    AccountData account = accountStore.getAccount(ROBOT_ID);
    assertEquals(robotAccount, account);

    accountStore.putAccount(convertedRobot);
    AccountData updatedAccount = accountStore.getAccount(ROBOT_ID);
    assertEquals(convertedRobot, updatedAccount);
  }
View Full Code Here

  public final void testRemoveAccount() throws Exception {
    AccountStore accountStore = newAccountStore();

    accountStore.putAccount(robotAccount);
    AccountData account = accountStore.getAccount(ROBOT_ID);
    assertEquals(robotAccount, account);

    accountStore.removeAccount(ROBOT_ID);
    assertNull("Removed account was not null", accountStore.getAccount(ROBOT_ID));
  }
View Full Code Here

  public void testRegisterNewUserEnabled() throws Exception {
    attemptToRegister(req, resp, "foo@example.com", "internet", false);

    verify(resp).setStatus(HttpServletResponse.SC_OK);
    ParticipantId participantId = ParticipantId.ofUnsafe("foo@example.com");
    AccountData account = store.getAccount(participantId);
    assertNotNull(account);
    assertTrue(account.asHuman().getPasswordDigest().verify("internet".toCharArray()));
    verify(welcomeBot).greet(eq(participantId));
  }
View Full Code Here

  public void testRegisterNewUserDisabled() throws Exception {
    attemptToRegister(req, resp, "foo@example.com", "internet", true);

    verify(resp).setStatus(HttpServletResponse.SC_FORBIDDEN);
    ParticipantId participantId = ParticipantId.ofUnsafe("foo@example.com");
    AccountData account = store.getAccount(participantId);
    assertNull(account);
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.server.account.AccountData

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.