1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package org.apache.commons.httpclient;
33
34 /*** {@link Credentials} for use with the NTLM authentication scheme which requires additional
35 * information.
36 *
37 * @author <a href="mailto:adrian@ephox.com">Adrian Sutton</a>
38 * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
39 *
40 * @version $Revision: 1.6.2.2 $ $Date: 2004/02/22 18:21:13 $
41 *
42 * @since 2.0
43 */
44 public class NTCredentials extends UsernamePasswordCredentials {
45
46
47
48 /*** The Domain to authenticate with. */
49 private String domain;
50
51 /*** The host the authentication request is originating from. */
52 private String host;
53
54
55
56
57 /***
58 * Default constructor.
59 */
60 public NTCredentials() {
61 super();
62 }
63
64 /***
65 * Constructor.
66 * @param userName The user name. This should not include the domain to authenticate with.
67 * For example: "user" is correct whereas "DOMAIN//user" is not.
68 * @param password The password.
69 * @param host The host the authentication request is originating from. Essentially, the
70 * computer name for this machine.
71 * @param domain The domain to authenticate within.
72 */
73 public NTCredentials(String userName, String password, String host,
74 String domain) {
75 super(userName, password);
76 this.domain = domain;
77 this.host = host;
78 }
79
80
81
82 /***
83 * Sets the domain to authenticate with.
84 *
85 * @param domain the NT domain to authenticate in.
86 *
87 * @see #getDomain()
88 *
89 */
90 public void setDomain(String domain) {
91 this.domain = domain;
92 }
93
94 /***
95 * Retrieves the name to authenticate with.
96 *
97 * @return String the domain these credentials are intended to authenticate with.
98 *
99 * @see #setDomain(String)
100 *
101 */
102 public String getDomain() {
103 return domain;
104 }
105
106 /*** Sets the host name of the computer originating the request.
107 *
108 * @param host the Host the user is logged into.
109 */
110 public void setHost(String host) {
111 this.host = host;
112 }
113
114 /***
115 * Retrieves the host name of the computer originating the request.
116 *
117 * @return String the host the user is logged into.
118 */
119 public String getHost() {
120 return this.host;
121 }
122
123 /***
124 * Return a string representation of this object.
125 * @return A string represenation of this object.
126 */
127 public String toString() {
128 final StringBuffer sbResult = new StringBuffer(super.toString());
129
130 sbResult.append(":");
131 sbResult.append(this.host == null ? "null" : this.host);
132 sbResult.append(this.domain == null ? "null" : this.domain);
133
134 return sbResult.toString();
135 }
136
137 }