Source Code Cross Referenced for UsernamePasswordCredentials.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/UsernamePasswordCredentials.java,v 1.14 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:        /**
036:         * <p>Username and password {@link Credentials}.</p>
037:         *
038:         * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
039:         * @author Sean C. Sullivan
040:         * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
041:         * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
042:         * 
043:         * @version $Revision: 480424 $ $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
044:         * 
045:         */
046:        public class UsernamePasswordCredentials implements  Credentials {
047:
048:            // ----------------------------------------------------------- Constructors
049:
050:            /**
051:             * Default constructor.
052:             * 
053:             * @deprecated Do not use. Null user name no longer allowed
054:             */
055:            public UsernamePasswordCredentials() {
056:                super ();
057:            }
058:
059:            /**
060:             * The constructor with the username and password combined string argument.
061:             *
062:             * @param usernamePassword the username:password formed string
063:             * @see #toString
064:             */
065:            public UsernamePasswordCredentials(String usernamePassword) {
066:                super ();
067:                if (usernamePassword == null) {
068:                    throw new IllegalArgumentException(
069:                            "Username:password string may not be null");
070:                }
071:                int atColon = usernamePassword.indexOf(':');
072:                if (atColon >= 0) {
073:                    this .userName = usernamePassword.substring(0, atColon);
074:                    this .password = usernamePassword.substring(atColon + 1);
075:                } else {
076:                    this .userName = usernamePassword;
077:                }
078:            }
079:
080:            /**
081:             * The constructor with the username and password arguments.
082:             *
083:             * @param userName the user name
084:             * @param password the password
085:             */
086:            public UsernamePasswordCredentials(String userName, String password) {
087:                super ();
088:                if (userName == null) {
089:                    throw new IllegalArgumentException(
090:                            "Username may not be null");
091:                }
092:                this .userName = userName;
093:                this .password = password;
094:            }
095:
096:            // ----------------------------------------------------- Instance Variables
097:
098:            /**
099:             * User name.
100:             */
101:            private String userName;
102:
103:            /**
104:             * Password.
105:             */
106:            private String password;
107:
108:            // ------------------------------------------------------------- Properties
109:
110:            /**
111:             * User name property setter. User name may not be null.
112:             *
113:             * @param userName
114:             * @see #getUserName()
115:             * 
116:             * @deprecated Do not use. The UsernamePasswordCredentials objects should be immutable
117:             */
118:            public void setUserName(String userName) {
119:                if (userName == null) {
120:                    throw new IllegalArgumentException(
121:                            "Username may not be null");
122:                }
123:                this .userName = userName;
124:            }
125:
126:            /**
127:             * User name property getter.
128:             *
129:             * @return the userName
130:             * @see #setUserName(String)
131:             */
132:            public String getUserName() {
133:                return userName;
134:            }
135:
136:            /**
137:             * Password property setter.
138:             *
139:             * @param password
140:             * @see #getPassword()
141:             * 
142:             * @deprecated Do not use. The UsernamePasswordCredentials objects should be immutable
143:             */
144:            public void setPassword(String password) {
145:                this .password = password;
146:            }
147:
148:            /**
149:             * Password property getter.
150:             *
151:             * @return the password
152:             * @see #setPassword(String)
153:             */
154:            public String getPassword() {
155:                return password;
156:            }
157:
158:            /**
159:             * Get this object string.
160:             *
161:             * @return the username:password formed string
162:             */
163:            public String toString() {
164:                StringBuffer result = new StringBuffer();
165:                result.append(this .userName);
166:                result.append(":");
167:                result.append((this .password == null) ? "null" : this .password);
168:                return result.toString();
169:            }
170:
171:            /**
172:             * Does a hash of both user name and password.
173:             *
174:             * @return The hash code including user name and password.
175:             */
176:            public int hashCode() {
177:                int hash = LangUtils.HASH_SEED;
178:                hash = LangUtils.hashCode(hash, this .userName);
179:                hash = LangUtils.hashCode(hash, this .password);
180:                return hash;
181:            }
182:
183:            /**
184:             * These credentials are assumed equal if the username and password are the
185:             * same.
186:             *
187:             * @param o The other object to compare with.
188:             *
189:             * @return  <code>true</code> if the object is equivalent.
190:             */
191:            public boolean equals(Object o) {
192:                if (o == null)
193:                    return false;
194:                if (this  == o)
195:                    return true;
196:                // note - to allow for sub-classing, this checks that class is the same
197:                // rather than do "instanceof".
198:                if (this .getClass().equals(o.getClass())) {
199:                    UsernamePasswordCredentials that = (UsernamePasswordCredentials) o;
200:
201:                    if (LangUtils.equals(this .userName, that.userName)
202:                            && LangUtils.equals(this .password, that.password)) {
203:                        return true;
204:                    }
205:                }
206:                return false;
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.