Package org.apache.rave.model

Examples of org.apache.rave.model.User



    @Override
    public void sendUserNameReminder(User newUser) {
        log.debug("Calling send username  {}", newUser);
        User user = userRepository.getByUserEmail(newUser.getEmail());
        if (user == null) {
            throw new IllegalArgumentException("Could not find user for email " + newUser.getEmail());
        }
        String to = user.getUsername() + " <" + user.getEmail() + '>';
        Map<String, Object> templateData = new HashMap<String, Object>();
        templateData.put("user", user);
        emailService.sendEmail(to, userNameReminderSubject, userNameReminderTemplate, templateData);

    }
View Full Code Here



    @Override
    public void sendPasswordReminder(User newUser) {
        log.debug("Calling send password change link for user {}", newUser);
        User user = userRepository.getByUserEmail(newUser.getEmail());
        if (user == null) {
            throw new IllegalArgumentException("Could not find user for email " + newUser.getEmail());
        }
        // create user hash:
        String input = user.getEmail() + user.getUsername() + String.valueOf(user.getId()) + System.nanoTime();
        // hash needs to be URL friendly:
        String safeString = new String(Base64.encode(passwordEncoder.encode(input).getBytes()));
        String  hashedInput = safeString.replaceAll("[/=]", "A");
        user.setForgotPasswordHash(hashedInput);
        user.setForgotPasswordTime(Calendar.getInstance().getTime());
        userRepository.save(user);
        String to = user.getUsername() + " <" + user.getEmail() + '>';
        Map<String, Object> templateData = new HashMap<String, Object>();
        templateData.put("user", user);
        templateData.put("reminderUrl", baseUrl + hashedInput);
        emailService.sendEmail(to, passwordReminderSubject, passwordReminderTemplate, templateData);
    }
View Full Code Here

    public boolean isValidReminderRequest(String forgotPasswordHash, int nrOfMinutesValid) {
        if (StringUtils.isBlank(forgotPasswordHash)) {
            return false;
        }

        User userForHash = userRepository.getByForgotPasswordHash(forgotPasswordHash);
        if (userForHash == null) {
            return false;
        }
        Date requestTime = userForHash.getForgotPasswordTime();
        Calendar expiredDate = Calendar.getInstance();
        expiredDate.add(Calendar.MINUTE, nrOfMinutesValid);

        if (requestTime == null || requestTime.after(expiredDate.getTime())) {
            // reset,  this is invalid state
            userForHash.setForgotPasswordHash(null);
            userForHash.setForgotPasswordTime(null);
            userRepository.save(userForHash);
            return false;
        }
        return true;
    }
View Full Code Here

    }

  @Override
  public UserDetails loadUserDetails(OpenIDAuthenticationToken token) throws UsernameNotFoundException {
    final String openId = token.getIdentityUrl();
    User user = this.getUserByOpenId(openId);
    if (user == null) {
      log.info("Open ID User with URL "+openId+" was not found!");
      throw new UsernameNotFoundException("Open ID User with URL "+openId+" was not found!");
    }
    return user;
View Full Code Here

        return link;
    }

    private String getCreator(Page page){
        String result="";
        User user = userService.getUserById(page.getOwnerId());
        result = user.getDisplayName();
        if(result == null || result.equals("")){
            result = user.getPreferredName();
            if(result == null || result.equals("")){
                result = user.getUsername();
            }
        }
        return result;
    }
View Full Code Here

        assertTrue("Can validate org.apache.rave.model.User", validator.supports(UserImpl.class));
    }

    @Test
    public void testValidate() throws Exception {
        User user = new UserImpl();
        user.setUsername(VALID_NAME);
        user.setPassword(VALID_PASSWORD);
        user.setConfirmPassword(VALID_PASSWORD);
        user.setEmail(VALID_EMAIL);

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertFalse("No errors", errors.hasErrors());
View Full Code Here

        assertFalse("No errors", errors.hasErrors());
    }

    @Test
    public void testValidateFailsOnEmptyPassword() throws Exception {
        User user = new UserImpl();
        user.setUsername(VALID_NAME);
        user.setEmail(VALID_EMAIL);

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertTrue("Validation errors", errors.hasErrors());
View Full Code Here

    }

    @Test
    public void testValidateFailsOnShortPassword() throws Exception {
        User user = new UserImpl();
        user.setUsername(VALID_NAME);
        user.setPassword("123");
        user.setPassword("123");

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertTrue("Validation errors", errors.hasErrors());
View Full Code Here

    }

    @Test
    public void testValidateFailsOnPasswordMismatch() throws Exception {
        User user = new UserImpl();
        user.setUsername(VALID_NAME);
        user.setPassword(VALID_PASSWORD);
        user.setConfirmPassword("DoesNotMatch");

        Errors errors = new BindException(user, USER);
        validator.validate(user, errors);

        assertTrue("Validation errors", errors.hasErrors());
View Full Code Here

    @Test
    public void testMapUserFromContext_new() throws Exception {
        DirContextOperations ctx = createMock(DirContextOperations.class);

        final String username = "johnldap";
        User user = new UserImpl("123", username);

        expect(userService.getUserByUsername(username)).andReturn(null).once();
        expect(ctx.attributeExists(MAIL_ATTRIBUTE_NAME)).andReturn(true);
        expect(ctx.getStringAttribute(MAIL_ATTRIBUTE_NAME)).andReturn("johnldap@example.com").times(2);
        expect(ctx.attributeExists(DISPLAY_NAME_ATTRIBUTE_NAME)).andReturn(true);
View Full Code Here

TOP

Related Classes of org.apache.rave.model.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.