
com.truelayer.java.http.auth.AccessTokenInvalidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truelayer-java Show documentation
Show all versions of truelayer-java Show documentation
TrueLayer Java SDK for https://truelayer.com
package com.truelayer.java.http.auth;
import static com.truelayer.java.Constants.HeaderNames.AUTHORIZATION;
import static org.apache.commons.lang3.ObjectUtils.isNotEmpty;
import com.truelayer.java.entities.RequestScopes;
import lombok.RequiredArgsConstructor;
import okhttp3.Authenticator;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import org.apache.commons.lang3.ObjectUtils;
@RequiredArgsConstructor
public class AccessTokenInvalidator implements Authenticator {
private final IAccessTokenManager tokenManager;
@Override
public Request authenticate(Route route, Response response) {
if (isNotEmpty(response.request().header(AUTHORIZATION))) {
// we are here in case of 401 on requests containing an Authorization HTTP header
RequestScopes requestedScopes = response.request().tag(RequestScopes.class);
if (ObjectUtils.isNotEmpty(requestedScopes)
&& !requestedScopes.getScopes().isEmpty()) tokenManager.invalidateToken(requestedScopes);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy