Search in sources :

Example 6 with ClientDetails

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;
}
Also used : ClientDetails(io.github.tesla.authz.domain.ClientDetails) AccessToken(io.github.tesla.authz.domain.AccessToken)

Aggregations

ClientDetails (io.github.tesla.authz.domain.ClientDetails)6 OAuthResponse (org.apache.oltu.oauth2.common.message.OAuthResponse)2 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 AccessToken (io.github.tesla.authz.domain.AccessToken)1 Log (io.github.tesla.ops.common.Log)1 Query (io.github.tesla.ops.utils.Query)1 OAuthASResponse (org.apache.oltu.oauth2.as.response.OAuthASResponse)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1