| | |
| | | String password = (String) authentication.getCredentials(); |
| | | LoginMode mode = (LoginMode) authentication.getDetails(); |
| | | Account account = accountService.queryAccountByName(accountName).orElseThrow(() -> new UsernameNotFoundException("User not found: " + accountName)); |
| | | Date expireTime = Optional.of(account.getExpireTime()) |
| | | Date expireTime = Optional.ofNullable(account.getExpireTime()) |
| | | .orElseThrow( |
| | | ()-> new AccountExpiredBadCredentialsException("Authentication Failed. Account has expired.") |
| | | ); |
| | |
| | | throw new InsufficientAuthenticationException("User has no roles assigned"); |
| | | } |
| | | List<GrantedAuthority> authorities = account.getRoles().stream() |
| | | .map(authority -> new SimpleGrantedAuthority(authority.getName())) |
| | | .map(authority -> new SimpleGrantedAuthority(authority.getRoleName())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | UserContext userContext = UserContext.create(account.getAccountName(),mode,account.getOrganizationId(),authorities); |