methods for HttpClientConfiguration
19049
protected final void setHttpProxyHost(String proxyHost) {
        httpConf = new MyHttpClientConfiguration(proxyHost
                , httpConf.getHttpProxyUser()
                , httpConf.getHttpProxyPassword()
                , httpConf.getHttpProxyPort()
                , httpConf.isHttpProxySocks()
                , httpConf.getHttpConnectionTimeout()
                , httpConf.getHttpReadTimeout()
                , httpConf.isPrettyDebugEnabled(), httpConf.isGZIPEnabled()
        );
    }
970537
public static HttpClientBuilder createBuilder(DigipostHttpClientSettings settings) {
        if (settings.timeoutsMs.isPotentiallyDangerous()) {
            settings.logger.warn("New http client with potential dangerous settings. These settings should probably not be used in production:\n{}", settings);
        } else {
            settings.logger.info("New http client:\n{}", settings);
        }

        return HttpClientBuilder.create()
                .setDefaultConnectionConfig(settings.connectionConfig)
                .setDefaultSocketConfig(createSocketConfig(settings.timeoutsMs))
                .setDefaultRequestConfig(createRequestConfig(settings.timeoutsMs))
                .setMaxConnTotal(settings.connectionAmount.maxTotal)
                .setMaxConnPerRoute(settings.connectionAmount.maxPerRoute)
                .setProxy(settings.httpProxy);
    }
339016
public final HttpClient protocol(HttpProtocol... supportedProtocols) {
		return tcpConfiguration(tcpClient -> tcpClient.bootstrap(b -> HttpClientConfiguration.protocols(b, supportedProtocols)));
	}
681125
public HttpClientActionBuilder client(String httpClient) {
		HttpClientActionBuilder clientAction = new HttpClientActionBuilder(action, httpClient)
				.withApplicationContext(applicationContext);
		return clientAction;
	}
309514
public final HttpServer httpRequestDecoder(Function<HttpRequestDecoderSpec, HttpRequestDecoderSpec> requestDecoderOptions) {
		return tcpConfiguration(
				requestDecoderOptions.apply(new HttpRequestDecoderSpec())
				                     .build());
	}
1063169
private function prepareHttp(Configuration\HttpConfiguration $config)
    {
        switch ($config->method) {
            case 'GET':
                $this->options[CURLOPT_HTTPGET] = true;
                break;
            case 'PUT':
                if (is_resource($config->body)) {
                    $this->options[CURLOPT_PUT] = true;
                } else {
                    $this->options[CURLOPT_CUSTOMREQUEST] = 'PUT';
                }
                break;
            default:
                $this->options[CURLOPT_CUSTOMREQUEST] = $config->method;
        }

        if ($config->redirectsAllowed()) {
            $this->options[CURLOPT_AUTOREFERER] = $config->allowRedirectsReferer();
            $this->options[CURLOPT_MAXREDIRS] = $config->allowRedirectsMax();
        } else {
            $this->options[CURLOPT_FOLLOWLOCATION] = false;
        }

        if (null !== $config->accept_encoding) {
            $this->options[CURLOPT_ENCODING] = $config->accept_encoding;
        }

        if (true === $config->verify) {
            $this->options[CURLOPT_SSL_VERIFYPEER] = true;
            $this->options[CURLOPT_SSL_VERIFYHOST] = 2;
            $this->options[CURLOPT_CAINFO] = CaBundle::getSystemCaRootBundlePath();
        } else {
            $this->options[CURLOPT_SSL_VERIFYPEER] = false;
            $this->options[CURLOPT_SSL_VERIFYHOST] = 0;
        }
    }
