mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 02:47:07 +00:00
Added getSigners API for SmartUpate
This commit is contained in:
parent
51b564df36
commit
5f24c79522
@ -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 */
|
||||
|
@ -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
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user