use of io.github.tesla.authz.domain.ClientDetails in project tesla by linking12.
the class OauthService method changeAccessTokenByRefreshToken.
public AccessToken changeAccessTokenByRefreshToken(String refreshToken, String clientId) throws OAuthSystemException {
final AccessToken oldToken = loadAccessTokenByRefreshToken(refreshToken, clientId);
AccessToken newAccessToken = oldToken.cloneMe();
LOG.debug("Create new AccessToken: {} from old AccessToken: {}", newAccessToken, oldToken);
ClientDetails details = oauthRepository.findClientDetails(clientId);
newAccessToken.updateByClientDetails(details);
final String authId = authenticationIdGenerator.generate(clientId, oldToken.username(), null);
newAccessToken.authenticationId(authId).tokenId(oAuthIssuer.accessToken()).refreshToken(oAuthIssuer.refreshToken());
oauthRepository.deleteAccessToken(oldToken);
LOG.debug("Delete old AccessToken: {}", oldToken);
oauthRepository.saveAccessToken(newAccessToken);
LOG.debug("Save new AccessToken: {}", newAccessToken);
return newAccessToken;
}
Aggregations