Source Code Cross Referenced for AuthState.java in  » Net » Apache-common-HttpClient » org » apache » commons » httpclient » auth » 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.auth 
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/auth/AuthState.java,v 1.3 2004/11/02 19:39:16 olegk 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.auth;
032:
033:        /**
034:         * This class provides detailed information about the state of the
035:         * authentication process.
036:         * 
037:         * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
038:         * @since 3.0
039:         */
040:        public class AuthState {
041:
042:            public static final String PREEMPTIVE_AUTH_SCHEME = "basic";
043:
044:            /** Actual authentication scheme */
045:            private AuthScheme authScheme = null;
046:
047:            /** Whether an authetication challenged has been received */
048:            private boolean authRequested = false;
049:
050:            /** Whether the authetication challenge has been responsed to */
051:            private boolean authAttempted = false;
052:
053:            /** Whether preemtive authentication is attempted */
054:            private boolean preemptive = false;
055:
056:            /**
057:             * Default constructor.
058:             * 
059:             */
060:            public AuthState() {
061:                super ();
062:            }
063:
064:            /**
065:             * Invalidates the authentication state by resetting its parameters.
066:             */
067:            public void invalidate() {
068:                this .authScheme = null;
069:                this .authRequested = false;
070:                this .authAttempted = false;
071:                this .preemptive = false;
072:            }
073:
074:            /** 
075:             * Tests whether authenication challenge has been received
076:             *  
077:             * @return <tt>true</tt> if authenication challenge has been received, 
078:             *  <tt>false</tt> otherwise
079:             */
080:            public boolean isAuthRequested() {
081:                return this .authRequested;
082:            }
083:
084:            /** 
085:             * Sets authentication request status
086:             *  
087:             * @param challengeReceived <tt>true</tt> if authenication has been requested, 
088:             *  <tt>false</tt> otherwise
089:             */
090:            public void setAuthRequested(boolean challengeReceived) {
091:                this .authRequested = challengeReceived;
092:            }
093:
094:            /** 
095:             * Tests whether authenication challenge has been responsed to
096:             *  
097:             * @return <tt>true</tt> if authenication challenge has been responsed to, 
098:             *  <tt>false</tt> otherwise
099:             */
100:            public boolean isAuthAttempted() {
101:                return this .authAttempted;
102:            }
103:
104:            /** 
105:             * Sets authentication attempt status
106:             *  
107:             * @param challengeResponded <tt>true</tt> if authenication has been attempted, 
108:             *  <tt>false</tt> otherwise
109:             */
110:            public void setAuthAttempted(boolean challengeResponded) {
111:                this .authAttempted = challengeResponded;
112:            }
113:
114:            /**
115:             * Preemptively assigns Basic authentication scheme.
116:             */
117:            public void setPreemptive() {
118:                if (!this .preemptive) {
119:                    if (this .authScheme != null) {
120:                        throw new IllegalStateException(
121:                                "Authentication state already initialized");
122:                    }
123:                    this .authScheme = AuthPolicy
124:                            .getAuthScheme(PREEMPTIVE_AUTH_SCHEME);
125:                    this .preemptive = true;
126:                }
127:            }
128:
129:            /**
130:             * Tests if preemptive authentication is used.
131:             * 
132:             * @return <tt>true</tt> if using the default Basic {@link AuthScheme 
133:             * authentication scheme}, <tt>false</tt> otherwise.
134:             */
135:            public boolean isPreemptive() {
136:                return this .preemptive;
137:            }
138:
139:            /**
140:             * Assigns the given {@link AuthScheme authentication scheme}.
141:             * 
142:             * @param authScheme the {@link AuthScheme authentication scheme}
143:             */
144:            public void setAuthScheme(final AuthScheme authScheme) {
145:                if (authScheme == null) {
146:                    invalidate();
147:                    return;
148:                }
149:                if (this .preemptive
150:                        && !(this .authScheme.getClass().isInstance(authScheme))) {
151:                    this .preemptive = false;
152:                    this .authAttempted = false;
153:                }
154:                this .authScheme = authScheme;
155:            }
156:
157:            /**
158:             * Returns the {@link AuthScheme authentication scheme}.
159:             * 
160:             * @return {@link AuthScheme authentication scheme}
161:             */
162:            public AuthScheme getAuthScheme() {
163:                return authScheme;
164:            }
165:
166:            /**
167:             * Returns the authentication realm.
168:             * 
169:             * @return the name of the authentication realm
170:             */
171:            public String getRealm() {
172:                if (this .authScheme != null) {
173:                    return this .authScheme.getRealm();
174:                } else {
175:                    return null;
176:                }
177:            }
178:
179:            public String toString() {
180:                StringBuffer buffer = new StringBuffer();
181:                buffer.append("Auth state: auth requested [");
182:                buffer.append(this .authRequested);
183:                buffer.append("]; auth attempted [");
184:                buffer.append(this .authAttempted);
185:                if (this .authScheme != null) {
186:                    buffer.append("]; auth scheme [");
187:                    buffer.append(this .authScheme.getSchemeName());
188:                    buffer.append("]; realm [");
189:                    buffer.append(this .authScheme.getRealm());
190:                }
191:                buffer.append("] preemptive [");
192:                buffer.append(this .preemptive);
193:                buffer.append("]");
194:                return buffer.toString();
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.