Annotation of libwww/Library/src/HTAAUtil.html, revision 2.8
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 */
97: HTAA_BY_RULE, /* 403 Forbidden by rule */
98: HTAA_NO_ACL, /* 403 Forbidden, ACL non-existent */
99: HTAA_NO_ENTRY, /* 403 Forbidden, no ACL entry */
100: HTAA_SETUP_ERROR, /* 403 Forbidden, server setup error */
101: HTAA_DOTDOT, /* 403 Forbidden, URL with /../ illegal */
102: HTAA_HTBIN, /* 403 Forbidden, /htbin not enabled */
2.7 luotonen 103: HTAA_INVALID_REDIRECT,
104: /* 403 Forbidden, bad redirection setup */
105: HTAA_NOT_ALLOWED, /* 403 Forbidden, dangerous method must */
106: /* be explicitly allowed */
2.8 ! luotonen 107: HTAA_NOT_FOUND, /* 404 Not found, or read protected */
! 108: HTAA_MULTI_FAILED /* 404 No suitable presentation found */
2.6 luotonen 109: } HTAAFailReason;
110:
111:
2.1 luotonen 112: </PRE>
113: <H2>Datatype definitions</H2>
2.2 timbl 114: <H3>HTAAScheme</H3>The enumeration HTAAScheme represents
115: the possible authentication schemes
116: used by the WWW Access Authorization.
2.1 luotonen 117: <PRE>
118: typedef enum {
119: HTAA_UNKNOWN,
120: HTAA_NONE,
121: HTAA_BASIC,
122: HTAA_PUBKEY,
123: HTAA_KERBEROS_V4,
124: HTAA_KERBEROS_V5,
125: HTAA_MAX_SCHEMES /* THIS MUST ALWAYS BE LAST! Number of schemes */
126: } HTAAScheme;
127:
2.2 timbl 128: </PRE>
2.1 luotonen 129:
130: <H2>Authentication Schemes</H2>
131: <PRE>
132: /* PUBLIC HTAAScheme_enum()
133: ** TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
134: ** ON ENTRY:
135: ** name is a string representing the scheme name.
136: **
137: ** ON EXIT:
138: ** returns the enumerated constant for that scheme.
139: */
140: PUBLIC HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
141:
142:
143: /* PUBLIC HTAAScheme_name()
144: ** GET THE NAME OF A GIVEN SCHEME
145: ** ON ENTRY:
146: ** scheme is one of the scheme enum values:
147: ** HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
148: **
149: ** ON EXIT:
150: ** returns the name of the scheme, i.e.
151: ** "none", "basic", "pubkey", ...
152: */
153: PUBLIC char *HTAAScheme_name PARAMS((HTAAScheme scheme));
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: */
178: PUBLIC BOOL HTAA_templateCaseMatch PARAMS((CONST char * template,
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: */
201: PUBLIC char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
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: */
232: PUBLIC HTList *HTAA_parseArgList PARAMS((char * str));
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