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
ConstructorsConstructorDescriptionConstructor.Constructor with an HTTP client.HttpComponentsClientHttpRequestFactoryBasicAuth(HttpClient client, CredentialsProvider credentialsProvider) Constructor with an HTTP client and credentials provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpContextcreateHttpContext(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.voidsetCredentials(URL url, Credentials credentials) Set the credentials based on the protocol, host and port in the URL.voidsetCredentials(HttpHost host, Credentials credentials) Set the credentials based on the HTTP host specification.voidsetCredentialsProvider(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, setReadTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 sameHttpContextcan be returned each time.- Overrides:
createHttpContextin classHttpComponentsClientHttpRequestFactory- Parameters:
httpMethod- The HTTP method.uri- The request URI.- Returns:
- The HttpContext.
-
getHost
Description copied from interface:AuthenticatingClientHttpRequestFactoryGet the host to which the credentials will be applied.- Specified by:
getHostin interfaceAuthenticatingClientHttpRequestFactory- Returns:
- The HttpHost specification to which the authentication applies.
-
getCredentials
Description copied from interface:AuthenticatingClientHttpRequestFactoryGet the credentials currently in use.- Specified by:
getCredentialsin interfaceAuthenticatingClientHttpRequestFactory- Returns:
- The credentials.
-
setCredentials
Description copied from interface:AuthenticatingClientHttpRequestFactorySet the credentials based on the protocol, host and port in the URL.- Specified by:
setCredentialsin interfaceAuthenticatingClientHttpRequestFactory- Parameters:
url- The URL of the HTTP server.credentials- The credentials to use, or null to reset.
-
setCredentials
Description copied from interface:AuthenticatingClientHttpRequestFactorySet the credentials based on the HTTP host specification.- Specified by:
setCredentialsin interfaceAuthenticatingClientHttpRequestFactory- Parameters:
host- The host specification of the HTTP server.credentials- The credentials to use, or null to reset.
-