michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __RECENTBADCERTS_H__ michael@0: #define __RECENTBADCERTS_H__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/ReentrantMonitor.h" michael@0: michael@0: #include "nsIRecentBadCertsService.h" michael@0: #include "nsTHashtable.h" michael@0: #include "nsString.h" michael@0: #include "cert.h" michael@0: #include "secitem.h" michael@0: michael@0: class RecentBadCert michael@0: { michael@0: public: michael@0: michael@0: RecentBadCert() michael@0: { michael@0: mDERCert.len = 0; michael@0: mDERCert.data = nullptr; michael@0: isDomainMismatch = false; michael@0: isNotValidAtThisTime = false; michael@0: isUntrusted = false; michael@0: } michael@0: michael@0: ~RecentBadCert() michael@0: { michael@0: Clear(); michael@0: } michael@0: michael@0: void Clear() michael@0: { michael@0: mHostWithPort.Truncate(); michael@0: if (mDERCert.len) michael@0: nsMemory::Free(mDERCert.data); michael@0: mDERCert.len = 0; michael@0: mDERCert.data = nullptr; michael@0: } michael@0: michael@0: nsString mHostWithPort; michael@0: SECItem mDERCert; michael@0: bool isDomainMismatch; michael@0: bool isNotValidAtThisTime; michael@0: bool isUntrusted; michael@0: michael@0: private: michael@0: RecentBadCert(const RecentBadCert &other) MOZ_DELETE; michael@0: RecentBadCert &operator=(const RecentBadCert &other) MOZ_DELETE; michael@0: }; michael@0: michael@0: class nsRecentBadCerts MOZ_FINAL : public nsIRecentBadCerts michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIRECENTBADCERTS michael@0: michael@0: nsRecentBadCerts(); michael@0: ~nsRecentBadCerts(); michael@0: michael@0: protected: michael@0: mozilla::ReentrantMonitor monitor; michael@0: michael@0: enum {const_recently_seen_list_size = 5}; michael@0: RecentBadCert mCerts[const_recently_seen_list_size]; michael@0: michael@0: // will be in the range of 0 to list_size-1 michael@0: uint32_t mNextStorePosition; michael@0: }; michael@0: michael@0: #define NS_RECENTBADCERTS_CID { /* e7caf8c0-3570-47fe-aa1b-da47539b5d07 */ \ michael@0: 0xe7caf8c0, \ michael@0: 0x3570, \ michael@0: 0x47fe, \ michael@0: {0xaa, 0x1b, 0xda, 0x47, 0x53, 0x9b, 0x5d, 0x07} \ michael@0: } michael@0: michael@0: #endif