Package org.itnaf.model

Examples of org.itnaf.model.User


    }

    // Test fix to http://issues.appfuse.org/browse/APF-96
    public void testUpdateUserWithUserRole() throws Exception {
        UserManager userManager = (UserManager) makeInterceptedTarget();
        User user = new User("user");
        user.getRoles().add(new Role(Constants.USER_ROLE));

        userDao.expects(once()).method("saveUser");
        userManager.saveUser(user);
        userDao.verify();
    }
View Full Code Here


        SecurityContextHolder.setContext(context);
       
        UserManager userManager = (UserManager) makeInterceptedTarget();
       
        UserCache cache = (UserCache) ctx.getBean("userCache");
        User user = new User("cacheduser");
        user.setVersion(new Integer(1));
        user.getRoles().add(new Role(Constants.USER_ROLE));
        cache.putUserInCache(user);
       
        assertNotNull(cache.getUserFromCache(user.getUsername().toLowerCase()));
       
        userDao.expects(once()).method("saveUser");
        userManager.saveUser(user);
        assertNull(cache.getUserFromCache(user.getUsername()));
    }
View Full Code Here

    }

    public void testAddExistingUser() throws Exception {
        logger.debug("entered 'testAddExistingUser' method");

        User user = manager.getUser("1");
       
        // create new object with null id - Hibernate doesn't like setId(null)
        User user2 = new User();
        BeanUtils.copyProperties(user, user2);
        user2.setId(null);
        user2.setVersion(null);
       
        // try saving as new user, this should fail b/c of unique keys
        try {
            manager.saveUser(user2);
            fail("Duplicate user didn't throw UserExistsException");
View Full Code Here

public class UserDaoHibernate extends BaseDaoHibernate implements UserDao, UserDetailsService {
    /**
     * @see org.itnaf.dao.UserDao#getUser(Long)
     */
    public User getUser(Long userId) {
        User user = (User) getHibernateTemplate().get(User.class, userId);

        if (user == null) {
            log.warn("uh oh, user '" + userId + "' not found...");
            throw new ObjectRetrievalFailureException(User.class, userId);
        }
View Full Code Here

     */
    public void attributeAdded(HttpSessionBindingEvent event) {
        log.debug("event.name: " + event.getName());
        if (event.getName().equals(EVENT_KEY)) {
            SecurityContext securityContext = (SecurityContext) event.getValue();
            User user =
              (User) securityContext.getAuthentication().getPrincipal();
            addUsername(user);
        }
    }
View Full Code Here

     * @see javax.servlet.http.HttpSessionAttributeListener#attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)
     */
    public void attributeRemoved(HttpSessionBindingEvent event) {
        if (event.getName().equals(EVENT_KEY)) {
            SecurityContext securityContext = (SecurityContext) event.getValue();
            User user =
              (User) securityContext.getAuthentication().getPrincipal();
            removeUsername(user);
        }
    }
View Full Code Here

       }
     
    System.out.println("****** " + newValues);
   
    if (newValues.containsKey("userName")) {
        User user2 = new User();
        user2.setUsername((String)newValues.get("userName"));
        if (newValues.containsKey("password")) {
          user2.setPassword((String)newValues.get("password"));
        } else {
          user2.setPassword("NOT SET");
        }
        user2.setAccountExpired(false);
        if (newValues.containsKey("firstName")) {
          user2.setFirstName((String)newValues.get("firstName"));
        } else {
          user2.setFirstName("");
        }
        if (newValues.containsKey("lastName")) {
          user2.setLastName((String)newValues.get("lastName"));
        } else {
          user2.setLastName("");
        }
        if (newValues.containsKey("email")) {
          user2.setEmail((String)newValues.get("email"));
        } else {
          user2.setEmail("");
        }
        if (newValues.containsKey("website")) {
          user2.setWebsite((String)newValues.get("website"));
        } else {
          user2.setWebsite("");
        }
        if (newValues.containsKey("passwordHint")) {
          user2.setPasswordHint((String)newValues.get("passwordHint"));
        } else {
          user2.setPasswordHint("");
        }
        Address address = new Address();
          address.setCity("Denver");
          address.setProvince("CO");
          address.setCountry("United States");
          address.setPostalCode("80210");       
          user2.setAddress(address);     
          user2.addRole(new Role(Constants.USER_ROLE));
        try {
          System.out.println("*********************** " + user2);
          userManager.saveUser(user2);
           } catch (Exception e) {
          System.out.println("error saving user" + e);
View Full Code Here

            // lookup the user using that id
            user = userManager.getUserByUsername(username);
        } else if (username == null) {
            user = userManager.getUserByUsername(request.getRemoteUser());
        } else {
            user = new User();
            user.addRole(new Role(Constants.USER_ROLE));
        }

        if (user.getUsername() != null) {
            user.setConfirmPassword(user.getPassword());
View Full Code Here

    DataObject[] newDobs = inDobs;

    HashSet ouSet = new HashSet();
    for (int i = 0; i < newDobs.length; i++) {
      System.out.println("" + newDobs[i]);
      User user = new User();
      user.setPassword("NOT_SET");
      user.setPasswordHint("NOT SET");
      user.setEnabled(new Boolean(true));
      try {
        if (attributes.containsKey(userid)) {
            user.setUsername(
                (String)newDobs[i].getAttributeValue(
                (String)attributes.get(userid)));
        }
        if (attributes.containsKey(fname)) {
          user.setFirstName(
              (String)newDobs[i].getAttributeValue(
              (String)attributes.get(fname)));
        }
        if (attributes.containsKey(lname)) {
          user.setLastName(
              (String)newDobs[i].getAttributeValue(
              (String)attributes.get(lname)));
        }
        if (attributes.containsKey(email)) {
          user.setEmail(
              (String)newDobs[i].getAttributeValue(
              (String)attributes.get(email)));
        }
        if (attributes.containsKey(userid)) {
          user.setUsername(
              (String)newDobs[i].getAttributeValue(
              (String)attributes.get(userid)));
        }
        if (attributes.containsKey(password)) {
          user.setPassword(
              (String)newDobs[i].getAttributeValue(
              (String)attributes.get(password)));
          user.setPasswordHint(
              (String)newDobs[i].getAttributeValue(
              (String)attributes.get(password)));
        }
        if (attributes.containsKey(manager)) {
          // TODO
View Full Code Here

            log.debug("Processing Password Hint...");
        }
       
        // look up the user's information
        try {
            User user = userManager.getUserByUsername(username);

            StringBuffer msg = new StringBuffer();
            msg.append("Your password hint is: " + user.getPasswordHint());
            msg.append("\n\nLogin at: " + RequestUtil.getAppURL(getRequest()));

            message.setTo(user.getEmail());
            String subject = '[' + getText("webapp.name") + "] " + getText("user.passwordHint");
            message.setSubject(subject);
            message.setText(msg.toString());
            mailEngine.send(message);
           
            addMessage("login.passwordHint.sent",
                       new Object[] { username, user.getEmail() });
           
        } catch (Exception e) {
            e.printStackTrace();
            // If exception is expected do not rethrow
            addError("login.passwordHint.error", username);
View Full Code Here

TOP

Related Classes of org.itnaf.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.