smolnar82 commented on code in PR #1461: URL: https://github.com/apache/knox/pull/1461#discussion_r4338922078
########## gateway-server/src/main/java/org/apache/knox/gateway/util/MetadataHttpClients.java: ########## @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.knox.gateway.util; + +import org.apache.http.client.config.RequestConfig; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpRequestRetryHandler; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import java.util.concurrent.TimeUnit; + +/** + * Builds the HTTP clients used to fetch identity-provider metadata - OIDC discovery documents and + * JWK sets. Both are small, idempotent JSON GETs over TLS, so they want the same configuration. + * <p> + * The number of in-client retries is a parameter rather than a constant: a caller with retry + * layers above it wants {@link #NO_RETRIES}, while one that is the only layer wants + * {@link #DEFAULT_RETRIES}. + * <p> + * Apache HttpClient is used rather than {@link java.net.HttpURLConnection} because it + * layers TLS over an already-connected socket and hands it the target host, so a + * JSSE provider that takes the endpoint identification hostname from the socket, BouncyCastle's + * FIPS provider among them has a hostname to check. {@code HttpURLConnection} creates its socket + * without one. + */ +public final class MetadataHttpClients { Review Comment: I'm not sure I like this class name. Maybe `OidcHttpClients`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
