01: /*
02: * Copyright 2001-2007 Hippo (www.hippo.nl)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package nl.hippo.util;
17:
18: import org.apache.commons.httpclient.HttpState;
19: import org.apache.commons.httpclient.UsernamePasswordCredentials;
20:
21: public class HttpStateFactory {
22:
23: private String m_host;
24:
25: private String m_authenticationRealm;
26:
27: private String m_username;
28:
29: private String m_password;
30:
31: private boolean m_authenticationPreemptive;
32:
33: public HttpStateFactory() {
34: super ();
35: }
36:
37: public void setHost(String host) {
38: m_host = host;
39: }
40:
41: public void setAuthenticationRealm(String authenticationRealm) {
42: m_authenticationRealm = authenticationRealm;
43: }
44:
45: public void setUsername(String username) {
46: m_username = username;
47: }
48:
49: public void setPassword(String password) {
50: m_password = password;
51: }
52:
53: public void setAuthenticationPreemptive(
54: boolean authenticationPreemptive) {
55: m_authenticationPreemptive = authenticationPreemptive;
56: }
57:
58: public HttpState createHttpState() {
59: HttpState result = new HttpState();
60: UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(
61: m_username, m_password);
62: result.setCredentials(m_authenticationRealm, m_host,
63: credentials);
64: result.setAuthenticationPreemptive(m_authenticationPreemptive);
65: return result;
66: }
67:
68: }
|