Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
nsHttpAuthCache Class Reference

#include <nsHttpAuthCache.h>

Collaboration diagram for nsHttpAuthCache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsHttpAuthCache ()
 ~nsHttpAuthCache ()
nsresult Init ()
nsresult GetAuthEntryForPath (const char *scheme, const char *host, PRInt32 port, const char *path, nsHttpAuthEntry **entry)
nsresult GetAuthEntryForDomain (const char *scheme, const char *host, PRInt32 port, const char *realm, nsHttpAuthEntry **entry)
nsresult SetAuthEntry (const char *scheme, const char *host, PRInt32 port, const char *directory, const char *realm, const char *credentials, const char *challenge, const nsHttpAuthIdentity &ident, nsISupports *metadata)
void ClearAuthEntry (const char *scheme, const char *host, PRInt32 port, const char *realm)
nsresult ClearAll ()

Private Member Functions

nsHttpAuthNodeLookupAuthNode (const char *scheme, const char *host, PRInt32 port, nsCString &key)

Static Private Member Functions

static void *PR_CALLBACK AllocTable (void *, PRSize size)
static void PR_CALLBACK FreeTable (void *, void *item)
static PLHashEntry *PR_CALLBACK AllocEntry (void *, const void *key)
static void PR_CALLBACK FreeEntry (void *, PLHashEntry *he, PRUintn flag)

Private Attributes

PLHashTablemDB

Static Private Attributes

static PLHashAllocOps gHashAllocOps

Detailed Description

Definition at line 200 of file nsHttpAuthCache.h.


Constructor & Destructor Documentation

Definition at line 75 of file nsHttpAuthCache.cpp.

    : mDB(nsnull)
{
}

Definition at line 80 of file nsHttpAuthCache.cpp.

{
    if (mDB)
        ClearAll();
}

Here is the call graph for this function:


Member Function Documentation

PLHashEntry * nsHttpAuthCache::AllocEntry ( void self,
const void key 
) [static, private]

Definition at line 238 of file nsHttpAuthCache.cpp.

{
    return (PLHashEntry *) malloc(sizeof(PLHashEntry));
}
void * nsHttpAuthCache::AllocTable ( void self,
PRSize  size 
) [static, private]

Definition at line 226 of file nsHttpAuthCache.cpp.

{
    return malloc(size);
}

Definition at line 196 of file nsHttpAuthCache.cpp.

{
    LOG(("nsHttpAuthCache::ClearAll\n"));

    if (mDB) {
        PL_HashTableDestroy(mDB);
        mDB = 0;
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsHttpAuthCache::ClearAuthEntry ( const char *  scheme,
const char *  host,
PRInt32  port,
const char *  realm 
)

Definition at line 182 of file nsHttpAuthCache.cpp.

{
    if (!mDB)
        return;

    nsCAutoString key;
    GetAuthKey(scheme, host, port, key);
    PL_HashTableRemove(mDB, key.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsHttpAuthCache::FreeEntry ( void self,
PLHashEntry he,
PRUintn  flag 
) [static, private]

Definition at line 244 of file nsHttpAuthCache.cpp.

{
    if (flag == HT_FREE_VALUE) {
        // this would only happen if PL_HashTableAdd were to replace an
        // existing entry in the hash table, but we _always_ do a lookup
        // before adding a new entry to avoid this case.
        NS_NOTREACHED("should never happen");
    }
    else if (flag == HT_FREE_ENTRY) {
        // three wonderful flavors of freeing memory ;-)
        delete (nsHttpAuthNode *) he->value;
        nsCRT::free((char *) he->key);
        free(he);
    }
}
void nsHttpAuthCache::FreeTable ( void self,
void item 
) [static, private]

Definition at line 232 of file nsHttpAuthCache.cpp.

{
    free(item);
}
nsresult nsHttpAuthCache::GetAuthEntryForDomain ( const char *  scheme,
const char *  host,
PRInt32  port,
const char *  realm,
nsHttpAuthEntry **  entry 
)

Definition at line 122 of file nsHttpAuthCache.cpp.

{
    LOG(("nsHttpAuthCache::GetAuthEntryForDomain [key=%s://%s:%d realm=%s]\n",
        scheme, host, port, realm));

    nsCAutoString key;
    nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, key);
    if (!node)
        return NS_ERROR_NOT_AVAILABLE;

    *entry = node->LookupEntryByRealm(realm);
    return *entry ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpAuthCache::GetAuthEntryForPath ( const char *  scheme,
const char *  host,
PRInt32  port,
const char *  path,
nsHttpAuthEntry **  entry 
)

Definition at line 103 of file nsHttpAuthCache.cpp.

{
    LOG(("nsHttpAuthCache::GetAuthEntryForPath [key=%s://%s:%d path=%s]\n",
        scheme, host, port, path));

    nsCAutoString key;
    nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, key);
    if (!node)
        return NS_ERROR_NOT_AVAILABLE;

    *entry = node->LookupEntryByPath(path);
    return *entry ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 87 of file nsHttpAuthCache.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsHttpAuthNode * nsHttpAuthCache::LookupAuthNode ( const char *  scheme,
const char *  host,
PRInt32  port,
nsCString key 
) [private]

Definition at line 212 of file nsHttpAuthCache.cpp.

{
    if (!mDB)
        return nsnull;

    GetAuthKey(scheme, host, port, key);

    return (nsHttpAuthNode *) PL_HashTableLookup(mDB, key.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHttpAuthCache::SetAuthEntry ( const char *  scheme,
const char *  host,
PRInt32  port,
const char *  directory,
const char *  realm,
const char *  credentials,
const char *  challenge,
const nsHttpAuthIdentity ident,
nsISupports *  metadata 
)

Definition at line 142 of file nsHttpAuthCache.cpp.

{
    nsresult rv;

    LOG(("nsHttpAuthCache::SetAuthEntry [key=%s://%s:%d realm=%s path=%s metadata=%x]\n",
        scheme, host, port, realm, path, metadata));

    if (!mDB) {
        rv = Init();
        if (NS_FAILED(rv)) return rv;
    }

    nsCAutoString key;
    nsHttpAuthNode *node = LookupAuthNode(scheme, host, port, key);

    if (!node) {
        // create a new entry node and set the given entry
        node = new nsHttpAuthNode();
        if (!node)
            return NS_ERROR_OUT_OF_MEMORY;
        rv = node->SetAuthEntry(path, realm, creds, challenge, ident, metadata);
        if (NS_FAILED(rv))
            delete node;
        else
            PL_HashTableAdd(mDB, nsCRT::strdup(key.get()), node);
        return rv;
    }

    return node->SetAuthEntry(path, realm, creds, challenge, ident, metadata);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 264 of file nsHttpAuthCache.h.


The documentation for this class was generated from the following files: