LCOV - code coverage report
Current view: directory - security/manager/ssl/src - nsCertTree.h (source / functions) Found Hit Coverage
Test: app.info Lines: 3 0 0.0 %
Date: 2012-06-02 Functions: 3 0 0.0 %

       1                 : /* ***** BEGIN LICENSE BLOCK *****
       2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       3                 :  *
       4                 :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :  * the License. You may obtain a copy of the License at
       7                 :  * http://www.mozilla.org/MPL/
       8                 :  *
       9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :  * for the specific language governing rights and limitations under the
      12                 :  * License.
      13                 :  *
      14                 :  * The Original Code is the Netscape security libraries.
      15                 :  *
      16                 :  * The Initial Developer of the Original Code is
      17                 :  * Netscape Communications Corporation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2000
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Ian McGreer <mcgreer@netscape.com>
      23                 :  *   Kai Engert <kengert@redhat.com>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef _NS_CERTTREE_H_
      40                 : #define _NS_CERTTREE_H_
      41                 : 
      42                 : #include "nsCOMPtr.h"
      43                 : #include "nsAutoPtr.h"
      44                 : #include "nsIServiceManager.h"
      45                 : #include "nsICertTree.h"
      46                 : #include "nsITreeView.h"
      47                 : #include "nsITreeBoxObject.h"
      48                 : #include "nsITreeSelection.h"
      49                 : #include "nsISupportsArray.h"
      50                 : #include "nsIMutableArray.h"
      51                 : #include "nsTArray.h"
      52                 : #include "pldhash.h"
      53                 : #include "nsIX509CertDB.h"
      54                 : #include "nsCertOverrideService.h"
      55                 : 
      56                 : 
      57                 : typedef struct treeArrayElStr treeArrayEl;
      58                 : 
      59               0 : struct CompareCacheHashEntry {
      60                 :   enum { max_criterions = 3 };
      61                 :   CompareCacheHashEntry();
      62                 : 
      63                 :   void *key; // no ownership
      64                 :   bool mCritInit[max_criterions];
      65                 :   nsXPIDLString mCrit[max_criterions];
      66                 : };
      67                 : 
      68                 : struct CompareCacheHashEntryPtr : PLDHashEntryHdr {
      69                 :   CompareCacheHashEntryPtr();
      70                 :   ~CompareCacheHashEntryPtr();
      71                 :   CompareCacheHashEntry *entry;
      72                 : };
      73                 : 
      74                 : class nsCertAddonInfo : public nsISupports
      75               0 : {
      76                 : public:
      77                 :   NS_DECL_ISUPPORTS
      78                 : 
      79               0 :   nsCertAddonInfo() : mUsageCount(0) {}
      80                 : 
      81                 :   nsRefPtr<nsIX509Cert> mCert;
      82                 :   // how many display entries reference this?
      83                 :   // (and therefore depend on the underlying cert)
      84                 :   PRInt32 mUsageCount;
      85                 : };
      86                 : 
      87                 : class nsCertTreeDispInfo : public nsICertTreeItem
      88                 : {
      89                 : public:
      90                 :   NS_DECL_ISUPPORTS
      91                 :   NS_DECL_NSICERTTREEITEM
      92                 : 
      93                 :   nsCertTreeDispInfo();
      94                 :   nsCertTreeDispInfo(nsCertTreeDispInfo &other);
      95                 :   virtual ~nsCertTreeDispInfo();
      96                 : 
      97                 :   nsRefPtr<nsCertAddonInfo> mAddonInfo;
      98                 :   enum {
      99                 :     direct_db, host_port_override
     100                 :   } mTypeOfEntry;
     101                 :   nsCString mAsciiHost;
     102                 :   PRInt32 mPort;
     103                 :   nsCertOverride::OverrideBits mOverrideBits;
     104                 :   bool mIsTemporary;
     105                 :   nsCOMPtr<nsIX509Cert> mCert;
     106                 : };
     107                 : 
     108                 : class nsCertTree : public nsICertTree
     109                 : {
     110                 : public:
     111                 :   NS_DECL_ISUPPORTS
     112                 :   NS_DECL_NSICERTTREE
     113                 :   NS_DECL_NSITREEVIEW
     114                 : 
     115                 :   nsCertTree();
     116                 :   virtual ~nsCertTree();
     117                 : 
     118                 :   enum sortCriterion { sort_IssuerOrg, sort_Org, sort_Token, 
     119                 :     sort_CommonName, sort_IssuedDateDescending, sort_Email, sort_None };
     120                 : 
     121                 : protected:
     122                 :   nsresult InitCompareHash();
     123                 :   void ClearCompareHash();
     124                 :   void RemoveCacheEntry(void *key);
     125                 : 
     126                 :   typedef int (*nsCertCompareFunc)(void *, nsIX509Cert *a, nsIX509Cert *b);
     127                 : 
     128                 :   static CompareCacheHashEntry *getCacheEntry(void *cache, void *aCert);
     129                 :   static void CmpInitCriterion(nsIX509Cert *cert, CompareCacheHashEntry *entry,
     130                 :                                sortCriterion crit, PRInt32 level);
     131                 :   static PRInt32 CmpByCrit(nsIX509Cert *a, CompareCacheHashEntry *ace, 
     132                 :                            nsIX509Cert *b, CompareCacheHashEntry *bce, 
     133                 :                            sortCriterion crit, PRInt32 level);
     134                 :   static PRInt32 CmpBy(void *cache, nsIX509Cert *a, nsIX509Cert *b, 
     135                 :                        sortCriterion c0, sortCriterion c1, sortCriterion c2);
     136                 :   static PRInt32 CmpCACert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     137                 :   static PRInt32 CmpWebSiteCert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     138                 :   static PRInt32 CmpUserCert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     139                 :   static PRInt32 CmpEmailCert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     140                 :   nsCertCompareFunc GetCompareFuncFromCertType(PRUint32 aType);
     141                 :   PRInt32 CountOrganizations();
     142                 : 
     143                 :   nsresult GetCertsByType(PRUint32 aType, nsCertCompareFunc aCertCmpFn,
     144                 :                           void *aCertCmpFnArg);
     145                 : 
     146                 :   nsresult GetCertsByTypeFromCache(nsINSSCertCache *aCache, PRUint32 aType,
     147                 :                                    nsCertCompareFunc aCertCmpFn, void *aCertCmpFnArg);
     148                 : private:
     149                 :   nsTArray< nsRefPtr<nsCertTreeDispInfo> > mDispInfo;
     150                 :   nsCOMPtr<nsITreeBoxObject>  mTree;
     151                 :   nsCOMPtr<nsITreeSelection>  mSelection;
     152                 :   treeArrayEl                *mTreeArray;
     153                 :   PRInt32                         mNumOrgs;
     154                 :   PRInt32                         mNumRows;
     155                 :   PLDHashTable mCompareCache;
     156                 :   nsCOMPtr<nsINSSComponent> mNSSComponent;
     157                 :   nsCOMPtr<nsICertOverrideService> mOverrideService;
     158                 :   nsRefPtr<nsCertOverrideService> mOriginalOverrideService;
     159                 : 
     160                 :   treeArrayEl *GetThreadDescAtIndex(PRInt32 _index);
     161                 :   already_AddRefed<nsIX509Cert> 
     162                 :     GetCertAtIndex(PRInt32 _index, PRInt32 *outAbsoluteCertOffset = nsnull);
     163                 :   already_AddRefed<nsCertTreeDispInfo> 
     164                 :     GetDispInfoAtIndex(PRInt32 index, PRInt32 *outAbsoluteCertOffset = nsnull);
     165                 :   void FreeCertArray();
     166                 :   nsresult UpdateUIContents();
     167                 : 
     168                 :   nsresult GetCertsByTypeFromCertList(CERTCertList *aCertList,
     169                 :                                       PRUint32 aType,
     170                 :                                       nsCertCompareFunc  aCertCmpFn,
     171                 :                                       void              *aCertCmpFnArg);
     172                 : 
     173                 :   nsCOMPtr<nsIMutableArray> mCellText;
     174                 : 
     175                 : #ifdef DEBUG_CERT_TREE
     176                 :   /* for debugging purposes */
     177                 :   void dumpMap();
     178                 : #endif
     179                 : };
     180                 : 
     181                 : #endif /* _NS_CERTTREE_H_ */
     182                 : 

Generated by: LCOV version 1.7