Annotation of libwww/Library/src/HTAAUtil.html, revision 2.19
2.2 timbl 1: <HTML>
2.1 luotonen 2: <HEAD>
2.13 frystyk 3: <TITLE>Utilities for the Authorization parts of libwww</TITLE>
4: </HEAD>
2.1 luotonen 5: <BODY>
2.13 frystyk 6:
7: <H1>Common Parts of Authorization Module to Both Server And
8: Browser</H1>
9:
10: <PRE>
11: /*
2.18 frystyk 12: ** (c) COPYRIGHT MIT 1995.
2.13 frystyk 13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
16:
17: This module is the interface to the common parts of Access
18: Authorization (AA) package for both server and browser. Important to
19: know about memory allocation:<P>
20:
21: Routines in this module use dynamic allocation, but free automatically
22: all the memory reserved by them. Therefore the caller never has to
23: (and never should) free() any object returned by these functions.<P>
24:
25: Therefore also all the strings returned by this package are only valid
26: until the next call to the same function is made. This approach is
27: selected, because of the nature of access authorization: no string
28: returned by the package needs to be valid longer than until the next
29: call. This also makes it easy to plug the AA package in: you don't
30: have to ponder whether to free() something here or is it done
31: somewhere else (because it is always done somewhere else).<P>
32:
33: The strings that the package needs to store are copied so the original
34: strings given as parameters to AA functions may be freed or modified
2.2 timbl 35: with no side effects.<P>
2.13 frystyk 36:
37: Also note: The AA package does not free() anything else than what it
38: has itself allocated. <P>
39:
40: This module is implemented by <A HREF="HTAAUtil.c">HTAAUtil.c</A>, and
41: it is a part of the <A
2.16 frystyk 42: HREF="http://www.w3.org/hypertext/WWW/Library/User/Guide/Guide.html">
2.13 frystyk 43: Library of Common Code</A>.
44:
2.1 luotonen 45: <PRE>
46: #ifndef HTAAUTIL_H
47: #define HTAAUTIL_H
48: #include "HTList.h"
2.19 ! frystyk 49: #include "HTAccess.h"
2.15 frystyk 50: </PRE>
2.1 luotonen 51:
2.15 frystyk 52: <H2>Default filenames</H2>
2.1 luotonen 53:
2.15 frystyk 54: <PRE>
55: #ifndef PASSWD_FILE
2.1 luotonen 56: #define PASSWD_FILE "/home2/luotonen/passwd"
57: #endif
58:
59: #ifndef GROUP_FILE
60: #define GROUP_FILE "/home2/luotonen/group"
61: #endif
62:
63: #define ACL_FILE_NAME ".www_acl"
64:
65: /*
66: ** Numeric constants
67: */
68: #define MAX_USERNAME_LEN 16 /* @@ Longest allowed username */
2.5 luotonen 69: #define MAX_PASSWORD_LEN 4*13 /* @@ Longest allowed password */
70: /* (encrypted, so really only 4*8)*/
2.1 luotonen 71: #define MAX_METHODNAME_LEN 12 /* @@ Longest allowed method name */
72: #define MAX_FIELDNAME_LEN 16 /* @@ Longest field name in */
73: /* protection setup file */
74: #define MAX_PATHNAME_LEN 80 /* @@ Longest passwd/group file */
75: /* patname to allow */
76:
77: /*
2.6 luotonen 78: ** Access Authorization failure reasons
79: */
80: typedef enum {
81: HTAA_OK, /* 200 OK */
82: HTAA_OK_GATEWAY, /* 200 OK, acting as a gateway */
2.7 luotonen 83: HTAA_OK_REDIRECT, /* 302 OK, redirected */
2.6 luotonen 84: HTAA_NO_AUTH, /* 401 Unauthorized, not authenticated */
85: HTAA_NOT_MEMBER, /* 401 Unauthorized, not authorized */
86: HTAA_IP_MASK, /* 403 Forbidden by IP mask */
2.9 luotonen 87: HTAA_IP_MASK_PROXY, /* 403 Forbidden by IP mask on proxy */
2.6 luotonen 88: HTAA_BY_RULE, /* 403 Forbidden by rule */
89: HTAA_NO_ACL, /* 403 Forbidden, ACL non-existent */
90: HTAA_NO_ENTRY, /* 403 Forbidden, no ACL entry */
91: HTAA_SETUP_ERROR, /* 403 Forbidden, server setup error */
92: HTAA_DOTDOT, /* 403 Forbidden, URL with /../ illegal */
93: HTAA_HTBIN, /* 403 Forbidden, /htbin not enabled */
2.7 luotonen 94: HTAA_INVALID_REDIRECT,
95: /* 403 Forbidden, bad redirection setup */
2.10 luotonen 96: HTAA_INVALID_USER, /* 403 Forbidden, bad user directory */
2.7 luotonen 97: HTAA_NOT_ALLOWED, /* 403 Forbidden, dangerous method must */
98: /* be explicitly allowed */
2.8 luotonen 99: HTAA_NOT_FOUND, /* 404 Not found, or read protected */
100: HTAA_MULTI_FAILED /* 404 No suitable presentation found */
2.6 luotonen 101: } HTAAFailReason;
2.2 timbl 102: </PRE>
2.1 luotonen 103:
104: <H2>Authentication Schemes</H2>
105: <PRE>
106: /* PUBLIC HTAAScheme_enum()
107: ** TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
108: ** ON ENTRY:
109: ** name is a string representing the scheme name.
110: **
111: ** ON EXIT:
112: ** returns the enumerated constant for that scheme.
113: */
2.12 frystyk 114: extern HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
2.1 luotonen 115:
116:
117: /* PUBLIC HTAAScheme_name()
118: ** GET THE NAME OF A GIVEN SCHEME
119: ** ON ENTRY:
120: ** scheme is one of the scheme enum values:
121: ** HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
122: **
123: ** ON EXIT:
124: ** returns the name of the scheme, i.e.
125: ** "none", "basic", "pubkey", ...
126: */
2.12 frystyk 127: extern char *HTAAScheme_name PARAMS((HTAAScheme scheme));
2.19 ! frystyk 128:
! 129:
! 130: /* extern HTAA_templateMatch()
! 131: ** STRING COMPARISON FUNCTION FOR FILE NAMES
! 132: ** WITH ONE WILDCARD * IN THE TEMPLATE
! 133: ** NOTE:
! 134: ** This is essentially the same code as in HTRules.c, but it
! 135: ** cannot be used because it is embedded in between other code.
! 136: ** (In fact, HTRules.c should use this routine, but then this
! 137: ** routine would have to be more sophisticated... why is life
! 138: ** sometimes so hard...)
! 139: **
! 140: ** ON ENTRY:
! 141: ** tmplate is a template string to match the file name
! 142: ** agaist, may contain a single wildcard
! 143: ** character * which matches zero or more
! 144: ** arbitrary characters.
! 145: ** filename is the filename (or pathname) to be matched
! 146: ** agaist the template.
! 147: **
! 148: ** ON EXIT:
! 149: ** returns YES, if filename matches the template.
! 150: ** NO, otherwise.
! 151: */
! 152: extern BOOL HTAA_templateMatch PARAMS((CONST char * tmplate,
! 153: CONST char * filename));
2.2 timbl 154:
2.1 luotonen 155:
2.7 luotonen 156: /* PUBLIC HTAA_templateCaseMatch()
2.4 duns 157: ** STRING COMPARISON FUNCTION FOR FILE NAMES
158: ** WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
159: ** NOTE:
160: ** This is essentially the same code as in HTAA_templateMatch, but
161: ** it compares case insensitive (for VMS). Reason for this routine
162: ** is that HTAA_templateMatch gets called from several places, also
163: ** there where a case sensitive match is needed, so one cannot just
164: ** change the HTAA_templateMatch routine for VMS.
165: **
166: ** ON ENTRY:
167: ** template is a template string to match the file name
168: ** agaist, may contain a single wildcard
169: ** character * which matches zero or more
170: ** arbitrary characters.
171: ** filename is the filename (or pathname) to be matched
172: ** agaist the template.
173: **
174: ** ON EXIT:
175: ** returns YES, if filename matches the template.
176: ** NO, otherwise.
177: */
2.12 frystyk 178: extern BOOL HTAA_templateCaseMatch PARAMS((CONST char * tmplate,
2.7 luotonen 179: CONST char * filename));
2.4 duns 180:
181:
2.1 luotonen 182: /* PUBLIC HTAA_makeProtectionTemplate()
183: ** CREATE A PROTECTION TEMPLATE FOR THE FILES
184: ** IN THE SAME DIRECTORY AS THE GIVEN FILE
185: ** (Used by server if there is no fancier way for
186: ** it to tell the client, and by browser if server
187: ** didn't send WWW-ProtectionTemplate: field)
188: ** ON ENTRY:
189: ** docname is the document pathname (from URL).
190: **
191: ** ON EXIT:
192: ** returns a template matching docname, and other files
193: ** files in that directory.
194: **
195: ** E.g. /foo/bar/x.html => /foo/bar/ *
196: ** ^
197: ** Space only to prevent it from
198: ** being a comment marker here,
199: ** there really isn't any space.
200: */
2.12 frystyk 201: extern char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
2.1 luotonen 202: </PRE>
203: <H2>MIME Argument List Parser</H2>
204: <PRE>
205:
206: /* PUBLIC HTAA_parseArgList()
207: ** PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
208: ** ON ENTRY:
209: ** str is a comma-separated list:
210: **
211: ** item, item, item
212: ** where
213: ** item ::= value
214: ** | name=value
215: ** | name="value"
216: **
217: ** Leading and trailing whitespace is ignored
218: ** everywhere except inside quotes, so the following
219: ** examples are equal:
220: **
221: ** name=value,foo=bar
222: ** name="value",foo="bar"
223: ** name = value , foo = bar
224: ** name = "value" , foo = "bar"
225: **
226: ** ON EXIT:
227: ** returns a list of name-value pairs (actually HTAssocList*).
228: ** For items with no name, just value, the name is
229: ** the number of order number of that item. E.g.
230: ** "1" for the first, etc.
231: */
2.12 frystyk 232: extern HTList *HTAA_parseArgList PARAMS((char * str));
2.1 luotonen 233:
234: </PRE>
2.5 luotonen 235:
2.1 luotonen 236: <PRE>
237: #endif /* NOT HTAAUTIL_H */
2.2 timbl 238: </PRE>End of file HTAAUtil.h.</BODY>
239: </HTML>
Webmaster