Class DefaultTokenEndpointClient
- All Implemented Interfaces:
TokenEndpointClient
TokenEndpointClient.
The HTTP clients this class creates never follow redirects. The default client copies the settings of the
HttpClientConfiguration. If an HttpClientConfiguration bean named after the provider exists
(micronaut.http.services.<provider>.*), or an HttpClient bean named after the provider is declared,
a client is created from that configuration (or from the default configuration when only the client bean exists) with
the load balancer of the service. The named HttpClient bean itself is not used, because its redirect policy
cannot be enforced.
- Since:
- 1.2.0
- Author:
- James Kleeh
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultTokenEndpointClient(@NonNull io.micronaut.context.BeanContext beanContext, io.micronaut.http.client.HttpClientConfiguration defaultClientConfiguration) DefaultTokenEndpointClient(@Nullable io.micronaut.context.BeanContext beanContext, Supplier<io.micronaut.http.client.HttpClient> defaultTokenClientSupplier) DefaultTokenEndpointClient(io.micronaut.http.client.HttpClient client) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the HTTP clients this bean created.protected io.micronaut.http.client.HttpClientRetrieves a client for the given provider.protected <G, R extends TokenResponse>
voidsecureRequest(@NonNull io.micronaut.http.MutableHttpRequest<G> request, TokenRequestContext<G, R> requestContext) Secures the request according to the context's endpoint supported authentication methods.<G, R extends TokenResponse>
@NonNull org.reactivestreams.Publisher<R> sendRequest(TokenRequestContext<G, R> requestContext)
-
Constructor Details
-
DefaultTokenEndpointClient
public DefaultTokenEndpointClient(@NonNull io.micronaut.context.BeanContext beanContext, io.micronaut.http.client.HttpClientConfiguration defaultClientConfiguration) - Parameters:
beanContext- The bean contextdefaultClientConfiguration- The default client configuration. Its settings are copied, but the client created from it never follows redirects.
-
DefaultTokenEndpointClient
public DefaultTokenEndpointClient(@Nullable io.micronaut.context.BeanContext beanContext, Supplier<io.micronaut.http.client.HttpClient> defaultTokenClientSupplier) - Parameters:
beanContext- Bean ContextdefaultTokenClientSupplier- Default Token Client Supplier. The caller is responsible for configuring the client so that it does not follow redirects.
-
DefaultTokenEndpointClient
public DefaultTokenEndpointClient(io.micronaut.http.client.HttpClient client) - Parameters:
client- HttpClient. The caller is responsible for configuring the client so that it does not follow redirects.
-
-
Method Details
-
sendRequest
public <G, R extends TokenResponse> @NonNull org.reactivestreams.Publisher<R> sendRequest(TokenRequestContext<G, R> requestContext) - Specified by:
sendRequestin interfaceTokenEndpointClient- Type Parameters:
G- The token request grant or bodyR- The token response type- Parameters:
requestContext- The token request context- Returns:
- a HTTP Request to the Token Endpoint with Authorization Code Grant payload.
-
secureRequest
protected <G, R extends TokenResponse> void secureRequest(@NonNull io.micronaut.http.MutableHttpRequest<G> request, TokenRequestContext<G, R> requestContext) Secures the request according to the context's endpoint supported authentication methods.- Type Parameters:
G- The token request grant or bodyR- The token response type- Parameters:
request- Token endpoint RequestrequestContext- The request context
-
getClient
Retrieves a client for the given provider. The returned client never follows redirects.If an
HttpClientConfigurationbean named after the provider exists, or anHttpClientbean named after the provider is declared, a client is created from the named configuration (or from the default configuration when only the client bean exists) with the load balancer of the service. Otherwise, the default client is returned.- Parameters:
providerName- The provider name- Returns:
- An HTTP client to use to send the request
-
close
@PreDestroy public void close()Closes the HTTP clients this bean created. A client supplied by the caller is not closed.- Since:
- 5.5.2
-