Java Doc for AuthorizationInfo.java in  » Net » SkunkDAV » 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 » SkunkDAV » HTTPClient 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   HTTPClient.AuthorizationInfo

AuthorizationInfo
public class AuthorizationInfo implements GlobalConstants,Cloneable(Code)
Holds the information for an authorization response.

There are 7 fields which make up this class: host, port, scheme, realm, cookie, params, and extra_info. The host and port select which server the info will be sent to. The realm is server specified string which groups various URLs under a given server together and which is used to select the correct info when a server issues an auth challenge; for schemes which don't use a realm (such as "NTLM", "PEM", and "Kerberos") the realm must be the empty string (""). The scheme is the authorization scheme used (such as "Basic" or "Digest").

There are basically two formats used for the Authorization header, the one used by the "Basic" scheme and derivatives, and the one used by the "Digest" scheme and derivatives. The first form contains just the the scheme and a "cookie":

    Authorization: Basic aGVsbG86d29ybGQ=
The second form contains the scheme followed by a number of parameters in the form of name=value pairs:
    Authorization: Digest username="hello", realm="test", nonce="42", ...
The two fields "cookie" and "params" correspond to these two forms. toString() is used by the AuthorizationModule when generating the Authorization header and will format the info accordingly. Note that "cookie" and "params" are mutually exclusive: if the cookie field is non-null then toString() will generate the first form; otherwise it will generate the second form.

In some schemes "extra" information needs to be kept which doesn't appear directly in the Authorization header. An example of this are the A1 and A2 strings in the Digest scheme. Since all elements in the params field will appear in the Authorization header this field can't be used for storing such info. This is what the extra_info field is for. It is an arbitrary object which can be manipulated by the corresponding setExtraInfo() and getExtraInfo() methods, but which will not be printed by toString().

The addXXXAuthorization(), removeXXXAuthorization(), and getAuthorization() methods manipulate and query an internal list of AuthorizationInfo instances. There can be only one instance per host, port, scheme, and realm combination (see equals()).
version:
   0.3-2 18/06/1999
author:
   Ronald Tschalär
since:
   V0.1




Constructor Summary
 AuthorizationInfo(String host, int port)
     Creates an new info structure for the specified host and port.
public  AuthorizationInfo(String host, int port, String scheme, String realm, NVPair params, Object info)
     Creates a new info structure for the specified host and port with the specified scheme, realm, params.
public  AuthorizationInfo(String host, int port, String scheme, String realm, String cookie)
     Creates a new info structure for the specified host and port with the specified scheme, realm and cookie.
 AuthorizationInfo(AuthorizationInfo templ)
     Creates a new copy of the given AuthorizationInfo.

Method Summary
public static  voidaddAuthorization(AuthorizationInfo auth_info)
     Adds an authorization entry to the list using the default context.
public static  voidaddAuthorization(AuthorizationInfo auth_info, Object context)
     Adds an authorization entry to the list.
public static  voidaddAuthorization(String host, int port, String scheme, String realm, String cookie, NVPair params, Object info)
     Adds an authorization entry to the list using the default context.
public static  voidaddAuthorization(String host, int port, String scheme, String realm, String cookie, NVPair params, Object info, Object context)
     Adds an authorization entry to the list.
public static  voidaddBasicAuthorization(String host, int port, String realm, String user, String passwd)
     Adds an authorization entry for the "Basic" authorization scheme to the list using the default context.
public static  voidaddBasicAuthorization(String host, int port, String realm, String user, String passwd, Object context)
     Adds an authorization entry for the "Basic" authorization scheme to the list.
public static  voidaddDigestAuthorization(String host, int port, String realm, String user, String passwd)
     Adds an authorization entry for the "Digest" authorization scheme to the list using the default context.
public static  voidaddDigestAuthorization(String host, int port, String realm, String user, String passwd, Object context)
     Adds an authorization entry for the "Digest" authorization scheme to the list.
public synchronized  voidaddPath(String resource)
     Adds the path from the given resource to our path list.
public  Objectclone()
    
public  booleanequals(Object obj)
     Two AuthorizationInfos are considered equal if their host, port, scheme and realm match.
static  AuthorizationInfofindBest(RoRequest req)
     Tries to find the candidate in the current list of auth info for the given request.
public static  AuthorizationHandlergetAuthHandler()
     Get's the current authorization handler.
public static  AuthorizationInfogetAuthorization(String host, int port, String scheme, String realm)
     Searches for the authorization info using the given host, port, scheme and realm.
