Annotation of libwww/Library/src/HTAAUtil.html, revision 2.10.2.1

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

Webmaster