579707
protected Optional<ProviderLoginPageConfiguration> buildProviderConfiguration(final IndirectClient client, final WebContext webContext,
                                                                                  final WebApplicationService service) {
        val name = client.getName();
        val matcher = PAC4J_CLIENT_SUFFIX_PATTERN.matcher(client.getClass().getSimpleName());
        val type = matcher.replaceAll(StringUtils.EMPTY).toLowerCase();
        val uriBuilder = UriComponentsBuilder
            .fromUriString(DelegatedClientNavigationController.ENDPOINT_REDIRECT)
            .queryParam(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, name);

        if (service != null) {
            val sourceParam = service.getSource();
            val serviceParam = service.getOriginalUrl();
            if (StringUtils.isNotBlank(sourceParam) && StringUtils.isNotBlank(serviceParam)) {
                uriBuilder.queryParam(sourceParam, serviceParam);
            }
        }

        val methodParam = webContext.getRequestParameter(CasProtocolConstants.PARAMETER_METHOD);
        if (StringUtils.isNotBlank(methodParam)) {
            uriBuilder.queryParam(CasProtocolConstants.PARAMETER_METHOD, methodParam);
        }
        val localeParam = webContext.getRequestParameter(this.localeParamName);
        if (StringUtils.isNotBlank(localeParam)) {
            uriBuilder.queryParam(this.localeParamName, localeParam);
        }
        val themeParam = webContext.getRequestParameter(this.themeParamName);
        if (StringUtils.isNotBlank(themeParam)) {
            uriBuilder.queryParam(this.themeParamName, themeParam);
        }
        val redirectUrl = uriBuilder.toUriString();
        val autoRedirect = (Boolean) client.getCustomProperties().getOrDefault(ClientCustomPropertyConstants.CLIENT_CUSTOM_PROPERTY_AUTO_REDIRECT, Boolean.FALSE);
        val p = new ProviderLoginPageConfiguration(name, redirectUrl, type, getCssClass(name), autoRedirect);
        return Optional.of(p);
    }
714820
public static Client http(ClientSettings clientSettings) {
    HttpClientCodec clientCodec =
        new HttpClientCodec(DataCodec.getInstance(clientSettings.contentType()));

    ClientTransport clientTransport =
        new HttpClientTransport(clientSettings, clientCodec, clientSettings.loopResources());

    return new Client(clientTransport, clientCodec, clientSettings.errorMapper());
  }
245303
private CloseableHttpClient createHttpClient(HttpClientConnectionManager connectionManager) {
        HttpClientBuilder builder =
                HttpClients.custom().setConnectionManager(connectionManager).disableAutomaticRetries();

        int socketBufferSizeInBytes = this.config.getSocketBufferSizeInBytes();
        if (socketBufferSizeInBytes > 0) {
            builder.setDefaultConnectionConfig(
                    ConnectionConfig.custom().setBufferSize(socketBufferSizeInBytes).build());
        }

        return builder.build();
    }
1131474
public HTTPClientConfiguration createHTTPClientConfiguration(ConfigurationHolder configurationHolder)
    {
        //get server values
        String hostName=configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.HOST_NAME_PROPERTY_KEY);
        if(hostName==null)
        {
            throw new FaxException("Host name not defined in property: "+HTTPClientConfigurationConstants.HOST_NAME_PROPERTY_KEY);
        }
        String value=configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.PORT_PROPERTY_KEY);
        if(value==null)
        {
            value=String.valueOf(-1);
        }
        int port=Integer.parseInt(value);
        boolean ssl=Boolean.parseBoolean(configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.SSL_PROPERTY_KEY));
        
        //create configuration
        CommonHTTPClientConfiguration configuration=new CommonHTTPClientConfiguration();
        
        //set values
        configuration.setHostName(hostName);
        configuration.setPort(port);
        configuration.setSSL(ssl);

        //set methods
        Enum<?>[] methodProperties=new Enum<?>[]{HTTPClientConfigurationConstants.SUBMIT_HTTP_METHOD_PROPERTY_KEY,
                                                 HTTPClientConfigurationConstants.SUSPEND_HTTP_METHOD_PROPERTY_KEY,
                                                 HTTPClientConfigurationConstants.RESUME_HTTP_METHOD_PROPERTY_KEY,
                                                 HTTPClientConfigurationConstants.CANCEL_HTTP_METHOD_PROPERTY_KEY,
                                                 HTTPClientConfigurationConstants.GET_STATUS_HTTP_METHOD_PROPERTY_KEY};
        FaxActionType[] faxActionTypes=new FaxActionType[]{FaxActionType.SUBMIT_FAX_JOB,
                                                           FaxActionType.SUSPEND_FAX_JOB,
                                                           FaxActionType.RESUME_FAX_JOB,
                                                           FaxActionType.CANCEL_FAX_JOB,
                                                           FaxActionType.GET_FAX_JOB_STATUS};
        HTTPMethod httpMethod=null;
        for(int index=0;index<methodProperties.length;index++)
        {
            //set next method
            value=configurationHolder.getConfigurationValue(methodProperties[index]);
            httpMethod=HTTPMethod.POST;
            if(value!=null)
            {
                httpMethod=HTTPMethod.valueOf(value);
            }
            configuration.setMethod(faxActionTypes[index],httpMethod);
        }

        return configuration;
    }
