Annotation of libwww/Library/src/HTAAUtil.html, revision 2.18
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:
49: #include "HTList.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;
102:
103:
2.1 luotonen 104: </PRE>
105: <H2>Datatype definitions</H2>
2.2 timbl 106: <H3>HTAAScheme</H3>The enumeration HTAAScheme represents
107: the possible authentication schemes
108: used by the WWW Access Authorization.
2.1 luotonen 109: <PRE>
110: typedef enum {
111: HTAA_UNKNOWN,
112: HTAA_NONE,
113: HTAA_BASIC,
114: HTAA_PUBKEY,
115: HTAA_KERBEROS_V4,
116: HTAA_KERBEROS_V5,
117: HTAA_MAX_SCHEMES /* THIS MUST ALWAYS BE LAST! Number of schemes */
118: } HTAAScheme;
119:
2.2 timbl 120: </PRE>
2.1 luotonen 121:
122: <H2>Authentication Schemes</H2>
123: <PRE>
124: /* PUBLIC HTAAScheme_enum()
125: ** TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
126: ** ON ENTRY:
127: ** name is a string representing the scheme name.
128: **
129: ** ON EXIT:
130: ** returns the enumerated constant for that scheme.
131: */
2.12 frystyk 132: extern HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
2.1 luotonen 133:
134:
135: /* PUBLIC HTAAScheme_name()
136: ** GET THE NAME OF A GIVEN SCHEME
137: ** ON ENTRY:
138: ** scheme is one of the scheme enum values:
139: ** HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
140: **
141: ** ON EXIT:
142: ** returns the name of the scheme, i.e.
143: ** "none", "basic", "pubkey", ...
144: */
2.12 frystyk 145: extern char *HTAAScheme_name PARAMS((HTAAScheme scheme));
2.2 timbl 146:
2.1 luotonen 147:
2.7 luotonen 148: /* PUBLIC HTAA_templateCaseMatch()
2.4 duns 149: ** STRING COMPARISON FUNCTION FOR FILE NAMES
150: ** WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
151: ** NOTE:
152: ** This is essentially the same code as in HTAA_templateMatch, but
153: ** it compares case insensitive (for VMS). Reason for this routine
154: ** is that HTAA_templateMatch gets called from several places, also
155: ** there where a case sensitive match is needed, so one cannot just
156: ** change the HTAA_templateMatch routine for VMS.
157: **
158: ** ON ENTRY:
159: ** template is a template string to match the file name
160: ** agaist, may contain a single wildcard
161: ** character * which matches zero or more
162: ** arbitrary characters.
163: ** filename is the filename (or pathname) to be matched
164: ** agaist the template.
165: **
166: ** ON EXIT:
167: ** returns YES, if filename matches the template.
168: ** NO, otherwise.
169: */
2.12 frystyk 170: extern BOOL HTAA_templateCaseMatch PARAMS((CONST char * tmplate,
2.7 luotonen 171: CONST char * filename));
2.4 duns 172:
173:
2.1 luotonen 174: /* PUBLIC HTAA_makeProtectionTemplate()
175: ** CREATE A PROTECTION TEMPLATE FOR THE FILES
176: ** IN THE SAME DIRECTORY AS THE GIVEN FILE
177: ** (Used by server if there is no fancier way for
178: ** it to tell the client, and by browser if server
179: ** didn't send WWW-ProtectionTemplate: field)
180: ** ON ENTRY:
181: ** docname is the document pathname (from URL).
182: **
183: ** ON EXIT:
184: ** returns a template matching docname, and other files
185: ** files in that directory.
186: **
187: ** E.g. /foo/bar/x.html => /foo/bar/ *
188: ** ^
189: ** Space only to prevent it from
190: ** being a comment marker here,
191: ** there really isn't any space.
192: */
2.12 frystyk 193: extern char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
2.1 luotonen 194: </PRE>
195: <H2>MIME Argument List Parser</H2>
196: <PRE>
197:
198: /* PUBLIC HTAA_parseArgList()
199: ** PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
200: ** ON ENTRY:
201: ** str is a comma-separated list:
202: **
203: ** item, item, item
204: ** where
205: ** item ::= value
206: ** | name=value
207: ** | name="value"
208: **
209: ** Leading and trailing whitespace is ignored
210: ** everywhere except inside quotes, so the following
211: ** examples are equal:
212: **
213: ** name=value,foo=bar
214: ** name="value",foo="bar"
215: ** name = value , foo = bar
216: ** name = "value" , foo = "bar"
217: **
218: ** ON EXIT:
219: ** returns a list of name-value pairs (actually HTAssocList*).
220: ** For items with no name, just value, the name is
221: ** the number of order number of that item. E.g.
222: ** "1" for the first, etc.
223: */
2.12 frystyk 224: extern HTList *HTAA_parseArgList PARAMS((char * str));
2.1 luotonen 225:
226: </PRE>
2.5 luotonen 227:
2.1 luotonen 228: <PRE>
229: #endif /* NOT HTAAUTIL_H */
2.2 timbl 230: </PRE>End of file HTAAUtil.h.</BODY>
231: </HTML>
Webmaster