001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.transport.http;
020:
021: import org.apache.commons.httpclient.HttpVersion;
022: import org.apache.commons.httpclient.auth.AuthPolicy;
023: import org.apache.commons.httpclient.auth.AuthScope;
024:
025: import java.util.List;
026: import java.util.Properties;
027:
028: /**
029: * Utility bean for setting transport properties in runtime.
030: */
031: public class HttpTransportProperties {
032: protected boolean chunked;
033: protected HttpVersion httpVersion;
034: protected String protocol;
035:
036: public HttpTransportProperties() {
037: }
038:
039: public boolean getChunked() {
040: return chunked;
041: }
042:
043: public HttpVersion getHttpVersion() {
044: return httpVersion;
045: }
046:
047: public String getProtocol() {
048: return protocol;
049: }
050:
051: public void setChunked(boolean chunked) {
052: this .chunked = chunked;
053: }
054:
055: public void setHttpVersion(HttpVersion httpVerion) {
056: this .httpVersion = httpVerion;
057: }
058:
059: public void setProtocol(String protocol) {
060: this .protocol = protocol;
061: }
062:
063: public static class ProxyProperties {
064: protected int proxyPort = -1;
065: protected String domain = null;
066: protected String passWord = null;
067: protected String proxyHostName = null;
068: protected String userName = null;
069:
070: public ProxyProperties() {
071: }
072:
073: public String getDomain() {
074: return domain;
075: }
076:
077: public String getPassWord() {
078: return passWord;
079: }
080:
081: public String getProxyHostName() {
082: return proxyHostName;
083: }
084:
085: public int getProxyPort() {
086: return proxyPort;
087: }
088:
089: public String getUserName() {
090: return userName;
091: }
092:
093: public void setDomain(String domain) {
094: this .domain = domain;
095: }
096:
097: public void setPassWord(String passWord) {
098: this .passWord = passWord;
099: }
100:
101: public void setProxyName(String proxyHostName) {
102: this .proxyHostName = proxyHostName;
103: }
104:
105: public void setProxyPort(int proxyPort) {
106: this .proxyPort = proxyPort;
107: }
108:
109: public void setUserName(String userName) {
110: this .userName = userName;
111: }
112: }
113:
114: /*
115: This class is responsible for holding all the necessary information needed for NTML, Digest
116: and Basic Authentication. Authentication itself is handled by httpclient. User doesn't need to
117: warry about what authentication mechanism it uses. Axis2 uses httpclinet's default authentication
118: patterns.
119: */
120: public static class Authenticator {
121: /*host that needed to be authenticated with*/
122: private String host;
123: /*port of the host that needed to be authenticated with*/
124: private int port = AuthScope.ANY_PORT;
125: /*Realm for authentication scope*/
126: private String realm = AuthScope.ANY_REALM;
127: /*Domain needed by NTCredentials for NT Domain*/
128: private String domain;
129: /*User for authenticate*/
130: private String username;
131: /*Password of the user for authenticate*/
132: private String password;
133: /* Switch to use preemptive authentication or not*/
134: private boolean preemptive = false;
135: /* if Authentication scheme needs retry just turn on the following flag */
136: private boolean allowedRetry = false;
137: /* Changing the priorty or adding a custom AuthPolicy*/
138: private List authSchemes;
139:
140: /* Default Auth Schems*/
141: public static final String NTLM = AuthPolicy.NTLM;
142: public static final String DIGEST = AuthPolicy.DIGEST;
143: public static final String BASIC = AuthPolicy.BASIC;
144:
145: public String getHost() {
146: return host;
147: }
148:
149: public void setHost(String host) {
150: this .host = host;
151: }
152:
153: public int getPort() {
154: return port;
155: }
156:
157: public void setPort(int port) {
158: this .port = port;
159: }
160:
161: public String getRealm() {
162: return realm;
163: }
164:
165: public void setRealm(String realm) {
166: this .realm = realm;
167: }
168:
169: public String getUsername() {
170: return username;
171: }
172:
173: public void setUsername(String username) {
174: this .username = username;
175: }
176:
177: public String getPassword() {
178: return password;
179: }
180:
181: public void setPassword(String password) {
182: this .password = password;
183: }
184:
185: public void setPreemptiveAuthentication(boolean preemptive) {
186: this .preemptive = preemptive;
187: }
188:
189: public boolean getPreemptiveAuthentication() {
190: return this .preemptive;
191: }
192:
193: public String getDomain() {
194: return domain;
195: }
196:
197: public void setDomain(String domain) {
198: this .domain = domain;
199: }
200:
201: public void setAuthSchemes(List authSchemes) {
202: this .authSchemes = authSchemes;
203: }
204:
205: public List getAuthSchemes() {
206: return this .authSchemes;
207: }
208:
209: public void setAllowedRetry(boolean allowedRetry) {
210: this .allowedRetry = allowedRetry;
211: }
212:
213: public boolean isAllowedRetry() {
214: return this .allowedRetry;
215: }
216: }
217:
218: /**
219: * @deprecated org.apache.axis2.transport.http.HttpTransportProperties.MailProperties has been
220: * deprecated and user are encourage the use of java.util.Properties instead.
221: */
222: public static class MailProperties {
223: final Properties mailProperties = new Properties();
224:
225: private String password;
226:
227: public void addProperty(String key, String value) {
228: mailProperties.put(key, value);
229: }
230:
231: public void deleteProperty(String key) {
232: mailProperties.remove(key);
233: }
234:
235: public Properties getProperties() {
236: return mailProperties;
237: }
238:
239: public String getPassword() {
240: return password;
241: }
242:
243: public void setPassword(String password) {
244: this.password = password;
245: }
246:
247: }
248: }
|