Refine search
public UserDetails loadUserByUsername(String username) { if ("peter".equals(username)) { return new User("peter", "opal", false, true, true, true, ROLES_12); } throw new UsernameNotFoundException("Could not find: " + username); } }
@Override public UaaUser retrieveUserByName(String username, String origin) throws UsernameNotFoundException { UaaUser u = users.get(username+"-"+origin); if (u == null) { throw new UsernameNotFoundException("User " + username + " not found"); } return u; }
for (Privilege p : user.getPrivileges()) { roles.add(new GrantedAuthorityImpl(p.getName())); user.getUsername(), user.getLdapAuth() ? getLdapPassword(user.getUsername()) : user.getPassword(), user.getStatus() != User.Status.NOT_COMMITED, user.getStatus() != User.Status.BLOCKED, true, true, roles.toArray(new GrantedAuthority[0]) throw new UsernameNotFoundException("No user with username '" + username + "' found!");
User existingUser = this.userDao.getUserByUsername(username); if (existingUser != null) { List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>(); roles.add(Role.USER); org.springframework.security.core.userdetails.User user = new org.springframework.security.core.userdetails.User( existingUser.getUsername(), existingUser.getPassword(), existingUser.getEnable(), true, true, true, roles); return user; } else { throw new UsernameNotFoundException("User not found"); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { return this.accountRepository.findByUsername(username) .map(account -> User.withUsername(account.getUsername()) .password(account.getPassword()).roles("USER") .build()) .orElseThrow(() -> new UsernameNotFoundException("couldn't find " + username + "!")); } }
@ExceptionHandler( UsernameNotFoundException.class ) public ResponseEntity serviceErrorHandler ( UsernameNotFoundException e ) { LogUtils.getLogger().error( "error" , e ); return ResponseEntityPro.unauthorized( e.getMessage() , e.getMessage() ); }
@PreAuthorize("hasRole('USER')") @DeleteMapping(path = "/api/user/remove", produces = "application/json") public ResponseEntity<?> removeUser() { try { accountService.removeAuthenticatedAccount(); return new ResponseEntity<Object>(new RestResponse("User removed."), HttpStatus.OK); } catch (UsernameNotFoundException e) { e.printStackTrace(); return new ResponseEntity<Object>(new RestError(e.getMessage()), HttpStatus.OK); } }
@Override public UaaUser retrieveUserById(String id) throws UsernameNotFoundException { UaaUser u = ids.get(id); if (u == null) { throw new UsernameNotFoundException("User ID:" + id + " not found"); } return u; }
@ExceptionHandler(value = UsernameNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody public ApiResponse handleUsernameNotFoundException(UsernameNotFoundException ex) { ApiResponse apiResponse = new ApiResponse(); apiResponse.setSuccess(false); apiResponse.setData(ex.getMessage()); return apiResponse; }
public UserDetails loadUserByUsername(String username) { if ("peter".equals(username)) { return new User("peter", "opal", true, false, true, true, ROLES_12); } throw new UsernameNotFoundException("Could not find: " + username); } }
public UaaUser updateUser(String userId, UaaUser user) throws UsernameNotFoundException { if (!ids.containsKey(userId)) { throw new UsernameNotFoundException("User " + userId + " not found"); } ids.put(userId, user); return user; }
@Override public SocialUserDetails loadUserByUserId(final String username) throws UsernameNotFoundException, DataAccessException { try { log.debug("LOAD USER : {}", username); UserDetails userDetails = userDetailsService.loadUserByUsername(username); return new SocialUser(username, "N/A", userDetails.getAuthorities()); } catch (UsernameNotFoundException e) { log.warn(e.getMessage(), e); } return null; }
public UserDetails loadUserByUsername(String username) { if ("rod".equals(username)) { return new User("rod", password, true, true, true, true, ROLES_12); } throw new UsernameNotFoundException("Could not find: " + username); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { return repository.findById(username).orElseThrow(()->new UsernameNotFoundException(username)); } }
public UserDetails loadUserByUsername(String username) { if ("peter".equals(username)) { return new User("peter", "opal", true, true, true, false, ROLES_12); } throw new UsernameNotFoundException("Could not find: " + username); } }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { checkUserMap(); UserDetails user = userMap.get(username); if (user == null) throw new UsernameNotFoundException("Could not find user: " + username); return user; }
public UserDetails loadUserByUsername(String username) { if ("peter".equals(username)) { return new User("peter", "opal", true, true, false, true, ROLES_12); } throw new UsernameNotFoundException("Could not find: " + username); } }
@RequestMapping(path = "/me") public ResponseEntity me(Principal principal) { User user = null; if(principal != null) { user = userService.getUserByUsername(principal.getName()); } return Optional.ofNullable(user) .map(a -> new ResponseEntity<User>(a, HttpStatus.OK)) .orElseThrow(() -> new UsernameNotFoundException("Username not found")); } }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { ClientDetails clientDetails; try { clientDetails = clientDetailsService.loadClientByClientId(username); } catch (NoSuchClientException e) { throw new UsernameNotFoundException(e.getMessage(), e); } String clientSecret = clientDetails.getClientSecret(); if (clientSecret== null || clientSecret.trim().length()==0) { clientSecret = emptyPassword; } return new User(username, clientSecret, clientDetails.getAuthorities()); }
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); } } });