Class HttpClientProxyValidator
java.lang.Object
net.shibboleth.idp.cas.proxy.impl.HttpClientProxyValidator
- All Implemented Interfaces:
ProxyValidator
Authenticates a CAS proxy callback endpoint using an
HttpClient
instance to establish
the connection and a TrustEngine
to verify the TLS certificate presented by the remote peer. The endpoint
is validated if and only if the following requirements are met:
- Proxy callback URI specifies the
https
scheme. - The TLS certificate presented by the remote peer is trusted.
- The HTTP response status code is approved via
setAllowedResponseCodes(Set)
(only 200 by default).
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of HTTP response codes permitted for successful proxy callback.private final org.apache.http.client.HttpClient
HTTP client that connects to proxy callback endpoint.protected static final String
Required https scheme for proxy callbacks.private final org.slf4j.Logger
Class logger.private final HttpClientSecurityParameters
HTTP client security parameters.private final Function<ProfileRequestContext,
ServiceContext> Looks up a ServiceContext from the profile request context. -
Constructor Summary
ConstructorsConstructorDescriptionHttpClientProxyValidator
(org.apache.http.client.HttpClient client, HttpClientSecurityParameters parameters) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Connect to the given CAS proxy callback endpoint and return the HTTP response code.void
setAllowedResponseCodes
(Set<Integer> responseCodes) Sets the HTTP response codes permitted for successful authentication of the proxy callback URL.private static void
setCASTLSTrustEngineCriteria
(org.apache.http.client.protocol.HttpClientContext context, URI requestUri, Service service) Install TLS trust criteria.void
validate
(ProfileRequestContext profileRequestContext, URI proxyCallbackUri) Validates the proxy callback endpoint.
-
Field Details
-
HTTPS_SCHEME
Required https scheme for proxy callbacks.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
serviceCtxLookupFunction
Looks up a ServiceContext from the profile request context. -
httpClient
@Nonnull private final org.apache.http.client.HttpClient httpClientHTTP client that connects to proxy callback endpoint. -
securityParameters
HTTP client security parameters. -
allowedResponseCodes
List of HTTP response codes permitted for successful proxy callback.
-
-
Constructor Details
-
HttpClientProxyValidator
public HttpClientProxyValidator(@Nonnull org.apache.http.client.HttpClient client, @Nonnull HttpClientSecurityParameters parameters) Constructor.- Parameters:
client
- HttpClient to useparameters
- security parameters for client
-
-
Method Details
-
setAllowedResponseCodes
Sets the HTTP response codes permitted for successful authentication of the proxy callback URL.- Parameters:
responseCodes
- One or more HTTP response codes.
-
validate
public void validate(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull URI proxyCallbackUri) throws GeneralSecurityException Validates the proxy callback endpoint.- Specified by:
validate
in interfaceProxyValidator
- Parameters:
profileRequestContext
- Profile request context.proxyCallbackUri
- Proxy callback URI to validate.- Throws:
GeneralSecurityException
- On validation failure.
-
connect
Connect to the given CAS proxy callback endpoint and return the HTTP response code. TLS peer certificate validation is an essential security aspect of establishing the connection.- Parameters:
uri
- CAS proxy callback URI to connect to.service
- CAS service requesting the connection.- Returns:
- HTTP response code.
- Throws:
GeneralSecurityException
- On connection errors, e.g. invalid/untrusted cert.
-
setCASTLSTrustEngineCriteria
private static void setCASTLSTrustEngineCriteria(org.apache.http.client.protocol.HttpClientContext context, URI requestUri, Service service) Install TLS trust criteria.- Parameters:
context
- client contextrequestUri
- URI to obtain hostnameservice
- CAS service
-