Package org.springframework.security.core.userdetails

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


            public Object executeWithContext(DirContext ctx) throws NamingException {
                try {
                    Attributes attrs = ctx.getAttributes(dn, attributesToRetrieve);
                    return new DirContextAdapter(attrs, LdapUtils.getFullDn(dn, ctx));
                } catch(NameNotFoundException notFound) {
                    throw new UsernameNotFoundException("User " + username + " not found", notFound);
                }
            }
        });
    }
View Full Code Here


        roleHierarchy.setHierarchy("ROLE_A > ROLE_B");
        final UserDetails user = new User("EXISTING_USER", "PASSWORD", true, true, true, true,
                AuthorityUtils.createAuthorityList("ROLE_A"));
        final UserDetailsService wrappedUserDetailsService = mock(UserDetailsService.class);
        when(wrappedUserDetailsService.loadUserByUsername("EXISTING_USER")).thenReturn(user);
        when(wrappedUserDetailsService.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION")).thenThrow(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION"));

        this.wrappedUserDetailsService = wrappedUserDetailsService;
        userDetailsServiceWrapper = new UserDetailsServiceWrapper();
        userDetailsServiceWrapper.setRoleHierarchy(roleHierarchy);
        userDetailsServiceWrapper.setUserDetailsService(wrappedUserDetailsService);
View Full Code Here

        SecurityContextHolder.clearContext();
    }

    @Test
    public void testAuthenticateUserDigestUserNotFound() throws Exception {
        expect(userDetailsService.loadUserByUsername(username)).andThrow(new UsernameNotFoundException(username));

        replay(userDetailsService);

        callbackHandler.handleInternal(callback);
        boolean authenticated = callback.getResult();
View Full Code Here

   
    try {
      details = this.entityManager.createQuery("select o from Employee o where o.username = :username",
          Employee.class).setParameter("username", usernameParam).getSingleResult();
    } catch (DataAccessException e) {
      throw new UsernameNotFoundException(usernameParam);
    } catch (NoResultException e) {
      throw new UsernameNotFoundException(usernameParam);
      }
   
    return details;
  }
View Full Code Here

    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
         User user = (User) getSqlMapClientTemplate().queryForObject("getUserByUsername", username);

         if (user == null) {
             log.warn("uh oh, user not found...");
             throw new UsernameNotFoundException("user '" + username + "' not found...");
         } else {
             List roles = getSqlMapClientTemplate().queryForList("getUserRoles", user);
             user.setRoles(new HashSet<Role>(roles));
         }
View Full Code Here

     * {@inheritDoc}
     */
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        List users = getSession().createCriteria(User.class).add(Restrictions.eq("username", username)).list();
        if (users == null || users.isEmpty()) {
            throw new UsernameNotFoundException("user '" + username + "' not found...");
        } else {
            return (UserDetails) users.get(0);
        }
    }
View Full Code Here

      // TODO: this should really be our own UserDetails wrapper class, shouldn't it?
      User user = new User(userInfo.getSub(), password, authorities);
      return user;
    } else {
      throw new UsernameNotFoundException("Could not find username: " + username);
    }
  }
View Full Code Here

    } else {
      strRoleRead = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "R", objUserInfo.getRoleGrpId());
      strRoleWrite = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "W", objUserInfo.getRoleGrpId());
    }     
    // 목록 조회시 [읽기권한]이 없는 경우 로그인 페이지로 이동시킨다.
    if (strRoleRead == "") throw new UsernameNotFoundException("목록 조회시 접근한 게시판에 Read 권한이 존재하지않습니다.");


    // 게시판 정보
    Article article = new Article();
    article.setBbsId(bbsId);
View Full Code Here

    } else {
      strRoleRead = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "R", objUserInfo.getRoleGrpId());
      strRoleWrite = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "W", objUserInfo.getRoleGrpId());
    }     
    // 내용 조회시 [읽기권한]이 없는 경우 로그인 페이지로 이동시킨다.
    if (strRoleRead == "") throw new UsernameNotFoundException("내용 조회시 접근한 게시판에 Read 권한이 존재하지않습니다.");


    // 게시판 정보
    Article article = new Article();
    article.setBbsId(bbsId);
View Full Code Here

    } else {
      strRoleRead = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "R", objUserInfo.getRoleGrpId());
      strRoleWrite = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "W", objUserInfo.getRoleGrpId());
    }     
    // 내용 추가시 [쓰기권한]이 없는 경우 로그인 페이지로 이동시킨다.
    if (strRoleWrite == "") throw new UsernameNotFoundException("내용 작성시 접근한 게시판에 Write 권한이 존재하지않습니다.");

    // 사용자 정보
    String strId = "";
    if (objUserInfo != null) strId = objUserInfo.getId();
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.