use of io.jmix.securityoauth2.event.OAuth2TokenRevokedEvent in project jmix by jmix-framework.
the class TokenRevoker method revokeAccessToken.
@Nullable
protected String revokeAccessToken(String token, @Nullable Authentication clientAuth, TokenRevocationInitiator revocationInitiator) {
OAuth2AccessToken accessToken = tokenStore.readAccessToken(token);
if (accessToken != null) {
OAuth2Authentication authToRevoke = tokenStore.readAuthentication(accessToken);
if (revocationInitiator == TokenRevocationInitiator.CLIENT) {
checkIfTokenIsIssuedToClient(clientAuth, authToRevoke);
}
if (accessToken.getRefreshToken() != null) {
tokenStore.removeRefreshToken(accessToken.getRefreshToken());
}
tokenStore.removeAccessToken(accessToken);
log.debug("Access token removed: {}", tokenMasker.maskToken(token));
if (applicationEventPublisher != null) {
applicationEventPublisher.publishEvent(new OAuth2TokenRevokedEvent(accessToken, revocationInitiator));
}
return accessToken.getValue();
}
log.debug("No access token {} found in the token store", tokenMasker.maskToken(token));
return null;
}
Aggregations