Package org.springframework.security.core.userdetails

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


        log.debug("Authenticating {}", login);
        String lowercaseLogin = login.toLowerCase();

        User userFromDatabase = userRepository.findOne(lowercaseLogin);
        if (userFromDatabase == null) {
            throw new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the database");
        } else if (!userFromDatabase.getActivated()) {
            throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
        }

        Collection<GrantedAuthority> grantedAuthorities = new ArrayList<>();
View Full Code Here


          userAuthorities);
      currentUser.set(user);
      return user;

    } catch (Exception e) {
      throw new UsernameNotFoundException("Username " + username
          + " not found!");
    }

  }
View Full Code Here

    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
  com.bolbachchan.blog.hibernate.domain.UserDetails userDetails = userDetailsDao
    .getUserDetailsByUsername(username);

  if (userDetails == null) {
      throw new UsernameNotFoundException(username + " not found in the Database");
  }

  BlogUser user = buildUser(username, userDetails);
  return user;
    }
View Full Code Here

        Page personProfile = new Page();
        PageLayout pageLayout = new PageLayout();
        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

    @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

            throws UsernameNotFoundException {
       
        PracticalUserDetails retr = this.pud.read(username);
       
        if ( retr == null )
            throw new UsernameNotFoundException(username);
       
        return retr;
       
    }
View Full Code Here

            throws UsernameNotFoundException {
       
        PracticalUserDetails retr = this.pud.read(username);
       
        if ( retr == null )
            throw new UsernameNotFoundException(username);
       
        return retr;
       
    }
View Full Code Here

                    throws AuthenticationException {
                Object principal = authentication.getPrincipal();
                String username = String.valueOf(principal);
                User user = myUserRepository.findByUsername(username);
                if(user == null) {
                    throw new UsernameNotFoundException("No user for principal "+principal);
                }
                if(!authentication.getCredentials().equals(user.getPassword())) {
                    throw new BadCredentialsException("Invalid password");
                }
                return new TestingAuthenticationToken(principal, null, "ROLE_USER");
View Full Code Here

            return new org.springframework.security.core.userdetails.User(user
                    .getUsername(), user.getPassword(), true, true, true, true,
                    AuthorityUtils.createAuthorityList("ROLE_USER"));
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
            throw new UsernameNotFoundException("No matching account", e);
        }
    }
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.