489341
private static HttpTransportOptions getHttpTransportOptions(ConnectionParameters parameters) {
    HttpTransportOptions.Builder httpOptionsBuilder = HttpTransportOptions.newBuilder();
    httpOptionsBuilder.setConnectTimeout(parameters.getConnectionTimeout());
    httpOptionsBuilder.setReadTimeout(parameters.getReadTimeout());

    HttpTransportFactory httpTransportFactory = parameters.getHttpTransportFactory();
    if (httpTransportFactory != null) {
      httpOptionsBuilder.setHttpTransportFactory(httpTransportFactory);
    }
    return httpOptionsBuilder.build();
  }
1069997
private HttpHeaders createHttpHeaders(HttpMessage httpMessage,
                                          HttpEndpointConfiguration endpointConfiguration) {

        HttpHeaders httpHeaders = new HttpHeaders();

        endpointConfiguration
                .getHeaderMapper()
                .fromHeaders(
                        new org.springframework.messaging.MessageHeaders(httpMessage.getHeaders()),
                        httpHeaders);

        Map<String, Object> messageHeaders = httpMessage.getHeaders();
        for (Map.Entry<String, Object> header : messageHeaders.entrySet()) {
            if (!header.getKey().startsWith(MessageHeaders.PREFIX) &&
                    !MessageHeaderUtils.isSpringInternalHeader(header.getKey()) &&
                    !httpHeaders.containsKey(header.getKey())) {
                httpHeaders.add(header.getKey(), header.getValue().toString());
            }
        }

        if (httpHeaders.getFirst(HttpMessageHeaders.HTTP_CONTENT_TYPE) == null) {
            httpHeaders.add(HttpMessageHeaders.HTTP_CONTENT_TYPE, composeContentTypeHeaderValue(endpointConfiguration));
        }

        return httpHeaders;
    }
162245
@Override
	protected void configure(HttpSecurity http) throws Exception {
		ConfigObject protectedResources = Config.getConfig().getObject("security.protected");
		ConfigValue apiSec = Config.getConfig().getValue("security.api_security");
		boolean enableRestFilter = apiSec != null && Boolean.TRUE.equals(apiSec.unwrapped());
		String signinPath = Config.getConfigParam("security.signin", "/signin");
		String signoutPath = Config.getConfigParam("security.signout", "/signout");
		String accessDeniedPath = Config.getConfigParam("security.access_denied", "/403");
		String signoutSuccessPath = Config.getConfigParam("security.signout_success", signinPath);

		// If API security is disabled don't add the API endpoint to the list of protected resources
		if (enableRestFilter) {
			http.authorizeRequests().requestMatchers(RestRequestMatcher.INSTANCE);
		}

		parseProtectedResources(http, protectedResources);

		if (Config.getConfigBoolean("security.csrf_protection", true)) {
			http.csrf().requireCsrfProtectionMatcher(CsrfProtectionRequestMatcher.INSTANCE).
					csrfTokenRepository(csrfTokenRepository);
		} else {
			http.csrf().disable();
		}

		http.sessionManagement().enableSessionUrlRewriting(false);
		http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
		http.sessionManagement().sessionAuthenticationStrategy(new NullAuthenticatedSessionStrategy());
		http.exceptionHandling().authenticationEntryPoint(new SimpleAuthenticationEntryPoint(signinPath));
		http.exceptionHandling().accessDeniedHandler(new SimpleAccessDeniedHandler(accessDeniedPath));
		http.requestCache().requestCache(new SimpleRequestCache());
		http.logout().logoutUrl(signoutPath).logoutSuccessUrl(signoutSuccessPath);
		http.rememberMe().rememberMeServices(rememberMeServices);

		registerAuthFilters(http);

		if (enableRestFilter) {
			if (jwtFilter != null) {
				jwtFilter.setAuthenticationManager(authenticationManager());
				http.addFilterBefore(jwtFilter, RememberMeAuthenticationFilter.class);
			}
			RestAuthFilter restFilter = new RestAuthFilter();
			http.addFilterAfter(restFilter, JWTRestfulAuthFilter.class);
		}
	}
