Source Code Cross Referenced for NTCredentials.java in  » Net » Apache-common-HttpClient » org » apache » commons » httpclient » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Apache common HttpClient » org.apache.commons.httpclient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/NTCredentials.java,v 1.10 2004/04/18 23:51:35 jsdever Exp $
003:         * $Revision: 480424 $
004:         * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005:         *
006:         * ====================================================================
007:         *
008:         *  Licensed to the Apache Software Foundation (ASF) under one or more
009:         *  contributor license agreements.  See the NOTICE file distributed with
010:         *  this work for additional information regarding copyright ownership.
011:         *  The ASF licenses this file to You under the Apache License, Version 2.0
012:         *  (the "License"); you may not use this file except in compliance with
013:         *  the License.  You may obtain a copy of the License at
014:         *
015:         *      http://www.apache.org/licenses/LICENSE-2.0
016:         *
017:         *  Unless required by applicable law or agreed to in writing, software
018:         *  distributed under the License is distributed on an "AS IS" BASIS,
019:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020:         *  See the License for the specific language governing permissions and
021:         *  limitations under the License.
022:         * ====================================================================
023:         *
024:         * This software consists of voluntary contributions made by many
025:         * individuals on behalf of the Apache Software Foundation.  For more
026:         * information on the Apache Software Foundation, please see
027:         * <http://www.apache.org/>.
028:         *
029:         */
030:
031:        package org.apache.commons.httpclient;
032:
033:        import org.apache.commons.httpclient.util.LangUtils;
034:
035:        /** {@link Credentials} for use with the NTLM authentication scheme which requires additional
036:         * information.
037:         *
038:         * @author <a href="mailto:adrian@ephox.com">Adrian Sutton</a>
039:         * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
040:         * 
041:         * @version $Revision: 480424 $ $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
042:         * 
043:         * @since 2.0
044:         */
045:        public class NTCredentials extends UsernamePasswordCredentials {
046:
047:            // ----------------------------------------------------- Instance Variables
048:
049:            /** The Domain to authenticate with.  */
050:            private String domain;
051:
052:            /** The host the authentication request is originating from.  */
053:            private String host;
054:
055:            // ----------------------------------------------------------- Constructors
056:
057:            /**
058:             * Default constructor.
059:             * 
060:             * @deprecated Do not use. Null user name, domain & host no longer allowed
061:             */
062:            public NTCredentials() {
063:                super ();
064:            }
065:
066:            /**
067:             * Constructor.
068:             * @param userName The user name.  This should not include the domain to authenticate with.
069:             * For example: "user" is correct whereas "DOMAIN\\user" is not.
070:     * @param password The password.
071:     * @param host The host the authentication request is originating from.  Essentially, the
072:     * computer name for this machine.
073:     * @param domain The domain to authenticate within.
074:     */
075:            public NTCredentials(String userName, String password, String host,
076:                    String domain) {
077:                super (userName, password);
078:                if (domain == null) {
079:                    throw new IllegalArgumentException("Domain may not be null");
080:                }
081:                this .domain = domain;
082:                if (host == null) {
083:                    throw new IllegalArgumentException("Host may not be null");
084:                }
085:                this .host = host;
086:            }
087:
088:            // ------------------------------------------------------- Instance Methods
089:
090:            /**
091:             * Sets the domain to authenticate with. The domain may not be null.
092:             *
093:             * @param domain the NT domain to authenticate in.
094:             * 
095:             * @see #getDomain()
096:             * 
097:             * @deprecated Do not use. The NTCredentials objects should be immutable
098:             */
099:            public void setDomain(String domain) {
100:                if (domain == null) {
101:                    throw new IllegalArgumentException("Domain may not be null");
102:                }
103:                this .domain = domain;
104:            }
105:
106:            /**
107:             * Retrieves the name to authenticate with.
108:             *
109:             * @return String the domain these credentials are intended to authenticate with.
110:             * 
111:             * @see #setDomain(String)
112:             * 
113:             */
114:            public String getDomain() {
115:                return domain;
116:            }
117:
118:            /** 
119:             * Sets the host name of the computer originating the request. The host name may
120:             * not be null.
121:             *
122:             * @param host the Host the user is logged into.
123:             * 
124:             * @deprecated Do not use. The NTCredentials objects should be immutable
125:             */
126:            public void setHost(String host) {
127:                if (host == null) {
128:                    throw new IllegalArgumentException("Host may not be null");
129:                }
130:                this .host = host;
131:            }
132:
133:            /**
134:             * Retrieves the host name of the computer originating the request.
135:             *
136:             * @return String the host the user is logged into.
137:             */
138:            public String getHost() {
139:                return this .host;
140:            }
141:
142:            /**
143:             * Return a string representation of this object.
144:             * @return A string represenation of this object.
145:             */
146:            public String toString() {
147:                final StringBuffer sbResult = new StringBuffer(super .toString());
148:
149:                sbResult.append("@");
150:                sbResult.append(this .host);
151:                sbResult.append(".");
152:                sbResult.append(this .domain);
153:
154:                return sbResult.toString();
155:            }
156:
157:            /**
158:             * Computes a hash code based on all the case-sensitive parts of the credentials object.
159:             *
160:             * @return  The hash code for the credentials.
161:             */
162:            public int hashCode() {
163:                int hash = super .hashCode();
164:                hash = LangUtils.hashCode(hash, this .host);
165:                hash = LangUtils.hashCode(hash, this .domain);
166:                return hash;
167:            }
168:
169:            /**
170:             * Performs a case-sensitive check to see if the components of the credentials
171:             * are the same.
172:             *
173:             * @param o  The object to match.
174:             *
175:             * @return <code>true</code> if all of the credentials match.
176:             */
177:            public boolean equals(Object o) {
178:                if (o == null)
179:                    return false;
180:                if (this  == o)
181:                    return true;
182:                if (super .equals(o)) {
183:                    if (o instanceof  NTCredentials) {
184:                        NTCredentials that = (NTCredentials) o;
185:
186:                        return LangUtils.equals(this .domain, that.domain)
187:                                && LangUtils.equals(this .host, that.host);
188:                    }
189:                }
190:
191:                return false;
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.