Package com.denimgroup.threadfix.data.entities

Examples of com.denimgroup.threadfix.data.entities.User


    return User.class.equals(clazz);
  }

  @Override
  public void validate(Object target, Errors errors) {
    User user = (User) target;
   
    if (!user.getHasGlobalGroupAccess() || user.getGlobalRole() == null ||
        user.getGlobalRole().getId() == null || user.getGlobalRole().getId() == null ||
        user.getGlobalRole().getId() == 0 ||
        roleService == null ||
        roleService.loadRole(user.getGlobalRole().getId()) == null) {
      user.setGlobalRole(null);
    } else {
            user.setGlobalRole(roleService.loadRole(user.getGlobalRole().getId()));
        }

    if (isEmptyOrWhitespace(user.getName())) {
      errors.rejectValue("name", MessageConstants.ERROR_REQUIRED, new String[] { "Name" }, null);
    } else if (user.getName() != null && user.getName().length() > 25) {
      errors.rejectValue("name", null, "Name has a maximum length of 25.");
    }

    // Validate password
    if (!user.getIsLdapUser()) {
      if (user.isNew()) {
        if (isEmptyOrWhitespace(user.getUnencryptedPassword())) {
          errors.rejectValue("password", MessageConstants.ERROR_REQUIRED, new String[] { "Password" }, "");
        }
      }

      if(errors.getFieldError("password") == null &&
          user.getWasLdap() &&
          user.getUnencryptedPassword().length() < 12){
        errors.rejectValue("password", null, "Password has a minimum length of 12.");
      }
     
      if (errors.getFieldError("password") == null && user.getUnencryptedPassword() != null &&
          user.getUnencryptedPassword().length() < 12 &&
          user.getUnencryptedPassword().length() != 0) {
        errors.rejectValue("password", null, "Password has a minimum length of 12.");
      }
 
      // Confirm password
      if (errors.getFieldError("password") == null) {
        if (!isEmptyOrWhitespace(user.getUnencryptedPassword())
            || !isEmptyOrWhitespace(user.getPasswordConfirm())) {
          if (isEmptyOrWhitespace(user.getUnencryptedPassword())) {
            errors.rejectValue("password", null, "Passwords do not match.");
          } else if (isEmptyOrWhitespace(user.getPasswordConfirm())) {
            errors.rejectValue("password", null, "Passwords do not match.");
          } else if (!user.getUnencryptedPassword().equals(user.getPasswordConfirm())) {
            errors.rejectValue("password", null, "Passwords do not match.");
          }
        }
      }
    }
View Full Code Here


  @RequestMapping(method = RequestMethod.GET)
  public ModelAndView editForm(HttpServletRequest request) {
   
    String userName = SecurityContextHolder.getContext().getAuthentication().getName();
   
    User user = null;
   
    Object successMessage = ControllerUtils.getSuccessMessage(request);
        Object errorMessage = ControllerUtils.getErrorMessage(request);
   
    if (userName != null){
View Full Code Here

                return "redirect:/configuration/users/password";
      }
     
      String currentUserName = SecurityContextHolder.getContext().getAuthentication().getName();
     
      User databaseUser = userService.loadUser(user.getName());
      if (databaseUser != null && !databaseUser.getId().equals(user.getId())) {
        // TODO check this out
                ControllerUtils.addItem(request, CURRENT_PASSWORD_FIELD_STR, "The user has changed since starting this procedure.");
                return "redirect:/configuration/users/password";
      }
     
View Full Code Here

    return roleService.loadAll();
  }
 
  @RequestMapping(value="/permissions", method = RequestMethod.GET)
  public ModelAndView editForm(@PathVariable("userId") int userId) {
    User user = userService.loadUser(userId);
   
    if (user == null){
      log.warn(ResourceNotFoundException.getLogMessage("User", userId));
      throw new ResourceNotFoundException();
    }
   
    String currentUser = SecurityContextHolder.getContext().getAuthentication().getName();
   
    boolean isThisUser = currentUser != null && user.getName().equals(currentUser);
   
    ModelAndView mav = new ModelAndView("config/users/rolesConfiguration");
    mav.addObject(user);
    mav.addObject("teams",organizationService.loadAllActive());
    mav.addObject("maps",accessControlMapService.loadAllMapsForUser(userId));
View Full Code Here

 
  @RequestMapping(value="/access/new", method = RequestMethod.POST)
  public @ResponseBody RestResponse<AccessControlTeamMap> createMapping(@PathVariable("userId") int userId,
      @ModelAttribute AccessControlMapModel accessControlModel) {

    User user = userService.loadUser(userId);
    if (user == null) {
      throw new ResourceNotFoundException();
    }
   
    accessControlModel.setUserId(userId);
View Full Code Here

  @RequestMapping(value="/access/{mapId}/edit", method = RequestMethod.POST)
  public @ResponseBody RestResponse<AccessControlTeamMap> editMapping(@ModelAttribute AccessControlMapModel accessControlModel,
      @PathVariable("userId") int userId,
      @PathVariable("mapId") int mapId) {
   
    User user = userService.loadUser(userId);
    if (user == null) {
      throw new ResourceNotFoundException();
    }
   
    accessControlModel.setUserId(userId);
View Full Code Here

        return userDetails;
    }

    @Override
    public final UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        User user = userService.loadUser(username);
        if (user == null) {
            throw new UsernameNotFoundException("");
        }

        log.info("User " + user.getName() + " logged in successfully at " + new Date());
        return loadUser(user);
    }
View Full Code Here

    if (vuln == null) {
      log.error("Invalid vuln ID");
      return VULN;
    }
   
    User user = null;
   
    Object auth = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    if (auth != null && auth instanceof ThreadFixUserDetails) {
      user = userDao.retrieveById(((ThreadFixUserDetails) auth).getUserId());
    }
View Full Code Here

   
    if (result.hasErrors()) {
      return FormRestResponse.failure("Errors", result);
    } else {

      User databaseUser = userService.loadUser(user.getName());
      if (databaseUser != null && !databaseUser.getId().equals(user.getId())) {
        result.rejectValue("name", MessageConstants.ERROR_NAMETAKEN);
                return FormRestResponse.failure("Errors", result);
      }
     
      if (user.getGlobalRole() != null && user.getGlobalRole().getId() != null) {
View Full Code Here

  public @ResponseBody RestResponse<User> processNew(@Valid @ModelAttribute User user, BindingResult result) {
    new UserValidator(roleService).validate(user, result);
    if (result.hasErrors()) {
            return FormRestResponse.failure("Errors", result);
    } else {
      User databaseUser = userService.loadUser(user.getName().trim());
      if (databaseUser != null) {
        result.rejectValue("name", MessageConstants.ERROR_NAMETAKEN);
                return FormRestResponse.failure("Errors", result);
      }
View Full Code Here

TOP

Related Classes of com.denimgroup.threadfix.data.entities.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.