HttpProxyOptions.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. /**
  23.  * HttpProxyOptions
  24.  *
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public class HttpProxyOptions implements HttpOptions {
  30.    
  31.     private static final long serialVersionUID = 1L;
  32.    
  33.     private Proxy.Type proxyType = null;
  34.     private String proxyHostname = null;
  35.     private int proxyPort;
  36.     private String proxyUsername;
  37.     private String proxyPassword;
  38.    
  39.     @Override
  40.     public String toString() {
  41.         StringBuilder bf = new StringBuilder();
  42.         bf.append("Proxy (").append(this.proxyType).append(") ");
  43.         if(this.proxyHostname!=null) {
  44.             bf.append(this.proxyHostname).append(":").append(this.proxyPort);
  45.         }
  46.         if(this.proxyUsername!=null) {
  47.             bf.append(" [auth ").append(this.proxyUsername).append(":").append(this.proxyPassword).append("]");
  48.         }
  49.         return bf.toString();
  50.     }
  51.    
  52.     @Override
  53.     public void fill(HttpRequest request) {
  54.         request.setProxyType(this.proxyType);
  55.         request.setProxyHostname(this.proxyHostname);
  56.         request.setProxyPort(this.proxyPort);
  57.         request.setProxyUsername(this.proxyUsername);
  58.         request.setProxyPassword(this.proxyPassword);
  59.     }
  60.        
  61.     public Proxy.Type getProxyType() {
  62.         return this.proxyType;
  63.     }

  64.     public void setProxyType(Proxy.Type proxyType) {
  65.         this.proxyType = proxyType;
  66.     }

  67.     public String getProxyHostname() {
  68.         return this.proxyHostname;
  69.     }

  70.     public void setProxyHostname(String proxyHostname) {
  71.         this.proxyHostname = proxyHostname;
  72.     }

  73.     public int getProxyPort() {
  74.         return this.proxyPort;
  75.     }

  76.     public void setProxyPort(int proxyPort) {
  77.         this.proxyPort = proxyPort;
  78.     }

  79.     public String getProxyUsername() {
  80.         return this.proxyUsername;
  81.     }

  82.     public void setProxyUsername(String proxyUsername) {
  83.         this.proxyUsername = proxyUsername;
  84.     }

  85.     public String getProxyPassword() {
  86.         return this.proxyPassword;
  87.     }

  88.     public void setProxyPassword(String proxyPassword) {
  89.         this.proxyPassword = proxyPassword;
  90.     }
  91. }