LCOV - code coverage report
Current view: top level - security/manager/ssl - nsClientAuthRemember.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 27 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  *
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef __NSCLIENTAUTHREMEMBER_H__
       8             : #define __NSCLIENTAUTHREMEMBER_H__
       9             : 
      10             : #include "mozilla/ReentrantMonitor.h"
      11             : #include "nsTHashtable.h"
      12             : #include "nsIObserver.h"
      13             : #include "nsIX509Cert.h"
      14             : #include "nsNSSCertificate.h"
      15             : #include "nsString.h"
      16             : #include "nsWeakReference.h"
      17             : #include "mozilla/Attributes.h"
      18             : 
      19             : namespace mozilla {
      20             :   class OriginAttributes;
      21             : }
      22             : 
      23             : using mozilla::OriginAttributes;
      24             : 
      25           0 : class nsClientAuthRemember
      26             : {
      27             : public:
      28             : 
      29           0 :   nsClientAuthRemember()
      30           0 :   {
      31           0 :   }
      32             : 
      33             :   nsClientAuthRemember(const nsClientAuthRemember& aOther)
      34             :   {
      35             :     this->operator=(aOther);
      36             :   }
      37             : 
      38           0 :   nsClientAuthRemember& operator=(const nsClientAuthRemember& aOther)
      39             :   {
      40           0 :     mAsciiHost = aOther.mAsciiHost;
      41           0 :     mFingerprint = aOther.mFingerprint;
      42           0 :     mDBKey = aOther.mDBKey;
      43           0 :     return *this;
      44             :   }
      45             : 
      46             :   nsCString mAsciiHost;
      47             :   nsCString mFingerprint;
      48             :   nsCString mDBKey;
      49             : };
      50             : 
      51             : 
      52             : // hash entry class
      53             : class nsClientAuthRememberEntry final : public PLDHashEntryHdr
      54             : {
      55             :   public:
      56             :     // Hash methods
      57             :     typedef const char* KeyType;
      58             :     typedef const char* KeyTypePointer;
      59             : 
      60             :     // do nothing with aHost - we require mHead to be set before we're live!
      61           0 :     explicit nsClientAuthRememberEntry(KeyTypePointer aHostWithCertUTF8)
      62           0 :     {
      63           0 :     }
      64             : 
      65           0 :     nsClientAuthRememberEntry(const nsClientAuthRememberEntry& aToCopy)
      66           0 :     {
      67           0 :       mSettings = aToCopy.mSettings;
      68           0 :     }
      69             : 
      70           0 :     ~nsClientAuthRememberEntry()
      71           0 :     {
      72           0 :     }
      73             : 
      74             :     KeyType GetKey() const
      75             :     {
      76             :       return EntryKeyPtr();
      77             :     }
      78             : 
      79             :     KeyTypePointer GetKeyPointer() const
      80             :     {
      81             :       return EntryKeyPtr();
      82             :     }
      83             : 
      84           0 :     bool KeyEquals(KeyTypePointer aKey) const
      85             :     {
      86           0 :       return !strcmp(EntryKeyPtr(), aKey);
      87             :     }
      88             : 
      89           0 :     static KeyTypePointer KeyToPointer(KeyType aKey)
      90             :     {
      91           0 :       return aKey;
      92             :     }
      93             : 
      94           0 :     static PLDHashNumber HashKey(KeyTypePointer aKey)
      95             :     {
      96           0 :       return PLDHashTable::HashStringKey(aKey);
      97             :     }
      98             : 
      99             :     enum { ALLOW_MEMMOVE = false };
     100             : 
     101             :     // get methods
     102             :     inline const nsCString& GetEntryKey() const { return mEntryKey; }
     103             : 
     104           0 :     inline KeyTypePointer EntryKeyPtr() const
     105             :     {
     106           0 :       return mEntryKey.get();
     107             :     }
     108             : 
     109             :     nsClientAuthRemember mSettings;
     110             :     nsCString mEntryKey;
     111             : };
     112             : 
     113             : class nsClientAuthRememberService final : public nsIObserver,
     114             :                                           public nsSupportsWeakReference
     115             : {
     116             : public:
     117             :   NS_DECL_THREADSAFE_ISUPPORTS
     118             :   NS_DECL_NSIOBSERVER
     119             : 
     120             :   nsClientAuthRememberService();
     121             : 
     122             :   nsresult Init();
     123             : 
     124             :   static void GetEntryKey(const nsACString& aHostName,
     125             :                           const OriginAttributes& aOriginAttributes,
     126             :                           const nsACString& aFingerprint,
     127             :                           /*out*/ nsACString& aEntryKey);
     128             : 
     129             :   nsresult RememberDecision(const nsACString& aHostName,
     130             :                             const OriginAttributes& aOriginAttributes,
     131             :                             CERTCertificate* aServerCert,
     132             :                             CERTCertificate* aClientCert);
     133             : 
     134             :   nsresult HasRememberedDecision(const nsACString& aHostName,
     135             :                                  const OriginAttributes& aOriginAttributes,
     136             :                                  CERTCertificate* aServerCert,
     137             :                                  nsACString& aCertDBKey, bool* aRetVal);
     138             : 
     139             :   void ClearRememberedDecisions();
     140             :   static void ClearAllRememberedDecisions();
     141             : 
     142             : protected:
     143             :     ~nsClientAuthRememberService();
     144             : 
     145             :     mozilla::ReentrantMonitor monitor;
     146             :     nsTHashtable<nsClientAuthRememberEntry> mSettingsTable;
     147             : 
     148             :     void RemoveAllFromMemory();
     149             :     nsresult AddEntryToList(const nsACString& aHost,
     150             :                             const OriginAttributes& aOriginAttributes,
     151             :                             const nsACString& aServerFingerprint,
     152             :                             const nsACString& aDBKey);
     153             : };
     154             : 
     155             : #endif

Generated by: LCOV version 1.13