Package org.opensaml.security.httpclient

# Class HttpClientSecuritySupport

java.lang.Object
org.opensaml.security.httpclient.HttpClientSecuritySupport

public final class HttpClientSecuritySupport extends Object
Support class for working with `HttpClient` security features.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final org.slf4j.Logger`
`LOG`
Logger.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`HttpClientSecuritySupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static void`
`addDefaultTLSTrustEngineCriteria(org.apache.hc.client5.http.protocol.HttpClientContext context, org.apache.hc.core5.http.HttpRequest request)`
Add default trust engine criteria for TLS usage to the `HttpClientContext`.
`static org.apache.hc.client5.http.protocol.HttpClientContext`
`buildHttpClientContext(HttpClientSecurityParameters securityParameters)`
Builds a new `HttpClientContext` and marshals the supplied `HttpClientSecurityParameters` into it.
`static void`
`checkTLSCredentialEvaluated(org.apache.hc.client5.http.protocol.HttpClientContext context, String scheme)`
Check that trust engine evaluation of the server TLS credential was actually performed when the scheme is HTTPS.
`static HttpClientSecurityConfiguration`
`getGlobalHttpClientSecurityConfiguration()`
Get the global `HttpClientSecurityConfiguration` instance.
`static void`
`marshalSecurityParameters(org.apache.hc.client5.http.protocol.HttpClientContext context, HttpClientSecurityParameters securityParameters)`
Marshal the supplied `HttpClientSecurityParameters` to the supplied `HttpClientContext`.
`static void`
`marshalSecurityParameters(org.apache.hc.client5.http.protocol.HttpClientContext context, HttpClientSecurityParameters securityParameters, boolean replace)`
Marshal the supplied `HttpClientSecurityParameters` to the supplied `HttpClientContext`.
`static void`
`setContextValue(org.apache.hc.client5.http.protocol.HttpClientContext context, String attributeName, Object attributeValue, boolean replace)`
Set the supplied attribute value in the client context.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### LOG

@Nonnull private static final org.slf4j.Logger LOG
Logger.

## Constructor Details

### HttpClientSecuritySupport

private HttpClientSecuritySupport()
Constructor.

## Method Details

### getGlobalHttpClientSecurityConfiguration

public static HttpClientSecurityConfiguration getGlobalHttpClientSecurityConfiguration()
Get the global `HttpClientSecurityConfiguration` instance.

Returns:
  the global HttpClient security configuration

### addDefaultTLSTrustEngineCriteria

public static void addDefaultTLSTrustEngineCriteria(@Nonnull org.apache.hc.client5.http.protocol.HttpClientContext context, @Nonnull org.apache.hc.core5.http.HttpRequest request)
Add default trust engine criteria for TLS usage to the `HttpClientContext`.

Parameters:
  `context` - the current HTTP context instance in use
  `request` - the current HTTP request

### checkTLSCredentialEvaluated

public static void checkTLSCredentialEvaluated(@Nonnull org.apache.hc.client5.http.protocol.HttpClientContext context, @Nonnull String scheme) throws SSLPeerUnverifiedException
Check that trust engine evaluation of the server TLS credential was actually performed when the scheme is HTTPS.

Parameters:
  `context` - the current HTTP context instance in use
  `scheme` - the HTTP request scheme
Throws:
  `SSLPeerUnverifiedException` - thrown if the TLS credential was not actually evaluated by the trust engine

### buildHttpClientContext

@Nonnull public static org.apache.hc.client5.http.protocol.HttpClientContext buildHttpClientContext(@Nullable HttpClientSecurityParameters securityParameters)
Builds a new `HttpClientContext` and marshals the supplied `HttpClientSecurityParameters` into it.

Parameters:
  `securityParameters` - the parameters to apply to the context
Returns:
  the fresh context
Since:
  5.0.0

### marshalSecurityParameters

public static void marshalSecurityParameters(@Nonnull org.apache.hc.client5.http.protocol.HttpClientContext context, @Nullable HttpClientSecurityParameters securityParameters)
Marshal the supplied `HttpClientSecurityParameters` to the supplied `HttpClientContext`.

Existing context values will NOT be replaced by non-null parameter values.

Parameters:
  `context` - the client context instance
  `securityParameters` - the security parameters instance

### marshalSecurityParameters

public static void marshalSecurityParameters(@Nonnull org.apache.hc.client5.http.protocol.HttpClientContext context, @Nullable HttpClientSecurityParameters securityParameters, boolean replace)
Marshal the supplied `HttpClientSecurityParameters` to the supplied `HttpClientContext`.

Parameters:
  `context` - the client context instance
  `securityParameters` - the security parameters instance
  `replace` - whether a non-null security parameter value should replace an existing context value

### setContextValue

public static void setContextValue(@Nonnull org.apache.hc.client5.http.protocol.HttpClientContext context, @Nonnull String attributeName, @Nullable Object attributeValue, boolean replace)
Set the supplied attribute value in the client context.

Parameters:
  `context` - the client context instance
  `attributeName` - the context attribute name to
  `attributeValue` - the context attribute value to set, may be null
  `replace` - whether a non-null argument value should replace an existing context value