Added getSigners API for SmartUpate

This commit is contained in:
raman%netscape.com 1998-09-02 19:10:57 +00:00
parent 51b564df36
commit 5f24c79522
2 changed files with 57 additions and 0 deletions

View File

@ -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 */

View File

@ -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
//