pl.edu.icm.unity.oauth.as.token.access.OAuthClientTokensCleaner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unity-server-oauth Show documentation
Show all versions of unity-server-oauth Show documentation
Client and server OAuth support
The newest version!
/*
* Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package pl.edu.icm.unity.oauth.as.token.access;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;
import pl.edu.icm.unity.base.exceptions.EngineException;
import pl.edu.icm.unity.base.utils.Log;
@Component
public class OAuthClientTokensCleaner
{
private static final Logger log = Log.getLogger(Log.U_SERVER_OAUTH, OAuthRefreshTokenExpirationListener.class);
private final OAuthAccessTokenRepository accessTokenRepository;
private final OAuthRefreshTokenRepository refreshTokenRepository;
public OAuthClientTokensCleaner(OAuthAccessTokenRepository accessTokenRepository,
OAuthRefreshTokenRepository refreshTokenRepository)
{
this.accessTokenRepository = accessTokenRepository;
this.refreshTokenRepository = refreshTokenRepository;
}
public void removeTokensForClient(long clientId, long userId, String rollingTokenId)
{
try
{
accessTokenRepository.removeOwnedByClient(clientId, userId);
} catch (EngineException e)
{
log.error("Can not remove access tokens for client {}", clientId);
}
try
{
refreshTokenRepository.clearHistoryForClient(rollingTokenId, clientId, userId);
} catch (EngineException e)
{
log.error("Can not remove refresh token history for client {}", clientId);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy