Beispiel #1
0
 /** {@inheritDoc} */
 @Override
 public UserDetails loadUserByUsername(String userName)
     throws UsernameNotFoundException, DataAccessException {
   User u = userDAO.getUser(userName);
   if (u == null) {
     log.warn("User " + userName + " not found.");
     throw new UsernameNotFoundException("User " + userName + " not found.");
   }
   log.info("User " + userName + " found, id " + u.getId().toString() + ".");
   return new UserDetails(u);
 }
  /**
   * Creates a system user with the supplied name.
   *
   * @param userName the name of the user to create - used for pretty much all fields.
   * @param admin true if the new User should have the administrator role.
   * @return the new User.
   */
  private User createUser(String userName, boolean admin) {

    String[] roles;
    if (admin) {
      roles = new String[] {Role.USER, Role.ADMIN};
    } else {
      roles = new String[] {Role.USER};
    }
    return userDAO.createUser(
        userName, userName, userName, userName + "@user.com", userName, "key", roles);
  }
 @RequestMapping(value = HOME_URL)
 public ModelAndView render(HttpServletRequest request, HttpServletResponse response) {
   ModelAndView view = new ModelAndView();
   if (request.getParameter("signin") != null) {
     view.setViewName("signin");
     configureRedirectAfterLogin(request);
   } else {
     view.setViewName("home");
     Record latestRecord = recordDAO.getLatestRecord();
     view.addObject("recordCount", recordDAO.countAllRecords());
     view.addObject("latestRecord", latestRecord);
     view.addObject("uniqueSpeciesCount", recordDAO.countUniqueSpecies());
     view.addObject("userCount", userDAO.countUsers());
     view.addObject("publicSurveys", surveyDAO.getActivePublicSurveys(true));
   }
   return view;
 }
Beispiel #4
0
 public User getUserByRegistrationKey(String rego) {
   User u = userDAO.getUserByRegistrationKey(rego);
   return u;
 }