Package org.waveprotocol.box.server.account

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


  public void testNullPasswordWorks() throws Exception {
    attemptToRegister(req, resp, "zd@example.com", null, false);

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


  }

  @Override
  public AccountData getAccount(ParticipantId id) throws PersistenceException {
    synchronized (accounts) {
      AccountData account = accounts.get(id);
      if (account == null) {
        account = readAccount(id);
        if (account != null) {
          accounts.put(id, account);
        }
View Full Code Here

      address = address + ParticipantId.DOMAIN_PREFIX + AccountStoreHolder.getDefaultDomain();
    }
   
    try {
      id = ParticipantId.of(address);
      AccountData account = accountStore.getAccount(id);
      char[] password = passwordCallback.getPassword();
     
      if (account == null) {
        // The user doesn't exist. Auth failed.
        success = false;
      } else if (!account.isHuman()) {
        // The account is owned by a robot. Auth failed.
        success = false;
      } else if (password == null) {
        // Null password provided by callback. We require a password (even an empty one).
        success = false;
      } else if (!account.asHuman().getPasswordDigest().verify(password)) {
        // The supplied password doesn't match. Auth failed.
        success = false;
      } else {
        success = true;
      }
View Full Code Here

    if (id == null) {
      response.sendRedirect(sessionManager.getLoginUrl("/"));
      return;
    }

    AccountData account = sessionManager.getLoggedInAccount(request.getSession(false));
    if (account != null) {
      String locale = account.asHuman().getLocale();
      if (locale != null) {
        String requestLocale = UrlParameters.getParameters(request.getQueryString()).get("locale");
        if (requestLocale == null) {
          response.sendRedirect(UrlParameters.addParameter(request.getRequestURL().toString(), "locale", locale));
          return;
View Full Code Here

      if (participant == null) {
        resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
        return;
      }
      String locale = URLDecoder.decode(req.getParameter("locale"), "UTF-8");
      AccountData account = accountStore.getAccount(participant);
      HumanAccountData humanAccount;
      if (account != null) {
        humanAccount = account.asHuman();
      } else {
        humanAccount = new HumanAccountDataImpl(participant);
      }
      humanAccount.setLocale(locale);
      accountStore.putAccount(humanAccount);
View Full Code Here

public class FakePermissiveAccountStore implements AccountStore {
  Map<ParticipantId, AccountData> accounts = CollectionUtils.newHashMap();

  @Override
  public AccountData getAccount(ParticipantId id) {
    AccountData account = accounts.get(id);

    if (account == null && !id.getAddress().startsWith("xxx")) {
      account = new HumanAccountDataImpl(id, new PasswordDigest("".toCharArray()));
      accounts.put(id, account);
    }
View Full Code Here

        OperationUtil.getRequiredParameter(operation, ParamsProperty.CAPABILITIES_HASH);

    RobotName robotName = RobotName.fromAddress(participant.getAddress());

    ParticipantId robotAccountId = ParticipantId.ofUnsafe(robotName.toEmailAddress());
    AccountData account;
    try {
      account = accountStore.getAccount(robotAccountId);
    } catch (PersistenceException e) {
      LOG.severe("Failed to retreive account data for " + robotAccountId, e);
      context.constructErrorResponse(operation, "Unable to retrieve account data");
      return;
    }

    if (account == null || !account.isRobot()) {
      throw new InvalidRequestException("Can't exectute robot.notify for unknown robot "
          + robotAccountId);
    }

    RobotAccountData robotAccountData = account.asRobot();
    RobotCapabilities capabilities = robotAccountData.getCapabilities();
    if (capabilities != null && capabilitiesHash.equals(capabilities.getCapabilitiesHash())) {
      // No change in capabilities indicated
      context.constructResponse(operation, Maps.<ParamsProperty, Object> newHashMap());
      return;
    }

    try {
      robotAccountData = connector.fetchCapabilities(robotAccountData, "");
    } catch (CapabilityFetchException e) {
      LOG.fine("Unable to retrieve capabilities for " + account.getId(), e);
      context.constructErrorResponse(operation, "Unable to retrieve new capabilities");
      return;
    }

    try {
View Full Code Here

  }
 
  @Override
  public AccountData getAccount(ParticipantId id) throws PersistenceException {
    synchronized (accounts) {
      AccountData account = accounts.get(id);
      if (account == null) {
        account = readAccount(id);
        if (account != null) {
          accounts.put(id, account);
        }
View Full Code Here

  @Override
  public RobotAccountData unregister(ParticipantId robotId) throws RobotRegistrationException,
      PersistenceException {
    Preconditions.checkNotNull(robotId);
    AccountData accountData = accountStore.getAccount(robotId);
    if (accountData == null) {
      return null;
    }
    throwExceptionIfNotRobot(accountData);
    RobotAccountData robotAccount = accountData.asRobot();
    removeRobotAccount(robotAccount);
    return robotAccount;
  }
View Full Code Here

      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

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.