Package org.opensaml.security.httpclient
Class HttpClientSecuritySupport
java.lang.Object
org.opensaml.security.httpclient.HttpClientSecuritySupport
Support class for working with
HttpClient security features.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDefaultTLSTrustEngineCriteria(org.apache.hc.client5.http.protocol.HttpClientContext context, org.apache.hc.core5.http.HttpRequest request) Add default trust engine criteria for TLS usage to theHttpClientContext.static org.apache.hc.client5.http.protocol.HttpClientContextbuildHttpClientContext(HttpClientSecurityParameters securityParameters) Builds a newHttpClientContextand marshals the suppliedHttpClientSecurityParametersinto it.static voidcheckTLSCredentialEvaluated(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.Get the globalHttpClientSecurityConfigurationinstance.static voidmarshalSecurityParameters(org.apache.hc.client5.http.protocol.HttpClientContext context, HttpClientSecurityParameters securityParameters) Marshal the suppliedHttpClientSecurityParametersto the suppliedHttpClientContext.static voidmarshalSecurityParameters(org.apache.hc.client5.http.protocol.HttpClientContext context, HttpClientSecurityParameters securityParameters, boolean replace) Marshal the suppliedHttpClientSecurityParametersto the suppliedHttpClientContext.static voidsetContextValue(org.apache.hc.client5.http.protocol.HttpClientContext context, String attributeName, Object attributeValue, boolean replace) Set the supplied attribute value in the client context.
-
Field Details
-
LOG
@Nonnull private static final org.slf4j.Logger LOGLogger.
-
-
Constructor Details
-
HttpClientSecuritySupport
private HttpClientSecuritySupport()Constructor.
-
-
Method Details
-
getGlobalHttpClientSecurityConfiguration
Get the globalHttpClientSecurityConfigurationinstance.- 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 theHttpClientContext.- Parameters:
context- the current HTTP context instance in userequest- 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 usescheme- 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 newHttpClientContextand marshals the suppliedHttpClientSecurityParametersinto 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 suppliedHttpClientSecurityParametersto the suppliedHttpClientContext.Existing context values will NOT be replaced by non-null parameter values.
- Parameters:
context- the client context instancesecurityParameters- 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 suppliedHttpClientSecurityParametersto the suppliedHttpClientContext.- Parameters:
context- the client context instancesecurityParameters- the security parameters instancereplace- 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 instanceattributeName- the context attribute name toattributeValue- the context attribute value to set, may be nullreplace- whether a non-null argument value should replace an existing context value
-