748916
@Override
    protected void configure(HttpSecurity http) throws Exception {
        // Gets a secure random key for the remember be token key
        SecureRandom random = new SecureRandom();
        byte[] randomBytes = new byte[64];
        random.nextBytes(randomBytes);
        String rememberBeKey = new String(Hex.encode(randomBytes));
        // @formatter:off
        http.antMatcher("/**")
            // Only BASIC authentication
            .httpBasic()
                .authenticationEntryPoint(apiBasicAuthenticationEntryPoint)
                .realmName("ontrack")
                .and()
            // Logout set-up
            .logout()
                .logoutUrl("/user/logout")
                .logoutSuccessUrl("/user/logged-out")
                .addLogoutHandler(basicRememberMeUserDetailsService())
                .and()
            // FIXME CSRF protection for a stateless API?
            //.csrf().requireCsrfProtectionMatcher(new CSRFRequestMatcher()).and()
            .csrf().disable()
            // Allows all at Web level
            .authorizeRequests()
                .antMatchers("/**").permitAll()
            // Remember be authentication token
            .and().rememberMe()
                .rememberMeServices(rememberMeServices(rememberBeKey))
                .key(rememberBeKey)
                .tokenValiditySeconds(604800)
            // Cache enabled
            .and().headers().cacheControl().disable()
        ;
        // @formatter:on
    }
578389
public function loadConfiguration(): void
	{
		$builder = $this->getContainerBuilder();

		$builder->addDefinition($this->prefix('client'))
			->setFactory(CurlClient::class);
	}
535094
private void initWebClientConfig() {
        m_webClientConfig = new WebClientConfiguration();

        if (getParameter("httpClientTimeoutSecs") != null)
            m_webClientConfig.setTimeoutSecs(Integer.parseInt(getParameter("httpClientTimeoutSecs")));

        if (getParameter("httpClientSocketTimeoutSecs") != null)
            m_webClientConfig.setSockTimeoutSecs(Integer.parseInt(getParameter("httpClientSocketTimeoutSecs")));

        if (getParameter("httpClientMaxConnectionsPerHost") != null)
            m_webClientConfig.setMaxConnPerHost(Integer.parseInt(getParameter("httpClientMaxConnectionsPerHost")));

        if (getParameter("httpClientMaxTotalConnections") != null)
            m_webClientConfig.setMaxTotalConn(Integer.parseInt(getParameter("httpClientMaxTotalConnections")));

        if (getParameter("httpClientFollowRedirects") != null)
            m_webClientConfig.setFollowRedirects(Boolean.parseBoolean(getParameter("httpClientFollowRedirects")));

        if (getParameter("httpClientMaxFollowRedirects") != null)
            m_webClientConfig.setMaxRedirects(Integer.parseInt(getParameter("httpClientMaxFollowRedirects")));

        if (getParameter("httpClientUserAgent") != null)
            m_webClientConfig.setUserAgent(getParameter("httpClientUserAgent"));
    }
72625
protected void configureMessageController(ApplicationContext context) {
        if (context.containsBean(MESSAGE_CONTROLLER_BEAN_NAME)) {
            HttpMessageController messageController = context.getBean(MESSAGE_CONTROLLER_BEAN_NAME, HttpMessageController.class);
            EndpointAdapter endpointAdapter = httpServer.getEndpointAdapter();

            HttpEndpointConfiguration endpointConfiguration = new HttpEndpointConfiguration();
            endpointConfiguration.setMessageConverter(httpServer.getMessageConverter());
            endpointConfiguration.setHeaderMapper(DefaultHttpHeaderMapper.inboundMapper());
            endpointConfiguration.setHandleAttributeHeaders(httpServer.isHandleAttributeHeaders());
            endpointConfiguration.setHandleCookies(httpServer.isHandleCookies());
            endpointConfiguration.setDefaultStatusCode(httpServer.getDefaultStatusCode());
            messageController.setEndpointConfiguration(endpointConfiguration);

            if (endpointAdapter != null) {
                messageController.setEndpointAdapter(endpointAdapter);
            }
        }
    }