Package org.springframework.security.core.userdetails

Examples of org.springframework.security.core.userdetails.UsernameNotFoundException


    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        log.debug("loadUserByUsername called with: {}", username);
        final User user = userRepository.getByUsername(username);
        if (user == null) {
            throw new UsernameNotFoundException("User with username '" + username + "' was not found!");
        }
        return user;
    }
View Full Code Here


    @Override
    public void setAuthenticatedUser(long userId) {
        final User user = userRepository.get(userId);
        if (user == null) {
            throw new UsernameNotFoundException("User with id '" + userId + "' was not found!");
        }
        SecurityContext securityContext = createContext(user);
        SecurityContextHolder.setContext(securityContext);
    }
View Full Code Here

        Page personProfile = new PageImpl();
        PageLayout pageLayout = new PageLayoutImpl();
        pageLayout.setCode("person_profile");
        personProfile.setPageLayout(pageLayout);

        expect(userService.getUserByUsername(username)).andThrow(new UsernameNotFoundException("Username does not exist"));

        replay(userService, pageService);

        profileController.viewProfile(username, model, null);
View Full Code Here

    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if (log.isDebugEnabled()) log.debug("========> loadUserByUsername() username: {}", username);

        AppUser user = userService.findByUserLoginName(username);
        if (user == null)
            throw new UsernameNotFoundException("用户(" + username + ")不存在");

        if (log.isDebugEnabled()) {
            log.debug("========> user: {}", user);
            log.debug("========> password: {}", user.getUserPassword());
        }
View Full Code Here

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        log.debug("loadUserByUsername called with: {}", username);
        final User user = userRepository.getByUsername(username);
        if (user == null) {
            throw new UsernameNotFoundException("User with username '" + username + "' was not found!");
        }
        return user;
    }
View Full Code Here

    @Override
    public void setAuthenticatedUser(long userId) {
        final User user = userRepository.get(userId);
        if (user == null) {
            throw new UsernameNotFoundException("User with id '" + userId + "' was not found!");
        }
        SecurityContext securityContext = createContext(user);
        SecurityContextHolder.setContext(securityContext);
    }
View Full Code Here

    public void setDao(UserDAO dao) {
        this.dao = dao;
    }
    public UserDetails loadUserByUsername(String string) throws UsernameNotFoundException {
        User found = dao.getByName(string);
        if(found==null) throw new UsernameNotFoundException("User with given name is not present within the system.");
        List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
        auths.add(new DDTroopsUserGrantedAuthority(found.getAuthority()));

        DDTroopsUserDetails userDetails = new DDTroopsUserDetails(found.getId(),found.getName(),found.getPassword(),auths);
        return userDetails;
View Full Code Here

      throws UsernameNotFoundException, DataAccessException {
    // TODO Auto-generated method stub
        List<UserDetails> users = loadUsersByUsername(username);

        if (users.size() == 0) {
            throw new UsernameNotFoundException(
                    messages.getMessage("SophicUserService.notFound", new Object[]{username}, "Username {0} not found"), username);
        }

        UserDetails user = users.get(0); // contains no GrantedAuthority[]

        Set<GrantedAuthority> dbAuthsSet = new HashSet<GrantedAuthority>();

        dbAuthsSet.addAll(loadUserAuthorities(user.getUsername()));

        List<GrantedAuthority> dbAuths = new ArrayList<GrantedAuthority>(dbAuthsSet);

        if (dbAuths.size() == 0) {
            throw new UsernameNotFoundException(
                    messages.getMessage("SophicUserService.noAuthority",
                            new Object[] {username}, "User {0} has no GrantedAuthority"), username);
        }

        return createUserDetails(username, user, dbAuths);
View Full Code Here

 
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        List<UserDetails> users = loadUsersByUsername(username);

        if (users.size() == 0) {
            throw new UsernameNotFoundException(
                    messages.getMessage("JdbcDaoImpl.notFound", new Object[]{username}, "Username {0} not found"), username);
        }
        UserDetails user = users.get(0); // contains no GrantedAuthority[]

        Set<GrantedAuthority> dbAuthsSet = new HashSet<GrantedAuthority>();
View Full Code Here

  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
    try {
      return findByEmail(username);
    }
    catch(final EntityNotFoundException enfe) {
      throw new UsernameNotFoundException("Username '" + username + "' not found");
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.UsernameNotFoundException

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.