Package com.brienwheeler.svc.users.domain

Examples of com.brienwheeler.svc.users.domain.User


  public void addEmailAddress(User user, VerifiableEmailAddress emailAddress)
  {
    ValidationUtils.assertNotNull(user, "user cannot be null");
    ValidationUtils.assertNotNull(emailAddress, "emailAddress cannot be null");
   
    User existingUser = findByEmailAddress(emailAddress);
    if (existingUser != null)
    {
      if (existingUser.equals(user))
        return;
      throw new DuplicateUserEmailAddressException("email address " + emailAddress.getAddress() + " already in use");
    }
   
    userEmailAddressDao.save(new UserEmailAddress(user, emailAddress));
View Full Code Here


    newHashedPassword = ValidationUtils.assertNotEmpty(newHashedPassword, "newHashedPassword cannot be empty");
   
    if (!isValid(verificationData))
      return false;
   
    User user = userEmailAddressService.findByEmailAddress(verificationData.getEmailAddress());
    if (user == null)
      return false; // hard to imagine how this would happen
   
    userService.setNewPassword(user, newHashedPassword);
    return true;
View Full Code Here

    return true;
  }

  private ForgottenPasswordData doGetForgottenPasswordData(EmailAddress emailAddress)
  {
    User user = userEmailAddressService.findByEmailAddress(emailAddress);
    if (user == null)
      return null;
    long expiration = new DateTime().plus(expirationPeriod).getMillis();
    return new ForgottenPasswordData(emailAddress, expiration, getSignature(emailAddress, expiration));
  }
View Full Code Here

    hashedPassword = ValidationUtils.assertNotEmpty(hashedPassword, "hashedPassword cannot be empty");
 
    if (findByUsername(username) != null)
      throw new DuplicateUserException("username already exists: " + username);

    User user = userDao.save(new User(username, hashedPassword));
   
    if (callbacks != null)
    {
      for (CreateUserCallback callback : callbacks)
        callback.userCreated(user);
View Full Code Here

   
    Object attribute = session.getAttribute(LOGGED_IN_USER);
    if ((attribute instanceof User) && (((User) attribute).getId() == userId))
      return (User) attribute;
   
    User user = userService.findById(new DbId<User>(User.class, userId));
    if (user == null)
      throw new IllegalStateException("logged in user id not found in database");
   
    session.setAttribute(LOGGED_IN_USER, user);
    return user;
View Full Code Here

   
    if (userId != 0) {
      // we have a logged in user, see if the session has the user on it
      HttpSession session = request.getSession(false);
      if (session != null) {
        User user = (User) session.getAttribute(SESSION_ATTR_USER);
        if (user == null) {
          user = userService.findById(new DbId<User>(User.class, userId));
          if (user == null)
            throw new IllegalStateException("failed to lookup authenticated user");
          else {
            log.info("setting user id " + user.getId() + " into session " + session.getId());
            session.setAttribute(SESSION_ATTR_USER, user);
          }
        }
        else if (user.getId() != userId)
          throw new IllegalStateException("id of stored user does not match current authenticated user");
      }
    }
   
    return super.preHandle(request, response, handler);
View Full Code Here

  }

  public static User getCachedUser(HttpSession session, boolean throwOnFail)
  {
    ValidationUtils.assertNotNull(session, "session cannot be null");
    User user = (User) session.getAttribute(SESSION_ATTR_USER);
    if ((user == null) && throwOnFail)
      throw new IllegalStateException("no cached user found in session");
    return user;
  }
View Full Code Here

  @Override
  @Transactional(readOnly=true, propagation=Propagation.SUPPORTS)
  public UserDetails loadUserByUsername(String username)
      throws UsernameNotFoundException, DataAccessException
  {
    User user = null;
   
    if (allowEmailLookup && EmailAddress.isValid(username))
      user = userEmailAddressService.findByEmailAddress(new EmailAddress(username));
   
    if ((user == null) && allowUsernameLookup)
View Full Code Here

  {
    String existingCustomerProfileId = userAttributeService.getAttribute(userId, ATTR_PROFILE_ID);
    if (existingCustomerProfileId != null)
      return existingCustomerProfileId;
   
    final User user = userService.findById(userId);
    DbValidationUtils.assertPersisted(user);
   
    CustomerProfile customerProfile = CustomerProfile.createCustomerProfile();
    customerProfile.setMerchantCustomerId(Long.toString(userId.getId()));
View Full Code Here

TOP

Related Classes of com.brienwheeler.svc.users.domain.User

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.