HttpRequest.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.transport.http;

  21. import java.net.Proxy;
  22. import java.security.KeyStore;
  23. import java.security.cert.CertStore;

  24. /**
  25.  * Classe che contiene la risposta http
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class HttpRequest extends AbstractHttp {

  32.     private String url;
  33.    
  34.     private int readTimeout = HttpUtilities.HTTP_READ_CONNECTION_TIMEOUT;
  35.     private int connectTimeout = HttpUtilities.HTTP_CONNECTION_TIMEOUT;
  36.    
  37.     private String username;
  38.     private String password;
  39.    
  40.     private HttpRequestMethod method;
  41.    
  42.     private Boolean followRedirects;
  43.        
  44.     private boolean trustAllCerts = false;
  45.     private KeyStore trustStore;
  46.     private boolean trustStoreHsm;
  47.     private String trustStorePath;
  48.     private String trustStorePassword;
  49.     private String trustStoreType;
  50.    
  51.     private CertStore crlStore;
  52.     private String crlPath;
  53.    
  54.     private String ocspPolicy;
  55.     private IOCSPValidator ocspValidator;
  56.    
  57.     private KeyStore keyStore;
  58.     private String keyStorePath;
  59.     private String keyStorePassword;
  60.     private String keyStoreType;
  61.     private String keyAlias;
  62.     private String keyPassword;
  63.    
  64.     private boolean secureRandom = false;
  65.     private String secureRandomAlgorithm = null;
  66.    
  67.     private boolean hostnameVerifier = false; // nelle versioni precedenti era configurato disabilitato direttamente in HttpUtilities
  68.    
  69.     private boolean forceTransferEncodingChunked = false;
  70.    
  71.     // throttling send bytes every ms
  72.     private Integer throttlingSendMs;
  73.     private Integer throttlingSendByte;
  74.    
  75.     private String forwardProxyEndpoint;
  76.     private HttpForwardProxyConfig forwardProxyConfig;
  77.    
  78.     private Proxy.Type proxyType = null;
  79.     private String proxyHostname = null;
  80.     private int proxyPort;
  81.     private String proxyUsername;
  82.     private String proxyPassword;
  83.    
  84.     private boolean disconnect = true;
  85.    
  86.     public Boolean getFollowRedirects() {
  87.         return this.followRedirects;
  88.     }

  89.     public void setFollowRedirects(Boolean followRedirects) {
  90.         this.followRedirects = followRedirects;
  91.     }

  92.     public String getUrl() {
  93.         return this.url;
  94.     }

  95.     public void setUrl(String url) {
  96.         this.url = url;
  97.     }

  98.     public int getReadTimeout() {
  99.         return this.readTimeout;
  100.     }

  101.     public void setReadTimeout(int readTimeout) {
  102.         this.readTimeout = readTimeout;
  103.     }

  104.     public int getConnectTimeout() {
  105.         return this.connectTimeout;
  106.     }

  107.     public void setConnectTimeout(int connectTimeout) {
  108.         this.connectTimeout = connectTimeout;
  109.     }

  110.     public String getUsername() {
  111.         return this.username;
  112.     }

  113.     public void setUsername(String username) {
  114.         this.username = username;
  115.     }

  116.     public String getPassword() {
  117.         return this.password;
  118.     }

  119.     public void setPassword(String password) {
  120.         this.password = password;
  121.     }

  122.     public HttpRequestMethod getMethod() {
  123.         return this.method;
  124.     }

  125.     public void setMethod(HttpRequestMethod method) {
  126.         this.method = method;
  127.     }
  128.    
  129.     public boolean isTrustAllCerts() {
  130.         return this.trustAllCerts;
  131.     }

  132.     public void setTrustAllCerts(boolean trustAllCerts) {
  133.         this.trustAllCerts = trustAllCerts;
  134.     }
  135.    
  136.     public String getTrustStorePath() {
  137.         return this.trustStorePath;
  138.     }

  139.     public void setTrustStorePath(String trustStorePath) {
  140.         this.trustStorePath = trustStorePath;
  141.     }

  142.     public String getTrustStorePassword() {
  143.         return this.trustStorePassword;
  144.     }

  145.     public void setTrustStorePassword(String trustStorePassword) {
  146.         this.trustStorePassword = trustStorePassword;
  147.     }

  148.     public String getTrustStoreType() {
  149.         return this.trustStoreType;
  150.     }

  151.     public void setTrustStoreType(String trustStoreType) {
  152.         this.trustStoreType = trustStoreType;
  153.     }
  154.    
  155.     public KeyStore getTrustStore() {
  156.         return this.trustStore;
  157.     }
  158.    
  159.     public boolean isTrustStoreHsm() {
  160.         return this.trustStoreHsm;
  161.     }

  162.     public void setTrustStore(KeyStore trustStore) {
  163.         setTrustStore(trustStore, false);
  164.     }
  165.     public void setTrustStore(KeyStore trustStore, boolean hsm) {
  166.         this.trustStore = trustStore;
  167.         this.trustStoreHsm = hsm;
  168.     }
  169.    
  170.     public CertStore getCrlStore() {
  171.         return this.crlStore;
  172.     }

  173.     public void setCrlStore(CertStore crlStore) {
  174.         this.crlStore = crlStore;
  175.     }

  176.     public String getCrlPath() {
  177.         return this.crlPath;
  178.     }

  179.     public void setCrlPath(String crlPath) {
  180.         this.crlPath = crlPath;
  181.     }

  182.     public String getOcspPolicy() {
  183.         return this.ocspPolicy;
  184.     }

  185.     public void setOcspPolicy(String ocspPolicy) {
  186.         this.ocspPolicy = ocspPolicy;
  187.     }
  188.    
  189.     public IOCSPValidator getOcspValidator() {
  190.         return this.ocspValidator;
  191.     }

  192.     public void setOcspValidator(IOCSPValidator ocspValidator) {
  193.         this.ocspValidator = ocspValidator;
  194.     }
  195.    
  196.     public boolean isSecureRandom() {
  197.         return this.secureRandom;
  198.     }

  199.     public void setSecureRandom(boolean secureRandom) {
  200.         this.secureRandom = secureRandom;
  201.     }

  202.     public String getSecureRandomAlgorithm() {
  203.         return this.secureRandomAlgorithm;
  204.     }

  205.     public void setSecureRandomAlgorithm(String secureRandomAlgorithm) {
  206.         this.secureRandomAlgorithm = secureRandomAlgorithm;
  207.     }
  208.    
  209.     public boolean isHostnameVerifier() {
  210.         return this.hostnameVerifier;
  211.     }

  212.     public void setHostnameVerifier(boolean hostnameVerifier) {
  213.         this.hostnameVerifier = hostnameVerifier;
  214.     }
  215.    
  216.     public Integer getThrottlingSendMs() {
  217.         return this.throttlingSendMs;
  218.     }

  219.     public void setThrottlingSendMs(Integer throttlingSendMs) {
  220.         this.throttlingSendMs = throttlingSendMs;
  221.     }

  222.     public Integer getThrottlingSendByte() {
  223.         return this.throttlingSendByte;
  224.     }

  225.     public void setThrottlingSendByte(Integer throttlingSendByte) {
  226.         this.throttlingSendByte = throttlingSendByte;
  227.     }
  228.    
  229.     public boolean isDisconnect() {
  230.         return this.disconnect;
  231.     }

  232.     public void setDisconnect(boolean disconnect) {
  233.         this.disconnect = disconnect;
  234.     }
  235.    
  236.     public KeyStore getKeyStore() {
  237.         return this.keyStore;
  238.     }

  239.     public void setKeyStore(KeyStore keyStore) {
  240.         this.keyStore = keyStore;
  241.     }

  242.     public String getKeyStorePath() {
  243.         return this.keyStorePath;
  244.     }

  245.     public void setKeyStorePath(String keyStorePath) {
  246.         this.keyStorePath = keyStorePath;
  247.     }

  248.     public String getKeyStorePassword() {
  249.         return this.keyStorePassword;
  250.     }

  251.     public void setKeyStorePassword(String keyStorePassword) {
  252.         this.keyStorePassword = keyStorePassword;
  253.     }

  254.     public String getKeyStoreType() {
  255.         return this.keyStoreType;
  256.     }

  257.     public void setKeyStoreType(String keyStoreType) {
  258.         this.keyStoreType = keyStoreType;
  259.     }

  260.     public String getKeyAlias() {
  261.         return this.keyAlias;
  262.     }

  263.     public void setKeyAlias(String keyAlias) {
  264.         this.keyAlias = keyAlias;
  265.     }

  266.     public String getKeyPassword() {
  267.         return this.keyPassword;
  268.     }

  269.     public void setKeyPassword(String keyPassword) {
  270.         this.keyPassword = keyPassword;
  271.     }
  272.    
  273.     public String getForwardProxyEndpoint() {
  274.         return this.forwardProxyEndpoint;
  275.     }

  276.     public void setForwardProxyEndpoint(String forwardProxyEndpoint) {
  277.         this.forwardProxyEndpoint = forwardProxyEndpoint;
  278.     }
  279.    
  280.     public HttpForwardProxyConfig getForwardProxyConfig() {
  281.         return this.forwardProxyConfig;
  282.     }

  283.     public void setForwardProxyConfig(HttpForwardProxyConfig forwardProxyConfig) {
  284.         this.forwardProxyConfig = forwardProxyConfig;
  285.     }
  286.    
  287.     public Proxy.Type getProxyType() {
  288.         return this.proxyType;
  289.     }

  290.     public void setProxyType(Proxy.Type proxyType) {
  291.         this.proxyType = proxyType;
  292.     }

  293.     public String getProxyHostname() {
  294.         return this.proxyHostname;
  295.     }

  296.     public void setProxyHostname(String proxyHostname) {
  297.         this.proxyHostname = proxyHostname;
  298.     }

  299.     public int getProxyPort() {
  300.         return this.proxyPort;
  301.     }

  302.     public void setProxyPort(int proxyPort) {
  303.         this.proxyPort = proxyPort;
  304.     }

  305.     public String getProxyUsername() {
  306.         return this.proxyUsername;
  307.     }

  308.     public void setProxyUsername(String proxyUsername) {
  309.         this.proxyUsername = proxyUsername;
  310.     }

  311.     public String getProxyPassword() {
  312.         return this.proxyPassword;
  313.     }

  314.     public void setProxyPassword(String proxyPassword) {
  315.         this.proxyPassword = proxyPassword;
  316.     }
  317.    
  318.     public boolean isForceTransferEncodingChunked() {
  319.         return this.forceTransferEncodingChunked;
  320.     }

  321.     public void setForceTransferEncodingChunked(boolean forceTransferEncodingChunked) {
  322.         this.forceTransferEncodingChunked = forceTransferEncodingChunked;
  323.     }
  324. }