use of com.vmware.flowgate.common.model.WormholeUser in project flowgate by vmware.
the class AccessTokenService method refreshToken.
public AuthToken refreshToken(String token) {
DecodedJWT jwt = jwtTokenUtil.getDecodedJwt(token);
WormholeUser user = userservice.getUserByName(jwt.getSubject());
ObjectMapper mapper = new ObjectMapper();
if (jwtTokenUtil.isCreatedAfterLastPasswordReset(jwt.getIssuedAt(), user.getLastPasswordResetDate())) {
String userdetailString = getUserJsonString(token);
WormholeUserDetails userDetails = null;
try {
userDetails = mapper.readValue(userdetailString, WormholeUserDetails.class);
} catch (IOException e) {
logger.error(e.getMessage());
return null;
}
AuthToken refreshToken = jwtTokenUtil.generate(userDetails);
redisTemplate.delete(JwtTokenUtil.Prefix_token + token);
return refreshToken;
}
return null;
}
use of com.vmware.flowgate.common.model.WormholeUser in project flowgate by vmware.
the class UserDetailsServiceImpl method loadUserByUsername.
@Override
public WormholeUserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
WormholeUser user = getUserByName(userName);
AuthorityUtil authorityUtil = new AuthorityUtil();
List<GrantedAuthority> privileges = new ArrayList<GrantedAuthority>();
if (user == null) {
throw new UsernameNotFoundException(String.format("No user found with username '%s'.", userName));
}
privileges = authorityUtil.createGrantedAuthorities(user.getRoleNames());
return new WormholeUserDetails(user.getId(), user.getUserName(), user.getPassword(), privileges);
}
Aggregations