5.3.3.3 Diagnostics

If successful, this function returns 0. If it fails, it returns -1 as shown in the example below:

Example 5-8 Credential Mapping for HTTP Basic Authentication Pseudo Code

int Credmap_HTTP_Basic(char * domain, char * realm, char * t_uid, char * t_gid, Cred_UserPass * credential)
{
       // Use domain and realm to determine scope
       credentialList = FindAllCredentialForDomainAndRealm(domain, realm);
       
       if ( error happens )
              return -1;

       // find appropriate credential in the scope

       foreach cred in credentialList {
              if (t_uid and t_gid match) {
                     *credential = cred;
                     return 0;
              }
       }
       if ( not found and no default credential) {
              return -1;
       }

       *credential = default_credential;
       return 0;
}

Tip:

The credentials can be stored in the database with domain and realm as the key or index.