PageRenderTime 31ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/ATF2/control-software/epics-3.14.8/extensions/src/ChannelArchiver/ThirdParty/w3c-libwww-5.4.0/Library/src/HTAAUtil.h

http://atf2flightsim.googlecode.com/
C Header | 251 lines | 25 code | 22 blank | 204 comment | 0 complexity | 1f75bec76994b75e7e6c40b308fcf0d2 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. /*
  2. W3C Sample Code Library libwww Access Authentication
  3. !
  4. Access Authentication Manager
  5. !
  6. */
  7. /*
  8. ** (c) COPYRIGHT MIT 1995.
  9. ** Please first read the full copyright statement in the file COPYRIGH.
  10. */
  11. /*
  12. The Authentication Manager is a registry for Authentication
  13. Schemes that follow the generic syntax defined by the
  14. HTTP WWW-authenticate and
  15. Authorization headers. Currently, the only scheme defined is
  16. Basic Authentication, but Digest Authentication will soon follow.
  17. All Authentication Schemes are registered at run-time in form of an
  18. Authentication Module. An Authentication Module consists of
  19. the following:
  20. scheme
  21. The name which is used to identify the scheme. This is equivalent to the
  22. <scheme> part of the WWW-authenticate HTTP
  23. header, for example "basic"
  24. BEFORE Filter
  25. When a new request is issued, the Authentication Manager looks in
  26. the URL tree to see if we have any access authentication information for
  27. this particular request. The search is based on the realm (if known) in which
  28. the request belongs and the URL itself. If a record is found then the
  29. Authentication Manager calls the Authentication Module in order
  30. to generate the credentials.
  31. AFTER Filter
  32. After a request has terminated and the result was lack of credentials, the
  33. request should normally be repeated with a new set of credentials. The AFTER
  34. filter is responsible for extracting the challenge from the HTTP response
  35. and store it in the URL tree, so that we next time we request the same URL
  36. we know that it is protected and we can ask the user for the appropriate
  37. credentials (user name and password, for example).
  38. garbage collection
  39. The authentication information is stored in a URL
  40. Tree but as it doesn't know the format of the scheme specific parts,
  41. you must register a garbage collector (gc). The gc is called when node is
  42. deleted in the tree.
  43. Note: The Authentication Manager itself consists of
  44. BEFORE and an AFTER filter - just
  45. like the Authentication Modules. This means that any Authentication
  46. Module also can be registered directly as a BEFORE and
  47. AFTER filter by the Net
  48. Manager. The reason for having the two layer model is that the
  49. Authentication Manager maintains a single URL
  50. tree for storing access information for all Authentication Schemes.
  51. An Authentication Module has three resources, it can use when creating
  52. challenges or credentials:
  53. o
  54. Handle the credentials which is a part of the
  55. Request obejct. The credentials are often
  56. generated by asking the user for a user name ansd a password.
  57. o
  58. Handle the challenges which is a part of the
  59. Request object. The MIME
  60. parser will normally find the credentials as we parse the HTTP response.
  61. o
  62. Add information to the URL Tree
  63. This module is implemented by HTAAUtil.c, and it
  64. is a part of the W3C Sample Code
  65. Library.
  66. */
  67. #ifndef HTAAUTIL_H
  68. #define HTAAUTIL_H
  69. #include "HTReq.h"
  70. #include "HTNet.h"
  71. #include "HTUTree.h"
  72. /*
  73. .
  74. Authentication Scheme Registration
  75. .
  76. An Authentication Scheme is registered by registering an
  77. Authentication Module to in the Authentication Manager.
  78. (
  79. Add an Authentication Module
  80. )
  81. You can add an authentication scheme by using the following method. Each
  82. of the callback function must have the type as defined below.
  83. */
  84. typedef struct _HTAAModule HTAAModule;
  85. extern HTAAModule * HTAA_newModule (const char * scheme,
  86. HTNetBefore * before,
  87. HTNetAfter * after,
  88. HTNetAfter * update,
  89. HTUTree_gc * gc);
  90. /*
  91. (
  92. Find an Authentication Module
  93. )
  94. */
  95. extern HTAAModule * HTAA_findModule (const char * scheme);
  96. /*
  97. (
  98. Delete an Authentication Module
  99. )
  100. */
  101. extern BOOL HTAA_deleteModule (const char * scheme);
  102. /*
  103. (
  104. Delete ALL Authentication modules
  105. )
  106. */
  107. extern BOOL HTAA_deleteAllModules (void);
  108. /*
  109. .
  110. Handling the URL Tree
  111. .
  112. The authentication information is stored as URL
  113. Trees. &nbsp;The root of a URL Tree is identified by a hostname
  114. and a port number. Each URL Tree contains a set of templates and realms
  115. which can be used to predict what information to use in a hierarchical tree.
  116. The URL trees are automatically collected after some time so the application
  117. does not have to worry about freeing the trees. When a node in a tree is
  118. freed, the gc registered as part of the Authentication Module is called.
  119. Server applications can have different authentication setups for each hostname
  120. and port number, they control. For example, a server with interfaces
  121. "www.foo.com" and "internal.foo.com" can have different
  122. protection setups for each interface.
  123. (
  124. Add new or Update a Note in the UTree
  125. )
  126. Add an access authentication information node to the database or update an
  127. existing one. If the entry is already found then it is replaced with the
  128. new one. The template must follow normal URI syntax but can include a wildcard
  129. Return YES if added (or replaced), else NO
  130. */
  131. extern void * HTAA_updateNode (BOOL proxy,
  132. char const * scheme,
  133. const char * realm, const char * url,
  134. void * context);
  135. /*
  136. (
  137. Delete a Node from the UTree
  138. )
  139. This is called if an already entered node has to be deleted, for example
  140. if it is not used (the user cancelled entering a username and password),
  141. or for some reason has expired.
  142. */
  143. extern BOOL HTAA_deleteNode (BOOL proxy_access, char const * scheme,
  144. const char * realm, const char * url);
  145. /*
  146. .
  147. The Authentication Manager Filters
  148. .
  149. As mentioned, the Access Authentication Manager is itself a set of
  150. filters that can be registered by the
  151. Net manager.
  152. (
  153. Before Filter
  154. )
  155. Make a lookup in the URL tree to find any context for this node, If no context
  156. is found then we assume that we don't know anything about this URL and hence
  157. we don't call any BEFORE filters at all.
  158. */
  159. HTNetBefore HTAA_beforeFilter;
  160. /*
  161. (
  162. After Filter
  163. )
  164. Call the AFTER filter that knows how to handle this scheme.
  165. */
  166. HTNetAfter HTAA_afterFilter;
  167. /*
  168. (
  169. Update Filter
  170. )
  171. Call the UPDATE filter that knows how to handle this scheme.
  172. */
  173. HTNetAfter HTAA_updateFilter;
  174. /*
  175. (
  176. Proxy Authentication Filter
  177. )
  178. Just as for normal authentication we have a filter for proxy authentication.
  179. The proxy authentication uses exactly the same code as normal authentication
  180. but it stores the information in a separate proxy authentication
  181. URL tree. That way, we don't get any clashes between
  182. a server acting as a proxy and a normal server at the same time on the same
  183. port. The difference is that we only have a ingoing filter (a before filter)
  184. as the out going filter is identical to the normal authentication filter.
  185. The filter requires to be called after a proxy filter as we otherwise don't
  186. know whether we are using a proxy or not.
  187. */
  188. HTNetBefore HTAA_proxyBeforeFilter;
  189. /*
  190. */
  191. #endif /* NOT HTAAUTIL_H */
  192. /*
  193. @(#) $Id: HTAAUtil.h,v 1.1.1.1 2009/03/14 06:44:12 whitegr Exp $
  194. */