use of io.github.tesla.authz.domain.AccessToken in project tesla by linking12.
the class Oauth2Controller method listTokens.
@ResponseBody
@GetMapping("/listToken")
@RequiresPermissions("sys:oauth2:listToken")
PageDO<AccessToken> listTokens(@RequestParam Map<String, Object> params) {
Query query = new Query(params);
PageDO<AccessToken> page = oauth2Service.queryTokenList(query);
return page;
}
use of io.github.tesla.authz.domain.AccessToken in project tesla by linking12.
the class TokenAuthorizeHandler method forceTokenResponse.
private void forceTokenResponse() throws OAuthSystemException {
AccessToken accessToken = oauthService.retrieveNewAccessToken(clientDetails(), oauthRequest.getScopes());
normalTokenResponse(accessToken);
}
use of io.github.tesla.authz.domain.AccessToken in project tesla by linking12.
the class ClientCredentialsTokenHandler method handleAfterValidation.
@Override
public void handleAfterValidation() throws OAuthProblemException, OAuthSystemException {
AccessToken accessToken = oauthService.retrieveClientCredentialsAccessToken(clientDetails(), tokenRequest.getScopes());
final OAuthResponse tokenResponse = createTokenResponse(accessToken, false);
LOG.debug("'client_credentials' response: {}", tokenResponse);
WebUtils.writeOAuthJsonResponse(response, tokenResponse);
}
use of io.github.tesla.authz.domain.AccessToken in project tesla by linking12.
the class PasswordTokenHandler method handleAfterValidation.
@Override
public void handleAfterValidation() throws OAuthProblemException, OAuthSystemException {
AccessToken accessToken = oauthService.retrievePasswordAccessToken(clientDetails(), tokenRequest.getScopes(), tokenRequest.getUsername());
final OAuthResponse tokenResponse = createTokenResponse(accessToken, false);
LOG.debug("'password' response: {}", tokenResponse);
WebUtils.writeOAuthJsonResponse(response, tokenResponse);
}
use of io.github.tesla.authz.domain.AccessToken in project tesla by linking12.
the class OauthService method retrievePasswordAccessToken.
public AccessToken retrievePasswordAccessToken(ClientDetails clientDetails, Set<String> scopes, String username) throws OAuthSystemException {
String scope = OAuthUtils.encodeScopes(scopes);
final String clientId = clientDetails.getClientId();
final String authenticationId = authenticationIdGenerator.generate(clientId, username, scope);
AccessToken accessToken = oauthRepository.findAccessToken(clientId, username, authenticationId);
boolean needCreate = false;
if (accessToken == null) {
needCreate = true;
LOG.debug("Not found AccessToken from repository, will create a new one, client_id: {}", clientId);
} else if (accessToken.tokenExpired()) {
LOG.debug("Delete expired AccessToken: {} and create a new one, client_id: {}", accessToken, clientId);
oauthRepository.deleteAccessToken(accessToken);
needCreate = true;
} else {
LOG.debug("Use existed AccessToken: {}, client_id: {}", accessToken, clientId);
}
if (needCreate) {
accessToken = createAndSaveAccessToken(clientDetails, clientDetails.supportRefreshToken(), username, authenticationId);
LOG.debug("Create a new AccessToken: {}", accessToken);
}
return accessToken;
}
Aggregations