Class HttpClientProxyValidator
- java.lang.Object
-
- net.shibboleth.idp.cas.proxy.impl.HttpClientProxyValidator
-
- All Implemented Interfaces:
ProxyValidator
public class HttpClientProxyValidator extends Object implements ProxyValidator
Authenticates a CAS proxy callback endpoint using anHttpClientinstance to establish the connection and aTrustEngineto 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
httpsscheme. - 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
Fields Modifier and Type Field Description private Set<Integer>allowedResponseCodesList of HTTP response codes permitted for successful proxy callback.private org.apache.http.client.HttpClienthttpClientHTTP client that connects to proxy callback endpoint.protected static StringHTTPS_SCHEMERequired https scheme for proxy callbacks.private org.slf4j.LoggerlogClass logger.private HttpClientSecurityParameterssecurityParametersHTTP client security parameters.private Function<ProfileRequestContext,ServiceContext>serviceCtxLookupFunctionLooks up a ServiceContext from the profile request context.
-
Constructor Summary
Constructors Constructor Description HttpClientProxyValidator(org.apache.http.client.HttpClient client, HttpClientSecurityParameters parameters)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intconnect(URI uri, Service service)Connect to the given CAS proxy callback endpoint and return the HTTP response code.voidsetAllowedResponseCodes(Set<Integer> responseCodes)Sets the HTTP response codes permitted for successful authentication of the proxy callback URL.private static voidsetCASTLSTrustEngineCriteria(org.apache.http.client.protocol.HttpClientContext context, URI requestUri, Service service)Install TLS trust criteria.voidvalidate(ProfileRequestContext profileRequestContext, URI proxyCallbackUri)
-
-
-
Field Detail
-
HTTPS_SCHEME
@Nonnull @NotEmpty protected static final String HTTPS_SCHEME
Required https scheme for proxy callbacks.- See Also:
- Constant Field Values
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
serviceCtxLookupFunction
@Nonnull private final Function<ProfileRequestContext,ServiceContext> serviceCtxLookupFunction
Looks up a ServiceContext from the profile request context.
-
httpClient
@Nonnull private final org.apache.http.client.HttpClient httpClient
HTTP client that connects to proxy callback endpoint.
-
securityParameters
@Nonnull private final HttpClientSecurityParameters securityParameters
HTTP client security parameters.
-
allowedResponseCodes
@NotEmpty @NonnullElements private Set<Integer> allowedResponseCodes
List of HTTP response codes permitted for successful proxy callback.
-
-
Constructor Detail
-
HttpClientProxyValidator
public HttpClientProxyValidator(@Nonnull org.apache.http.client.HttpClient client, @Nonnull HttpClientSecurityParameters parameters)Constructor.- Parameters:
client- HttpClient to useparameters- security parameters for client
-
-
Method Detail
-
setAllowedResponseCodes
public void setAllowedResponseCodes(@NotEmpty @NonnullElements Set<Integer> responseCodes)
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- Specified by:
validatein interfaceProxyValidator- Throws:
GeneralSecurityException
-
connect
protected int connect(@Nonnull URI uri, @Nonnull Service service) throws GeneralSecurityExceptionConnect 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.
-
-