Bug fixes from MozillaClassic branch, plus changes to build caps without rdf

This commit is contained in:
raman%netscape.com 1998-11-16 21:57:13 +00:00
Родитель 936238d763
Коммит 69d8e9a511
9 изменённых файлов: 93 добавлений и 85 удалений

Просмотреть файл

@ -31,7 +31,7 @@ PR_PUBLIC_API(void)
java_netscape_security_savePrivilege(nsPermState permState);
PR_PUBLIC_API(nsPermState)
nsJSJavaDisplayDialog(char *prinStr, char *targetStr, char *rsikStr, PRBool isCert);
nsJSJavaDisplayDialog(char *prinStr, char *targetStr, char *rsikStr, PRBool isCert, void*cert);
PR_PUBLIC_API(void)
java_netscape_security_getTargetDetails(const char *charSetName,

Просмотреть файл

@ -62,6 +62,8 @@ public:
nsPrincipalType getType();
void *getCertificate();
char *getKey();
PRUint32 getKeyLength();

Просмотреть файл

@ -1,56 +0,0 @@
#!gmake
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../..
include $(DEPTH)/config/config.mk
MODULE = caps
LIBRARY_NAME = caps
CPPSRCS = \
nsUserDialogHelper.cpp \
nsZig.cpp \
nsPrincipal.cpp \
nsPrivilege.cpp \
nsPrivilegeManager.cpp \
nsPrivilegeTable.cpp \
nsSystemPrivilegeTable.cpp \
nsTarget.cpp \
nsUserTarget.cpp \
admin.cpp \
nsCaps.cpp \
nsCCapsManager.cpp \
nsCCertPrincipal.cpp \
nsCCodebasePrincipal.cpp \
nsCCapsManagerFactory.cpp \
nsCCodeSourcePrincipal.cpp \
$(NULL)
REQUIRES = nspr xpcom security layer js jar zlib pref img util rdf caps
CSRCS = \
nsZip.c \
nsLoadZig.c \
jpermission.c \
$(NULL)
include $(DEPTH)/config/rules.mk
INCLUDES += -I$(DEPTH)/include \
-I$(PUBLIC)/public \

Просмотреть файл

@ -39,14 +39,14 @@ CPPSRCS = \
nsUserTarget.cpp \
admin.cpp \
nsCaps.cpp \
nsCCapsManager.cpp \
nsCCertPrincipal.cpp \
nsCCodebasePrincipal.cpp \
nsCCapsManagerFactory.cpp \
nsCCodeSourcePrincipal.cpp \
nsCCapsManager.cpp \
nsCCertPrincipal.cpp \
nsCCodebasePrincipal.cpp \
nsCCapsManagerFactory.cpp \
nsCCodeSourcePrincipal.cpp \
$(NULL)
REQUIRES = xpcom security layer js jar pref img util rdf caps
REQUIRES = nspr xpcom security layer js jar pref img util rdf caps
ifndef MOZ_NATIVE_ZLIB
REQUIRES += zlib
@ -61,4 +61,3 @@ CSRCS = \
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(topsrcdir)/include

Просмотреть файл

@ -30,6 +30,7 @@
static char *userTargetErrMsg;
static nsPermState gPermState;
void *gPrincipalCert;
static void
nsUserTargetHandleMonitorError(int rv)
@ -54,17 +55,27 @@ java_netscape_security_savePrivilege(nsPermState permState)
PR_CExitMonitor((void *)&gPermState);
}
PR_PUBLIC_API(void *)
java_netscape_security_getCert(char *prinStr)
{
return gPrincipalCert;
}
PR_PUBLIC_API(nsPermState)
nsJSJavaDisplayDialog(char *prinStr, char *targetStr, char *riskStr, PRBool isCert)
nsJSJavaDisplayDialog(char *prinStr, char *targetStr, char *riskStr, PRBool isCert, void*cert)
{
void * context = XP_FindSomeContext();
PRIntervalTime sleep = (PRIntervalTime)PR_INTERVAL_NO_TIMEOUT;
nsPermState ret_val=nsPermState_NotSet;
PR_CEnterMonitor((void *)&gPermState);
/* XXX: The following is a hack, we should passs gPrincipalCert to SECNAV_... code,
* but all this code will change real soon in the new world order
*/
gPrincipalCert = cert;
SECNAV_signedAppletPrivileges(context, prinStr, targetStr,
riskStr, isCert);
PR_CEnterMonitor((void *)&gPermState);
nsUserTargetHandleMonitorError(PR_CWait((void*)&gPermState, sleep));
nsUserTargetHandleMonitorError(PR_CNotifyAll((void*)&gPermState));
ret_val = gPermState;

Просмотреть файл

@ -64,11 +64,11 @@ OBJS= \
.\$(OBJDIR)\nsUserTarget.obj \
.\$(OBJDIR)\admin.obj \
.\$(OBJDIR)\nsCaps.obj \
.\$(OBJDIR)\nsCCapsManager.obj \
.\$(OBJDIR)\nsCCapsManager.obj \
.\$(OBJDIR)\nsCCertPrincipal.obj \
.\$(OBJDIR)\nsCCodebasePrincipal.obj \
.\$(OBJDIR)\nsCCapsManagerFactory.obj \
.\$(OBJDIR)\nsCCodeSourcePrincipal.obj \
.\$(OBJDIR)\nsCCapsManagerFactory.obj \
.\$(OBJDIR)\nsCCodeSourcePrincipal.obj \
$(NULL)
@ -93,7 +93,7 @@ LINCS= $(LINCS) \
# ns/dist/public/win16
#
!if "$(MOZ_BITS)" == "32"
-I$(PUBLIC)/js \
-I$(PUBLIC)\js \
-I$(PUBLIC)\nspr \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\security \
@ -104,9 +104,9 @@ LINCS= $(LINCS) \
-I$(PUBLIC)\pref \
-I$(DEPTH)\lib\layout \
-I$(DEPTH)\lib\libstyle \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\caps \
-I$(PUBLIC)\public \
# -I$(PUBLIC)\rdf \
$(NULL)
#//------------------------------------------------------------------------

Просмотреть файл

@ -414,7 +414,7 @@ char * nsPrincipal::getNickname(void)
return "Classes for whom we don't the principal";
}
if ((nsPrincipalType_CertKey != itsType) ||
if ((nsPrincipalType_CertKey != itsType) &&
(nsPrincipalType_CertChain != itsType))
return itsKey;
@ -429,6 +429,17 @@ nsPrincipal::getType()
return itsType;
}
void*
nsPrincipal::getCertificate()
{
void* cert=NULL;
if ((itsType == nsPrincipalType_CertChain) &&
(itsCertArray != NULL)) {
cert = itsCertArray->Get(0);
}
return cert;
}
char *
nsPrincipal::getKey()
{
@ -756,7 +767,7 @@ nsPrincipal::getCertAttribute(int attrib)
attributeStr = SECNAV_GetJarCertInfo(cert, snjExpirationDate);
break;
case ZIG_C_NICKNAME:
attributeStr = SECNAV_GetJarCertInfo(cert, snjNickname);
attributeStr = SECNAV_GetJarCertInfo(cert, snjCommonName);
break;
case ZIG_C_FP:
attributeStr = SECNAV_GetJarCertInfo(cert, snjFingerprint);
@ -765,10 +776,14 @@ nsPrincipal::getCertAttribute(int attrib)
default:
return NULL;
}
attrStr = new char[strlen(attributeStr)+1];
XP_STRCPY(attrStr, attributeStr);
PR_FREEIF(attributeStr);
return attrStr;
if (attributeStr) {
attrStr = new char[strlen(attributeStr)+1];
XP_STRCPY(attrStr, attributeStr);
PR_FREEIF(attributeStr);
return attrStr;
} else {
return "Untrusted certificate (unknown attributes)";
}
}
if (SOB_cert_attribute(attrib, zig,

Просмотреть файл

@ -24,9 +24,11 @@
#include "prprf.h"
#include "plbase64.h"
#include "jpermission.h"
#include "rdf.h"
#ifdef ENABLE_RDF
#include "rdf.h"
#include "jsec2rdf.h"
#endif /* ENABLE_RDF */
static nsPrivilegeManager * thePrivilegeManager = NULL;
@ -53,7 +55,11 @@ nsPrivilegeTable *gPrivilegeTable;
static PRBool getPrincipalString(nsHashKey *aKey, void *aData, void* closure);
#ifdef ENABLE_RDF
static nsPrincipal *RDF_getPrincipal(JSec_Principal jsec_pr);
static JSec_Principal RDF_CreatePrincipal(nsPrincipal *prin);
#endif /* ENABLE_RDF */
static PRBool RDF_RemovePrincipal(nsPrincipal *prin);
static PRBool RDF_RemovePrincipalsPrivilege(nsPrincipal *prin, nsTarget *target);
@ -1354,6 +1360,7 @@ nsPrivilegeManager::getPrivilegeTableFromStack(void *context, PRInt32 callerDept
return privTable;
}
#ifdef ENABLE_RDF
static JSec_Principal
RDF_CreatePrincipal(nsPrincipal *prin)
{
@ -1373,13 +1380,18 @@ RDF_CreatePrincipal(nsPrincipal *prin)
RDFJSec_AddPrincipal(pr);
return pr;
}
#endif /* ENABLE_RDF */
static PRBool
RDF_RemovePrincipal(nsPrincipal *prin)
{
nsCaps_lock();
PRBool found = PR_FALSE;
#ifdef ENABLE_RDF
nsCaps_lock();
RDFJSec_InitPrivilegeDB();
RDF_Cursor prin_cursor = RDFJSec_ListAllPrincipals();
if (prin_cursor == NULL) {
nsCaps_unlock();
@ -1388,7 +1400,6 @@ RDF_RemovePrincipal(nsPrincipal *prin)
JSec_Principal jsec_prin;
nsPrincipal *cur_prin = NULL;
PRBool found = PR_FALSE;
while ((jsec_prin = RDFJSec_NextPrincipal(prin_cursor)) != NULL) {
if ((cur_prin = RDF_getPrincipal(jsec_prin)) == NULL) {
continue;
@ -1404,9 +1415,14 @@ RDF_RemovePrincipal(nsPrincipal *prin)
RDFJSec_DeletePrincipal(jsec_prin);
}
nsCaps_unlock();
#endif /* ENABLE_RDF */
return found;
}
#ifdef ENABLE_RDF
static nsPrincipal *
RDF_getPrincipal(JSec_Principal jsec_pr)
{
@ -1441,12 +1457,19 @@ RDF_getTarget(JSec_Target jsec_target)
char *targetName = RDFJSec_GetTargetName(jsec_target);
return nsTarget::findTarget(targetName);
}
#endif /* ENABLE_RDF */
static PRBool
RDF_RemovePrincipalsPrivilege(nsPrincipal *prin, nsTarget *target)
{
PRBool found = PR_FALSE;
#ifdef ENABLE_RDF
nsCaps_lock();
RDFJSec_InitPrivilegeDB();
RDF_Cursor prin_cursor = RDFJSec_ListAllPrincipals();
if (prin_cursor == NULL) {
@ -1456,7 +1479,6 @@ RDF_RemovePrincipalsPrivilege(nsPrincipal *prin, nsTarget *target)
JSec_Principal jsec_prin;
nsPrincipal *cur_prin = NULL;
PRBool found = PR_FALSE;
JSec_PrincipalUse jsec_pr_use = NULL;
while ((jsec_prin = RDFJSec_NextPrincipal(prin_cursor)) != NULL) {
@ -1492,6 +1514,8 @@ RDF_RemovePrincipalsPrivilege(nsPrincipal *prin, nsTarget *target)
RDFJSec_DeletePrincipalUse(jsec_prin, jsec_pr_use);
}
nsCaps_unlock();
#endif /* ENABLE_RDF */
return found;
}
@ -1506,6 +1530,9 @@ void nsPrivilegeManager::save(nsPrincipal *prin,
if (prin->equals(getSystemPrincipal())) {
return;
}
#ifdef ENABLE_RDF
nsCaps_lock();
RDFJSec_InitPrivilegeDB();
JSec_Principal pr = RDF_CreatePrincipal(prin);
@ -1515,6 +1542,8 @@ void nsPrivilegeManager::save(nsPrincipal *prin,
RDFJSec_AddPrincipalUse(pr, prUse);
nsCaps_unlock();
#endif /* ENABLE_RDF */
}
/* The following routine should be called after setting up the system targets
@ -1522,6 +1551,8 @@ void nsPrivilegeManager::save(nsPrincipal *prin,
*/
void nsPrivilegeManager::load(void)
{
#ifdef ENABLE_RDF
nsCaps_lock();
RDFJSec_InitPrivilegeDB();
RDF_Cursor prin_cursor = RDFJSec_ListAllPrincipals();
@ -1559,6 +1590,8 @@ void nsPrivilegeManager::load(void)
RDFJSec_ReleaseCursor(prin_cursor);
nsCaps_unlock();
#endif /* ENABLE_RDF */
}
@ -1581,7 +1614,10 @@ PRBool nsPrivilegeManagerInitialize(void)
theUnknownPrincipalArray->Add(theUnknownPrincipal);
thePrivilegeManager = new nsPrivilegeManager();
#ifdef ENABLE_RDF
RDFJSec_InitPrivilegeDB();
#endif /* ENABLE_RDF */
return PR_FALSE;
}

Просмотреть файл

@ -31,9 +31,9 @@ extern "C" {
static PRBool displayUI=PR_FALSE;
static nsPermState
displayPermissionDialog(char *prinStr, char *targetStr, char *riskStr, PRBool isCert)
displayPermissionDialog(char *prinStr, char *targetStr, char *riskStr, PRBool isCert, void *cert)
{
return nsJSJavaDisplayDialog(prinStr, targetStr, riskStr, isCert);
return nsJSJavaDisplayDialog(prinStr, targetStr, riskStr, isCert, cert);
}
@ -60,6 +60,7 @@ nsPrivilege * nsUserTarget::enablePrivilege(nsPrincipal *prin, void *data)
XP_STRCPY(targetStr, OPTION);
XP_STRCAT(targetStr, desc);
PRBool isCert = (prin->isCodebase()) ? PR_FALSE : PR_TRUE;
void *cert = prin->getCertificate();
nsPermState permState = nsPermState_AllowedSession;
/*
@ -73,7 +74,7 @@ nsPrivilege * nsUserTarget::enablePrivilege(nsPrincipal *prin, void *data)
} else if (displayUI) {
/* set displayUI to TRUE, to enable UI */
nsCaps_lock();
permState = displayPermissionDialog(prinStr, targetStr, riskStr, isCert);
permState = displayPermissionDialog(prinStr, targetStr, riskStr, isCert, cert);
nsCaps_unlock();
}