|  |  |  | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | import org.springframework.util.Assert; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | String password = (String) authentication.getCredentials(); | 
|---|
|  |  |  | LoginMode mode = (LoginMode) authentication.getDetails(); | 
|---|
|  |  |  | Account account = accountService.queryAccountByName(accountName).orElseThrow(() -> new UsernameNotFoundException("User not found: " + accountName)); | 
|---|
|  |  |  | if (!encoder.matches(password, account.getPassword())) { | 
|---|
|  |  |  | if (!encoder.matches(password, account.getPassword()) || account.getExpireTime().before(new Date())) { | 
|---|
|  |  |  | throw new BadCredentialsException("Authentication Failed. Username or Password not valid."); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|