mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
33f0551ea5
- Bug 1172382 - Enable AccessibleCaret on B2G. r=roc (f5c58c2798) - remove duplicated (8823cc4a43) - Bug 1219310 - part 1 - ask the prefs file for its size directly; r=njn (93073cbc5e) - Bug 1219310 - part 2 - keep track of how much pref file we have read; r=njn (6a2a10a8b1) - Bug 1213123 - Make Preferences::SetString accept char16ptr_t instead of char16_t*. r=froydnj (a895a36861) - Bug 1216901 - Make the FasterMake backend reticulate splines when moz.build or jar.mn files are modified. r=mshal (ed4ec93b18) - Bug 1219122 - Move webapprt.ini definition to moz.build. - Add corresponding webpprt files. (da6bc91b5c) - Bug 1219126 - Move greprefs.js definition in moz.build. r=mshal (52f404c935) - code style (1b1e543834) - Bug 1162690 - Remove malformed uri warning in nsURLParser::ParseURL r=mcmanus (8534fcebb7) - Bug 1163028 - URL: stop escaping [ and ] in path r=mcmanus (f2f3deec40) - Bug 1163030 - URL: stop escaping ` in query r=mcmanus (17d6c07640) - Bug 1191423 - Disallow illegal characters in cookies set via HTTP. r=jduell (b1786d140f) - Bug 1210235 - Skip package verification if pref out or no signature. The package would be treated unsigned. r=valentin (63870dd7ef) - Bug 1216062 - Notify OnStartSignedPackagedRequest with package identifier. r=valentin. (81a14af3db) - Bug 1214079 - Doom the package cache if the signature verification failed. r=valentin (83824c2d5d) - Bug 1178448 - Use imported CA in developer mode. r=keeler,valentin (b9cf64b477) - Bug 1216469 - Bypass verification for signed packages from trust origins. r=valentin (a36d0a6d2f) - Bug 1218284 - Match signed packages' with trust origin without suffix. r=valentin (45529dc7df) - Bug 412457 - should unescape hostname first, then perform IDNA r=mcmanus (23ebe47574) - Bug 1217316 - Remove for-each from netwerk/. r=jduell (8d0ca69e9e) - Bug 1208847 - Add telemetry to measure how often secure cookies are set from non-secure origins r=mcmanus (57ecf3651d) - Bug 1165267 - Part 1: Replace appId and inBrowser by originAttributes v2. r=honzab (7710301407) - Bug 1165267 - Fix downgrading issue by restoring appId and inBrowserElement columns v3. r=honzab (3e8b8e4dfb) - Bug 1221049 - Use originAttributes from TabContext. r=kanru (5eaebe3b28) - Bug 1197944 - Change pref so that the http auth dialog is presented for sub resources as well. r=jduell (e3a7e2a1a7) - Bug 1202421 - Rename the network.auth.allow-subresource-auth pref. r=michal (87e29e1fdf) - Bug 1213577 - Use OriginAttributes in nsHttpAuthManager, r=mcmanus (33d0a25ac4) - Bug 961049 - Part 1: Remove unused members and methods; r=baku (0f3e6de06b)
260 lines
8.1 KiB
C++
260 lines
8.1 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef nsHttpAuthCache_h__
|
|
#define nsHttpAuthCache_h__
|
|
|
|
#include "nsError.h"
|
|
#include "nsTArray.h"
|
|
#include "nsAutoPtr.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "plhash.h"
|
|
#include "nsIObserver.h"
|
|
|
|
class nsCString;
|
|
|
|
namespace mozilla {
|
|
|
|
class OriginAttributesPattern;
|
|
|
|
namespace net {
|
|
|
|
struct nsHttpAuthPath {
|
|
struct nsHttpAuthPath *mNext;
|
|
char mPath[1];
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// nsHttpAuthIdentity
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class nsHttpAuthIdentity
|
|
{
|
|
public:
|
|
nsHttpAuthIdentity()
|
|
: mUser(nullptr)
|
|
, mPass(nullptr)
|
|
, mDomain(nullptr)
|
|
{
|
|
}
|
|
nsHttpAuthIdentity(const char16_t *domain,
|
|
const char16_t *user,
|
|
const char16_t *password)
|
|
: mUser(nullptr)
|
|
{
|
|
Set(domain, user, password);
|
|
}
|
|
~nsHttpAuthIdentity()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
const char16_t *Domain() const { return mDomain; }
|
|
const char16_t *User() const { return mUser; }
|
|
const char16_t *Password() const { return mPass; }
|
|
|
|
nsresult Set(const char16_t *domain,
|
|
const char16_t *user,
|
|
const char16_t *password);
|
|
nsresult Set(const nsHttpAuthIdentity &other) { return Set(other.mDomain, other.mUser, other.mPass); }
|
|
void Clear();
|
|
|
|
bool Equals(const nsHttpAuthIdentity &other) const;
|
|
bool IsEmpty() const { return !mUser; }
|
|
|
|
private:
|
|
// allocated as one contiguous blob, starting at mUser.
|
|
char16_t *mUser;
|
|
char16_t *mPass;
|
|
char16_t *mDomain;
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// nsHttpAuthEntry
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class nsHttpAuthEntry
|
|
{
|
|
public:
|
|
const char *Realm() const { return mRealm; }
|
|
const char *Creds() const { return mCreds; }
|
|
const char *Challenge() const { return mChallenge; }
|
|
const char16_t *Domain() const { return mIdent.Domain(); }
|
|
const char16_t *User() const { return mIdent.User(); }
|
|
const char16_t *Pass() const { return mIdent.Password(); }
|
|
nsHttpAuthPath *RootPath() { return mRoot; }
|
|
|
|
const nsHttpAuthIdentity &Identity() const { return mIdent; }
|
|
|
|
nsresult AddPath(const char *aPath);
|
|
|
|
nsCOMPtr<nsISupports> mMetaData;
|
|
|
|
private:
|
|
nsHttpAuthEntry(const char *path,
|
|
const char *realm,
|
|
const char *creds,
|
|
const char *challenge,
|
|
const nsHttpAuthIdentity *ident,
|
|
nsISupports *metadata)
|
|
: mRoot(nullptr)
|
|
, mTail(nullptr)
|
|
, mRealm(nullptr)
|
|
{
|
|
Set(path, realm, creds, challenge, ident, metadata);
|
|
}
|
|
~nsHttpAuthEntry();
|
|
|
|
nsresult Set(const char *path,
|
|
const char *realm,
|
|
const char *creds,
|
|
const char *challenge,
|
|
const nsHttpAuthIdentity *ident,
|
|
nsISupports *metadata);
|
|
|
|
nsHttpAuthIdentity mIdent;
|
|
|
|
nsHttpAuthPath *mRoot; //root pointer
|
|
nsHttpAuthPath *mTail; //tail pointer
|
|
|
|
// allocated together in one blob, starting with mRealm.
|
|
char *mRealm;
|
|
char *mCreds;
|
|
char *mChallenge;
|
|
|
|
friend class nsHttpAuthNode;
|
|
friend class nsHttpAuthCache;
|
|
friend class nsAutoPtr<nsHttpAuthEntry>; // needs to call the destructor
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// nsHttpAuthNode
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class nsHttpAuthNode
|
|
{
|
|
private:
|
|
nsHttpAuthNode();
|
|
~nsHttpAuthNode();
|
|
|
|
// path can be null, in which case we'll search for an entry
|
|
// with a null path.
|
|
nsHttpAuthEntry *LookupEntryByPath(const char *path);
|
|
|
|
// realm must not be null
|
|
nsHttpAuthEntry *LookupEntryByRealm(const char *realm);
|
|
|
|
// if a matching entry is found, then credentials will be changed.
|
|
nsresult SetAuthEntry(const char *path,
|
|
const char *realm,
|
|
const char *credentials,
|
|
const char *challenge,
|
|
const nsHttpAuthIdentity *ident,
|
|
nsISupports *metadata);
|
|
|
|
void ClearAuthEntry(const char *realm);
|
|
|
|
uint32_t EntryCount() { return mList.Length(); }
|
|
|
|
private:
|
|
nsTArray<nsAutoPtr<nsHttpAuthEntry> > mList;
|
|
|
|
friend class nsHttpAuthCache;
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// nsHttpAuthCache
|
|
// (holds a hash table from host:port to nsHttpAuthNode)
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class nsHttpAuthCache
|
|
{
|
|
public:
|
|
nsHttpAuthCache();
|
|
~nsHttpAuthCache();
|
|
|
|
nsresult Init();
|
|
|
|
// |scheme|, |host|, and |port| are required
|
|
// |path| can be null
|
|
// |entry| is either null or a weak reference
|
|
nsresult GetAuthEntryForPath(const char *scheme,
|
|
const char *host,
|
|
int32_t port,
|
|
const char *path,
|
|
nsACString const &originSuffix,
|
|
nsHttpAuthEntry **entry);
|
|
|
|
// |scheme|, |host|, and |port| are required
|
|
// |realm| must not be null
|
|
// |entry| is either null or a weak reference
|
|
nsresult GetAuthEntryForDomain(const char *scheme,
|
|
const char *host,
|
|
int32_t port,
|
|
const char *realm,
|
|
nsACString const &originSuffix,
|
|
nsHttpAuthEntry **entry);
|
|
|
|
// |scheme|, |host|, and |port| are required
|
|
// |path| can be null
|
|
// |realm| must not be null
|
|
// if |credentials|, |user|, |pass|, and |challenge| are each
|
|
// null, then the entry is deleted.
|
|
nsresult SetAuthEntry(const char *scheme,
|
|
const char *host,
|
|
int32_t port,
|
|
const char *directory,
|
|
const char *realm,
|
|
const char *credentials,
|
|
const char *challenge,
|
|
nsACString const &originSuffix,
|
|
const nsHttpAuthIdentity *ident,
|
|
nsISupports *metadata);
|
|
|
|
void ClearAuthEntry(const char *scheme,
|
|
const char *host,
|
|
int32_t port,
|
|
const char *realm,
|
|
nsACString const &originSuffix);
|
|
|
|
// expire all existing auth list entries including proxy auths.
|
|
nsresult ClearAll();
|
|
|
|
private:
|
|
nsHttpAuthNode *LookupAuthNode(const char *scheme,
|
|
const char *host,
|
|
int32_t port,
|
|
nsACString const &originSuffix,
|
|
nsCString &key);
|
|
|
|
// hash table allocation functions
|
|
static void* AllocTable(void *, size_t size);
|
|
static void FreeTable(void *, void *item);
|
|
static PLHashEntry* AllocEntry(void *, const void *key);
|
|
static void FreeEntry(void *, PLHashEntry *he, unsigned flag);
|
|
|
|
static PLHashAllocOps gHashAllocOps;
|
|
|
|
class OriginClearObserver : public nsIObserver {
|
|
virtual ~OriginClearObserver() {}
|
|
public:
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIOBSERVER
|
|
explicit OriginClearObserver(nsHttpAuthCache* aOwner) : mOwner(aOwner) {}
|
|
nsHttpAuthCache* mOwner;
|
|
};
|
|
|
|
void ClearOriginData(OriginAttributesPattern const &pattern);
|
|
|
|
private:
|
|
PLHashTable *mDB; // "host:port" --> nsHttpAuthNode
|
|
RefPtr<OriginClearObserver> mObserver;
|
|
};
|
|
|
|
} // namespace net
|
|
} // namespace mozilla
|
|
|
|
#endif // nsHttpAuthCache_h__
|