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