Source Code Cross Referenced for HttpBasicAuthSupplier.java in  » Web-Services-apache-cxf-2.0.1 » transports » org » apache » cxf » transport » http » 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 » Web Services apache cxf 2.0.1 » transports » org.apache.cxf.transport.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.transport.http;
019:
020:        import java.net.URL;
021:
022:        import org.apache.cxf.message.Message;
023:
024:        /**
025:         * This abstract class is extended by developers who need HTTP Basic Auth
026:         * functionality on the client side. It supplies userid and password
027:         * combinations to an HTTPConduit.
028:         * <p>
029:         * The HTTPConduit will make a call to getPreemptiveUserPass before
030:         * an HTTP request is made. The HTTPConduit will call on 
031:         * getUserPassForRealm upon getting a 401 HTTP Response with a
032:         * "WWW-Authenticate: Basic realm=????" header. 
033:         * <p>
034:         * A HTTPConduit keeps a reference to this HttpBasicAuthSupplier for the life
035:         * of the HTTPConduit, unless changed out by dynamic configuration.
036:         * Therefore, an implementation of this HttpBasicAuthSupplier may maintain
037:         * state for subsequent calls. 
038:         * <p>
039:         * For instance, an implemenation may not provide a UserPass preemptively for 
040:         * a particular URL and decide to get the realm information from 
041:         * a 401 response in which the HTTPConduit will call getUserPassForReam for
042:         * that URL. Then this implementation may provide the UserPass for this
043:         * particular URL preemptively for subsequent calls to getPreemptiveUserPass.
044:         */
045:        public abstract class HttpBasicAuthSupplier {
046:
047:            /**
048:             * This field contains the logical name of this HttpBasicAuthSuppler.
049:             * This field is not assigned to be final, since an extension may be
050:             * Spring initialized as a bean, have an appropriate setLogicalName
051:             * method, and set this field.
052:             */
053:            protected String logicalName;
054:
055:            /**
056:             * The default constructor assigns the class name as the LogicalName.
057:             *
058:             */
059:            protected HttpBasicAuthSupplier() {
060:                logicalName = this .getClass().getName();
061:            }
062:
063:            /**
064:             * This constructor assigns the LogicalName of this HttpBasicAuthSupplier.
065:             * 
066:             * @param name The Logical Name.
067:             */
068:            protected HttpBasicAuthSupplier(String name) {
069:                logicalName = name;
070:            }
071:
072:            /**
073:             * This method returns the LogicalName of this HttpBasicAuthSupplier.
074:             */
075:            public String getLogicalName() {
076:                return logicalName;
077:            }
078:
079:            /**
080:             * This class is used to return the values of the 
081:             * userid and password used in the HTTP Authorization
082:             * Header. 
083:             */
084:            public static final class UserPass {
085:                private final String userid;
086:                private final String password;
087:
088:                /**
089:                 * This constructor forms the userid and password pair for 
090:                 * the HTTP Authorization header.
091:                 * 
092:                 * @param user The userid that will be returned from getUserid().
093:                 *             This argument must not contain a colon (":"). If
094:                 *             it does, it will throw an IllegalArgumentException.
095:                 *             
096:                 * @param pass The password that will be returned from getPassword().
097:                 */
098:                UserPass(String user, String pass) {
099:                    if (user.contains(":")) {
100:                        throw new IllegalArgumentException(
101:                                "The argument \"user\" cannot contain ':'.");
102:                    }
103:                    userid = user;
104:                    password = pass;
105:                }
106:
107:                /**
108:                 * This method returns the userid.
109:                 */
110:                public String getUserid() {
111:                    return userid;
112:                }
113:
114:                /**
115:                 * This method returns the password.
116:                 */
117:                public String getPassword() {
118:                    return password;
119:                }
120:            }
121:
122:            /**
123:             * This method is used by extensions of this class to create
124:             * a UserPass to return.
125:             * @param userid   The userid that will be returned from getUserid().
126:             *                 This argument must not contain a colon (":"). If
127:             *                 it does, it will throw an IllegalArgumentException.
128:             * @param password The password that will be returned from getPassword().
129:             * @return
130:             */
131:            protected UserPass createUserPass(final String userid,
132:                    final String password) {
133:                return new UserPass(userid, password);
134:            }
135:
136:            /**
137:             * The HTTPConduit makes a call to this method before connecting
138:             * to the server behind a particular URL. If this implementation does not 
139:             * have a UserPass for this URL, it should return null.
140:             * 
141:             * @param conduitName The HTTPConduit making the call.
142:             * @param currentURL  The URL to which the request is to be made.
143:             * @param message     The CXF Message.
144:             * 
145:             * @return This method returns null if no UserPass is available.
146:             */
147:            public abstract UserPass getPreemptiveUserPass(String conduitName,
148:                    URL currentURL, Message message);
149:
150:            /**
151:             * The HTTPConduit makes a call to this method if it
152:             * receives a 401 response to a particular URL for
153:             * a given message. The realm information is taken
154:             * from the "WWW-Authenticate: Basic realm=?????"
155:             * header. The current message may be retransmitted
156:             * if this call returns a UserPass. The current message will
157:             * fail with a 401 if null is returned. If no UserPass is available
158:             * for this particular URL, realm, and message, then null
159:             * should be returned.
160:             * 
161:             * @param conduitName The name of the conduit making the call.
162:             * @param currentURL  The current URL from which the reponse came.
163:             * @param message     The CXF Message.
164:             * @param realm       The realm extraced from the basic auth header.
165:             * @return
166:             */
167:            public abstract UserPass getUserPassForRealm(String conduitName,
168:                    URL currentURL, Message message, String realm);
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.