View Javadoc

1   /*
2    * Copyright 2007-2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
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  
17  package org.springbyexample.httpclient.auth;
18  
19  import java.io.Serializable;
20  
21  /**
22   * <p>NTLM Credentials bean used to create 
23   * <code>org.apache.commons.httpclient.NTCredentials</code>
24   * and <code>org.apache.commons.httpclient.auth.AuthScope</code>.</p>
25   * 
26   * <p><strong>Note</strong>: User name, password, host, and domain are required.</p>
27   * 
28   * @author David Winterfeldt
29   */
30  public class NTCredentials extends Credentials implements Serializable {
31  
32      private static final long serialVersionUID = -6920896316432574273L;
33      
34      protected String host = null;
35      protected String domain = null;
36      
37      /**
38       * Constructor
39       */
40      public NTCredentials() {}
41      
42      /**
43       * Constructor
44       */
45      public NTCredentials(String authScopeHost, int authScopePort,
46                           String userName, String password,
47                           String host, String domain) {
48          super(authScopeHost, authScopePort, userName, password);
49          
50          this.host = host;
51          this.domain = domain;
52      }
53  
54      /**
55       * Gets host.
56       */
57      public String getHost() {
58          return host;
59      }
60  
61      /**
62       * Sets host.
63       */
64      public void setHost(String host) {
65          this.host = host;
66      }
67  
68      /**
69       * Gets domain.
70       */
71      public String getDomain() {
72          return domain;
73      }
74  
75      /**
76       * Sets domain.
77       */
78      public void setDomain(String domain) {
79          this.domain = domain;
80      }
81  
82      /**
83       * Returns a string representation of the object.
84       */
85      public String toString() {
86          StringBuilder sb = new StringBuilder();
87          
88          sb.append(this.getClass().getName());
89          sb.append(" { ");
90          sb.append("authScopeHost=" + authScopeHost);
91          sb.append("  authScopePort=" + authScopePort);
92          sb.append("  userName=" + userName);
93          sb.append("  password=" + password);
94          sb.append("  host=" + host);
95          sb.append("  domain=" + domain);
96          sb.append(" }");
97          
98          return sb.toString();
99      }
100     
101 }