From 8a29b1f0b1bbb3acd927347790bdc614bac15884 Mon Sep 17 00:00:00 2001 From: "raman%netscape.com" Date: Wed, 2 Sep 1998 19:10:57 +0000 Subject: [PATCH] Added getSigners API for SmartUpate git-svn-id: svn://10.0.0.236/trunk@9136 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/caps/include/nsPrincipal.h | 3 ++ mozilla/caps/src/nsPrincipal.cpp | 54 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/mozilla/caps/include/nsPrincipal.h b/mozilla/caps/include/nsPrincipal.h index c56420dc90d..04e1d8f2987 100755 --- a/mozilla/caps/include/nsPrincipal.h +++ b/mozilla/caps/include/nsPrincipal.h @@ -82,6 +82,9 @@ public: char * savePrincipalPermanently(void); + /* Caller should free the principals and the Principal array */ + static nsPrincipalArray* getSigners(void* zigPtr, char* pathname); + private: /* Private Field Accessors */ diff --git a/mozilla/caps/src/nsPrincipal.cpp b/mozilla/caps/src/nsPrincipal.cpp index e316d3693b4..712fd2bfa62 100755 --- a/mozilla/caps/src/nsPrincipal.cpp +++ b/mozilla/caps/src/nsPrincipal.cpp @@ -436,6 +436,60 @@ char * nsPrincipal::savePrincipalPermanently(void) } +/* The following used to be LJ_GetCertificates */ +nsPrincipalArray* nsPrincipal::getSigners(void* zigPtr, char* pathname) +{ + SOBITEM *item; + ZIG *zig = (ZIG *)zigPtr; + struct nsPrincipal *principal; + ZIG_Context * context; + FINGERZIG *fingPrint; + int size=0; + int slot=0; + + if (!pathname) + return NULL; + + if (!zig) { + return NULL; + } + + /* count the number of signers */ + if ((context = SOB_find(zig, pathname, ZIG_SIGN)) == NULL) + return NULL; + while (SOB_find_next (context, &item) >= 0) { + size++; + } + SOB_find_end(context); + + /* Now allocate the array */ + nsPrincipalArray *result = new nsPrincipalArray(); + result->SetSize(size, 1); + if (result == NULL) { + return NULL; + } + + if ((context = SOB_find(zig, pathname, ZIG_SIGN)) == NULL) { + return NULL; + } + while (SOB_find_next(context, &item) >= 0) { + PR_ASSERT(slot < size); + + /* Allocate the Cert's FP and put them in an array */ + fingPrint = (FINGERZIG *) item->data; + principal = nsCapsNewPrincipal(nsPrincipalType_CertKey, + fingPrint->key, + fingPrint->length, + zig); + nsCapsSetPrincipalArrayElement(result, slot++, principal); + + } + SOB_find_end(context); + + return result; +} + + // // PRIVATE METHODS //