Package org.entur.jwt.client
Class AbstractUrlAccessTokenProvider<T>
java.lang.Object
org.entur.jwt.client.AbstractUrlAccessTokenProvider<T>
- Type Parameters:
T- HTTP Response type
- All Implemented Interfaces:
Closeable,AutoCloseable,AccessTokenHealthProvider,AccessTokenProvider
- Direct Known Subclasses:
AbstractStatefulUrlAccessTokenProvider,UrlAccessTokenProvider
public abstract class AbstractUrlAccessTokenProvider<T>
extends Object
implements AccessTokenProvider
Abstract provider using URL. This simple abstraction exists so that the
underlying HTTP client can be swapped.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckArgument(boolean valid, String message) voidclose()protected byte[]createBody(Map<String, Object> map) protected StringgetAccessToken(boolean forceRefresh) protected abstract InputStreamgetResponseContent(T response) protected abstract intgetResponseStatusCode(T response) protected ClientCredentialsResponsegetToken()protected abstract StringBuilderprintHeadersIfPresent(T c, String... headerNames) protected abstract Tprotected voidvalidate(ClientCredentialsResponse clientCredentialsResponse) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.entur.jwt.client.AccessTokenHealthProvider
getHealth, supportsHealth
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
CONTENT_TYPE
- See Also:
-
KEY_GRANT_TYPE
- See Also:
-
issueUrl
-
issueBody
protected final byte[] issueBody -
issueHeaders
-
reader
protected final com.fasterxml.jackson.databind.ObjectReader reader
-
-
Constructor Details
-
AbstractUrlAccessTokenProvider
-
-
Method Details
-
checkArgument
-
createBody
-
encode
-
getToken
- Throws:
AccessTokenException
-
getResponseStatusCode
- Throws:
IOException
-
getResponseContent
- Throws:
IOException
-
printHeadersIfPresent
-
request
- Throws:
IOException
-
getAccessToken
- Specified by:
getAccessTokenin interfaceAccessTokenProvider- Throws:
AccessTokenException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
validate
protected void validate(ClientCredentialsResponse clientCredentialsResponse) throws AccessTokenUnavailableException - Throws:
AccessTokenUnavailableException
-