public static InputStream getResourceInputStream(final Resource resource, final Proxy proxy, final SSLSocketFactory sslSocketFactory,
                                                     final HostnameVerifier hostnameVerifier, final int connectTimeout,
                                                     final int readTimeout) throws IOException {
        if (resource instanceof UrlResource) {
            URLConnection con;
            if (proxy != null) {
                con = resource.getURL().openConnection(proxy);
            } else {
                con = resource.getURL().openConnection();
            }
            if (con instanceof HttpsURLConnection connection) {
                if (sslSocketFactory != null) {
                    connection.setSSLSocketFactory(sslSocketFactory);
                }
                if (hostnameVerifier != null) {
                    connection.setHostnameVerifier(hostnameVerifier);
                }
            }

            try {
                con.setConnectTimeout(connectTimeout);
                con.setReadTimeout(readTimeout);
                return con.getInputStream();
            } catch (final Exception e) {
                if (con instanceof HttpURLConnection) {
                    ((HttpURLConnection) con).disconnect();
                }
                throw new TechnicalException("Error getting URL resource", e);
            }
        }

        return resource.getInputStream();
    }
<p>getResourceInputStream.</p>

@param resource a {@link Resource} object
@param proxy a {@link Proxy} object
@param sslSocketFactory a {@link SSLSocketFactory} object
@param hostnameVerifier a {@link HostnameVerifier} object
@param connectTimeout a int
@param readTimeout a int
@return a {@link InputStream} object
@throws IOException if any.
pac4j-core/src/main/java/org/pac4j/core/resource/SpringResourceHelper.java