001 /*
002 * The MIT License
003 * Copyright (c) 2012 Microsoft Corporation
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023
024 package microsoft.exchange.webservices.data.core;
025
026 import microsoft.exchange.webservices.data.credential.WebProxyCredentials;
027
028 /**
029 * WebProxy is used for setting proxy details for proxy authentication schemes such as
030 * basic, digest, NTLM, and Kerberos authentication.
031 */
032 public class WebProxy {
033
034 private String host;
035
036 private int port;
037
038 private WebProxyCredentials credentials;
039
040
041 /**
042 * Initializes a new instance to use specified proxy details.
043 *
044 * @param host proxy host.
045 * @param port proxy port.
046 */
047 public WebProxy(String host, int port) {
048 this.host = host;
049 this.port = port;
050 }
051
052 /**
053 * Initializes a new instance to use specified proxy with default port 80.
054 *
055 * @param host proxy host.
056 */
057 public WebProxy(String host) {
058 this.host = host;
059 this.port = 80;
060 }
061
062 /**
063 * Initializes a new instance to use specified proxy with default port 80.
064 *
065 * @param host proxy host.
066 * @param credentials the credential to use for the proxy.
067 */
068 public WebProxy(String host, WebProxyCredentials credentials) {
069 this.host = host;
070 this.credentials = credentials;
071 }
072
073 /**
074 * Initializes a new instance to use specified proxy details.
075 *
076 * @param host proxy host.
077 * @param port proxy port.
078 * @param credentials the credential to use for the proxy.
079 */
080 public WebProxy(String host, int port, WebProxyCredentials credentials) {
081 this.host = host;
082 this.port = port;
083 this.credentials = credentials;
084 }
085
086 /**
087 * Gets the Proxy Host.
088 *
089 * @return the host
090 */
091 public String getHost() {
092 return this.host;
093 }
094
095 /**
096 * Gets the Proxy Port.
097 *
098 * @return the port
099 */
100 public int getPort() {
101 return this.port;
102 }
103
104 public boolean hasCredentials() {
105 return credentials != null;
106 }
107
108 /**
109 * Gets the Proxy Credentials.
110 *
111 * @return the proxy credential
112 */
113 public WebProxyCredentials getCredentials() {
114 return credentials;
115 }
116 }