Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends
nsHttpAuthEntry Class Reference

#include <nsHttpAuthCache.h>

Collaboration diagram for nsHttpAuthEntry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

const char * Realm () const
const char * Creds () const
const char * Challenge () const
const PRUnicharDomain () const
const PRUnicharUser () const
const PRUnicharPass () const
nsHttpAuthPathRootPath ()
const nsHttpAuthIdentityIdentity () const
nsresult AddPath (const char *aPath)

Public Attributes

nsCOMPtr< nsISupports > mMetaData

Private Member Functions

 nsHttpAuthEntry (const char *path, const char *realm, const char *creds, const char *challenge, const nsHttpAuthIdentity &ident, nsISupports *metadata)
 ~nsHttpAuthEntry ()
nsresult Set (const char *path, const char *realm, const char *creds, const char *challenge, const nsHttpAuthIdentity &ident, nsISupports *metadata)

Private Attributes

nsHttpAuthIdentity mIdent
nsHttpAuthPathmRoot
nsHttpAuthPathmTail
char * mRealm
char * mCreds
char * mChallenge

Friends

class nsHttpAuthNode
class nsHttpAuthCache

Detailed Description

Definition at line 107 of file nsHttpAuthCache.h.


Constructor & Destructor Documentation

nsHttpAuthEntry::nsHttpAuthEntry ( const char *  path,
const char *  realm,
const char *  creds,
const char *  challenge,
const nsHttpAuthIdentity ident,
nsISupports *  metadata 
) [inline, private]

Definition at line 125 of file nsHttpAuthCache.h.

        : mRoot(nsnull)
        , mTail(nsnull)
        , mRealm(nsnull)
    {
        Set(path, realm, creds, challenge, ident, metadata);
    }

Here is the call graph for this function:

Definition at line 336 of file nsHttpAuthCache.cpp.

{
    if (mRealm)
        free(mRealm);

    while (mRoot) {
        nsHttpAuthPath *ap = mRoot;
        mRoot = mRoot->mNext;
        free(ap);
    }
}

Member Function Documentation

Definition at line 349 of file nsHttpAuthCache.cpp.

{
    // null path matches empty path
    if (!aPath)
        aPath = "";

    nsHttpAuthPath *tempPtr = mRoot;
    while (tempPtr) {
        const char *curpath = tempPtr->mPath;
        if (strncmp(aPath, curpath, nsCRT::strlen(curpath)) == 0)
            return NS_OK; // subpath already exists in the list

        tempPtr = tempPtr->mNext;

    }
    
    //Append the aPath
    nsHttpAuthPath *newAuthPath;
    int newpathLen = nsCRT::strlen(aPath);
    newAuthPath = (nsHttpAuthPath *) malloc(sizeof(nsHttpAuthPath) + newpathLen);
    if (!newAuthPath)
        return NS_ERROR_OUT_OF_MEMORY;

    memcpy(newAuthPath->mPath, aPath, newpathLen+1);
    newAuthPath->mNext = nsnull;

    if (!mRoot)
        mRoot = newAuthPath; //first entry
    else
        mTail->mNext = newAuthPath; // Append newAuthPath

    //update the tail pointer.
    mTail = newAuthPath;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* nsHttpAuthEntry::Challenge ( ) const [inline]

Definition at line 112 of file nsHttpAuthCache.h.

{ return mChallenge; }

Here is the caller graph for this function:

const char* nsHttpAuthEntry::Creds ( ) const [inline]

Definition at line 111 of file nsHttpAuthCache.h.

{ return mCreds; }

Here is the caller graph for this function:

Definition at line 113 of file nsHttpAuthCache.h.

{ return mIdent.Domain(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 118 of file nsHttpAuthCache.h.

{ return mIdent; }

Here is the caller graph for this function:

const PRUnichar* nsHttpAuthEntry::Pass ( ) const [inline]

Definition at line 115 of file nsHttpAuthCache.h.

{ return mIdent.Password(); }

Here is the call graph for this function:

const char* nsHttpAuthEntry::Realm ( ) const [inline]

Definition at line 110 of file nsHttpAuthCache.h.

{ return mRealm; }

Here is the caller graph for this function:

Definition at line 116 of file nsHttpAuthCache.h.

{ return mRoot; }

Here is the caller graph for this function:

nsresult nsHttpAuthEntry::Set ( const char *  path,
const char *  realm,
const char *  creds,
const char *  challenge,
const nsHttpAuthIdentity ident,
nsISupports *  metadata 
) [private]

Definition at line 386 of file nsHttpAuthCache.cpp.

{
    char *newRealm, *newCreds, *newChall;

    int realmLen = realm ? nsCRT::strlen(realm) : 0;
    int credsLen = creds ? nsCRT::strlen(creds) : 0;
    int challLen = chall ? nsCRT::strlen(chall) : 0;

    int len = realmLen + 1 + credsLen + 1 + challLen + 1;
    newRealm = (char *) malloc(len);
    if (!newRealm)
        return NS_ERROR_OUT_OF_MEMORY;

    if (realm)
        memcpy(newRealm, realm, realmLen);
    newRealm[realmLen] = 0;

    newCreds = &newRealm[realmLen + 1];
    if (creds)
        memcpy(newCreds, creds, credsLen);
    newCreds[credsLen] = 0;

    newChall = &newCreds[credsLen + 1];
    if (chall)
        memcpy(newChall, chall, challLen);
    newChall[challLen] = 0;

    nsresult rv = mIdent.Set(ident);
    if (NS_FAILED(rv)) {
        free(newRealm);
        return rv;
    }

    rv = AddPath(path);
    if (NS_FAILED(rv)) {
        free(newRealm);
        return rv;
    }

    // wait until the end to clear member vars in case input params
    // reference our members!
    if (mRealm)
        free(mRealm);

    mRealm = newRealm;
    mCreds = newCreds;
    mChallenge = newChall;
    mMetaData = metadata;

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const PRUnichar* nsHttpAuthEntry::User ( ) const [inline]

Definition at line 114 of file nsHttpAuthCache.h.

{ return mIdent.User(); }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsHttpAuthCache [friend]

Definition at line 157 of file nsHttpAuthCache.h.

friend class nsHttpAuthNode [friend]

Definition at line 156 of file nsHttpAuthCache.h.


Member Data Documentation

char* nsHttpAuthEntry::mChallenge [private]

Definition at line 154 of file nsHttpAuthCache.h.

char* nsHttpAuthEntry::mCreds [private]

Definition at line 153 of file nsHttpAuthCache.h.

Definition at line 146 of file nsHttpAuthCache.h.

Definition at line 122 of file nsHttpAuthCache.h.

char* nsHttpAuthEntry::mRealm [private]

Definition at line 152 of file nsHttpAuthCache.h.

Definition at line 148 of file nsHttpAuthCache.h.

Definition at line 149 of file nsHttpAuthCache.h.


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