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

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: /*
                     12: **     (c) COPYRIGHT CERN 1994.
                     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
                     42: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">
                     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.2       timbl      50: </PRE>
2.13.2.1! frystyk    51: 
2.2       timbl      52: <H2>Default filenames</H2>
2.13.2.1! frystyk    53: 
        !            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: /*
                     78: ** Helpful macros
                     79: */
                     80: #define FREE(x)        if (x) {free(x); x=NULL;}
                     81: 
2.6       luotonen   82: 
                     83: /*
                     84: ** Access Authorization failure reasons
                     85: */
                     86: typedef enum {
                     87:     HTAA_OK,           /* 200 OK                               */
                     88:     HTAA_OK_GATEWAY,   /* 200 OK, acting as a gateway          */
2.7       luotonen   89:     HTAA_OK_REDIRECT,  /* 302 OK, redirected                   */
2.6       luotonen   90:     HTAA_NO_AUTH,      /* 401 Unauthorized, not authenticated  */
                     91:     HTAA_NOT_MEMBER,   /* 401 Unauthorized, not authorized     */
                     92:     HTAA_IP_MASK,      /* 403 Forbidden by IP mask             */
2.9       luotonen   93:     HTAA_IP_MASK_PROXY,        /* 403 Forbidden by IP mask on proxy    */
2.6       luotonen   94:     HTAA_BY_RULE,      /* 403 Forbidden by rule                */
                     95:     HTAA_NO_ACL,       /* 403 Forbidden, ACL non-existent      */
                     96:     HTAA_NO_ENTRY,     /* 403 Forbidden, no ACL entry          */
                     97:     HTAA_SETUP_ERROR,  /* 403 Forbidden, server setup error    */
                     98:     HTAA_DOTDOT,       /* 403 Forbidden, URL with /../ illegal */
                     99:     HTAA_HTBIN,                /* 403 Forbidden, /htbin not enabled    */
2.7       luotonen  100:     HTAA_INVALID_REDIRECT,
                    101:                        /* 403 Forbidden, bad redirection setup */
2.10      luotonen  102:     HTAA_INVALID_USER, /* 403 Forbidden, bad user directory    */
2.7       luotonen  103:     HTAA_NOT_ALLOWED,  /* 403 Forbidden, dangerous method must */
                    104:                        /*                be explicitly allowed */
2.8       luotonen  105:     HTAA_NOT_FOUND,    /* 404 Not found, or read protected     */
                    106:     HTAA_MULTI_FAILED  /* 404 No suitable presentation found   */
2.6       luotonen  107: } HTAAFailReason;
                    108: 
                    109: 
2.1       luotonen  110: </PRE>
                    111: <H2>Datatype definitions</H2>
2.2       timbl     112: <H3>HTAAScheme</H3>The enumeration HTAAScheme represents
                    113: the possible authentication schemes
                    114: used by the WWW Access Authorization.
2.1       luotonen  115: <PRE>
                    116: typedef enum {
                    117:     HTAA_UNKNOWN,
                    118:     HTAA_NONE,
                    119:     HTAA_BASIC,
                    120:     HTAA_PUBKEY,
                    121:     HTAA_KERBEROS_V4,
                    122:     HTAA_KERBEROS_V5,
                    123:     HTAA_MAX_SCHEMES /* THIS MUST ALWAYS BE LAST! Number of schemes */
                    124: } HTAAScheme;
                    125: 
2.2       timbl     126: </PRE>
2.1       luotonen  127: 
                    128: <H2>Authentication Schemes</H2>
                    129: <PRE>
                    130: /* PUBLIC                                              HTAAScheme_enum()
                    131: **             TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
                    132: ** ON ENTRY:
                    133: **     name            is a string representing the scheme name.
                    134: **
                    135: ** ON EXIT:
                    136: **     returns         the enumerated constant for that scheme.
                    137: */
2.12      frystyk   138: extern HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
2.1       luotonen  139: 
                    140: 
                    141: /* PUBLIC                                              HTAAScheme_name()
                    142: **                     GET THE NAME OF A GIVEN SCHEME
                    143: ** ON ENTRY:
                    144: **     scheme          is one of the scheme enum values:
                    145: **                     HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
                    146: **
                    147: ** ON EXIT:
                    148: **     returns         the name of the scheme, i.e.
                    149: **                     "none", "basic", "pubkey", ...
                    150: */
2.12      frystyk   151: extern char *HTAAScheme_name PARAMS((HTAAScheme scheme));
2.2       timbl     152: 
2.1       luotonen  153: 
2.7       luotonen  154: /* PUBLIC                                          HTAA_templateCaseMatch()
2.4       duns      155: **             STRING COMPARISON FUNCTION FOR FILE NAMES
                    156: **                WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
                    157: ** NOTE:
                    158: **     This is essentially the same code as in HTAA_templateMatch, but
                    159: **     it compares case insensitive (for VMS). Reason for this routine
                    160: **     is that HTAA_templateMatch gets called from several places, also 
                    161: **     there where a case sensitive match is needed, so one cannot just
                    162: **     change the HTAA_templateMatch routine for VMS.
                    163: **
                    164: ** ON ENTRY:
                    165: **     template        is a template string to match the file name
                    166: **                     agaist, may contain a single wildcard
                    167: **                     character * which matches zero or more
                    168: **                     arbitrary characters.
                    169: **     filename        is the filename (or pathname) to be matched
                    170: **                     agaist the template.
                    171: **
                    172: ** ON EXIT:
                    173: **     returns         YES, if filename matches the template.
                    174: **                     NO, otherwise.
                    175: */
2.12      frystyk   176: extern BOOL HTAA_templateCaseMatch PARAMS((CONST char * tmplate, 
2.7       luotonen  177:                                           CONST char * filename));
2.4       duns      178: 
                    179: 
2.1       luotonen  180: /* PUBLIC                                      HTAA_makeProtectionTemplate()
                    181: **             CREATE A PROTECTION TEMPLATE FOR THE FILES
                    182: **             IN THE SAME DIRECTORY AS THE GIVEN FILE
                    183: **             (Used by server if there is no fancier way for
                    184: **             it to tell the client, and by browser if server
                    185: **             didn't send WWW-ProtectionTemplate: field)
                    186: ** ON ENTRY:
                    187: **     docname is the document pathname (from URL).
                    188: **
                    189: ** ON EXIT:
                    190: **     returns a template matching docname, and other files
                    191: **             files in that directory.
                    192: **
                    193: **             E.g.  /foo/bar/x.html  =>  /foo/bar/ *
                    194: **                                                 ^
                    195: **                             Space only to prevent it from
                    196: **                             being a comment marker here,
                    197: **                             there really isn't any space.
                    198: */
2.12      frystyk   199: extern char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
2.1       luotonen  200: </PRE>
                    201: <H2>MIME Argument List Parser</H2>
                    202: <PRE>
                    203: 
                    204: /* PUBLIC                                              HTAA_parseArgList()
                    205: **             PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
                    206: ** ON ENTRY:
                    207: **     str     is a comma-separated list:
                    208: **
                    209: **                     item, item, item
                    210: **             where
                    211: **                     item ::= value
                    212: **                            | name=value
                    213: **                            | name="value"
                    214: **
                    215: **             Leading and trailing whitespace is ignored
                    216: **             everywhere except inside quotes, so the following
                    217: **             examples are equal:
                    218: **
                    219: **                     name=value,foo=bar
                    220: **                      name="value",foo="bar"
                    221: **                       name = value ,  foo = bar
                    222: **                        name = "value" ,  foo = "bar"
                    223: **
                    224: ** ON EXIT:
                    225: **     returns a list of name-value pairs (actually HTAssocList*).
                    226: **             For items with no name, just value, the name is
                    227: **             the number of order number of that item. E.g.
                    228: **             "1" for the first, etc.
                    229: */
2.12      frystyk   230: extern HTList *HTAA_parseArgList PARAMS((char * str));
2.1       luotonen  231: 
                    232: </PRE>
2.5       luotonen  233: 
2.1       luotonen  234: <PRE>
                    235: #endif /* NOT HTAAUTIL_H */
2.2       timbl     236: </PRE>End of file HTAAUtil.h.</BODY>
                    237: </HTML>

Webmaster