
com.aeontronix.anypointsdk.auth.AnypointClientCredentialsAuthenticationHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anypoint-sdk Show documentation
Show all versions of anypoint-sdk Show documentation
Anypoint Software Development Toolkit
package com.aeontronix.anypointsdk.auth;
import com.aeontronix.commons.URLBuilder;
import com.aeontronix.commons.exception.UnexpectedException;
import com.aeontronix.restclient.RESTClient;
import com.aeontronix.restclient.RESTException;
import com.aeontronix.restclient.RESTResponse;
import com.aeontronix.restclient.ResponseConversionException;
import com.aeontronix.restclient.auth.AuthenticationException;
import com.aeontronix.restclient.json.JsonConvertionException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;
public class AnypointClientCredentialsAuthenticationHandler extends AnypointAuthenticationHandler {
private String clientId;
private String clientSecret;
private LocalDateTime expires;
private ObjectMapper objectMapper = new ObjectMapper();
public AnypointClientCredentialsAuthenticationHandler(String clientId, String clientSecret) {
this.clientId = clientId;
this.clientSecret = clientSecret;
}
@Override
public boolean isRefreshRequired() {
return expires == null || LocalDateTime.now().isAfter(expires);
}
@Override
public boolean isRefreshable() {
return true;
}
@SuppressWarnings("unchecked")
@Override
public void refreshCredential(RESTClient restClient) throws RESTException, AuthenticationException {
final HashMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy