001package org.apache.maven.wagon.proxy;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.maven.wagon.WagonConstants;
023
024import java.io.Serializable;
025
026/**
027 * Contains set of properties used by <code>Wagon</code> objects
028 * while connection to the repository must go thru a proxy server.
029 *
030 * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
031 *
032 * @todo Propose standard types of proxy servers (e.g. <i>SOCKSv4</i>),
033 * which can be shared between wagon api and providers
034 */
035public class ProxyInfo
036    implements Serializable
037{
038    public static final String PROXY_SOCKS5 = "SOCKS_5";
039
040    public static final String PROXY_SOCKS4 = "SOCKS4";
041
042    public static final String PROXY_HTTP = "HTTP";
043
044    /**
045     * Proxy server host
046     */
047    private String host = null;
048
049    /**
050     * Username used to access the proxy server
051     */
052    private String userName = null;
053
054    /**
055     * Password associated with the proxy server
056     */
057    private String password = null;
058
059    /**
060     * Proxy server port
061     */
062    private int port = WagonConstants.UNKNOWN_PORT;
063
064    /**
065     * Type of the proxy
066     */
067    private String type = null;
068
069    /**
070     * The non-proxy hosts. Follows Java system property format: <code>*.foo.com|localhost</code>.
071     */
072    private String nonProxyHosts;
073
074    /**
075     * For NTLM proxies, specifies the NTLM host.
076     */
077    private String ntlmHost;
078
079    /**
080     * For NTLM proxies, specifies the NTLM domain.
081     */
082    private String ntlmDomain;
083
084    /**
085     * Return proxy server host name.
086     *
087     * @return proxy server host name
088     */
089    public String getHost()
090    {
091        return host;
092    }
093
094    /**
095     * Set proxy host name.
096     *
097     * @param host proxy server host name
098     */
099    public void setHost( final String host )
100    {
101        this.host = host;
102    }
103
104    /**
105     * Get user's password used to login to proxy server.
106     *
107     * @return user's password at proxy host
108     */
109    public String getPassword()
110    {
111        return password;
112    }
113
114    /**
115     * Set the user's password for the proxy server.
116     *
117     * @param password password to use to login to a proxy server
118     */
119    public void setPassword( final String password )
120    {
121        this.password = password;
122    }
123
124    /**
125     * Get the proxy port.
126     *
127     * @return proxy server port
128     */
129    public int getPort()
130    {
131        return port;
132    }
133
134    /**
135     * Set the proxy port.
136     *
137     * @param port proxy server port
138     */
139    public void setPort( final int port )
140    {
141        this.port = port;
142    }
143
144    /**
145     * Get the proxy username.
146     *
147     * @return username for the proxy server
148     */
149    public String getUserName()
150    {
151        return userName;
152    }
153
154    /**
155     * Set the proxy username.
156     *
157     * @param userName username for the proxy server
158     */
159    public void setUserName( final String userName )
160    {
161        this.userName = userName;
162    }
163
164    /**
165     * Get the type of the proxy server.
166     *
167     * @return the type of the proxy server
168     */
169    public String getType()
170    {
171        return type;
172    }
173
174    /**
175     * @param type the type of the proxy server like <i>SOCKSv4</i>
176     */
177    public void setType( final String type )
178    {
179        this.type = type;
180    }
181
182    public String getNonProxyHosts()
183    {
184        return nonProxyHosts;
185    }
186
187    public void setNonProxyHosts( String nonProxyHosts )
188    {
189        this.nonProxyHosts = nonProxyHosts;
190    }
191
192    public String getNtlmHost()
193    {
194        return ntlmHost;
195    }
196
197    public void setNtlmHost( String ntlmHost )
198    {
199        this.ntlmHost = ntlmHost;
200    }
201
202    public void setNtlmDomain( String ntlmDomain )
203    {
204        this.ntlmDomain = ntlmDomain;
205    }
206
207    public String getNtlmDomain()
208    {
209        return ntlmDomain;
210    }
211
212    @Override
213    public String toString()
214    {
215        return "ProxyInfo{" + "host='" + host + '\'' + ", userName='" + userName + '\'' + ", port=" + port + ", type='"
216            + type + '\'' + ", nonProxyHosts='" + nonProxyHosts + '\'' + '}';
217    }
218}