diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /security/manager/ssl/nsClientAuthRemember.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'security/manager/ssl/nsClientAuthRemember.h')
-rw-r--r-- | security/manager/ssl/nsClientAuthRemember.h | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/security/manager/ssl/nsClientAuthRemember.h b/security/manager/ssl/nsClientAuthRemember.h new file mode 100644 index 000000000..1be5601ce --- /dev/null +++ b/security/manager/ssl/nsClientAuthRemember.h @@ -0,0 +1,155 @@ +/* -*- 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 __NSCLIENTAUTHREMEMBER_H__ +#define __NSCLIENTAUTHREMEMBER_H__ + +#include "mozilla/ReentrantMonitor.h" +#include "nsTHashtable.h" +#include "nsIObserver.h" +#include "nsIX509Cert.h" +#include "nsNSSCertificate.h" +#include "nsString.h" +#include "nsWeakReference.h" +#include "mozilla/Attributes.h" + +namespace mozilla { + class NeckoOriginAttributes; +} + +using mozilla::NeckoOriginAttributes; + +class nsClientAuthRemember +{ +public: + + nsClientAuthRemember() + { + } + + nsClientAuthRemember(const nsClientAuthRemember& aOther) + { + this->operator=(aOther); + } + + nsClientAuthRemember& operator=(const nsClientAuthRemember& aOther) + { + mAsciiHost = aOther.mAsciiHost; + mFingerprint = aOther.mFingerprint; + mDBKey = aOther.mDBKey; + return *this; + } + + nsCString mAsciiHost; + nsCString mFingerprint; + nsCString mDBKey; +}; + + +// hash entry class +class nsClientAuthRememberEntry final : public PLDHashEntryHdr +{ + public: + // Hash methods + typedef const char* KeyType; + typedef const char* KeyTypePointer; + + // do nothing with aHost - we require mHead to be set before we're live! + explicit nsClientAuthRememberEntry(KeyTypePointer aHostWithCertUTF8) + { + } + + nsClientAuthRememberEntry(const nsClientAuthRememberEntry& aToCopy) + { + mSettings = aToCopy.mSettings; + } + + ~nsClientAuthRememberEntry() + { + } + + KeyType GetKey() const + { + return EntryKeyPtr(); + } + + KeyTypePointer GetKeyPointer() const + { + return EntryKeyPtr(); + } + + bool KeyEquals(KeyTypePointer aKey) const + { + return !strcmp(EntryKeyPtr(), aKey); + } + + static KeyTypePointer KeyToPointer(KeyType aKey) + { + return aKey; + } + + static PLDHashNumber HashKey(KeyTypePointer aKey) + { + return PLDHashTable::HashStringKey(aKey); + } + + enum { ALLOW_MEMMOVE = false }; + + // get methods + inline const nsCString& GetEntryKey() const { return mEntryKey; } + + inline KeyTypePointer EntryKeyPtr() const + { + return mEntryKey.get(); + } + + nsClientAuthRemember mSettings; + nsCString mEntryKey; +}; + +class nsClientAuthRememberService final : public nsIObserver, + public nsSupportsWeakReference +{ +public: + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSIOBSERVER + + nsClientAuthRememberService(); + + nsresult Init(); + + static void GetEntryKey(const nsACString& aHostName, + const NeckoOriginAttributes& aOriginAttributes, + const nsACString& aFingerprint, + /*out*/ nsACString& aEntryKey); + + nsresult RememberDecision(const nsACString& aHostName, + const NeckoOriginAttributes& aOriginAttributes, + CERTCertificate* aServerCert, + CERTCertificate* aClientCert); + + nsresult HasRememberedDecision(const nsACString& aHostName, + const NeckoOriginAttributes& aOriginAttributes, + CERTCertificate* aServerCert, + nsACString& aCertDBKey, bool* aRetVal); + + void ClearRememberedDecisions(); + static void ClearAllRememberedDecisions(); + +protected: + ~nsClientAuthRememberService(); + + mozilla::ReentrantMonitor monitor; + nsTHashtable<nsClientAuthRememberEntry> mSettingsTable; + + void RemoveAllFromMemory(); + nsresult AddEntryToList(const nsACString& aHost, + const NeckoOriginAttributes& aOriginAttributes, + const nsACString& aServerFingerprint, + const nsACString& aDBKey); +}; + +#endif |