public static synchronized  AuthorizationInfogetAuthorization(String host, int port, String scheme, String realm, Object context)
     Searches for the authorization info in the given context using the given host, port, scheme and realm.
static synchronized  AuthorizationInfogetAuthorization(AuthorizationInfo auth_info, RoRequest req, RoResponse resp, boolean query_auth_h)
     Searches for the authorization info using the host, port, scheme and realm from the given info struct.
static  AuthorizationInfogetAuthorization(String host, int port, String scheme, String realm, boolean query_auth_h)
     Searches for the authorization info given a host, port, scheme and realm.
final public  StringgetCookie()
    
final public  ObjectgetExtraInfo()
     Get the extra info.
final public  StringgetHost()
     Get the host.
final public  NVPair[]getParams()
     Get the authentication parameters.
final public  intgetPort()
     Get the port.
final public  StringgetRealm()
     Get the realm.
final public  StringgetScheme()
     Get the scheme.
public  inthashCode()
     Produces a hash code based on host, scheme and realm.
static  AuthorizationInfo[]parseAuthString(String challenge, RoRequest req, RoResponse resp)
     Parses the authentication challenge(s) into an array of new info structures for the specified host and port.
Parameters:
  challenge - a string containing authentication info.
static  AuthorizationInfoqueryAuthHandler(AuthorizationInfo auth_info, RoRequest req, RoResponse resp)
     Queries the AuthHandler for authorization info.
public static  voidremoveAuthorization(AuthorizationInfo auth_info)
     Removes an authorization entry from the list using the default context.
public static  voidremoveAuthorization(AuthorizationInfo auth_info, Object context)
     Removes an authorization entry from the list.
public static  voidremoveAuthorization(String host, int port, String scheme, String realm)
     Removes an authorization entry from the list using the default context.
public static  voidremoveAuthorization(String host, int port, String scheme, String realm, Object context)
     Removes an authorization entry from the list.
public static  AuthorizationHandlersetAuthHandler(AuthorizationHandler handler)
     Set's the authorization handler.
final public  voidsetCookie(String cookie)
    
final public  voidsetExtraInfo(Object info)
     Set the extra info.
final public  voidsetParams(NVPair[] params)
     Set the authentication parameters.
public  StringtoString()
     Constructs a string containing the authorization info.


Constructor Detail
AuthorizationInfo
AuthorizationInfo(String host, int port)(Code)
Creates an new info structure for the specified host and port.
Parameters:
  host - the host
Parameters:
  port - the port



AuthorizationInfo
public AuthorizationInfo(String host, int port, String scheme, String realm, NVPair params, Object info)(Code)
Creates a new info structure for the specified host and port with the specified scheme, realm, params. The cookie is set to null.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm
Parameters:
  params - the parameters as an array of name/value pairs, or null
Parameters:
  info - arbitrary extra info, or null



AuthorizationInfo
public AuthorizationInfo(String host, int port, String scheme, String realm, String cookie)(Code)
Creates a new info structure for the specified host and port with the specified scheme, realm and cookie. The params is set to a zero-length array, and the extra_info is set to null.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm
Parameters:
  cookie - for the "Basic" scheme this is the base64-encodedusername/password; for the "NTLM" scheme this is thebase64-encoded username/password message.



AuthorizationInfo
AuthorizationInfo(AuthorizationInfo templ)(Code)
Creates a new copy of the given AuthorizationInfo.
Parameters:
  templ - the info to copy




Method Detail
addAuthorization
public static void addAuthorization(AuthorizationInfo auth_info)(Code)
Adds an authorization entry to the list using the default context. If an entry for the specified scheme and realm already exists then its cookie and params are replaced with the new data.
Parameters:
  auth_info - the AuthorizationInfo to add



addAuthorization
public static void addAuthorization(AuthorizationInfo auth_info, Object context)(Code)
Adds an authorization entry to the list. If an entry for the specified scheme and realm already exists then its cookie and params are replaced with the new data.
Parameters:
  auth_info - the AuthorizationInfo to add
Parameters:
  context - the context to associate this info with



addAuthorization
public static void addAuthorization(String host, int port, String scheme, String realm, String cookie, NVPair params, Object info)(Code)
Adds an authorization entry to the list using the default context. If an entry for the specified scheme and realm already exists then its cookie and params are replaced with the new data.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm
Parameters:
  cookie - the cookie
Parameters:
  params - an array of name/value pairs of parameters
Parameters:
  info - arbitrary extra auth info



