Annotation of libwww/Library/src/HTAAUtil.html, revision 2.9
2.2 timbl 1: <HTML>
2.1 luotonen 2: <HEAD>
2.2 timbl 3: <TITLE>Utilities for the Authorization parts of libwww</TITLE></HEAD>
2.1 luotonen 4: <BODY>
2.2 timbl 5: <H1>Common Parts of Authorization Module
6: to Both Server And Browser</H1>This module is the interface to the
7: common parts of Access Authorization
8: (AA) package for both server and
9: browser. Important to know about
10: memory allocation:<P>
11: Routines in this module use dynamic
12: allocation, but free automatically
13: all the memory reserved by them.<P>
14: Therefore the caller never has to
15: (and never should) free() any object
16: returned by these functions.<P>
17: Therefore also all the strings returned
18: by this package are only valid until
19: the next call to the same function
20: is made. This approach is selected,
21: because of the nature of access authorization:
22: no string returned by the package
23: needs to be valid longer than until
24: the next call.<P>
25: This also makes it easy to plug the
26: AA package in: you don't have to
27: ponder whether to free() something
28: here or is it done somewhere else
29: (because it is always done somewhere
30: else).<P>
31: The strings that the package needs
32: to store are copied so the original
33: strings given as parameters to AA
34: functions may be freed or modified
35: with no side effects.<P>
36: Also note: The AA package does not
37: free() anything else than what it
38: has itself allocated.
2.1 luotonen 39: <PRE>
40: #ifndef HTAAUTIL_H
41: #define HTAAUTIL_H
42:
43: #include "HTUtils.h" /* BOOL, PARAMS, ARGS */
44: #include "HTList.h"
2.2 timbl 45: #include "tcp.h"
2.1 luotonen 46:
47: #ifdef SHORT_NAMES
48: #define HTAASenu HTAAScheme_enum
49: #define HTAASnam HTAAScheme_name
50: #define HTAAteMa HTAA_templateMatch
51: #define HTAAmaPT HTAA_makeProtectionTemplate
52: #define HTAApALi HTAA_parseArgList
53: #endif /*SHORT_NAMES*/
54:
55:
2.2 timbl 56: </PRE>
57: <H2>Default filenames</H2>
58: <PRE>#ifndef PASSWD_FILE
2.1 luotonen 59: #define PASSWD_FILE "/home2/luotonen/passwd"
60: #endif
61:
62: #ifndef GROUP_FILE
63: #define GROUP_FILE "/home2/luotonen/group"
64: #endif
65:
66: #define ACL_FILE_NAME ".www_acl"
67:
68:
69: /*
70: ** Numeric constants
71: */
72: #define MAX_USERNAME_LEN 16 /* @@ Longest allowed username */
2.5 luotonen 73: #define MAX_PASSWORD_LEN 4*13 /* @@ Longest allowed password */
74: /* (encrypted, so really only 4*8)*/
2.1 luotonen 75: #define MAX_METHODNAME_LEN 12 /* @@ Longest allowed method name */
76: #define MAX_FIELDNAME_LEN 16 /* @@ Longest field name in */
77: /* protection setup file */
78: #define MAX_PATHNAME_LEN 80 /* @@ Longest passwd/group file */
79: /* patname to allow */
80:
81: /*
82: ** Helpful macros
83: */
84: #define FREE(x) if (x) {free(x); x=NULL;}
85:
2.6 luotonen 86:
87: /*
88: ** Access Authorization failure reasons
89: */
90: typedef enum {
91: HTAA_OK, /* 200 OK */
92: HTAA_OK_GATEWAY, /* 200 OK, acting as a gateway */
2.7 luotonen 93: HTAA_OK_REDIRECT, /* 302 OK, redirected */
2.6 luotonen 94: HTAA_NO_AUTH, /* 401 Unauthorized, not authenticated */
95: HTAA_NOT_MEMBER, /* 401 Unauthorized, not authorized */
96: HTAA_IP_MASK, /* 403 Forbidden by IP mask */
2.9 ! luotonen 97: HTAA_IP_MASK_PROXY, /* 403 Forbidden by IP mask on proxy */
2.6 luotonen 98: HTAA_BY_RULE, /* 403 Forbidden by rule */
99: HTAA_NO_ACL, /* 403 Forbidden, ACL non-existent */
100: HTAA_NO_ENTRY, /* 403 Forbidden, no ACL entry */
101: HTAA_SETUP_ERROR, /* 403 Forbidden, server setup error */
102: HTAA_DOTDOT, /* 403 Forbidden, URL with /../ illegal */
103: HTAA_HTBIN, /* 403 Forbidden, /htbin not enabled */
2.7 luotonen 104: HTAA_INVALID_REDIRECT,
105: /* 403 Forbidden, bad redirection setup */
106: HTAA_NOT_ALLOWED, /* 403 Forbidden, dangerous method must */
107: /* be explicitly allowed */
2.8 luotonen 108: HTAA_NOT_FOUND, /* 404 Not found, or read protected */
109: HTAA_MULTI_FAILED /* 404 No suitable presentation found */
2.6 luotonen 110: } HTAAFailReason;
111:
112:
2.1 luotonen 113: </PRE>
114: <H2>Datatype definitions</H2>
2.2 timbl 115: <H3>HTAAScheme</H3>The enumeration HTAAScheme represents
116: the possible authentication schemes
117: used by the WWW Access Authorization.
2.1 luotonen 118: <PRE>
119: typedef enum {
120: HTAA_UNKNOWN,
121: HTAA_NONE,
122: HTAA_BASIC,
123: HTAA_PUBKEY,
124: HTAA_KERBEROS_V4,
125: HTAA_KERBEROS_V5,
126: HTAA_MAX_SCHEMES /* THIS MUST ALWAYS BE LAST! Number of schemes */
127: } HTAAScheme;
128:
2.2 timbl 129: </PRE>
2.1 luotonen 130:
131: <H2>Authentication Schemes</H2>
132: <PRE>
133: /* PUBLIC HTAAScheme_enum()
134: ** TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
135: ** ON ENTRY:
136: ** name is a string representing the scheme name.
137: **
138: ** ON EXIT:
139: ** returns the enumerated constant for that scheme.
140: */
141: PUBLIC HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
142:
143:
144: /* PUBLIC HTAAScheme_name()
145: ** GET THE NAME OF A GIVEN SCHEME
146: ** ON ENTRY:
147: ** scheme is one of the scheme enum values:
148: ** HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
149: **
150: ** ON EXIT:
151: ** returns the name of the scheme, i.e.
152: ** "none", "basic", "pubkey", ...
153: */
154: PUBLIC char *HTAAScheme_name PARAMS((HTAAScheme scheme));
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: */
179: PUBLIC BOOL HTAA_templateCaseMatch PARAMS((CONST char * template,
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: */
202: PUBLIC char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
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: */
233: PUBLIC HTList *HTAA_parseArgList PARAMS((char * str));
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