Module org.cruk.clarity.api
Package org.cruk.clarity.api.http
Class HttpComponentsClientHttpRequestFactoryBasicAuth
java.lang.Object
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
org.cruk.clarity.api.http.HttpComponentsClientHttpRequestFactoryBasicAuth
- All Implemented Interfaces:
AuthenticatingClientHttpRequestFactory
,DisposableBean
,ClientHttpRequestFactory
public class HttpComponentsClientHttpRequestFactoryBasicAuth
extends HttpComponentsClientHttpRequestFactory
implements AuthenticatingClientHttpRequestFactory
Client HTTP request factory adding basic authentication to the request.
- Since:
- 2.23.1
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructor.Constructor with an HTTP client.HttpComponentsClientHttpRequestFactoryBasicAuth
(HttpClient client, CredentialsProvider credentialsProvider) Constructor with an HTTP client and credentials provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpContext
createHttpContext
(HttpMethod httpMethod, URI uri) Provide the HTTP context set up for basic authentication by this factory.Get the credentials currently in use.Get the credentials provider used by this factory.getHost()
Get the host to which the credentials will be applied.void
setCredentials
(URL url, Credentials credentials) Set the credentials based on the protocol, host and port in the URL.void
setCredentials
(HttpHost host, Credentials credentials) Set the credentials based on the HTTP host specification.void
setCredentialsProvider
(CredentialsProvider credentialsProvider) Set the credentials provider to use.Methods inherited from class org.springframework.http.client.HttpComponentsClientHttpRequestFactory
createHttpUriRequest, createRequest, createRequestConfig, destroy, getHttpClient, mergeRequestConfig, postProcessHttpRequest, setBufferRequestBody, setConnectionRequestTimeout, setConnectTimeout, setHttpClient, setHttpContextFactory, setReadTimeout
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.http.client.ClientHttpRequestFactory
createRequest
-
Constructor Details
-
HttpComponentsClientHttpRequestFactoryBasicAuth
public HttpComponentsClientHttpRequestFactoryBasicAuth()Constructor. -
HttpComponentsClientHttpRequestFactoryBasicAuth
Constructor with an HTTP client.- Parameters:
client
- The underlying HTTP client.
-
HttpComponentsClientHttpRequestFactoryBasicAuth
public HttpComponentsClientHttpRequestFactoryBasicAuth(HttpClient client, CredentialsProvider credentialsProvider) Constructor with an HTTP client and credentials provider.- Parameters:
client
- The underlying HTTP client.credentialsProvider
- The authentication credentials provider.
-
-
Method Details
-
getCredentialsProvider
Get the credentials provider used by this factory.- Returns:
- The authentication credentials provider.
-
setCredentialsProvider
@Autowired @Qualifier("clarityCredentialsProvider") public void setCredentialsProvider(CredentialsProvider credentialsProvider) Set the credentials provider to use.- Parameters:
credentialsProvider
- The authentication credentials provider.
-
createHttpContext
Provide the HTTP context set up for basic authentication by this factory. Despite the method being called "create", the sameHttpContext
can be returned each time.- Overrides:
createHttpContext
in classHttpComponentsClientHttpRequestFactory
- Parameters:
httpMethod
- The HTTP method.uri
- The request URI.- Returns:
- The HttpContext.
-
getHost
Description copied from interface:AuthenticatingClientHttpRequestFactory
Get the host to which the credentials will be applied.- Specified by:
getHost
in interfaceAuthenticatingClientHttpRequestFactory
- Returns:
- The HttpHost specification to which the authentication applies.
-
getCredentials
Description copied from interface:AuthenticatingClientHttpRequestFactory
Get the credentials currently in use.- Specified by:
getCredentials
in interfaceAuthenticatingClientHttpRequestFactory
- Returns:
- The credentials.
-
setCredentials
Description copied from interface:AuthenticatingClientHttpRequestFactory
Set the credentials based on the protocol, host and port in the URL.- Specified by:
setCredentials
in interfaceAuthenticatingClientHttpRequestFactory
- Parameters:
url
- The URL of the HTTP server.credentials
- The credentials to use, or null to reset.
-
setCredentials
Description copied from interface:AuthenticatingClientHttpRequestFactory
Set the credentials based on the HTTP host specification.- Specified by:
setCredentials
in interfaceAuthenticatingClientHttpRequestFactory
- Parameters:
host
- The host specification of the HTTP server.credentials
- The credentials to use, or null to reset.
-