addAuthorization
public static void addAuthorization(String host, int port, String scheme, String realm, String cookie, NVPair params, Object info, Object context)(Code)
Adds an authorization entry to the list. If an entry for the specified scheme and realm already exists then its cookie and params are replaced with the new data.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm
Parameters:
  cookie - the cookie
Parameters:
  params - an array of name/value pairs of parameters
Parameters:
  info - arbitrary extra auth info
Parameters:
  context - the context to associate this info with



addBasicAuthorization
public static void addBasicAuthorization(String host, int port, String realm, String user, String passwd)(Code)
Adds an authorization entry for the "Basic" authorization scheme to the list using the default context. If an entry already exists for the "Basic" scheme and the specified realm then it is overwritten.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  realm - the realm
Parameters:
  user - the username
Parameters:
  passwd - the password



addBasicAuthorization
public static void addBasicAuthorization(String host, int port, String realm, String user, String passwd, Object context)(Code)
Adds an authorization entry for the "Basic" authorization scheme to the list. If an entry already exists for the "Basic" scheme and the specified realm then it is overwritten.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  realm - the realm
Parameters:
  user - the username
Parameters:
  passwd - the password
Parameters:
  context - the context to associate this info with



addDigestAuthorization
public static void addDigestAuthorization(String host, int port, String realm, String user, String passwd)(Code)
Adds an authorization entry for the "Digest" authorization scheme to the list using the default context. If an entry already exists for the "Digest" scheme and the specified realm then it is overwritten.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  realm - the realm
Parameters:
  user - the username
Parameters:
  passwd - the password



addDigestAuthorization
public static void addDigestAuthorization(String host, int port, String realm, String user, String passwd, Object context)(Code)
Adds an authorization entry for the "Digest" authorization scheme to the list. If an entry already exists for the "Digest" scheme and the specified realm then it is overwritten.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  realm - the realm
Parameters:
  user - the username
Parameters:
  passwd - the password
Parameters:
  context - the context to associate this info with



addPath
public synchronized void addPath(String resource)(Code)
Adds the path from the given resource to our path list. The path list is used for deciding when to preemptively send auth info.
Parameters:
  resource - the resource from which to extract the path



clone
public Object clone()(Code)
a clone of this AuthorizationInfo using a deep copy



equals
public boolean equals(Object obj)(Code)
Two AuthorizationInfos are considered equal if their host, port, scheme and realm match. Used in the AuthorizationInfo.AuthList hash table.
Parameters:
  obj - another AuthorizationInfo against which this one isto be compared. true if they match in the above mentioned fields; falseotherwise.



findBest
static AuthorizationInfo findBest(RoRequest req)(Code)
Tries to find the candidate in the current list of auth info for the given request. The paths associated with each auth info are examined, and the one with either the nearest direct parent or child is chosen. This is used for preemptively sending auth info.
Parameters:
  req - the Request an AuthorizationInfo containing the info for the best match,or null if none found.



getAuthHandler
public static AuthorizationHandler getAuthHandler()(Code)
Get's the current authorization handler. the current authorization handler, or null if none is set.
See Also:   AuthorizationHandler



getAuthorization
public static AuthorizationInfo getAuthorization(String host, int port, String scheme, String realm)(Code)
Searches for the authorization info using the given host, port, scheme and realm. The context is the default context.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm a pointer to the authorization data or null if not found



getAuthorization
public static synchronized AuthorizationInfo getAuthorization(String host, int port, String scheme, String realm, Object context)(Code)
Searches for the authorization info in the given context using the given host, port, scheme and realm.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm
Parameters:
  context - the context this info is associated with a pointer to the authorization data or null if not found



getAuthorization
static synchronized AuthorizationInfo getAuthorization(AuthorizationInfo auth_info, RoRequest req, RoResponse resp, boolean query_auth_h) throws AuthSchemeNotImplException(Code)
Searches for the authorization info using the host, port, scheme and realm from the given info struct. If not found it queries the AuthHandler (if set).
Parameters:
  auth_info - the AuthorizationInfo
Parameters:
  request - the request which initiated this query
Parameters:
  resp - the full response
Parameters:
  query_auth_h - if true, query the auth-handler if no info found. a pointer to the authorization data or null if not found
exception:
  AuthSchemeNotImplException - If thrown by the AuthHandler.



getAuthorization
static AuthorizationInfo getAuthorization(String host, int port, String scheme, String realm, boolean query_auth_h) throws AuthSchemeNotImplException(Code)
Searches for the authorization info given a host, port, scheme and realm. Queries the AuthHandler if not found in list.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm
Parameters:
  query_auth_h - if true, query the auth-handler if no info found. a pointer to the authorization data or null if not found
exception:
  AuthSchemeNotImplException - If thrown by the AuthHandler.



getCookie
final public String getCookie()(Code)
Get the cookie the cookie String
since:
   V0.3-1



getExtraInfo
final public Object getExtraInfo()(Code)
Get the extra info. the extra_info object



getHost
final public String getHost()(Code)
Get the host. a string containing the host name.



getParams
final public NVPair[] getParams()(Code)
Get the authentication parameters. an array of name/value pairs.



getPort
final public int getPort()(Code)
Get the port. an int containing the port number.



getRealm
final public String getRealm()(Code)
Get the realm. a string containing the realm.



getScheme
final public String getScheme()(Code)
Get the scheme. a string containing the scheme.



hashCode
public int hashCode()(Code)
Produces a hash code based on host, scheme and realm. Port is not included for simplicity (and because it probably won't make much difference). Used in the AuthorizationInfo.AuthList hash table. the hash code



parseAuthString
static AuthorizationInfo[] parseAuthString(String challenge, RoRequest req, RoResponse resp) throws ProtocolException(Code)
Parses the authentication challenge(s) into an array of new info structures for the specified host and port.
Parameters:
  challenge - a string containing authentication info. This musthave the same format as value part of aWWW-authenticate response header field, and maycontain multiple authentication challenges.
Parameters:
  req - the original request.
exception:
  ProtocolException - if any error during the parsing occurs.



queryAuthHandler
static AuthorizationInfo queryAuthHandler(AuthorizationInfo auth_info, RoRequest req, RoResponse resp) throws AuthSchemeNotImplException(Code)
Queries the AuthHandler for authorization info. It also adds this info to the list.
Parameters:
  auth_info - any info needed by the AuthHandler; at a minimum thehost, scheme and realm should be set.
Parameters:
  req - the request which initiated this query
Parameters:
  resp - the full response a structure containing the requested info, or null if eitherno AuthHandler is set or the user canceled the request.
exception:
  AuthSchemeNotImplException - if this is thrown bythe AuthHandler.



removeAuthorization
public static void removeAuthorization(AuthorizationInfo auth_info)(Code)
Removes an authorization entry from the list using the default context. If no entry for the specified host, port, scheme and realm exists then this does nothing.
Parameters:
  auth_info - the AuthorizationInfo to remove



removeAuthorization
public static void removeAuthorization(AuthorizationInfo auth_info, Object context)(Code)
Removes an authorization entry from the list. If no entry for the specified host, port, scheme and realm exists then this does nothing.
Parameters:
  auth_info - the AuthorizationInfo to remove
Parameters:
  context - the context this info is associated with



removeAuthorization
public static void removeAuthorization(String host, int port, String scheme, String realm)(Code)
Removes an authorization entry from the list using the default context. If no entry for the specified host, port, scheme and realm exists then this does nothing.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm



removeAuthorization
public static void removeAuthorization(String host, int port, String scheme, String realm, Object context)(Code)
Removes an authorization entry from the list. If no entry for the specified host, port, scheme and realm exists then this does nothing.
Parameters:
  host - the host
Parameters:
  port - the port
Parameters:
  scheme - the scheme
Parameters:
  realm - the realm
Parameters:
  context - the context this info is associated with



setAuthHandler
public static AuthorizationHandler setAuthHandler(AuthorizationHandler handler)(Code)
Set's the authorization handler. This handler is called whenever the server requests authorization and no entry for the requested scheme and realm can be found in the list. The handler must implement the AuthorizationHandler interface.
If no handler is set then a default handler is used. This handler currently only handles the "Basic" scheme and brings up a popup which prompts for the username and password.
The default handler can be disabled by setting the auth handler to null.
Parameters:
  handler - the new authorization handler the old authorization handler
See Also:   AuthorizationHandler



setCookie
final public void setCookie(String cookie)(Code)
Set the cookie
Parameters:
  cookie - the new cookie
since:
   V0.3-1



setExtraInfo
final public void setExtraInfo(Object info)(Code)
Set the extra info.
Parameters:
  info - the extra info



setParams
final public void setParams(NVPair[] params)(Code)
Set the authentication parameters.
Parameters:
  an - array of name/value pairs.



toString
public String toString()(Code)
Constructs a string containing the authorization info. The format is that of the http Authorization header. a String containing all info.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.