diff --git a/mozilla/Makefile.in b/mozilla/Makefile.in
index 5b26224cb02..3d02ee26ad1 100644
--- a/mozilla/Makefile.in
+++ b/mozilla/Makefile.in
@@ -69,6 +69,7 @@ DIRS += \
widget/timer \
include \
modules/libutil \
+ security \
netwerk \
uriloader \
intl \
diff --git a/mozilla/allmakefiles.sh b/mozilla/allmakefiles.sh
index fd344ff58fc..fa393752788 100755
--- a/mozilla/allmakefiles.sh
+++ b/mozilla/allmakefiles.sh
@@ -322,6 +322,7 @@ netwerk/protocol/ftp/src/Makefile
netwerk/protocol/http/Makefile
netwerk/protocol/http/public/Makefile
netwerk/protocol/http/src/Makefile
+netwerk/protocol/http/res/Makefile
netwerk/protocol/jar/Makefile
netwerk/protocol/jar/public/Makefile
netwerk/protocol/jar/src/Makefile
@@ -335,8 +336,13 @@ netwerk/protocol/resource/src/Makefile
netwerk/mime/Makefile
netwerk/mime/public/Makefile
netwerk/mime/src/Makefile
+netwerk/security/Makefile
+netwerk/security/browser/Makefile
+netwerk/security/psm/Makefile
netwerk/socket/Makefile
netwerk/socket/base/Makefile
+netwerk/socket/ssl/Makefile
+netwerk/socket/tests/Makefile
netwerk/streamconv/Makefile
netwerk/streamconv/converters/Makefile
netwerk/streamconv/public/Makefile
@@ -638,6 +644,12 @@ embedding/browser/build/Makefile
embedding/browser/webBrowser/Makefile
embedding/browser/setup/Makefile
+# Security Makefiles
+security/Makefile
+security/psm/Makefile
+security/psm/lib/Makefile
+security/psm/lib/client/Makefile
+security/psm/lib/protocol/Makefile
# xpfe/browser/public/Makefile
diff --git a/mozilla/client.mak b/mozilla/client.mak
index db153d82838..5b8ddda2a71 100644
--- a/mozilla/client.mak
+++ b/mozilla/client.mak
@@ -117,6 +117,10 @@ pull_nspr:
cd $(MOZ_SRC)\.
$(CVSCO_NSPR) mozilla/nsprpub
+pull_psm:
+ cd $(MOZ_SRC)\.
+ $(CVSCO_PSM) mozilla/security
+
# pull either layout only or seamonkey the browser
pull_layout:
cd $(MOZ_SRC)\.
@@ -131,14 +135,19 @@ pull_seamonkey:
# nmake has to be hardcoded, or we have to depend on mozilla/config
# being pulled already to figure out what $(NMAKE) should be.
-clobber_all: clobber_nspr clobber_seamonkey
+clobber_all: clobber_nspr clobber_psm clobber_seamonkey
-build_all: build_nspr build_seamonkey
+build_all: build_nspr build_psm build_seamonkey
clobber_nspr:
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
nmake -f makefile.win clobber_all
+clobber_psm:
+ @cd $(MOZ_SRC)\$(MOZ_TOP)\security
+ nmake -f makefile.win clobber_all
+
+
clobber_seamonkey:
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
-rd /s /q dist
@@ -158,6 +167,10 @@ build_nspr:
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
nmake -f makefile.win export
+build_psm:
+ @cd $(MOZ_SRC)\$(MOZ_TOP)\security
+ nmake -f makefile.win export
+
build_seamonkey:
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
set DIST_DIRS=1
@@ -190,6 +203,8 @@ install:
export:
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
nmake -f makefile.win export
+ @cd $(MOZ_SRC)\$(MOZ_TOP)\security
+ nmake -f makefile.win export
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
set DIST_DIRS=1
set LAYOUT_DIRS=1
diff --git a/mozilla/client.mk b/mozilla/client.mk
index 903c3f1cbe5..ce3ded7177a 100644
--- a/mozilla/client.mk
+++ b/mozilla/client.mk
@@ -145,6 +145,20 @@ else
endif
+#######################################################################
+# PSM client libs
+#
+
+PSM_CO_MODULE= mozilla/security
+PSM_CO_FLAGS := -P
+CVSCO_PSM = cvs $(CVS_FLAGS) co $(PSM_CO_FLAGS)
+PSM_CO_TAG = SeaMonkey_M14_BRANCH
+
+ifdef PSM_CO_TAG
+ PSM_CO_FLAGS := $(PSM_CO_FLAGS) -r $(PSM_CO_TAG)
+endif
+
+
#######################################################################
# NSPR
#
@@ -204,6 +218,11 @@ real_checkout:
($(CVSCO_NSPR) $(NSPR_CO_MODULE) || touch cvs-failed.tmp) 2>&1 \
| tee -a $(CVSCO_LOGFILE); \
if test -f cvs-failed.tmp; then exit 1; else true; fi; \
+ : Checkout PSM client libs; \
+ echo $(CVSCO_PSM) $(PSM_CO_MODULE); \
+ ($(CVSCO_PSM) $(PSM_CO_MODULE) || touch cvs-failed.tmp) 2>&1 \
+ | tee -a $(CVSCO_LOGFILE); \
+ if test -f cvs-failed.tmp; then exit 1; else true; fi; \
: Checkout the SeaMonkeyAll; \
echo $(CVSCO) $(MOZ_CO_MODULE); \
($(CVSCO) $(MOZ_CO_MODULE) || touch cvs-failed.tmp) 2>&1 \
diff --git a/mozilla/makefile.win b/mozilla/makefile.win
index d3cf307e97b..2f6b58b1504 100644
--- a/mozilla/makefile.win
+++ b/mozilla/makefile.win
@@ -54,6 +54,7 @@ DIRS = \
db \
dbm \
modules\libutil \
+ security \
netwerk \
widget\timer \
js \
diff --git a/mozilla/netwerk/Makefile.in b/mozilla/netwerk/Makefile.in
index 977060f9839..a3601212a18 100644
--- a/mozilla/netwerk/Makefile.in
+++ b/mozilla/netwerk/Makefile.in
@@ -35,6 +35,7 @@ DIRS = \
protocol \
mime \
streamconv \
+ security \
$(NULL)
ifdef ENABLE_TESTS
diff --git a/mozilla/netwerk/makefile.win b/mozilla/netwerk/makefile.win
index a0516f122f7..a8e7ae59954 100644
--- a/mozilla/netwerk/makefile.win
+++ b/mozilla/netwerk/makefile.win
@@ -27,6 +27,7 @@ DIRS= \
cache \
base \
dns \
+ security \
socket \
mime \
streamconv \
diff --git a/mozilla/netwerk/protocol/http/Makefile.in b/mozilla/netwerk/protocol/http/Makefile.in
index 8e79579887a..d2bf494ad66 100644
--- a/mozilla/netwerk/protocol/http/Makefile.in
+++ b/mozilla/netwerk/protocol/http/Makefile.in
@@ -26,7 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
-DIRS = public src
+DIRS = public src res
include $(topsrcdir)/config/rules.mk
diff --git a/mozilla/netwerk/protocol/http/makefile.win b/mozilla/netwerk/protocol/http/makefile.win
index 456c6d94b61..c4495a9d190 100644
--- a/mozilla/netwerk/protocol/http/makefile.win
+++ b/mozilla/netwerk/protocol/http/makefile.win
@@ -28,7 +28,8 @@
DEPTH=..\..\..
DIRS= \
public \
- src \
+ src \
+ res \
$(NULL)
include <$(DEPTH)\config\rules.mak>
diff --git a/mozilla/netwerk/protocol/http/res/MANIFEST b/mozilla/netwerk/protocol/http/res/MANIFEST
new file mode 100644
index 00000000000..bf7251711de
--- /dev/null
+++ b/mozilla/netwerk/protocol/http/res/MANIFEST
@@ -0,0 +1 @@
+psm.js
\ No newline at end of file
diff --git a/mozilla/netwerk/protocol/http/res/Makefile.in b/mozilla/netwerk/protocol/http/res/Makefile.in
new file mode 100644
index 00000000000..4030f54f546
--- /dev/null
+++ b/mozilla/netwerk/protocol/http/res/Makefile.in
@@ -0,0 +1,42 @@
+#!nmake
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+DEPTH = ../../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+FILES_DIR = $(DIST)/bin/chrome/netwerk/content/default/https/
+
+EXPORT_RESOURCES = \
+ $(srcdir)/psm.js \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+install::
+ $(INSTALL) $(EXPORT_RESOURCES) $(FILES_DIR)
+
+
+
diff --git a/mozilla/netwerk/protocol/http/res/makefile.win b/mozilla/netwerk/protocol/http/res/makefile.win
new file mode 100644
index 00000000000..2574c14de16
--- /dev/null
+++ b/mozilla/netwerk/protocol/http/res/makefile.win
@@ -0,0 +1,34 @@
+#!nmake
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+DEPTH=..\..\..\..
+
+include <$(DEPTH)\config\rules.mak>
+
+DISTBROWSWER=$(DIST)\bin\chrome\netwerk\content\default\https\
+
+install::
+ $(MAKE_INSTALL) psm.js $(DISTBROWSWER)
+
+clobber::
+ rm -f $(DISTBROWSER)\successful.gif
+ rm -f $(DISTBROWSER)\failure.gif
diff --git a/mozilla/netwerk/protocol/http/res/psm.js b/mozilla/netwerk/protocol/http/res/psm.js
new file mode 100644
index 00000000000..ff2738c435e
--- /dev/null
+++ b/mozilla/netwerk/protocol/http/res/psm.js
@@ -0,0 +1,7 @@
+function displaySecurityAdvisor()
+{
+ var psm = Components.classes["component://netscape/psm"].getService();
+ psm = psm.QueryInterface(Components.interfaces.nsIPSMComponent);
+ psm.DisplaySecurityAdvisor( null );
+}
+
diff --git a/mozilla/netwerk/protocol/http/src/Makefile.in b/mozilla/netwerk/protocol/http/src/Makefile.in
index 250b9f9527c..58edc22293d 100644
--- a/mozilla/netwerk/protocol/http/src/Makefile.in
+++ b/mozilla/netwerk/protocol/http/src/Makefile.in
@@ -45,6 +45,7 @@ CPPSRCS = \
nsBasicAuth.cpp \
nsAuth.cpp \
nsAuthEngine.cpp \
+ nsHTTPSHandler.cpp \
$(NULL)
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
diff --git a/mozilla/netwerk/protocol/http/src/makefile.win b/mozilla/netwerk/protocol/http/src/makefile.win
index 09552c2d752..da2a3cb788d 100644
--- a/mozilla/netwerk/protocol/http/src/makefile.win
+++ b/mozilla/netwerk/protocol/http/src/makefile.win
@@ -39,11 +39,12 @@ DLL=.\$(OBJDIR)\$(DLLNAME).dll
LLIBS= $(LLIBS) \
$(LIBNSPR) \
- $(DIST)\lib\necko.lib \
+ $(DIST)\lib\necko.lib \
$(DIST)\lib\xpcom.lib \
$(NULL)
CPP_OBJS= \
+ .\$(OBJDIR)\nsHTTPSHandler.obj \
.\$(OBJDIR)\nsHTTPHandler.obj \
.\$(OBJDIR)\nsHTTPHandlerModule.obj \
.\$(OBJDIR)\nsHTTPChannel.obj \
@@ -55,7 +56,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsHTTPEncodeStream.obj \
.\$(OBJDIR)\nsBasicAuth.obj \
.\$(OBJDIR)\nsAuth.obj \
- .\$(OBJDIR)\nsAuthEngine.obj \
+ .\$(OBJDIR)\nsAuthEngine.obj \
$(NULL)
LOCAL_INCLUDES=-I.
diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp
index 5687c2651b6..61b0025b6fb 100644
--- a/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp
+++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandlerModule.cpp
@@ -27,17 +27,25 @@
#include "nsIHTTPProtocolHandler.h"
#include "nsHTTPHandler.h"
+#include "nsHTTPSHandler.h"
////////////////////////////////////////////////////////////////////////
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHTTPHandler, Init);
+//NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSHandler);
+
+#define NS_HTTPS_HANDLER_FACTORY_CID { 0xd2771480, 0xcac4, 0x11d3, { 0x8c, 0xaf, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
static nsModuleComponentInfo components[] =
{
{ "HTTP Handler",
NS_IHTTPHANDLER_CID,
NS_NETWORK_PROTOCOL_PROGID_PREFIX "http",
- nsHTTPHandlerConstructor }
+ nsHTTPHandlerConstructor },
+ { "HTTPS Handler",
+ NS_HTTPS_HANDLER_FACTORY_CID,
+ NS_NETWORK_PROTOCOL_PROGID_PREFIX "https",
+ nsHTTPSHandler::Create }
};
NS_IMPL_NSGETMODULE("nsHTTPHandlerModule", components)
diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp
new file mode 100644
index 00000000000..1342255374f
--- /dev/null
+++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nspr.h"
+#include "nsHTTPSHandler.h"
+#include "nsISocketTransportService.h"
+#include "nsIServiceManager.h"
+
+static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
+
+nsHTTPSHandler::nsHTTPSHandler()
+: nsHTTPHandler()
+{
+}
+
+nsHTTPSHandler::~nsHTTPSHandler()
+{
+}
+
+NS_METHOD
+nsHTTPSHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
+{
+ nsresult rv;
+ if (aOuter) return NS_ERROR_NO_AGGREGATION;
+
+ nsHTTPSHandler* handler = new nsHTTPSHandler();
+ if (!handler) return NS_ERROR_OUT_OF_MEMORY;
+ NS_ADDREF(handler);
+ rv = handler->Init();
+ if (NS_FAILED(rv)) {
+ delete handler;
+ return rv;
+ }
+ rv = handler->QueryInterface(aIID, aResult);
+ NS_RELEASE(handler);
+ return rv;
+}
+
+nsresult nsHTTPSHandler::CreateTransport(const char* host, PRInt32 port, const char* printHost,
+ PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize,
+ nsIChannel** o_pTrans)
+{
+ nsresult rv;
+
+ NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv);
+ if (NS_FAILED(rv)) return rv;
+
+ return rv = sts->CreateTransportOfType("ssl", host, port, printHost, bufferSegmentSize, bufferMaxSize, o_pTrans);
+}
+
diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h
new file mode 100644
index 00000000000..098a8f56398
--- /dev/null
+++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#ifndef _nsHTTPSHandler_h_
+#define _nsHTTPSHandler_h_
+
+#include "nsHTTPHandler.h"
+
+#include "nsIHTTPProtocolHandler.h"
+#include "nsIChannel.h"
+#include "nsISupportsArray.h"
+#include "nsCRT.h"
+
+class nsIChannel;
+class nsHTTPChannel;
+
+class nsHTTPSHandler : public nsHTTPHandler
+{
+public:
+
+ nsHTTPSHandler(void);
+ virtual ~nsHTTPSHandler();
+ static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
+
+ //Functions from nsIProtocolHandler
+ /*
+ GetDefaultPort returns the default port associated with this
+ protocol.
+ */
+ NS_IMETHOD GetDefaultPort(PRInt32 *result)
+ {
+ static const PRInt32 defaultPort = 443;
+ *result = defaultPort;
+ return NS_OK;
+ };
+
+ /*
+ The GetScheme function uniquely identifies the scheme this handler
+ is associated with.
+ */
+ NS_IMETHOD GetScheme(char * *o_Scheme)
+ {
+ static const char* scheme = "https";
+ *o_Scheme = nsCRT::strdup(scheme);
+ return NS_OK;
+ };
+
+ /**
+ * Called to create a transport from RequestTransport to accually
+ * make a new channel.
+ **/
+
+ virtual nsresult CreateTransport(const char* host, PRInt32 port,
+ const char* printHost,
+ PRUint32 bufferSegmentSize,
+ PRUint32 bufferMaxSize,
+ nsIChannel** o_pTrans);
+};
+
+#endif /* _nsHTTPSHandler_h_ */
diff --git a/mozilla/netwerk/security/Makefile.in b/mozilla/netwerk/security/Makefile.in
new file mode 100644
index 00000000000..8d096344e9e
--- /dev/null
+++ b/mozilla/netwerk/security/Makefile.in
@@ -0,0 +1,33 @@
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+
+DEPTH = ../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+DIRS = browser psm
+
+include $(topsrcdir)/config/rules.mk
+
diff --git a/mozilla/netwerk/security/browser/MANIFEST_CONTENT b/mozilla/netwerk/security/browser/MANIFEST_CONTENT
new file mode 100644
index 00000000000..5adbb689913
--- /dev/null
+++ b/mozilla/netwerk/security/browser/MANIFEST_CONTENT
@@ -0,0 +1,3 @@
+NavSecurityOverlay.xul
+NavSecurityUI.js
+NavSecurityOverlay.css
\ No newline at end of file
diff --git a/mozilla/netwerk/security/browser/MANIFEST_SKIN b/mozilla/netwerk/security/browser/MANIFEST_SKIN
new file mode 100644
index 00000000000..f662adddc0b
--- /dev/null
+++ b/mozilla/netwerk/security/browser/MANIFEST_SKIN
@@ -0,0 +1,3 @@
+lock.gif
+unlock.gif
+broken.gif
\ No newline at end of file
diff --git a/mozilla/netwerk/security/browser/Makefile.in b/mozilla/netwerk/security/browser/Makefile.in
new file mode 100644
index 00000000000..2c959b7aa02
--- /dev/null
+++ b/mozilla/netwerk/security/browser/Makefile.in
@@ -0,0 +1,67 @@
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = secureui
+
+IS_COMPONENT = 1
+LIBRARY_NAME = secureui
+
+CPPSRCS = \
+ nsSecureBrowserUIImpl.cpp \
+ $(NULL)
+
+EXTRA_DSO_LDOPTS = -L$(DIST)/lib -lxpcom
+
+XPIDLSRCS = \
+ nsSecureBrowserUI.idl \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
+SKIN_DIR = $(DIST)/bin/chrome/navigator/skin/default/
+EXPORT_SKINS = \
+ $(srcdir)/broken.gif \
+ $(srcdir)/lock.gif \
+ $(srcdir)/unlock.gif \
+ $(srcdir)/NavSecurityOverlay.css \
+ $(NULL)
+
+CONTENT_DIR = $(DIST)/bin/chrome/navigator/content/default/
+EXPORT_CONTENT = \
+ $(srcdir)/NavSecurityOverlay.xul \
+ $(srcdir)/NavSecurityUI.js \
+ $(NULL)
+
+install::
+ $(INSTALL) $(EXPORT_SKINS) $(SKIN_DIR)
+ $(INSTALL) $(EXPORT_CONTENT) $(CONTENT_DIR)
+
+
+
+
+
diff --git a/mozilla/netwerk/security/browser/NavSecurityOverlay.css b/mozilla/netwerk/security/browser/NavSecurityOverlay.css
new file mode 100644
index 00000000000..b6562774dfb
--- /dev/null
+++ b/mozilla/netwerk/security/browser/NavSecurityOverlay.css
@@ -0,0 +1,15 @@
+titledbutton#security-button {
+ list-style-image:url("chrome://navigator/skin/unlock.gif");
+}
+
+titledbutton#security-button[level="high"] {
+ list-style-image:url("chrome://navigator/skin/lock.gif");
+}
+
+titledbutton#security-button[level="low"] {
+ list-style-image:url("chrome://navigator/skin/lock.gif");
+}
+
+titledbutton#security-button[level="broken"] {
+ list-style-image:url("chrome://navigator/skin/broken.gif");
+}
\ No newline at end of file
diff --git a/mozilla/netwerk/security/browser/NavSecurityOverlay.xul b/mozilla/netwerk/security/browser/NavSecurityOverlay.xul
new file mode 100644
index 00000000000..fdcc741608e
--- /dev/null
+++ b/mozilla/netwerk/security/browser/NavSecurityOverlay.xul
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mozilla/netwerk/security/browser/NavSecurityUI.js b/mozilla/netwerk/security/browser/NavSecurityUI.js
new file mode 100644
index 00000000000..478b7cdc6b7
--- /dev/null
+++ b/mozilla/netwerk/security/browser/NavSecurityUI.js
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+window.addEventListener("load", SetSecurityButton, false);
+
+function SetSecurityButton()
+{
+ dump("in SetSecurityButton\n");
+
+ var ui = Components.classes["component://netscape/secure_browser_ui"].getService();
+ ui = ui.QueryInterface(Components.interfaces.nsSecureBrowserUI);
+
+ var button = document.getElementById('security-button');
+ if (button && window.content)
+ ui.init(window.content, button);
+}
+
+function displayPageInfo()
+{
+ var psm = Components.classes["component://netscape/psm"].getService();
+ psm = psm.QueryInterface(Components.interfaces.nsIPSMComponent);
+ psm.DisplaySecurityAdvisor( null );
+}
+
+
diff --git a/mozilla/netwerk/security/browser/broken.gif b/mozilla/netwerk/security/browser/broken.gif
new file mode 100644
index 00000000000..6ca1fc885cc
Binary files /dev/null and b/mozilla/netwerk/security/browser/broken.gif differ
diff --git a/mozilla/netwerk/security/browser/lock.gif b/mozilla/netwerk/security/browser/lock.gif
new file mode 100644
index 00000000000..6e59a68467a
Binary files /dev/null and b/mozilla/netwerk/security/browser/lock.gif differ
diff --git a/mozilla/netwerk/security/browser/makefile.win b/mozilla/netwerk/security/browser/makefile.win
new file mode 100644
index 00000000000..fb1f35d8047
--- /dev/null
+++ b/mozilla/netwerk/security/browser/makefile.win
@@ -0,0 +1,72 @@
+#!nmake
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+MODULE = secureui
+
+DEPTH=..\..\..
+IGNORE_MANIFEST=1
+
+DLLNAME = secureui
+PDBFILE = $(DLLNAME).pdb
+MAPFILE = $(DLLNAME).map
+DLL = .\$(OBJDIR)\$(DLLNAME).dll
+MAKE_OBJ_TYPE = DLL
+
+include <$(DEPTH)/config/config.mak>
+
+LINCS = $(LINCS) \
+ -I$(PUBLIC) \
+ $(NULL)
+
+LLIBS = \
+ $(LIBNSPR) \
+ $(DIST)\lib\xpcom.lib \
+ $(NULL)
+
+OBJS = \
+ .\$(OBJDIR)\nsSecureBrowserUIImpl.obj \
+ $(NULL)
+
+XPIDL_INCLUDES=-I$(DEPTH)\..\mozilla\dist\idl
+
+XPIDLSRCS= \
+ .\nsSecureBrowserUI.idl \
+ $(NULL)
+
+include <$(DEPTH)\config\rules.mak>
+
+install:: $(DLL)
+ $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
+ $(MAKE_INSTALL) broken.gif $(DIST)\bin\chrome\navigator\skin\default
+ $(MAKE_INSTALL) lock.gif $(DIST)\bin\chrome\navigator\skin\default
+ $(MAKE_INSTALL) unlock.gif $(DIST)\bin\chrome\navigator\skin\default
+ $(MAKE_INSTALL) NavSecurityOverlay.xul $(DIST)\bin\chrome\navigator\content\default
+ $(MAKE_INSTALL) NavSecurityUI.js $(DIST)\bin\chrome\navigator\content\default
+ $(MAKE_INSTALL) NavSecurityOverlay.css $(DIST)\bin\chrome\navigator\skin\default
+
+clobber::
+ rm $(DIST)\bin\components\$(DLLNAME).dll
+ rm $(DIST)\bin\chrome\navigator\skin\default\broken.gif
+ rm $(DIST)\bin\chrome\navigator\skin\default\lock.gif
+ rm $(DIST)\bin\chrome\navigator\skin\default\unlock.gif
+ rm $(DIST)\bin\chrome\navigator\content\default\NavSecurityOverlay.xul
+ rm $(DIST)\bin\chrome\navigator\skin\default\NavSecurityOverlay.css
diff --git a/mozilla/netwerk/security/browser/nsSecureBrowserUI.idl b/mozilla/netwerk/security/browser/nsSecureBrowserUI.idl
new file mode 100644
index 00000000000..bca25ec1324
--- /dev/null
+++ b/mozilla/netwerk/security/browser/nsSecureBrowserUI.idl
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsISupports.idl"
+#include "domstubs.idl"
+
+[scriptable, uuid(081e31e0-a144-11d3-8c7c-00609792278c)]
+interface nsSecureBrowserUI : nsISupports
+{
+ void init(in nsIDOMWindow window, in nsIDOMElement button);
+};
+
+%{C++
+#define NS_SECURE_BROWSER_UI_PROGID "component://netscape/secure_browser_ui"
+#define NS_SECURE_BROWSER_UI_CLASSNAME "Mozilla Secure Browser UI Handler"
+
+#define NS_SECURE_BROWSER_UI_CID \
+{ 0x10fe7ea0, 0xa10a, 0x11d3, {0x8c, 0x7c, 0x00, 0x60, 0x97, 0x92, 0x27, 0x8c}}
+
+%}
diff --git a/mozilla/netwerk/security/browser/nsSecureBrowserUIImpl.cpp b/mozilla/netwerk/security/browser/nsSecureBrowserUIImpl.cpp
new file mode 100644
index 00000000000..8901279947d
--- /dev/null
+++ b/mozilla/netwerk/security/browser/nsSecureBrowserUIImpl.cpp
@@ -0,0 +1,503 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsSecureBrowserUI.h"
+#include "nsSecureBrowserUIImpl.h"
+
+#include "nsCOMPtr.h"
+#include "nsIServiceManager.h"
+
+#include "nsIScriptGlobalObject.h"
+#include "nsIObserverService.h"
+#include "nsIDocumentLoader.h"
+#include "nsCURILoader.h"
+#include "nsIDocShell.h"
+#include "nsIDocumentViewer.h"
+#include "nsCURILoader.h"
+#include "nsIDocument.h"
+#include "nsIDOMHTMLDocument.h"
+#include "nsIDOMXULDocument.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMWindow.h"
+#include "nsIChannel.h"
+
+#include "nsIURI.h"
+
+#include "prmem.h"
+
+#include "nsIModule.h"
+#include "nsIGenericFactory.h"
+
+#include "nsINetSupportDialogService.h"
+#include "nsIPrompt.h"
+#include "nsIPref.h"
+
+static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
+static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
+
+
+#define ENTER_SITE_PREF "security.warn_entering_secure"
+#define LEAVE_SITE_PREF "security.warn_leaving_secure"
+#define MIXEDCONTENT_PREF "security.warn_viewing_mixed"
+#define INSECURE_SUBMIT_PREF "security.warn_submit_insecure"
+
+
+nsSecureBrowserUIImpl* nsSecureBrowserUIImpl::mInstance = nsnull;
+
+nsSecureBrowserUIImpl::nsSecureBrowserUIImpl()
+{
+ NS_INIT_REFCNT();
+}
+
+nsSecureBrowserUIImpl::~nsSecureBrowserUIImpl()
+{
+}
+
+NS_IMPL_ISUPPORTS1(nsSecureBrowserUIImpl, nsSecureBrowserUI);
+
+NS_IMETHODIMP
+nsSecureBrowserUIImpl::CreateSecureBrowserUI(nsISupports* aOuter, REFNSIID aIID, void **aResult)
+{
+ if (!aResult) {
+ return NS_ERROR_INVALID_POINTER;
+ }
+ if (aOuter) {
+ *aResult = nsnull;
+ return NS_ERROR_NO_AGGREGATION;
+ }
+
+ if (mInstance == nsnull)
+ {
+ mInstance = new nsSecureBrowserUIImpl();
+ }
+
+ if (mInstance == nsnull)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ nsresult rv = mInstance->QueryInterface(aIID, aResult);
+ if (NS_FAILED(rv))
+ {
+ *aResult = nsnull;
+ }
+ return rv;
+}
+
+NS_IMETHODIMP
+nsSecureBrowserUIImpl::Init(nsIDOMWindow *window, nsIDOMElement *button)
+{
+
+ nsCOMPtr sgo = do_QueryInterface(window);
+ if (sgo)
+ {
+ nsCOMPtr docShell;
+
+ sgo->GetDocShell(getter_AddRefs(docShell));
+ if (docShell)
+ {
+ nsSecureBrowserObserver *sbo = new nsSecureBrowserObserver();
+ if (sbo)
+ {
+ NS_ADDREF(sbo);
+ return sbo->Init(button, docShell); // does the window delete us when it close?
+ }
+ }
+ }
+ return NS_OK;
+}
+
+
+nsSecureBrowserObserver::nsSecureBrowserObserver()
+{
+ NS_INIT_REFCNT();
+ mIsSecureDocument = mMixContentAlertShown = mIsDocumentBroken = PR_FALSE;
+
+}
+
+nsSecureBrowserObserver::~nsSecureBrowserObserver()
+{
+}
+
+NS_IMPL_ISUPPORTS1(nsSecureBrowserObserver, nsIDocumentLoaderObserver);
+
+
+nsresult
+nsSecureBrowserObserver::Init(nsIDOMElement *button, nsIDocShell* content)
+{
+ if (!button || !content)
+ return NS_ERROR_NULL_POINTER;
+
+ mSecurityButton = button;
+ content->GetDocLoaderObserver(getter_AddRefs(mOldWebShellObserver));
+ content->SetDocLoaderObserver(this);
+ return NS_OK;
+}
+
+
+NS_IMETHODIMP
+nsSecureBrowserObserver::OnStartDocumentLoad(nsIDocumentLoader* aLoader,
+ nsIURI* aURL,
+ const char* aCommand)
+{
+ nsresult res;
+
+ if (mOldWebShellObserver)
+ {
+ mOldWebShellObserver->OnStartDocumentLoad(aLoader, aURL, aCommand);
+ }
+
+
+ if (!mSecurityButton)
+ return NS_OK;
+
+ if (!aURL || !aLoader)
+ return NS_ERROR_NULL_POINTER;
+
+
+ mIsSecureDocument = mMixContentAlertShown = mIsDocumentBroken = PR_FALSE;
+
+ // check to see that we are going to load the same
+ // kind of URL (scheme) as we just loaded.
+
+
+ PRBool isOldSchemeSecure;
+ res = IsSecureDocumentLoad(aLoader, &isOldSchemeSecure);
+ if (NS_FAILED(res))
+ return NS_OK;
+
+ PRBool isNewSchemeSecure;
+ res = IsSecureUrl(PR_FALSE, aURL, &isNewSchemeSecure);
+ if (NS_FAILED(res))
+ return NS_OK;
+
+#if DEBUG_dougt
+ printf("[StartPageLoad] isOldSchemeSecure = %d isNewSchemeSecure = %d\n", isOldSchemeSecure, isNewSchemeSecure);
+#endif
+ // if we are going from a secure page to and insecure page
+ if ( !isNewSchemeSecure && isOldSchemeSecure)
+ {
+#if DEBUG_dougt
+ printf("change lock icon to unlock - new document\n");
+#endif
+ mSecurityButton->RemoveAttribute( "level" );
+
+
+ PRBool boolpref;
+ NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res);
+ if (NS_FAILED(res))
+ return res;
+
+ if ((prefs->GetBoolPref(LEAVE_SITE_PREF, &boolpref) != 0))
+ boolpref = PR_TRUE;
+
+ if (boolpref)
+ {
+ NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res);
+ if (NS_FAILED(res))
+ return res;
+
+ dialog->Alert(nsString("You are leaving a secure document").GetUnicode()); // fix localize!
+ }
+ }
+ // if we are going from an insecure page to a secure one.
+ else if (isNewSchemeSecure && !isOldSchemeSecure)
+ {
+ PRBool boolpref;
+ NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res);
+ if (NS_FAILED(res))
+ return res;
+
+ if ((prefs->GetBoolPref(ENTER_SITE_PREF, &boolpref) != 0))
+ boolpref = PR_TRUE;
+
+ if (boolpref)
+ {
+ NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res);
+ if (NS_FAILED(res))
+ return res;
+
+ dialog->Alert(nsString("You are entering a secure document").GetUnicode()); // fix localize!
+ }
+ }
+
+ mIsSecureDocument = isNewSchemeSecure;
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsSecureBrowserObserver::OnEndDocumentLoad(nsIDocumentLoader* aLoader,
+ nsIChannel* channel,
+ nsresult aStatus)
+{
+ nsresult rv;
+
+ if (mOldWebShellObserver)
+ {
+ mOldWebShellObserver->OnEndDocumentLoad(aLoader, channel, aStatus);
+ }
+
+ if (!mIsSecureDocument)
+ return NS_OK;
+
+ if (!mSecurityButton)
+ return NS_ERROR_NULL_POINTER;
+
+#if DEBUG_dougt
+ printf("[EndPageLoad] mIsSecureDocument = %d aStatus = %d mIsDocumentBroken = %d\n", mIsSecureDocument, aStatus, mIsDocumentBroken);
+#endif
+
+ if ( NS_SUCCEEDED(aStatus) && !mIsDocumentBroken )
+ {
+#if DEBUG_dougt
+ printf("change lock icon to secure \n");
+#endif
+ rv = mSecurityButton->SetAttribute( "level", nsString("high") );
+ mIsSecureDocument = PR_TRUE;
+ }
+ else
+ {
+#if DEBUG_dougt
+ printf("change lock icon to broken\n");
+#endif
+ rv = mSecurityButton->SetAttribute( "level", nsString("broken") );
+ mIsSecureDocument = PR_FALSE;
+ }
+
+ return rv;
+}
+
+NS_IMETHODIMP
+nsSecureBrowserObserver::OnStartURLLoad(nsIDocumentLoader* loader,
+ nsIChannel* channel)
+{
+ if (mOldWebShellObserver)
+ {
+ mOldWebShellObserver->OnStartURLLoad(loader, channel);
+ }
+
+#if DEBUG_dougt
+ printf("[StartURLLoad] mIsSecureDocument = %d\n", mIsSecureDocument);
+#endif
+
+ PRBool secure;
+ nsresult rv = IsSecureChannelLoad(channel, &secure);
+ if (NS_FAILED(rv))
+ return rv;
+
+ if (mIsSecureDocument && !secure)
+ {
+ mIsDocumentBroken = PR_TRUE;
+
+// nsCOMPtr uri;
+// channel->GetURI(getter_AddRefs(uri));
+
+// uri->SetSpec("chrome://navigator/skin/insecureLink.gif"); //fix
+
+ nsresult res;
+
+ PRBool boolpref;
+ NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res);
+ if (NS_FAILED(res))
+ return res;
+
+ if ((prefs->GetBoolPref(MIXEDCONTENT_PREF, &boolpref) != 0))
+ boolpref = PR_TRUE;
+
+ if (boolpref && !mMixContentAlertShown)
+ {
+ NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res);
+ if (NS_FAILED(res))
+ return res;
+
+ dialog->Alert(nsString("There is mixed content on this page").GetUnicode()); // fix localize!
+ mMixContentAlertShown = PR_TRUE;
+ }
+ }
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsSecureBrowserObserver::OnProgressURLLoad(nsIDocumentLoader* loader,
+ nsIChannel* channel,
+ PRUint32 aProgress,
+ PRUint32 aProgressMax)
+{
+ if (mOldWebShellObserver)
+ {
+ mOldWebShellObserver->OnProgressURLLoad(loader, channel, aProgress, aProgressMax);
+ }
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsSecureBrowserObserver::OnStatusURLLoad(nsIDocumentLoader* loader,
+ nsIChannel* channel,
+ nsString& aMsg)
+{
+ if (mOldWebShellObserver)
+ {
+ mOldWebShellObserver->OnStatusURLLoad(loader, channel, aMsg);
+ }
+ return NS_OK;
+}
+
+
+NS_IMETHODIMP
+nsSecureBrowserObserver::OnEndURLLoad(nsIDocumentLoader* loader,
+ nsIChannel* channel,
+ nsresult aStatus)
+{
+ if (mOldWebShellObserver)
+ {
+ mOldWebShellObserver->OnEndURLLoad(loader, channel, aStatus);
+ }
+
+#if DEBUG_dougt
+ printf("[OnEndURLLoad] mIsSecureDocument = %d aStatus = %d\n", mIsSecureDocument, aStatus);
+#endif
+
+ if ( mIsSecureDocument && NS_FAILED(aStatus))
+ {
+#if DEBUG_dougt
+ printf("change lock icon to broken\n");
+#endif
+ mSecurityButton->SetAttribute( "level", nsString("broken") );
+ mIsDocumentBroken = PR_TRUE;
+ }
+ return NS_OK;
+}
+
+// fileSecure flag determines if we should include file: and other local protocols.
+nsresult
+nsSecureBrowserObserver::IsSecureUrl(PRBool fileSecure, nsIURI* aURL, PRBool* value)
+{
+ *value = PR_FALSE;
+
+ if (!aURL)
+ return NS_ERROR_NULL_POINTER;
+#if DEBUG
+ char* string;
+ aURL->GetSpec(&string);
+ printf("[ensuring channel]: %s\n", string);
+ nsAllocator::Free(string);
+#endif
+
+ char* scheme;
+ aURL->GetScheme(&scheme);
+
+ if (scheme == nsnull)
+ return NS_ERROR_NULL_POINTER;
+
+ if ( (strncmp(scheme, "https", 5) == 0) ||
+ (fileSecure &&
+ (strncmp(scheme, "file", 4) == 0) ))
+ *value = PR_TRUE;
+
+ nsAllocator::Free(scheme);
+ return NS_OK;
+
+}
+
+
+nsresult nsSecureBrowserObserver::IsSecureDocumentLoad(nsIDocumentLoader* loader, PRBool *value)
+{
+ if (!loader)
+ return NS_ERROR_NULL_POINTER;
+
+ nsCOMPtr uri;
+ nsresult rv = GetURIFromDocumentLoader(loader, getter_AddRefs(uri));
+
+ if (NS_FAILED(rv))
+ return rv;
+
+ return IsSecureUrl(PR_FALSE, uri, value);
+}
+
+nsresult nsSecureBrowserObserver::IsSecureChannelLoad(nsIChannel* channel, PRBool *value)
+{
+ if (!channel)
+ return NS_ERROR_NULL_POINTER;
+
+ nsCOMPtr uri;
+ nsresult rv = channel->GetURI(getter_AddRefs(uri));
+ if (NS_FAILED(rv))
+ return rv;
+
+ return IsSecureUrl(PR_TRUE, uri, value);
+}
+
+nsresult
+nsSecureBrowserObserver::GetURIFromDocumentLoader(nsIDocumentLoader* aLoader, nsIURI** uri)
+{
+ nsresult rv;
+
+ if (aLoader == nsnull)
+ return NS_ERROR_NULL_POINTER;
+
+ nsCOMPtr cont;
+ rv = aLoader->GetContainer(getter_AddRefs(cont));
+ if (NS_FAILED(rv) || (cont == nsnull))
+ return NS_ERROR_NULL_POINTER;
+
+ nsCOMPtr docShell(do_QueryInterface(cont));
+ NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
+
+ nsCOMPtr cv;
+ rv = docShell->GetContentViewer(getter_AddRefs(cv));
+ if (NS_FAILED(rv) || (cv == nsnull))
+ return NS_ERROR_NULL_POINTER;
+
+ nsCOMPtr docViewer(do_QueryInterface(cv));
+ NS_ENSURE_TRUE(docViewer, NS_ERROR_FAILURE);
+
+ nsCOMPtr doc;
+ rv = docViewer->GetDocument(*getter_AddRefs(doc));
+ if (NS_FAILED(rv) || (doc == nsnull))
+ return NS_ERROR_NULL_POINTER;
+
+ *uri = doc->GetDocumentURL();
+ if (!*uri)
+ return NS_ERROR_NULL_POINTER;
+
+ return NS_OK;
+}
+
+
+
+static nsModuleComponentInfo components[] =
+{
+ { NS_SECURE_BROWSER_UI_CLASSNAME,
+ NS_SECURE_BROWSER_UI_CID,
+ NS_SECURE_BROWSER_UI_PROGID,
+ nsSecureBrowserUIImpl::CreateSecureBrowserUI
+ },
+
+ { NS_SECURE_BROWSER_DOCOBSERVER_CLASSNAME,
+ NS_SECURE_BROWSER_DOCOBSERVER_CID,
+ NS_SECURE_BROWSER_DOCOBSERVER_PROGID,
+ nsSecureBrowserUIImpl::CreateSecureBrowserUI
+ },
+
+};
+
+NS_IMPL_NSGETMODULE("nsSecureBrowserUIImpl", components)
+
diff --git a/mozilla/netwerk/security/browser/nsSecureBrowserUIImpl.h b/mozilla/netwerk/security/browser/nsSecureBrowserUIImpl.h
new file mode 100644
index 00000000000..b19ebb3d82d
--- /dev/null
+++ b/mozilla/netwerk/security/browser/nsSecureBrowserUIImpl.h
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#ifndef nsSecureBrowserUIImpl_h_
+#define nsSecureBrowserUIImpl_h_
+
+#include "nsCOMPtr.h"
+#include "nsXPIDLString.h"
+#include "nsString.h"
+#include "nsIObserver.h"
+#include "nsIDocumentLoaderObserver.h"
+#include "nsIDOMElement.h"
+#include "nsSecureBrowserUI.h"
+#include "nsIDocShell.h"
+
+#define NS_SECURE_BROWSER_DOCOBSERVER_CLASSNAME "Mozilla Secure Browser Doc Observer"
+
+#define NS_SECURE_BROWSER_DOCOBSERVER_CID \
+{0x97c06c30, 0xa145, 0x11d3, \
+{0x8c, 0x7c, 0x00, 0x60, 0x97, 0x92, 0x27, 0x8c}}
+
+#define NS_SECURE_BROWSER_DOCOBSERVER_PROGID "component://netscape/secure_browser_docobserver"
+
+
+class nsSecureBrowserObserver : public nsIDocumentLoaderObserver
+{
+public:
+
+ nsSecureBrowserObserver();
+ virtual ~nsSecureBrowserObserver();
+
+ nsresult Init(nsIDOMElement *button, nsIDocShell* content);
+
+ NS_DECL_ISUPPORTS
+
+ // nsIDocumentLoaderObserver
+ NS_DECL_NSIDOCUMENTLOADEROBSERVER
+
+ static nsresult IsSecureDocumentLoad(nsIDocumentLoader* loader, PRBool *value);
+ static nsresult IsSecureChannelLoad(nsIChannel* channel, PRBool *value);
+ static nsresult IsSecureUrl(PRBool fileSecure, nsIURI* aURL, PRBool *value);
+ static nsresult GetURIFromDocumentLoader(nsIDocumentLoader* aLoader, nsIURI** uri);
+
+protected:
+
+ nsCOMPtr mSecurityButton;
+ nsCOMPtr mOldWebShellObserver;
+
+ PRBool mIsSecureDocument; // is https loaded
+ PRBool mIsDocumentBroken; //
+ PRBool mMixContentAlertShown;
+
+};
+
+class nsSecureBrowserUIImpl : public nsSecureBrowserUI
+{
+public:
+
+ nsSecureBrowserUIImpl();
+ virtual ~nsSecureBrowserUIImpl();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSSECUREBROWSERUI
+
+ static NS_METHOD CreateSecureBrowserUI(nsISupports* aOuter, REFNSIID aIID, void **aResult);
+
+protected:
+
+ static nsSecureBrowserUIImpl* mInstance;
+};
+
+
+#endif /* nsSecureBrowserUIImpl_h_ */
diff --git a/mozilla/netwerk/security/browser/unlock.gif b/mozilla/netwerk/security/browser/unlock.gif
new file mode 100644
index 00000000000..761b85ddfb3
Binary files /dev/null and b/mozilla/netwerk/security/browser/unlock.gif differ
diff --git a/mozilla/netwerk/security/makefile.win b/mozilla/netwerk/security/makefile.win
new file mode 100644
index 00000000000..08ab81487e9
--- /dev/null
+++ b/mozilla/netwerk/security/makefile.win
@@ -0,0 +1,31 @@
+#!nmake
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+# Doug Turner 7/29/99
+#
+
+DEPTH = ..\..
+
+DIRS= \
+ browser \
+ psm \
+ $(NULL)
+
+include <$(DEPTH)\config\rules.mak>
diff --git a/mozilla/netwerk/security/psm/Makefile.in b/mozilla/netwerk/security/psm/Makefile.in
new file mode 100644
index 00000000000..0511cebdf0c
--- /dev/null
+++ b/mozilla/netwerk/security/psm/Makefile.in
@@ -0,0 +1,56 @@
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = psmcomp
+
+IS_COMPONENT = 1
+LIBRARY_NAME = psmcomp
+
+CPPSRCS = \
+ nsPSMComponent.cpp \
+ nsPSMModule.cpp \
+ nsPSMUICallbacks.cpp \
+ $(NULL)
+
+CSRCS = \
+ nsPSMMutex.c \
+ nsPSMShimLayer.c \
+ $(NULL)
+
+XPIDLSRCS = \
+ nsIPSMComponent.idl \
+ nsIPSMUIHandler.idl \
+ $(NULL)
+
+EXTRA_DSO_LDOPTS = -L$(DIST)/lib -lcmt -lxpcom -lprotocol $(MOZ_REGISTRY_LIBS)
+
+include $(topsrcdir)/config/rules.mk
+
+INCLUDES += \
+ -I$(srcdir) \
+ $(NULL)
diff --git a/mozilla/netwerk/security/psm/makefile.win b/mozilla/netwerk/security/psm/makefile.win
new file mode 100644
index 00000000000..b56b3192644
--- /dev/null
+++ b/mozilla/netwerk/security/psm/makefile.win
@@ -0,0 +1,83 @@
+#!nmake
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+MODULE = psmcomp
+
+DEPTH=..\..\..
+IGNORE_MANIFEST=1
+
+DLLNAME = psmcomp
+PDBFILE = $(DLLNAME).pdb
+MAPFILE = $(DLLNAME).map
+DLL = .\$(OBJDIR)\$(DLLNAME).dll
+MAKE_OBJ_TYPE = DLL
+
+include <$(DEPTH)/config/config.mak>
+
+EXPORTS= \
+ $(NULL)
+
+LINCS = $(LINCS) \
+ -I$(PUBLIC) \
+ $(NULL)
+
+LLIBS = \
+ $(LIBNSPR) \
+ $(DIST)\lib\neckobase_s.lib \
+ $(DIST)\lib\xpcom.lib \
+ $(DIST)\lib\js3250.lib \
+ $(DIST)\lib\cmt.lib \
+ $(DIST)\lib\protocol.lib \
+ $(DIST)\lib\mozreg.lib \
+ $(NULL)
+
+LIBRARY_NAME=neckopsm_s
+
+OBJS = \
+ .\$(OBJDIR)\nsPSMMutex.obj \
+ .\$(OBJDIR)\nsPSMShimLayer.obj \
+ .\$(OBJDIR)\nsPSMComponent.obj \
+ .\$(OBJDIR)\nsPSMUICallbacks.obj \
+ .\$(OBJDIR)\nsPSMModule.obj \
+ $(NULL)
+
+XPIDL_INCLUDES=-I$(DEPTH)\..\mozilla\dist\idl
+
+XPIDLSRCS= \
+ .\nsIPSMComponent.idl \
+ .\nsIPSMUIHandler.idl \
+ $(NULL)
+
+#NO_GEN_XPT=1
+
+include <$(DEPTH)\config\rules.mak>
+
+install:: $(DLL)
+ $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
+
+# temporary we need to export this static library to
+# deal with gSocketFuncs in CMT lib being global
+install:: $(LIBRARY)
+ $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
+
+clobber::
+ -$(RM_R) $(OBJDIR) $(XPIDL_GEN_DIR)
diff --git a/mozilla/netwerk/security/psm/nsIPSMComponent.idl b/mozilla/netwerk/security/psm/nsIPSMComponent.idl
new file mode 100644
index 00000000000..5844b690220
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsIPSMComponent.idl
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsISupports.idl"
+//#include "nsIPrincipal.idl"
+interface nsIPrincipal;
+
+%{C++
+#include "cmtcmn.h"
+%}
+
+[ptr] native nsCMTControlStar(CMT_CONTROL);
+
+[scriptable, uuid(9e482670-5412-11d3-bbc8-0000861d1237)]
+interface nsIPSMComponent : nsISupports
+{
+
+ [noscript] nsCMTControlStar GetControlConnection( );
+ void DisplaySecurityAdvisor();
+
+ /* Secure Hashing functions */
+ void hashBegin(in unsigned long alg, out unsigned long id);
+ void hashUpdate(in unsigned long id, in string buf, in unsigned long buflen);
+ void hashEnd(in unsigned long id, out string hash, out unsigned long hashlen,
+ in unsigned long maxLen);
+
+ /* Signature Verification functions */
+ void verifyRSABegin(out unsigned long id);
+ void verifyRSAUpdate(in unsigned long id, in string buf,
+ in unsigned long buflen);
+ void verifyRSAEnd(in unsigned long id, in string plaintext,
+ in unsigned long plaintextLen,
+ in boolean keepCert, out nsIPrincipal principal);
+};
+
+%{C++
+#define PSM_COMPONENT_PROGID "component://netscape/psm"
+#define PSM_COMPONENT_CLASSNAME "Mozilla PSM Component"
+
+/* Hash Algorithms (based on cmtcmn.h) */
+#define PSM_HASH_MD2 1
+#define PSM_HASH_MD2_LENGTH 16
+#define PSM_HASH_MD5 2
+#define PSM_HASH_MD5_LENGTH 16
+#define PSM_HASH_SHA1 3
+#define PSM_HASH_SHA1_LENGTH 20
+#define PSM_HASH_MAX_LENGTH PSM_HASH_SHA1_LENGTH
+%}
+
diff --git a/mozilla/netwerk/security/psm/nsIPSMUIHandler.idl b/mozilla/netwerk/security/psm/nsIPSMUIHandler.idl
new file mode 100644
index 00000000000..ffd0fd9a1b1
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsIPSMUIHandler.idl
@@ -0,0 +1,35 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is the Mozilla browser.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications, Inc. Portions created by Netscape are
+ * Copyright (C) 1999, Mozilla. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Doug Turner
+ */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(d92be9b0-601b-11d3-8c4a-000064657374)]
+interface nsIPSMUIHandler : nsISupports
+{
+ void DisplayURI(in long width, in long height, in string urlStr);
+ void PromptForFile(in string prompt, in string fileRegEx, in boolean shouldFileExist, out string outFile);
+};
+
+%{C++
+#define PSM_UI_HANLDER_PROGID "component://netscape/psm/ui"
+#define PSM_UI_HANLDER_CLASSNAME "Mozilla PSM UI Handler"
+%}
diff --git a/mozilla/netwerk/security/psm/nsPSMComponent.cpp b/mozilla/netwerk/security/psm/nsPSMComponent.cpp
new file mode 100644
index 00000000000..26d34fe8128
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMComponent.cpp
@@ -0,0 +1,737 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsProxiedService.h"
+#include "nsPSMUICallbacks.h"
+#include "VerReg.h"
+
+#include "nspr.h"
+#include "nsPSMComponent.h"
+
+#include "nsCRT.h"
+
+#include "nsIPref.h"
+#include "nsIProfile.h"
+#include "nsILocalFile.h"
+#ifdef XP_MAC
+#include "nsILocalFileMac.h"
+#endif
+#include "nsSpecialSystemDirectory.h"
+
+#include "nsPSMMutex.h"
+#include "nsPSMShimLayer.h"
+#include "nsPSMUICallbacks.h"
+
+#include "nsSecureBrowserUI.h"
+#include "nsIDocumentLoaderObserver.h"
+#include "nsIScriptSecurityManager.h"
+
+#define PSM_VERSION_REG_KEY "/Netscape/Personal Security Manager"
+
+#ifdef WIN32
+#define PSM_FILE_NAME "psm.exe"
+#elif XP_UNIX
+#define PSM_FILE_NAME "start-psm"
+#define PSM_FILE_LOCATION "/opt/netscape/security/start-psm"
+#else
+#define PSM_FILE_NAME "psm"
+#endif
+
+
+static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID);
+
+
+nsPSMComponent* nsPSMComponent::mInstance = nsnull;
+
+nsPSMComponent::nsPSMComponent()
+{
+ NS_INIT_REFCNT();
+ mControl = nsnull;
+}
+
+nsPSMComponent::~nsPSMComponent()
+{
+ if (mControl)
+ {
+ CMT_CloseControlConnection(mControl);
+ mControl = nsnull;
+ }
+}
+
+
+NS_IMETHODIMP
+nsPSMComponent::CreatePSMComponent(nsISupports* aOuter, REFNSIID aIID, void **aResult)
+{
+ if (!aResult) {
+ return NS_ERROR_INVALID_POINTER;
+ }
+ if (aOuter) {
+ *aResult = nsnull;
+ return NS_ERROR_NO_AGGREGATION;
+ }
+
+ if (mInstance == nsnull)
+ {
+ mInstance = new nsPSMComponent();
+ }
+
+ if (mInstance == nsnull)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ nsresult rv = mInstance->QueryInterface(aIID, aResult);
+ if (NS_FAILED(rv))
+ {
+ *aResult = nsnull;
+ }
+ return rv;
+}
+
+/* nsISupports Implementation for the class */
+NS_IMPL_ISUPPORTS1 (nsPSMComponent, nsIPSMComponent);
+
+#define INIT_NUM_PREFS 100
+/* preference types */
+#define STRING_PREF 0
+#define BOOL_PREF 1
+#define INT_PREF 2
+
+
+/* resizable list struct that contains pref items */
+typedef struct CMSetPrefList {
+ int n; /* number of filled items */
+ int capacity; /* allocated memory */
+ CMTSetPrefElement* list; /* actual list */
+} CMSetPrefList;
+
+static void get_pack_bool_pref(nsIPref *prefManager, char* key, CMTSetPrefElement* list, int* n)
+{
+ PRBool boolpref;
+
+ list[*n].key = nsCRT::strdup(key);
+ list[*n].type = BOOL_PREF;
+
+ if ((prefManager->GetBoolPref(key, &boolpref) != 0) || boolpref)
+ {
+ list[*n].value = nsCRT::strdup("true");
+ }
+ else
+ {
+ list[*n].value = nsCRT::strdup("false");
+ }
+
+ (*n)++; /* increment the counter after done packing */
+
+ return;
+}
+static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
+
+static void SaveAllPrefs(int number, CMTSetPrefElement* list)
+{
+ nsCOMPtr prefManager;
+
+ nsresult res = nsServiceManager::GetService(kPrefCID,
+ nsIPref::GetIID(),
+ getter_AddRefs(prefManager));
+
+ if (NS_FAILED(res) || !prefManager)
+ {
+ return;
+ }
+
+
+ int i;
+ int intval;
+
+ for (i = 0; i < number; i++)
+ {
+ if (list[i].key == nsnull)
+ {
+ /* misconfigured item: next */
+ continue;
+ }
+
+ switch (list[i].type)
+ {
+ case 0: /* string type */
+ prefManager->SetCharPref(list[i].key, list[i].value);
+ break;
+ case 1: /* boolean type */
+ if (strcmp(list[i].value, "true") == 0) {
+ prefManager->SetBoolPref(list[i].key, (PRBool)1);
+ }
+ else if (strcmp(list[i].value, "false") == 0) {
+ prefManager->SetBoolPref(list[i].key, (PRBool)0);
+ }
+ break;
+ case 2:
+ intval = atoi(list[i].value);
+ prefManager->SetIntPref(list[i].key, intval);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return;
+}
+
+nsresult
+nsPSMComponent::PassAllPrefs()
+{
+ int i;
+ nsresult rv = NS_ERROR_FAILURE;
+ char* strpref = NULL;
+ int intpref;
+ PRBool boolpref;
+ CMSetPrefList prefs = {0};
+ CMTSetPrefElement* list = NULL;
+
+ char* pickAuto = "Select Automatically";
+ char* alwaysAsk = "Ask Every Time";
+
+ nsCOMPtr prefManager;
+
+ nsresult res = nsServiceManager::GetService(kPrefCID,
+ nsIPref::GetIID(),
+ getter_AddRefs(prefManager));
+
+ if (NS_OK != res)
+ {
+ return NS_ERROR_FAILURE;
+ }
+
+ /* allocate memory for list */
+ prefs.n = 0; /* counter */
+ prefs.capacity = INIT_NUM_PREFS;
+ prefs.list = (CMTSetPrefElement*) new char[(INIT_NUM_PREFS * sizeof(CMTSetPrefElement))];
+
+ if (prefs.list == NULL)
+ {
+ return rv;
+ }
+
+ /* shorthand */
+ list = prefs.list;
+
+ /* get preferences */
+ get_pack_bool_pref(prefManager, "security.enable_ssl2", (CMTSetPrefElement*)list, &(prefs.n));
+ get_pack_bool_pref(prefManager, "security.enable_ssl3", (CMTSetPrefElement*)list, &(prefs.n));
+
+ /* this pref is a boolean pref in nature but a string pref for
+ * historical reason
+ */
+
+ list[prefs.n].key = nsCRT::strdup("security.default_personal_cert");
+ list[prefs.n].type = STRING_PREF;
+
+ if ((prefManager->CopyCharPref(list[prefs.n].key, &strpref) == 0) && (strcmp(strpref, pickAuto) == 0))
+ {
+ list[prefs.n].value = nsCRT::strdup(pickAuto);
+ }
+ else
+ {
+ /* although one could choose a specific cert for client auth in
+ * Nova, that mode is deprecated with PSM and mapped to ASK
+ */
+ list[prefs.n].value = nsCRT::strdup(alwaysAsk);
+ }
+
+ prefs.n++;
+ if (strpref != NULL)
+ {
+ nsCRT::free(strpref);
+ }
+
+ list[prefs.n].key = nsCRT::strdup("security.default_mail_cert");
+ list[prefs.n].type = STRING_PREF;
+ if (prefManager->CopyCharPref(list[prefs.n].key, &list[prefs.n].value) != 0)
+ {
+ list[prefs.n].value = NULL;
+ }
+ prefs.n++;
+
+ list[prefs.n].key = nsCRT::strdup("security.ask_for_password");
+ list[prefs.n].type = INT_PREF;
+ if (prefManager->GetIntPref(list[prefs.n].key, &intpref) != 0)
+ {
+ intpref = 2; /* default */
+ }
+
+ list[prefs.n].value = PR_smprintf("%d", intpref);
+ prefs.n++;
+
+ list[prefs.n].key = nsCRT::strdup("security.password_lifetime");
+ list[prefs.n].type = INT_PREF;
+ if (prefManager->GetIntPref(list[prefs.n].key, &intpref) != 0)
+ {
+ intpref = 480; /* default */
+ }
+
+ list[prefs.n].value = PR_smprintf("%d", intpref);
+ prefs.n++;
+
+ /* OCSP preferences */
+ /* XXX since these are the new ones added by PSM, we will be more
+ * error-tolerant in fetching them
+ */
+ if (prefManager->GetBoolPref("security.OCSP.enabled", &boolpref) == 0)
+ {
+ if (boolpref)
+ {
+ list[prefs.n].value = nsCRT::strdup("true");
+ }
+ else
+ {
+ list[prefs.n].value = nsCRT::strdup("false");
+ }
+ list[prefs.n].key = nsCRT::strdup("security.OCSP.enabled");
+ list[prefs.n].type = BOOL_PREF;
+ prefs.n++;
+ }
+
+ if (prefManager->GetBoolPref("security.OCSP.useDefaultResponder", &boolpref) == 0)
+ {
+ if (boolpref)
+ {
+ list[prefs.n].value = nsCRT::strdup("true");
+ }
+ else
+ {
+ list[prefs.n].value = nsCRT::strdup("false");
+ }
+ list[prefs.n].key = nsCRT::strdup("security.OCSP.useDefaultResponder");
+ list[prefs.n].type = BOOL_PREF;
+ prefs.n++;
+ }
+
+ if (prefManager->CopyCharPref("security.OCSP.URL", &strpref) == 0)
+ {
+ list[prefs.n].value = strpref;
+ list[prefs.n].key = nsCRT::strdup("security.OCSP.URL");
+ list[prefs.n].type = STRING_PREF;
+ prefs.n++;
+ }
+
+ if (prefManager->CopyCharPref("security.OCSP.signingCA", &strpref) == 0)
+ {
+ list[prefs.n].value = strpref;
+ list[prefs.n].key = nsCRT::strdup("security.OCSP.signingCA");
+ list[prefs.n].type = STRING_PREF;
+ prefs.n++;
+ }
+
+ /* now application-specific preferences */
+ /* get navigator preferences */
+ get_pack_bool_pref(prefManager, "security.warn_entering_secure", (CMTSetPrefElement*)list, &prefs.n);
+ get_pack_bool_pref(prefManager, "security.warn_leaving_secure", (CMTSetPrefElement*)list, &prefs.n);
+ get_pack_bool_pref(prefManager, "security.warn_viewing_mixed", (CMTSetPrefElement*)list, &prefs.n);
+ get_pack_bool_pref(prefManager, "security.warn_submit_insecure", (CMTSetPrefElement*)list, &prefs.n);
+
+ // Add any other prefs here such as ldap or mail/news.
+
+ CMT_SetSavePrefsCallback(mControl, (savePrefsCallback_fn)SaveAllPrefs);
+
+ if (CMT_PassAllPrefs(mControl, prefs.n, (CMTSetPrefElement*)prefs.list) != CMTSuccess)
+ {
+ goto loser;
+ }
+
+ rv = NS_OK; /* success */
+loser:
+ /* clean out memory for prefs */
+ for (i = 0; i < prefs.n; i++)
+ {
+ if (prefs.list[i].key != NULL)
+ {
+ nsCRT::free(prefs.list[i].key);
+ }
+
+ if (prefs.list[i].value != NULL)
+ {
+ nsCRT::free(prefs.list[i].value);
+ }
+ }
+
+ if (prefs.list != NULL)
+ {
+ delete(prefs.list);
+ }
+ return rv;
+}
+
+NS_IMETHODIMP
+nsPSMComponent::GetControlConnection( CMT_CONTROL * *_retval )
+{
+ nsresult rv;
+ *_retval = nsnull;
+ if (mControl)
+ {
+ *_retval = mControl;
+ return NS_OK;
+ }
+ else /* initialize mutex, sock table, etc. */
+ {
+
+ if (nsPSMMutexInit() != PR_SUCCESS)
+ return NS_ERROR_FAILURE;
+
+ mControl = CMT_ControlConnect(&nsPSMMutexTbl, &nsPSMShimTbl);
+
+ if (mControl == nsnull)
+ {
+ //Try to find it.
+ int err;
+ char filepath[MAXREGPATHLEN];
+
+ err = VR_GetPath(PSM_VERSION_REG_KEY, sizeof(filepath), filepath);
+ if ( err == REGERR_OK )
+ {
+ nsFileSpec psmSpec(filepath);
+ psmSpec += PSM_FILE_NAME;
+
+ if (psmSpec.Exists())
+ {
+ mControl = CMT_EstablishControlConnection((char *)psmSpec.GetNativePathCString(), &nsPSMShimTbl, &nsPSMMutexTbl);
+ }
+ }
+ }
+
+#ifndef XP_MAC
+ if (mControl == nsnull)
+ {
+ nsSpecialSystemDirectory sysDir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
+ nsFileSpec spec = sysDir;
+
+ spec += "psm/";
+ spec += PSM_FILE_NAME;
+
+ if (spec.Exists())
+ {
+ mControl = CMT_EstablishControlConnection((char *)spec.GetNativePathCString(), &nsPSMShimTbl, &nsPSMMutexTbl);
+ }
+ }
+#else
+ if (mControl == nsnull)
+ {
+ // Attempt to locate "Personal Security Manager" in "Essential Files".
+ nsCOMPtr aPSMApp = do_CreateInstance(NS_LOCAL_FILE_PROGID, &rv);
+ if (NS_SUCCEEDED(rv))
+ {
+ nsCOMPtr psmAppMacFile = do_QueryInterface(aPSMApp, &rv);
+ if (NS_SUCCEEDED(rv))
+ {
+ rv = psmAppMacFile->InitFindingAppByCreatorCode('nPSM');
+ if (NS_SUCCEEDED(rv))
+ {
+ rv = psmAppMacFile->LaunchAppWithDoc(nsnull, PR_TRUE);
+ if (NS_SUCCEEDED(rv))
+ {
+ const PRUint32 kMaxWaitTicks = 180; // max 3 seconds
+ PRUint32 endTicks = ::TickCount() + kMaxWaitTicks;
+
+ do
+ {
+ EventRecord theEvent;
+ WaitNextEvent(0, &theEvent, 5, NULL);
+ mControl = CMT_ControlConnect(&nsPSMMutexTbl, &nsPSMShimTbl);
+ } while (!mControl && (::TickCount() < endTicks));
+
+ }
+ }
+ }
+ }
+ NS_ASSERTION(NS_SUCCEEDED(rv), "Launching Personal Security Manager failed");
+ }
+
+#endif
+
+#ifdef XP_UNIX
+ if (mControl == nsnull)
+ {
+ nsFileSpec psmSpec(PSM_FILE_LOCATION);
+ if (psmSpec.Exists())
+ {
+ mControl = CMT_EstablishControlConnection(PSM_FILE_LOCATION, &nsPSMShimTbl, &nsPSMMutexTbl);
+ }
+ }
+#endif
+
+ if (mControl == nsnull)
+ {
+ char* filePath = nsnull;
+
+ NS_WITH_PROXIED_SERVICE(nsIPSMUIHandler, handler, nsPSMUIHandlerImpl::GetCID(), NS_UI_THREAD_EVENTQ, &rv);
+ if(NS_SUCCEEDED(rv))
+ handler->PromptForFile("Please find the Personal Security Manager application", PSM_FILE_NAME, PR_TRUE, &filePath);
+ if (! filePath)
+ return NS_ERROR_FAILURE;
+
+ mControl = CMT_EstablishControlConnection(filePath, &nsPSMShimTbl, &nsPSMMutexTbl);
+ }
+
+
+ if (!mControl || InitPSMUICallbacks(mControl) != PR_SUCCESS)
+ goto failure;
+
+ nsFileSpec profileSpec;
+ char* profileName = nsnull;
+
+ NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv);
+ if (NS_FAILED(rv)) goto failure;
+
+ rv = profile->GetCurrentProfileDir(&profileSpec);
+ if (NS_FAILED(rv)) goto failure;;
+
+ rv = profile->GetCurrentProfile(&profileName);
+ if (NS_FAILED(rv)) goto failure;
+
+ CMTStatus psmStatus;
+
+ psmStatus = CMT_Hello( mControl,
+ PROTOCOL_VERSION,
+ profileName,
+ (char*)profileSpec.GetNativePathCString());
+
+ if (psmStatus == CMTFailure)
+ {
+ PR_FREEIF(profileName);
+ goto failure;
+ }
+
+ if (NS_FAILED(PassAllPrefs()))
+ {
+ PR_FREEIF(profileName);
+ goto failure;
+ }
+
+ PR_FREEIF(profileName);
+
+ *_retval = mControl;
+ return NS_OK;
+ }
+
+failure:
+
+ printf("*** Failure setting up Cartman! \n");
+
+ if (mControl)
+ {
+ CMT_CloseControlConnection(mControl);
+ mControl = NULL;
+ }
+
+ // TODO we need to unregister our UI callback BEFORE destroying our mutex.
+ // nsPSMMutexDestroy();
+
+ return NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+nsPSMComponent::DisplaySecurityAdvisor()
+{
+ CMT_CONTROL *controlConnection;
+ GetControlConnection( &controlConnection );
+ if (DisplayPSMUIDialog(controlConnection, nsnull) == PR_SUCCESS)
+ return NS_OK;
+ return NS_ERROR_FAILURE;
+}
+
+//-----------------------------------------
+// Secure Hash Functions
+//-----------------------------------------
+NS_IMETHODIMP
+nsPSMComponent::HashBegin(PRUint32 alg, PRUint32* id)
+{
+ CMT_CONTROL *controlConnection;
+ if (NS_FAILED(GetControlConnection( &controlConnection )))
+ return NS_ERROR_FAILURE;
+
+ if(CMT_HashCreate(controlConnection, alg, (CMUint32*)id) != CMTSuccess)
+ return NS_ERROR_FAILURE;
+ if(CMT_HASH_Begin(controlConnection, *id) != CMTSuccess)
+ return NS_ERROR_FAILURE;
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPSMComponent::HashUpdate(PRUint32 id, const char* buf, PRUint32 buflen)
+{
+ CMT_CONTROL *controlConnection;
+
+ if (NS_FAILED(GetControlConnection( &controlConnection )))
+ return NS_ERROR_FAILURE;
+ if (CMT_HASH_Update(controlConnection, id,
+ (const unsigned char*)buf, buflen) != CMTSuccess)
+ return NS_ERROR_FAILURE;
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPSMComponent::HashEnd(PRUint32 id, char** hash, PRUint32* hashlen,
+ PRUint32 maxLen)
+{
+ if (!hash)
+ return NS_ERROR_ILLEGAL_VALUE;
+
+ CMT_CONTROL *controlConnection;
+ if (NS_FAILED(GetControlConnection( &controlConnection )))
+ return NS_ERROR_FAILURE;
+
+ if(CMT_HASH_End(controlConnection, id, (unsigned char*)*hash,
+ (CMUint32*)hashlen, maxLen) != CMTSuccess)
+ return NS_ERROR_FAILURE;
+ CMT_HASH_Destroy(controlConnection, id);
+ return NS_OK;
+}
+
+//-----------------------------------------
+// Signature Verification Functions
+//-----------------------------------------
+PR_STATIC_CALLBACK(void)
+UselessPK7DataSink(void* arg, const char* buf, CMUint32 len)
+{
+}
+
+NS_IMETHODIMP
+nsPSMComponent::VerifyRSABegin(PRUint32* id)
+{
+ if (!id)
+ return NS_ERROR_ILLEGAL_VALUE;
+
+ CMT_CONTROL *controlConnection;
+ if (NS_FAILED(GetControlConnection( &controlConnection )))
+ return NS_ERROR_FAILURE;
+
+ CMInt32* blah = nsnull;
+ CMTStatus result = CMT_PKCS7DecoderStart(controlConnection, nsnull /*?*/,
+ (CMUint32*)id, blah,
+ UselessPK7DataSink, nsnull);
+ if (result == CMTSuccess)
+ return NS_OK;
+ else
+ return NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+nsPSMComponent::VerifyRSAUpdate(PRUint32 id, const char* buf, PRUint32 buflen)
+{
+ CMT_CONTROL *controlConnection;
+ if (NS_FAILED(GetControlConnection( &controlConnection )))
+ return NS_ERROR_FAILURE;
+
+ CMTStatus result = CMT_PKCS7DecoderUpdate(controlConnection, id, buf, buflen);
+ if (result == CMTSuccess)
+ return NS_OK;
+ else
+ return NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+nsPSMComponent::VerifyRSAEnd(PRUint32 id, const char* plaintext,
+ PRUint32 plaintextLen,
+ PRBool keepCert, nsIPrincipal** aPrincipal)
+{
+ CMT_CONTROL *controlConnection;
+ if (NS_FAILED(GetControlConnection( &controlConnection )))
+ return NS_ERROR_FAILURE;
+
+ CMUint32 contentInfo;
+ CMTStatus result = CMT_PKCS7DecoderFinish(controlConnection,
+ id, &contentInfo);
+ if (result != CMTSuccess)
+ return NS_ERROR_FAILURE;
+
+ //-- Make sure a signature is present
+ CMInt32 isSigned;
+ result = CMT_GetNumericAttribute(controlConnection, contentInfo,
+ SSM_FID_P7CINFO_IS_SIGNED, &isSigned);
+ if (result != CMTSuccess || !isSigned)
+ return NS_ERROR_FAILURE;
+
+ // SHA1 hash the plaintext to compare it to the signature
+ CMUint32 hashId;
+ CMT_HashCreate(controlConnection, PSM_HASH_SHA1, &hashId);
+ CMT_HASH_Begin(controlConnection, hashId);
+ result = CMT_HASH_Update(controlConnection, hashId,
+ (const unsigned char*)plaintext, plaintextLen);
+ if (result != CMTSuccess) return NS_ERROR_FAILURE;
+
+ unsigned char* hash = (unsigned char*)PR_MALLOC(PSM_HASH_SHA1_LENGTH);
+ if (!hash) return NS_ERROR_OUT_OF_MEMORY;
+ CMUint32 hashLen;
+ result = CMT_HASH_End(controlConnection, hashId, hash,
+ &hashLen, PSM_HASH_SHA1_LENGTH);
+ NS_ASSERTION(hashLen == PSM_HASH_SHA1_LENGTH,
+ "PSMComponent: Hash too short.");
+ CMT_HASH_Destroy(controlConnection, hashId);
+ if (result != CMTSuccess)
+ {
+ PR_FREEIF(hash);
+ return NS_ERROR_FAILURE;
+ }
+ //-- Verify signature
+ CMInt32 ok;
+ CMTItemStr item;
+ item.data = hash;
+ item.len = hashLen;
+ result = CMT_PKCS7VerifyDetachedSignature(controlConnection, contentInfo,
+ 6 /* =Object Sining Cert */,
+ 3 /* =SHA1 algorithm (MD5=2)*/,
+ (CMUint32)keepCert,
+ &item, &ok);
+ PR_FREEIF(hash);
+ if (result != CMTSuccess) return NS_ERROR_FAILURE;
+ //-- Did it verify?
+
+ if (ok != 0)
+ *aPrincipal = nsnull;
+ else
+ {
+ //-- Read cert info
+ CMInt32 cert;
+ result = CMT_GetNumericAttribute(controlConnection, contentInfo,
+ SSM_FID_P7CINFO_SIGNER_CERT, &cert);
+ if (result != CMTSuccess) return NS_ERROR_FAILURE;
+ CMTItemStr issuer;
+ result = CMT_GetStringAttribute(controlConnection, cert,
+ SSM_FID_CERT_ISSUER_NAME, &issuer);
+ CMTItemStr serial;
+ result = CMT_GetStringAttribute(controlConnection, cert,
+ SSM_FID_CERT_SERIAL_NUMBER, &serial);
+ //-- Get a principal
+ nsresult rv;
+ NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,
+ NS_SCRIPTSECURITYMANAGER_PROGID, &rv)
+ if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
+ rv = secMan->GetCertificatePrincipal((char*)issuer.data,
+ (char*)serial.data, aPrincipal);
+ if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
+ }
+
+
+ result = CMT_PKCS7DestroyContentInfo(controlConnection, contentInfo);
+
+ if(result != CMTSuccess) return NS_ERROR_FAILURE;
+ return NS_OK;
+}
diff --git a/mozilla/netwerk/security/psm/nsPSMComponent.h b/mozilla/netwerk/security/psm/nsPSMComponent.h
new file mode 100644
index 00000000000..c74b8a3ba83
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMComponent.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nscore.h"
+#include "nsIPSMComponent.h"
+
+#define NS_PSMCOMPONENT_CID {0xddcae170, 0x5412, 0x11d3, {0xbb, 0xc8, 0x00, 0x00, 0x86, 0x1d, 0x12, 0x37}}
+
+// Implementation of the PSM app shell component interface.
+class nsPSMComponent : public nsIPSMComponent
+{
+public:
+ NS_DEFINE_STATIC_CID_ACCESSOR( NS_PSMCOMPONENT_CID );
+
+ nsPSMComponent();
+ virtual ~nsPSMComponent();
+
+ NS_DECL_ISUPPORTS
+
+ NS_DECL_NSIPSMCOMPONENT
+
+ static NS_METHOD CreatePSMComponent(nsISupports* aOuter, REFNSIID aIID, void **aResult);
+
+private:
+
+ PCMT_CONTROL mControl;
+
+ nsCOMPtr mSecureBrowserIU;
+ static nsPSMComponent* mInstance;
+ nsresult PassAllPrefs();
+};
diff --git a/mozilla/netwerk/security/psm/nsPSMModule.cpp b/mozilla/netwerk/security/psm/nsPSMModule.cpp
new file mode 100644
index 00000000000..e6b5e1c966b
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMModule.cpp
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsIModule.h"
+#include "nsIGenericFactory.h"
+
+#include "nsPSMUICallbacks.h"
+#include "nsPSMComponent.h"
+
+static nsModuleComponentInfo components[] =
+{
+ { PSM_COMPONENT_CLASSNAME,
+ NS_PSMCOMPONENT_CID,
+ PSM_COMPONENT_PROGID,
+ nsPSMComponent::CreatePSMComponent},
+
+ { PSM_UI_HANLDER_CLASSNAME,
+ NS_PSMUIHANDLER_CID,
+ PSM_UI_HANLDER_PROGID,
+ nsPSMUIHandlerImpl::CreatePSMUIHandler}
+};
+
+NS_IMPL_NSGETMODULE("PSMComponent", components);
diff --git a/mozilla/netwerk/security/psm/nsPSMMutex.c b/mozilla/netwerk/security/psm/nsPSMMutex.c
new file mode 100644
index 00000000000..e4ca512d984
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMMutex.c
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "prmon.h"
+#include "prtypes.h"
+
+#include "nsPSMMutex.h"
+
+static PRMonitor *_nsPSMMutexVar;
+
+PRStatus
+nsPSMMutexInit()
+{
+ if (!_nsPSMMutexVar)
+ _nsPSMMutexVar = PR_NewMonitor();
+ else
+ printf("PSMMutex warning got called twice\n");
+
+ return _nsPSMMutexVar ? PR_SUCCESS : PR_FAILURE;
+}
+
+PRStatus
+nsPSMMutexDestroy()
+{
+ if (!_nsPSMMutexVar)
+ return PR_FAILURE;
+
+ PR_Wait(_nsPSMMutexVar, PR_INTERVAL_NO_TIMEOUT);
+
+ PR_DestroyMonitor(_nsPSMMutexVar);
+ return PR_SUCCESS;
+}
+
+static void
+nsPSMMutexLock(CMTMutexPointer *p)
+{
+ PR_EnterMonitor(*(PRMonitor **)p);
+ return;
+}
+
+static void
+nsPSMMutexUnlock(CMTMutexPointer *p)
+{
+ PR_ExitMonitor(*(PRMonitor **)p);
+ return;
+}
+
+CMT_MUTEX nsPSMMutexTbl =
+{
+ &_nsPSMMutexVar,
+ (CMTMutexFunction)nsPSMMutexLock,
+ (CMTMutexFunction)nsPSMMutexUnlock
+};
diff --git a/mozilla/netwerk/security/psm/nsPSMMutex.h b/mozilla/netwerk/security/psm/nsPSMMutex.h
new file mode 100644
index 00000000000..85a04359abb
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMMutex.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#ifndef _NSPSMMUTEX_H
+#define _NSPSMMUTEX_H
+
+#include "cmtcmn.h"
+
+PR_BEGIN_EXTERN_C
+
+PR_EXTERN(CMT_MUTEX) nsPSMMutexTbl;
+
+PR_EXTERN(PRStatus) nsPSMMutexInit(void);
+PR_EXTERN(PRStatus) nsPSMMutexDestroy(void);
+
+PR_END_EXTERN_C
+
+#endif
diff --git a/mozilla/netwerk/security/psm/nsPSMShimLayer.c b/mozilla/netwerk/security/psm/nsPSMShimLayer.c
new file mode 100644
index 00000000000..e4ada606e71
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMShimLayer.c
@@ -0,0 +1,267 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nspr.h"
+#include "nsPSMShimLayer.h"
+
+#ifdef XP_UNIX
+#include
+#include
+#endif
+
+
+#define NSPSMSHIMMAXFD 50
+
+CMT_SocketFuncs nsPSMShimTbl =
+{
+ nsPSMShimGetSocket,
+ nsPSMShimConnect,
+ nsPSMShimVerifyUnixSocket,
+ nsPSMShimSend,
+ nsPSMShimSelect,
+ nsPSMShimReceive,
+ nsPSMShimShutdown,
+ nsPSMShimClose
+};
+
+
+CMTSocket
+nsPSMShimGetSocket(int unixSock)
+{
+ PRStatus rv;
+ PRFileDesc *fd;
+ CMSocket *sock;
+
+
+ if (unixSock)
+ {
+#ifndef XP_UNIX
+ return NULL;
+#else
+ fd = PR_OpenTCPSocket(AF_UNIX);
+ PR_ASSERT(fd);
+#endif
+ }
+ else
+ {
+ PRSocketOptionData sockopt;
+
+ fd = PR_NewTCPSocket();
+ PR_ASSERT(fd);
+
+ /* disable Nagle algorithm delay for control sockets */
+ sockopt.option = PR_SockOpt_NoDelay;
+ sockopt.value.no_delay = PR_TRUE;
+
+ rv = PR_SetSocketOption(fd, &sockopt);
+ PR_ASSERT(PR_SUCCESS == rv);
+ }
+
+ sock = (CMSocket *)PR_Malloc(sizeof(CMSocket));
+
+ if (sock == NULL)
+ return sock;
+
+ sock->fd = fd;
+ sock->isUnix = unixSock;
+
+ memset(&sock->netAddr, 0, sizeof(PRNetAddr));
+
+ return (CMTSocket)sock;
+}
+
+CMTStatus
+nsPSMShimConnect(CMTSocket sock, short port, char *path)
+{
+ PRStatus err;
+ PRErrorCode errcode;
+ CMTStatus rv = CMTSuccess;
+ CMSocket *cmSock = (CMSocket *)sock;
+
+ if (cmSock->isUnix)
+ {
+#ifndef XP_UNIX
+ return CMTFailure;
+#else
+ int pathLen;
+ if (!path)
+ {
+ return CMTFailure;
+ }
+
+ /* check buffer overrun */
+ pathLen = strlen(path)+1;
+
+ pathLen = pathLen < sizeof(cmSock->netAddr.local.path)
+ ? pathLen : sizeof(cmSock->netAddr.local.path);
+
+ memcpy(&cmSock->netAddr.local.path, path, pathLen);
+ cmSock->netAddr.local.family = PR_AF_LOCAL;
+#endif
+ }
+ else /* cmSock->isUnix */
+ {
+ cmSock->netAddr.inet.family = PR_AF_INET;
+ cmSock->netAddr.inet.port = PR_htons(port);
+ cmSock->netAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK);
+ }
+
+ err = PR_Connect( cmSock->fd, &cmSock->netAddr, PR_INTERVAL_MAX );
+
+ if (err == PR_FAILURE)
+ {
+ errcode = PR_GetError();
+
+ /* TODO: verify PR_INVALID_ARGUMENT_ERROR continue with connect */
+
+ switch (errcode)
+ {
+ case PR_IS_CONNECTED_ERROR:
+ rv = CMTSuccess;
+ break;
+
+ case PR_IN_PROGRESS_ERROR:
+ case PR_IO_TIMEOUT_ERROR:
+#ifdef WIN32
+ case PR_WOULD_BLOCK_ERROR:
+ case PR_INVALID_ARGUMENT_ERROR:
+#endif
+ default:
+ rv = CMTFailure;
+ break;
+ }
+ }
+
+ return rv;
+}
+
+CMTStatus
+nsPSMShimVerifyUnixSocket(CMTSocket sock)
+{
+#ifndef XP_UNIX
+ return CMTFailure;
+#else
+
+ int rv;
+ CMSocket *cmSock = (CMSocket *)sock;
+ struct stat statbuf;
+
+ if (!cmSock->isUnix)
+ return CMTFailure;
+
+ rv = stat(cmSock->netAddr.local.path, &statbuf);
+ if (rv < 0 || statbuf.st_uid != geteuid() )
+ {
+ PR_Close(cmSock->fd);
+ cmSock->fd = NULL;
+ PR_Free(cmSock);
+ return CMTFailure;
+ }
+ return CMTSuccess;
+#endif
+}
+
+size_t
+nsPSMShimSend(CMTSocket sock, void *buffer, size_t length)
+{
+ PRInt32 total;
+ CMSocket *cmSock = (CMSocket *)sock;
+
+ total = PR_Send(cmSock->fd, buffer, length, 0, PR_INTERVAL_NO_TIMEOUT);
+
+ /* TODO: for now, return 0 if there's an error */
+ return (total < 0) ? 0 : total;
+}
+
+
+CMTSocket
+nsPSMShimSelect(CMTSocket *socks, int numsocks, int poll)
+{
+ CMSocket **sockArr = (CMSocket **)socks;
+ PRPollDesc readPDs[NSPSMSHIMMAXFD];
+ PRIntervalTime timeout;
+ PRInt32 cnt;
+ int i;
+
+ memset(readPDs, 0, sizeof(readPDs));
+
+ PR_ASSERT(NSPSMSHIMMAXFD >= numsocks);
+
+ for (i=0; ifd;
+ readPDs[i].in_flags = PR_POLL_READ;
+ }
+
+ timeout = poll ? PR_INTERVAL_NO_WAIT : PR_INTERVAL_NO_TIMEOUT;
+
+ cnt = PR_Poll(readPDs, numsocks, timeout);
+
+ /* Figure out which socket was selected */
+ if (cnt > 0)
+ {
+ for (i=0; ifd, buffer, bufSize, 0, PR_INTERVAL_NO_TIMEOUT);
+
+ /* TODO: for now, return 0 if there's an error */
+ return (total < 0) ? 0 : total;
+}
+
+CMTStatus
+nsPSMShimShutdown(CMTSocket sock)
+{
+ CMSocket *cmSock = (CMSocket*)sock;
+ PRStatus rv = PR_Shutdown(cmSock->fd, PR_SHUTDOWN_SEND);
+ return (PR_SUCCESS == rv) ? CMTSuccess : CMTFailure;
+}
+
+CMTStatus
+nsPSMShimClose(CMTSocket sock)
+{
+ CMSocket *cmSock = (CMSocket*)sock;
+ PRStatus rv = PR_SUCCESS;
+ PR_ASSERT(cmSock);
+
+ rv = PR_Close(cmSock->fd);
+ cmSock->fd = NULL;
+
+ /* TODO: release ref on control connection */
+ PR_Free(cmSock);
+
+ return (PR_SUCCESS == rv) ? CMTSuccess : CMTFailure;
+}
diff --git a/mozilla/netwerk/security/psm/nsPSMShimLayer.h b/mozilla/netwerk/security/psm/nsPSMShimLayer.h
new file mode 100644
index 00000000000..c074478bf9b
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMShimLayer.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#ifndef _NSPSMSHIMLAYER_H_
+#define _NSPSMSHIMLAYER_H_
+
+#include "cmtcmn.h"
+
+PR_BEGIN_EXTERN_C
+
+/* TODO: make sure CMSocket is cleaned up */
+typedef struct CMSocket {
+ PRFileDesc *fd;
+ PRBool isUnix;
+ PRNetAddr netAddr;
+} CMSocket;
+
+PR_EXTERN(CMT_SocketFuncs) nsPSMShimTbl;
+
+PR_EXTERN(CMTSocket)
+nsPSMShimGetSocket(int unixSock);
+
+PR_EXTERN(CMTStatus)
+nsPSMShimConnect(CMTSocket sock, short port, char *path);
+
+PR_EXTERN(CMTStatus)
+nsPSMShimVerifyUnixSocket(CMTSocket sock);
+
+PR_EXTERN(size_t)
+nsPSMShimSend(CMTSocket sock, void *buffer, size_t length);
+
+PR_EXTERN(CMTSocket)
+nsPSMShimSelect(CMTSocket *socks, int numsocks, int poll);
+
+PR_EXTERN(size_t)
+nsPSMShimReceive(CMTSocket sock, void *buffer, size_t bufSize);
+
+PR_EXTERN(CMTStatus)
+nsPSMShimShutdown(CMTSocket sock);
+
+PR_EXTERN(CMTStatus)
+nsPSMShimClose(CMTSocket sock);
+
+PR_END_EXTERN_C
+
+#endif /* _NSPSMSHIMLAYER_H_ */
diff --git a/mozilla/netwerk/security/psm/nsPSMUICallbacks.cpp b/mozilla/netwerk/security/psm/nsPSMUICallbacks.cpp
new file mode 100644
index 00000000000..dc070e0b2b2
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMUICallbacks.cpp
@@ -0,0 +1,303 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsProxiedService.h"
+#include "nsIEventQueueService.h"
+#include "nsPSMUICallbacks.h"
+
+#include "nsINetSupportDialogService.h"
+#include "nsIFileSpecWithUI.h"
+
+
+
+#include "nsAppShellCIDs.h"
+#include "prprf.h"
+
+// Interfaces Needed
+#include "nsIAppShellService.h"
+#include "nsIDocShell.h"
+#include "nsIDOMWindow.h"
+#include "nsIInterfaceRequestor.h"
+#include "nsIPrompt.h"
+#include "nsIScriptGlobalObject.h"
+#include "nsIURL.h"
+#include "nsIXULWindow.h"
+
+static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
+static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
+
+
+// Happy callbacks
+static char * PromptUserCallback(void *arg, char *prompt, int isPasswd);
+static char * FilePathPromptCallback(void *arg, char *prompt, char *fileRegEx, CMUint32 shouldFileExist);
+static void ApplicationFreeCallback(char *userInput);
+static void * CartmanUIHandler(uint32 resourceID, void* clientContext, uint32 width, uint32 height, char* urlStr, void *data);
+extern "C" void CARTMAN_UIEventLoop(void *data);
+
+
+/* nsISupports Implementation for the class */
+NS_IMPL_ISUPPORTS1(nsPSMUIHandlerImpl, nsIPSMUIHandler)
+
+NS_METHOD
+nsPSMUIHandlerImpl::DisplayURI(PRInt32 width, PRInt32 height, const char *urlStr)
+{
+ nsresult rv;
+
+ NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
+ if (NS_SUCCEEDED(rv))
+ {
+ // get a parent window for the new browser window
+ nsCOMPtr parent;
+ appShell->GetHiddenWindow(getter_AddRefs(parent));
+
+ // convert it to a DOMWindow
+ nsCOMPtr docShell;
+ if (parent)
+ {
+ parent->GetDocShell(getter_AddRefs(docShell));
+ }
+ nsCOMPtr domParent(do_GetInterface(docShell));
+ nsCOMPtr sgo(do_QueryInterface(domParent));
+
+ nsCOMPtr context;
+ if (sgo)
+ {
+ sgo->GetContext(getter_AddRefs(context));
+ }
+ if (context)
+ {
+ JSContext *jsContext = (JSContext*)context->GetNativeContext();
+ if (jsContext)
+ {
+ void *stackPtr;
+
+ char buffer[256];
+ PR_snprintf(buffer,
+ sizeof(buffer),
+ "menubar=no,height=%d,width=%d",
+ height,
+ width );
+
+ jsval *argv = JS_PushArguments(jsContext, &stackPtr, "sss", urlStr, "_blank", buffer);
+ if (argv)
+ {
+ // open the window
+ nsIDOMWindow *newWindow;
+ domParent->Open(jsContext, argv, 3, &newWindow);
+ newWindow->ResizeTo(width, height);
+ JS_PopArguments(jsContext, stackPtr);
+ }
+ }
+ }
+ }
+ return rv;
+}
+
+NS_IMETHODIMP
+nsPSMUIHandlerImpl::PromptForFile(const char *prompt, const char *fileRegEx, PRBool shouldFileExist, char **outFile)
+{
+ NS_ENSURE_ARG_POINTER(outFile);
+ nsIFileSpecWithUI* file = NS_CreateFileSpecWithUI();
+
+ if (file == nsnull)
+ return NS_ERROR_NULL_POINTER;
+
+ nsresult rv = file->ChooseInputFile(prompt,
+ nsIFileSpecWithUI::eAllFiles | nsIFileSpecWithUI::eExtraFilter,
+ fileRegEx, // FIX name?
+ fileRegEx);
+
+ if (NS_FAILED(rv))
+ return rv;
+
+ rv = file->GetNativePath(outFile);
+
+ NS_RELEASE(file);
+
+ return rv;
+}
+
+NS_METHOD
+nsPSMUIHandlerImpl::CreatePSMUIHandler(nsISupports* aOuter, REFNSIID aIID, void **aResult)
+{
+ nsresult rv = NS_OK;
+ if ( aResult )
+ {
+ /* Allocate new find component object. */
+ nsPSMUIHandlerImpl *component = new nsPSMUIHandlerImpl();
+ if ( component )
+ {
+ /* Allocated OK, do query interface to get proper */
+ /* pointer and increment refcount. */
+ rv = component->QueryInterface( aIID, aResult );
+ if ( NS_FAILED( rv ) )
+ {
+ /* refcount still at zero, delete it here. */
+ delete component;
+ }
+ }
+ else
+ {
+ rv = NS_ERROR_OUT_OF_MEMORY;
+ }
+ }
+ else
+ {
+ rv = NS_ERROR_NULL_POINTER;
+ }
+ return rv;
+}
+
+
+
+extern "C" void CARTMAN_UIEventLoop(void *data)
+{
+ CMT_EventLoop((PCMT_CONTROL)data);
+}
+
+PRStatus InitPSMUICallbacks(PCMT_CONTROL control)
+{
+ if (!control)
+ return PR_FAILURE;
+
+ CMT_SetPromptCallback(control, (promptCallback_fn)PromptUserCallback, nsnull);
+ CMT_SetAppFreeCallback(control, (applicationFreeCallback_fn) ApplicationFreeCallback);
+ CMT_SetFilePathPromptCallback(control, (filePathPromptCallback_fn) FilePathPromptCallback, nsnull);
+
+ if (CMT_SetUIHandlerCallback(control, (uiHandlerCallback_fn) CartmanUIHandler, NULL) != CMTSuccess)
+ return PR_FAILURE;
+
+ PR_CreateThread(PR_USER_THREAD,
+ CARTMAN_UIEventLoop,
+ control,
+ PR_PRIORITY_NORMAL,
+ PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD,
+ 0);
+
+ return PR_SUCCESS;
+}
+
+PRStatus DisplayPSMUIDialog(PCMT_CONTROL control, void *arg)
+{
+ CMUint32 advRID = 0;
+ CMInt32 width = 0;
+ CMInt32 height = 0;
+ CMTItem urlItem = {0, NULL, 0};
+ CMTStatus rv = CMTSuccess;
+ CMTItem advisorContext = {0, NULL, 0};
+ void * pwin;
+
+ CMTSecurityAdvisorData data;
+ memset(&data, '\0', sizeof(CMTSecurityAdvisorData));
+
+ /* Create a Security Advisor context object. */
+ rv = CMT_SecurityAdvisor(control, &data, &advRID);
+
+ if (rv != CMTSuccess)
+ return PR_FAILURE;
+
+ /* Get the URL, width, height, etc. from the advisor context. */
+ rv = CMT_GetStringAttribute(control,
+ advRID,
+ SSM_FID_SECADVISOR_URL,
+ &urlItem);
+
+ if ((rv != CMTSuccess) || (!urlItem.data))
+ return PR_FAILURE;
+
+ rv = CMT_GetNumericAttribute(control,
+ advRID,
+ SSM_FID_SECADVISOR_WIDTH,
+ &width);
+ if (rv != CMTSuccess)
+ return PR_FAILURE;
+
+ rv = CMT_GetNumericAttribute(control,
+ advRID,
+ SSM_FID_SECADVISOR_HEIGHT,
+ &height);
+ if (rv != CMTSuccess)
+ return PR_FAILURE;
+
+ /* Fire the URL up in a window of its own. */
+ pwin = CartmanUIHandler(advRID, arg, width, height, (char*)urlItem.data, NULL);
+ return PR_SUCCESS;
+}
+
+
+
+void* CartmanUIHandler(uint32 resourceID, void* clientContext, uint32 width, uint32 height, char* urlStr, void *data)
+{
+ nsresult rv = NS_OK;
+
+ NS_WITH_PROXIED_SERVICE(nsIPSMUIHandler, handler, nsPSMUIHandlerImpl::GetCID(), NS_UI_THREAD_EVENTQ, &rv);
+
+ if(NS_SUCCEEDED(rv))
+ handler->DisplayURI(width, height, urlStr);
+
+ return nsnull;
+}
+
+
+
+char * PromptUserCallback(void *arg, char *prompt, int isPasswd)
+{
+
+ nsresult rv = NS_OK;
+ PRUnichar *password;
+ PRInt32 value;
+
+ NS_WITH_PROXIED_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, NS_UI_THREAD_EVENTQ, &rv);
+
+ if (NS_SUCCEEDED(rv)) {
+ rv = dialog->PromptPassword(nsString(prompt).GetUnicode(), nsnull /* window title */, &password, &value);
+
+ if (NS_SUCCEEDED(rv)) {
+ nsString a(password);
+ char* str = a.ToNewCString();
+ Recycle(password);
+ return str;
+ }
+ }
+
+ return nsnull;
+}
+
+void ApplicationFreeCallback(char *userInput)
+{
+ nsAllocator::Free(userInput);
+}
+
+char * FilePathPromptCallback(void *arg, char *prompt, char *fileRegEx, CMUint32 shouldFileExist)
+{
+ nsresult rv = NS_OK;
+
+ char* filePath = nsnull;
+
+ NS_WITH_PROXIED_SERVICE(nsIPSMUIHandler, handler, nsPSMUIHandlerImpl::GetCID(), NS_UI_THREAD_EVENTQ, &rv);
+
+ if(NS_SUCCEEDED(rv))
+ handler->PromptForFile(prompt, fileRegEx, (PRBool)shouldFileExist, &filePath);
+
+ return filePath;
+}
diff --git a/mozilla/netwerk/security/psm/nsPSMUICallbacks.h b/mozilla/netwerk/security/psm/nsPSMUICallbacks.h
new file mode 100644
index 00000000000..e87cf9f58ac
--- /dev/null
+++ b/mozilla/netwerk/security/psm/nsPSMUICallbacks.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#ifndef _NSPSMUICALLBACKS_H
+#define _NSPSMUICALLBACKS_H
+
+#include "prtypes.h"
+#include "nsIPSMUIHandler.h"
+
+PR_BEGIN_EXTERN_C
+
+#include "cmtcmn.h" /* fix */
+#include "cmtjs.h"
+
+PRStatus InitPSMUICallbacks(PCMT_CONTROL gControl);
+PRStatus DisplayPSMUIDialog(PCMT_CONTROL control, void *arg);
+
+PR_END_EXTERN_C
+
+#define NS_PSMUIHANDLER_CID {0x15944e30, 0x601e, 0x11d3, {0x8c, 0x4a, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
+
+class nsPSMUIHandlerImpl : public nsIPSMUIHandler
+{
+ public:
+
+ NS_DEFINE_STATIC_CID_ACCESSOR( NS_PSMUIHANDLER_CID );
+
+ /* ctor/dtor */
+ nsPSMUIHandlerImpl() { NS_INIT_REFCNT(); }
+ virtual ~nsPSMUIHandlerImpl() { }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIPSMUIHANDLER
+
+ static NS_METHOD CreatePSMUIHandler(nsISupports* aOuter, REFNSIID aIID, void **aResult);
+};
+
+#endif
diff --git a/mozilla/netwerk/socket/Makefile.in b/mozilla/netwerk/socket/Makefile.in
index 29d9e870f7e..79ae3d5e8c9 100755
--- a/mozilla/netwerk/socket/Makefile.in
+++ b/mozilla/netwerk/socket/Makefile.in
@@ -26,7 +26,11 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
-DIRS = base
+DIRS = base ssl
+
+ifdef ENABLE_TESTS
+DIRS += tests
+endif
include $(topsrcdir)/config/rules.mk
diff --git a/mozilla/netwerk/socket/makefile.win b/mozilla/netwerk/socket/makefile.win
index c4f9d613543..fcfd374cbbd 100644
--- a/mozilla/netwerk/socket/makefile.win
+++ b/mozilla/netwerk/socket/makefile.win
@@ -25,6 +25,7 @@ MODULE = necko
DIRS= \
base \
+ ssl \
$(NULL)
include <$(DEPTH)\config\rules.mak>
diff --git a/mozilla/netwerk/socket/ssl/Makefile.in b/mozilla/netwerk/socket/ssl/Makefile.in
new file mode 100644
index 00000000000..7dce003d2c9
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/Makefile.in
@@ -0,0 +1,49 @@
+#
+# 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 = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = necko
+
+IS_COMPONENT = 1
+LIBRARY_NAME = nkssl
+
+CPPSRCS = \
+ nsSSLIOLayer.cpp \
+ nsSSLSocketFactory.cpp \
+ nsSSLSocketProvider.cpp \
+ $(NULL)
+
+XPIDLSRCS = \
+ nsISSLSocketProvider.idl \
+ $(NULL)
+
+EXTRA_DSO_LDOPTS = -L$(DIST)/lib -lcmt -lxpcom -lprotocol
+
+NO_GEN_XPT=1
+
+include $(topsrcdir)/config/rules.mk
+
+INCLUDES += \
+ -I$(srcdir) \
+ -I$(srcdir)/../../security/psm \
+ $(NULL)
diff --git a/mozilla/netwerk/socket/ssl/makefile.win b/mozilla/netwerk/socket/ssl/makefile.win
new file mode 100644
index 00000000000..16cc9129265
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/makefile.win
@@ -0,0 +1,72 @@
+#!nmake
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+MODULE = necko
+
+DEPTH=..\..\..
+IGNORE_MANIFEST=1
+
+LIBRARY_NAME=nkssl
+DLLNAME = nkssl
+PDBFILE = $(DLLNAME).pdb
+MAPFILE = $(DLLNAME).map
+DLL = .\$(OBJDIR)\$(DLLNAME).dll
+MAKE_OBJ_TYPE = DLL
+
+include <$(DEPTH)/config/config.mak>
+
+LINCS = \
+ -I$(PUBLIC) \
+ -I$(DEPTH)\..\mozilla\netwerk\base\src \
+ -I..\..\security\psm \
+ $(NULL)
+
+LLIBS = \
+ $(LIBNSPR) \
+ $(DIST)\lib\neckopsm_s.lib \
+ $(DIST)\lib\cmt.lib \
+ $(DIST)\lib\protocol.lib \
+ $(DIST)\lib\xpcom.lib \
+ $(NULL)
+
+OBJS = \
+ .\$(OBJDIR)\nsSSLIOLayer.obj \
+ .\$(OBJDIR)\nsSSLSocketFactory.obj \
+ .\$(OBJDIR)\nsSSLSocketProvider.obj \
+ $(NULL)
+
+
+XPIDL_INCLUDES=-I$(DEPTH)\..\mozilla\dist\idl
+
+XPIDLSRCS= \
+ .\nsISSLSocketProvider.idl \
+ $(NULL)
+
+NO_GEN_XPT=1
+
+include <$(DEPTH)\config\rules.mak>
+
+install:: $(DLL)
+ $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
+
+clobber::
+ rm -rf $(OBJDIR)
diff --git a/mozilla/netwerk/socket/ssl/nsISSLSocketProvider.idl b/mozilla/netwerk/socket/ssl/nsISSLSocketProvider.idl
new file mode 100644
index 00000000000..4388d2f873b
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/nsISSLSocketProvider.idl
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsISocketProvider.idl"
+
+[noscript, uuid(856a93d0-5415-11d3-bbc8-0000861d1237)]
+interface nsISSLSocketProvider : nsISocketProvider {
+};
+
+%{C++
+#define NS_ISSLSOCKETPROVIDER_PROGID NS_NETWORK_SOCKET_PROGID_PREFIX "ssl"
+#define NS_ISSLSOCKETPROVIDER_CLASSNAME "Mozilla SSL Socket Provider Component"
+
+%}
diff --git a/mozilla/netwerk/socket/ssl/nsSSLIOLayer.cpp b/mozilla/netwerk/socket/ssl/nsSSLIOLayer.cpp
new file mode 100644
index 00000000000..79c43367573
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/nsSSLIOLayer.cpp
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nspr.h"
+
+#include "cmtcmn.h"
+
+#include "nsIPSMComponent.h"
+#include "nsIServiceManager.h"
+#include "nsPSMShimLayer.h"
+#include "nsSSLIOLayer.h"
+
+/* TODO: check for failures */
+static PRDescIdentity nsSSLIOLayerIdentity;
+static PRIOMethods nsSSLIOLayerMethods;
+
+typedef struct nsSSLIOLayerSecretData
+{
+ PCMT_CONTROL control;
+ CMSocket *cmsock;
+} nsSSLIOLayerSecretData;
+
+static nsIPSMComponent* psm = nsnull;
+
+static PRStatus PR_CALLBACK
+nsSSLIOLayerConnect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout)
+{
+ nsSSLIOLayerSecretData *secret;
+ int i=1;
+ nsresult result;
+ PRStatus rv = PR_SUCCESS;
+ CMTStatus status;
+
+ const char* hostName;
+
+ /* Set the error in case of failure. */
+
+ PR_SetError(PR_UNKNOWN_ERROR, status);
+
+ if (!fd || !addr)
+ return PR_FAILURE;
+
+ secret = (nsSSLIOLayerSecretData *)PR_Malloc(sizeof(nsSSLIOLayerSecretData));
+ if (!secret) return PR_FAILURE;
+
+ memset(secret, 0, sizeof(nsSSLIOLayerSecretData));
+
+ /* TODO: this should be allocated from cmshim layer */
+ secret->cmsock = (CMSocket *)PR_Malloc(sizeof(CMSocket));
+ if (!secret->cmsock)
+ {
+ PR_Free(secret);
+ return PR_FAILURE;
+ }
+ memset(secret->cmsock, 0, sizeof(CMSocket));
+
+ if (psm == nsnull)
+ {
+ result = nsServiceManager::GetService( PSM_COMPONENT_PROGID,
+ NS_GET_IID(nsIPSMComponent),
+ (nsISupports**)&psm);
+ if (NS_FAILED(result))
+ {
+ rv=PR_FAILURE;
+ goto fail;
+ }
+ }
+
+ result = psm->GetControlConnection(&secret->control);
+
+ if (result != PR_SUCCESS)
+ {
+ rv = PR_FAILURE;
+ goto fail;
+ }
+
+ secret->cmsock->fd = fd->lower;
+ secret->cmsock->isUnix = PR_FALSE;
+
+ /* TODO: XXX fix this RSN */
+ {
+ PRSocketOptionData opt;
+
+ // Make the socket non-blocking...
+ opt.option = PR_SockOpt_Nonblocking;
+ opt.value.non_blocking = PR_FALSE;
+ rv = PR_SetSocketOption(fd->lower, &opt);
+ if (PR_SUCCESS != rv)
+ {
+ goto fail;
+ }
+ }
+
+ char ipBuffer[PR_NETDB_BUF_SIZE];
+ rv = PR_NetAddrToString(addr, (char*)&ipBuffer, PR_NETDB_BUF_SIZE);
+
+ if (rv != PR_SUCCESS)
+ {
+ goto fail;
+ }
+
+
+ if (fd->secret) // how do we know that this is a necko nsSocketTransportFDPrivate??
+ {
+ hostName = (const char*)fd->secret;
+ }
+ else
+ {
+ // no hostname, use ip address.
+ hostName = ipBuffer;
+ }
+
+
+ fd->secret = (PRFilePrivate *)secret;
+
+ status = CMT_OpenSSLConnection(secret->control,
+ secret->cmsock,
+ SSM_REQUEST_SSL_DATA_SSL,
+ PR_ntohs(addr->inet.port),
+ ipBuffer,
+ (char*)hostName,
+ CM_TRUE,
+ nsnull);
+ if (CMTSuccess == status)
+ {
+ // since our stuff can block, what we want to do is return PR_FAILURE,
+ // but set the nspr ERROR to BLOCK. This will put us into a select
+ // q.
+ PR_SetError(PR_WOULD_BLOCK_ERROR, status);
+ return PR_FAILURE;
+ }
+
+fail:
+ fd->secret = nsnull;
+ PR_FREEIF(secret->cmsock)
+
+ secret->cmsock = nsnull;
+ PR_FREEIF(secret);
+
+ secret = nsnull;
+ return rv;
+}
+
+ /* CMT_DestroyDataConnection(ctrl, sock); */
+ /* need to strip our layer, pass result to DestroyDataConnection */
+ /* which will clean up the CMT accounting of sock, then call our */
+ /* shim layer to translate back to NSPR */
+
+static PRStatus PR_CALLBACK
+nsSSLIOLayerClose(PRFileDesc *fd)
+{
+ nsSSLIOLayerSecretData *secret = (nsSSLIOLayerSecretData *)fd->secret;
+ PRDescIdentity id = PR_GetLayersIdentity(fd);
+
+ if (secret && id == nsSSLIOLayerIdentity)
+ {
+ CMInt32 errorCode = PR_FAILURE;
+
+ if (CMT_GetSSLDataErrorCode(secret->control, secret->cmsock, &errorCode) == PR_SUCCESS)
+ {
+ CMT_DestroyDataConnection(secret->control, secret->cmsock);
+
+ PR_Free(secret);
+
+ fd->secret = NULL;
+ fd->identity = PR_INVALID_IO_LAYER;
+ }
+ return (PRStatus)errorCode;
+ }
+
+ return PR_FAILURE;
+}
+
+static PRInt32 PR_CALLBACK
+nsSSLIOLayerRead( PRFileDesc *fd, void *buf, PRInt32 amount)
+{
+ if (!fd)
+ return PR_FAILURE;
+
+ PRInt32 result = PR_Recv(fd, buf, amount, 0, PR_INTERVAL_MIN);
+
+ if (result > 0)
+ return result;
+
+ if (result == -1)
+ {
+ PRErrorCode code = PR_GetError();
+
+ if (code == PR_IO_TIMEOUT_ERROR )
+ PR_SetError(PR_WOULD_BLOCK_ERROR, PR_WOULD_BLOCK_ERROR);
+ return PR_FAILURE;
+ }
+
+ if (result == 0)
+ {
+ nsSSLIOLayerSecretData *secret = (nsSSLIOLayerSecretData *)fd->secret;
+ PRDescIdentity id = PR_GetLayersIdentity(fd);
+
+ if (secret && id == nsSSLIOLayerIdentity)
+ {
+ CMInt32 errorCode = PR_FAILURE;
+
+ CMT_GetSSLDataErrorCode(secret->control, secret->cmsock, &errorCode);
+
+ if (errorCode == PR_IO_TIMEOUT_ERROR)
+ {
+ PR_SetError(PR_WOULD_BLOCK_ERROR, PR_WOULD_BLOCK_ERROR);
+ return PR_FAILURE;
+ }
+
+ PR_SetError(0, 0);
+ return errorCode;
+ }
+ }
+
+ return result;
+}
+
+static PRInt32 PR_CALLBACK
+nsSSLIOLayerWrite( PRFileDesc *fd, const void *buf, PRInt32 amount)
+{
+ if (!fd)
+ return PR_FAILURE;
+
+ PRInt32 result = PR_Send(fd, buf, amount, 0, PR_INTERVAL_MIN);
+
+ if (result > 0)
+ return result;
+
+ if (result == -1)
+ {
+ PRErrorCode code = PR_GetError();
+
+ if (code == PR_IO_TIMEOUT_ERROR )
+ PR_SetError(PR_WOULD_BLOCK_ERROR, PR_WOULD_BLOCK_ERROR);
+ return PR_FAILURE;
+ }
+
+ if (result == 0)
+ {
+ nsSSLIOLayerSecretData *secret = (nsSSLIOLayerSecretData *)fd->secret;
+ PRDescIdentity id = PR_GetLayersIdentity(fd);
+
+ if (secret && id == nsSSLIOLayerIdentity)
+ {
+ CMInt32 errorCode = PR_FAILURE;
+
+ CMT_GetSSLDataErrorCode(secret->control, secret->cmsock, &errorCode);
+ PR_SetError(0, 0);
+ return errorCode;
+ }
+ }
+
+
+ return result;
+}
+
+PRFileDesc *
+nsSSLIOLayerNewSocket(const char* hostName)
+{
+ static PRBool firstTime = PR_TRUE;
+ PRFileDesc * sock;
+ PRFileDesc * layer;
+ PRStatus rv;
+
+ /* Get a normal NSPR socket */
+ sock = PR_NewTCPSocket(); PR_ASSERT(NULL != sock);
+
+ if (! sock) return NULL;
+
+
+ if (firstTime)
+ {
+ nsSSLIOLayerIdentity = PR_GetUniqueIdentity("Cartman layer");
+ nsSSLIOLayerMethods = *PR_GetDefaultIOMethods();
+
+ nsSSLIOLayerMethods.connect = nsSSLIOLayerConnect;
+ nsSSLIOLayerMethods.close = nsSSLIOLayerClose;
+ nsSSLIOLayerMethods.read = nsSSLIOLayerRead;
+ nsSSLIOLayerMethods.write = nsSSLIOLayerWrite;
+ firstTime = PR_FALSE;
+ }
+
+ layer = PR_CreateIOLayerStub(nsSSLIOLayerIdentity, &nsSSLIOLayerMethods);
+
+ if (layer)
+ {
+ layer->secret = (PRFilePrivate*)hostName;
+ rv = PR_PushIOLayer(sock, PR_GetLayersIdentity(sock), layer);
+ }
+
+ if(PR_SUCCESS != rv)
+ return NULL;
+
+ return sock;
+}
diff --git a/mozilla/netwerk/socket/ssl/nsSSLIOLayer.h b/mozilla/netwerk/socket/ssl/nsSSLIOLayer.h
new file mode 100644
index 00000000000..dc832a120b9
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/nsSSLIOLayer.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#ifndef _NSSSLIOLAYER_H
+#define _NSSSLIOLAYER_H
+
+#include "prtypes.h"
+#include "prio.h"
+
+PR_BEGIN_EXTERN_C
+
+//typedef PRFileDesc* (PR_CALLBACK *NSPRSocketFN)(void); ??
+
+PR_EXTERN(PRFileDesc *) nsSSLIOLayerNewSocket(const char* hostName);
+
+PR_END_EXTERN_C
+
+#endif /* _NSSSLIOLAYER_H */
diff --git a/mozilla/netwerk/socket/ssl/nsSSLSocketFactory.cpp b/mozilla/netwerk/socket/ssl/nsSSLSocketFactory.cpp
new file mode 100644
index 00000000000..610d4988cfe
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/nsSSLSocketFactory.cpp
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsIFactory.h"
+#include "nsIGenericFactory.h"
+#include "nsIServiceManager.h"
+#include "nsIModule.h"
+
+#include "nsSSLSocketProvider.h"
+
+static nsModuleComponentInfo components[] =
+{
+ { NS_ISSLSOCKETPROVIDER_CLASSNAME,
+ NS_SSLSOCKETPROVIDER_CID,
+ NS_ISSLSOCKETPROVIDER_PROGID,
+ nsSSLSocketProvider::Create }
+};
+
+NS_IMPL_NSGETMODULE("SSLSocketProviderModule", components);
+
diff --git a/mozilla/netwerk/socket/ssl/nsSSLSocketProvider.cpp b/mozilla/netwerk/socket/ssl/nsSSLSocketProvider.cpp
new file mode 100644
index 00000000000..48668160361
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/nsSSLSocketProvider.cpp
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nsIComponentManager.h"
+#include "nsIServiceManager.h"
+#include "nsSSLSocketProvider.h"
+#include "nsSSLIOLayer.h"
+
+////////////////////////////////////////////////////////////////////////////////
+
+nsSSLSocketProvider::nsSSLSocketProvider()
+{
+ NS_INIT_REFCNT();
+}
+
+nsresult
+nsSSLSocketProvider::Init()
+{
+ nsresult rv = NS_OK;
+ return rv;
+}
+
+nsSSLSocketProvider::~nsSSLSocketProvider()
+{
+}
+
+NS_IMPL_ISUPPORTS2(nsSSLSocketProvider, nsISocketProvider, nsISSLSocketProvider);
+
+NS_METHOD
+nsSSLSocketProvider::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
+{
+ if (aOuter)
+ return NS_ERROR_NO_AGGREGATION;
+
+ nsSSLSocketProvider* pSockProv = new nsSSLSocketProvider();
+
+ if (nsnull == pSockProv)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ NS_ADDREF(pSockProv);
+
+ nsresult rv = pSockProv->Init();
+
+ if (NS_SUCCEEDED(rv))
+ {
+ rv = pSockProv->QueryInterface(aIID, aResult);
+ }
+
+ NS_RELEASE(pSockProv);
+
+ return rv;
+}
+
+NS_IMETHODIMP
+nsSSLSocketProvider::NewSocket(const char *hostName, PRFileDesc **_result)
+{
+ *_result = nsSSLIOLayerNewSocket(hostName);
+
+ return (nsnull == *_result) ? NS_ERROR_SOCKET_CREATE_FAILED : NS_OK;
+}
diff --git a/mozilla/netwerk/socket/ssl/nsSSLSocketProvider.h b/mozilla/netwerk/socket/ssl/nsSSLSocketProvider.h
new file mode 100644
index 00000000000..76bbee1e4ff
--- /dev/null
+++ b/mozilla/netwerk/socket/ssl/nsSSLSocketProvider.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#ifndef _NSSSLSOCKETPROVIDER_H_
+#define _NSSSLSOCKETPROVIDER_H_
+
+#include "nsISSLSocketProvider.h"
+
+
+/* 274418d0-5437-11d3-bbc8-0000861d1237 */
+#define NS_SSLSOCKETPROVIDER_CID { 0x274418d0, 0x5437, 0x11d3, {0xbb, 0xc8, 0x00, 0x00, 0x86, 0x1d, 0x12, 0x37}}
+
+
+class nsSSLSocketProvider : public nsISSLSocketProvider
+{
+public:
+ NS_DECL_ISUPPORTS
+
+ NS_DECL_NSISOCKETPROVIDER
+
+ NS_DECL_NSISSLSOCKETPROVIDER
+
+ // nsSSLSocketProvider methods:
+ nsSSLSocketProvider();
+ virtual ~nsSSLSocketProvider();
+
+ static NS_METHOD
+ Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
+
+ nsresult Init();
+
+protected:
+};
+
+#endif /* _NSSSLSOCKETPROVIDER_H_ */
diff --git a/mozilla/netwerk/socket/tests/Makefile.in b/mozilla/netwerk/socket/tests/Makefile.in
new file mode 100644
index 00000000000..bae8cf7d458
--- /dev/null
+++ b/mozilla/netwerk/socket/tests/Makefile.in
@@ -0,0 +1,36 @@
+#
+# 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 = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+PROGRAM = TestSSL
+
+CPPSRCS = \
+ TestSSL.cpp \
+ $(NULL)
+
+LIBS = -L$(DIST)/bin \
+ $(NSPR_LIBS) \
+ -lxpcom \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
diff --git a/mozilla/netwerk/socket/tests/TestSSL.cpp b/mozilla/netwerk/socket/tests/TestSSL.cpp
new file mode 100644
index 00000000000..47f88209d1b
--- /dev/null
+++ b/mozilla/netwerk/socket/tests/TestSSL.cpp
@@ -0,0 +1,495 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+*/
+
+#include "nspr.h"
+
+#include "nsIProfile.h"
+#include "nsIServiceManager.h"
+#include "nsSpecialSystemDirectory.h"
+
+#include "nsISocketProviderService.h"
+#include "nsISocketProvider.h"
+#include "nsIPSMComponent.h"
+
+static NS_DEFINE_CID(kSocketProviderService, NS_SOCKETPROVIDERSERVICE_CID);
+
+
+PRUint32
+TestSSL_syncprintf(const char *fmt, ...)
+{
+ static PRFileDesc *logFile=0;
+ va_list marker;
+
+ if (!logFile)
+ logFile = PR_GetSpecialFD(PR_StandardError);
+
+ PR_ASSERT(logFile);
+
+ va_start(marker, fmt);
+ PR_vfprintf(logFile, fmt, marker);
+ va_end(marker);
+
+ /* PR_Sync(logFile); */
+
+ return 0;
+}
+
+
+
+/* TODO: deal with bad arg, error cases */
+PRStatus
+GetPage(PRFileDesc *sock, char *sName, PRUint16 sPort, char *path)
+{
+ PRNetAddr netAddr;
+ PRHostEnt hostEntry;
+ char netBuf[2*PR_NETDB_BUF_SIZE];
+ char outBuf[2048]; /* TODO: worry about max sizes */
+ char inBuf[32768];
+ PRIntn cmdSize;
+ PRInt32 cnt;
+ PRStatus rv;
+
+ memset(&netAddr, 0, sizeof(PRNetAddr));
+
+ rv = PR_GetHostByName(sName, netBuf, sizeof(netBuf), &hostEntry);
+
+ if (PR_SUCCESS == rv)
+ {
+ netAddr.inet.family = PR_AF_INET;
+ netAddr.inet.port = PR_htons(sPort);
+ netAddr.inet.ip = *((PRUint32 *)hostEntry.h_addr_list[0]);
+
+ rv = PR_Connect(sock, &netAddr, PR_INTERVAL_NO_TIMEOUT);
+ }
+
+ if (PR_SUCCESS == rv)
+ {
+ TestSSL_syncprintf("Connected to %s on port %d\n", sName, sPort);
+ cmdSize = PR_snprintf(outBuf,
+ sizeof(outBuf), "GET %s HTTP/1.0\r\n\r\n", path);
+ outBuf[cmdSize] = 0; /* TODO: shouldn't assume positive value */
+
+ cnt = PR_Send(sock, outBuf, cmdSize, 0, PR_INTERVAL_NO_TIMEOUT);
+ TestSSL_syncprintf("Send command cmdSize=%d, cnt=%d\n", cmdSize, cnt);
+ TestSSL_syncprintf("Send command cmd\n%s", outBuf);
+ if (cnt < 0)
+ rv = PR_FAILURE;
+ }
+
+ if (PR_SUCCESS == rv)
+ {
+ PR_Sleep(PR_SecondsToInterval(1));
+ memset(inBuf, 0, sizeof(inBuf));
+
+ cnt = PR_Recv(sock, inBuf, sizeof(inBuf), 0, PR_INTERVAL_NO_TIMEOUT);
+
+ if (cnt < 0)
+ rv = PR_FAILURE;
+ }
+
+ if (PR_SUCCESS == rv)
+ {
+ inBuf[cnt] = 0;
+ TestSSL_syncprintf("Receive data cnt=%d\n", cnt);
+ TestSSL_syncprintf("----\n");
+ TestSSL_syncprintf("%s\n", inBuf);
+ TestSSL_syncprintf("----\n");
+ }
+
+ if (PR_SUCCESS == rv)
+ {
+ rv = PR_Shutdown(sock, PR_SHUTDOWN_BOTH);
+ }
+
+ return rv;
+}
+
+
+#define HTTPS_SERVER "omen"
+#define HTTPS_PORT 443
+
+#define HTTP_SERVER "omen"
+#define HTTP_PORT 80
+
+static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID);
+
+nsresult
+StartupServices(void)
+{
+ nsresult result;
+
+ NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &result);
+ if (NS_SUCCEEDED(result))
+ result = profile->Startup(nsnull);
+
+ if (NS_SUCCEEDED(result))
+ {
+ NS_WITH_SERVICE(nsIPSMComponent, psm, PSM_COMPONENT_PROGID, &result);
+// psm->Initialize(nsnull, nsnull);
+ }
+ return result;
+}
+
+PRIntn
+main(PRIntn argc, char **argv)
+{
+ PRFileDesc *sockS;
+ PRFileDesc *sock;
+ nsresult rv;
+
+ /* initialize NSPR and logFile */
+ PR_STDIO_INIT();
+
+ StartupServices();
+
+ NS_WITH_SERVICE(nsISocketProviderService,
+ pProviderService,
+ kSocketProviderService,
+ &rv);
+
+ nsISocketProvider *pProvider;
+ if (NS_SUCCEEDED(rv))
+ rv = pProviderService->GetSocketProvider("ssl", &pProvider);
+ if (NS_SUCCEEDED(rv))
+ rv = pProvider->NewSocket( HTTP_SERVER, &sockS );
+ sock = PR_NewTCPSocket();
+
+ /* grab pages using the PRFileDesc's */
+ GetPage(sockS, HTTPS_SERVER, HTTPS_PORT, "/index.html");
+ GetPage(sock, HTTP_SERVER, HTTP_PORT, "/index.html");
+ PR_Close(sockS);
+ PR_Close(sock);
+
+ if (NS_SUCCEEDED(rv))
+ rv = pProvider->NewSocket( HTTPS_SERVER, &sockS );
+ GetPage(sockS, HTTPS_SERVER, HTTPS_PORT, "/index.html");
+ PR_Close(sockS);
+ NS_RELEASE(pProvider);
+
+ return 0;
+}
+
+
+
+#ifdef TESTIOLAYER
+
+static PRDescIdentity identity;
+
+static PRIOMethods myMethods;
+
+static PRUint16 default_port = 12273;
+static PRNetAddr server_address;
+
+static PRIntn minor_iterations = 5;
+static PRIntn major_iterations = 1;
+
+
+static PRInt32 PR_CALLBACK
+MyRecv(PRFileDesc *fd, void *buf, PRInt32 amount,
+ PRIntn flags, PRIntervalTime timeout)
+{
+ char *b = (char*)buf;
+ PRFileDesc *lo = fd->lower;
+ PRInt32 rv, readin = 0, request;
+
+ TestSSL_syncprintf(
+ "MyRecv start\n");
+
+ TestSSL_syncprintf(
+ "MyRecv waiting for permission request\n");
+ rv = lo->methods->recv(lo, &request, sizeof(request), flags, timeout);
+
+ if (0 < rv)
+ {
+ TestSSL_syncprintf(
+ "MyRecv received permission request for %d bytes\n", request);
+
+
+ TestSSL_syncprintf(
+ "MyRecv sending permission for %d bytes\n", request);
+ rv = lo->methods->send(
+ lo, &request, sizeof(request), flags, timeout);
+
+ if (0 < rv)
+ {
+ TestSSL_syncprintf(
+ "MyRecv waiting for data\n");
+ while (readin < request)
+ {
+ rv = lo->methods->recv(
+ lo, b + readin, amount - readin, flags, timeout);
+ if (rv <= 0) break;
+ TestSSL_syncprintf(
+ "MyRecv received %d bytes\n", rv);
+ readin += rv;
+ }
+ rv = readin;
+ }
+ }
+
+ TestSSL_syncprintf(
+ "MyRecv end\n");
+
+ return rv;
+}
+
+static PRInt32 PR_CALLBACK
+MySend(PRFileDesc *fd, const void *buf, PRInt32 amount,
+ PRIntn flags, PRIntervalTime timeout)
+{
+ PRFileDesc *lo = fd->lower;
+ const char *b = (const char*)buf;
+ PRInt32 rv, wroteout = 0, request;
+
+ TestSSL_syncprintf(
+ "MySend start\n");
+ TestSSL_syncprintf(
+ "MySend asking permission to send %d bytes\n", amount);
+
+ rv = lo->methods->send(lo, &amount, sizeof(amount), flags, timeout);
+ if (0 < rv)
+ {
+ TestSSL_syncprintf(
+ "MySend waiting for permission to send %d bytes\n", amount);
+ rv = lo->methods->recv(
+ lo, &request, sizeof(request), flags, timeout);
+ if (0 < rv)
+ {
+ PR_ASSERT(request == amount);
+ TestSSL_syncprintf(
+ "MySend got permission to send %d bytes\n", request);
+ while (wroteout < request)
+ {
+ TestSSL_syncprintf("MySend writing %d bytes\n", request-wroteout);
+ rv = lo->methods->send(
+ lo, b + wroteout, request - wroteout, flags, timeout);
+ if (rv <= 0)
+ {
+ TestSSL_syncprintf("MySend send error %d\n", rv);
+ break;
+ }
+ TestSSL_syncprintf("MySend wrote %d bytes\n", rv);
+ wroteout += rv;
+ }
+ rv = amount;
+ }
+ }
+
+ TestSSL_syncprintf(
+ "MySend end\n");
+ return rv;
+}
+
+static void PR_CALLBACK ServerCallback(void *arg)
+{
+ PRStatus rv;
+ PRUint8 buffer[100];
+ PRFileDesc *service;
+ PRUintn empty_flags = 0;
+ PRIntn bytes_read, bytes_sent;
+ PRFileDesc *stack = (PRFileDesc*)arg;
+ PRNetAddr any_address, client_address;
+
+ TestSSL_syncprintf("Begin ServerCallback\n");
+
+ rv = PR_InitializeNetAddr(PR_IpAddrAny, default_port, &any_address);
+ PR_ASSERT(PR_SUCCESS == rv);
+
+ rv = PR_Bind(stack, &any_address); PR_ASSERT(PR_SUCCESS == rv);
+ rv = PR_Listen(stack, 10); PR_ASSERT(PR_SUCCESS == rv);
+
+ TestSSL_syncprintf("Server in accept(), waiting for connection\n");
+ service = PR_Accept(stack, &client_address, PR_INTERVAL_NO_TIMEOUT);
+ TestSSL_syncprintf("Server connection accepted\n");
+
+ do
+ {
+ TestSSL_syncprintf("Server starting to receive\n");
+ bytes_read = PR_Recv(
+ service, buffer, sizeof(buffer), empty_flags, PR_INTERVAL_NO_TIMEOUT);
+ if (0 != bytes_read)
+ {
+ TestSSL_syncprintf("Server received %d bytes\n", bytes_read);
+ PR_ASSERT(bytes_read > 0);
+
+ TestSSL_syncprintf("Server sending %d bytes\n", bytes_read);
+ bytes_sent = PR_Send(
+ service, buffer, bytes_read, empty_flags, PR_INTERVAL_NO_TIMEOUT);
+ PR_ASSERT(bytes_read == bytes_sent);
+ }
+
+ } while (0 != bytes_read);
+
+ TestSSL_syncprintf("Server shutting down and closing stack\n");
+
+ rv = PR_Shutdown(service, PR_SHUTDOWN_BOTH); PR_ASSERT(PR_SUCCESS == rv);
+ rv = PR_Close(service); PR_ASSERT(PR_SUCCESS == rv);
+
+ TestSSL_syncprintf("End ServerCallback\n");
+ return;
+}
+
+static void PR_CALLBACK ClientCallback(void *arg)
+{
+ PRStatus rv;
+ PRUint8 buffer[100];
+ PRIntn empty_flags = 0;
+ PRIntn bytes_read, bytes_sent;
+ PRFileDesc *stack = (PRFileDesc*)arg;
+
+ TestSSL_syncprintf("Begin ClientCallback\n");
+
+ TestSSL_syncprintf("Client connecting to server\n");
+ rv = PR_Connect(stack, &server_address, PR_INTERVAL_NO_TIMEOUT);
+ PR_ASSERT(PR_SUCCESS == rv);
+ TestSSL_syncprintf("Client connected to server\n");
+
+ while (minor_iterations-- > 0)
+ {
+ TestSSL_syncprintf("Client sending %d bytes\n", sizeof(buffer));
+ bytes_sent = PR_Send(
+ stack, buffer, sizeof(buffer), empty_flags, PR_INTERVAL_NO_TIMEOUT);
+ TestSSL_syncprintf("Client ended up sending %d bytes\n", bytes_sent);
+
+ TestSSL_syncprintf("Client expecting to receive %d bytes\n", bytes_sent);
+ PR_ASSERT(sizeof(buffer) == bytes_sent);
+ bytes_read = PR_Recv(
+ stack, buffer, bytes_sent, empty_flags, PR_INTERVAL_NO_TIMEOUT);
+ TestSSL_syncprintf("Client ended up reveiving %d bytes\n", bytes_read);
+ PR_ASSERT(bytes_read == bytes_sent);
+ }
+
+ TestSSL_syncprintf("Client shutting down stack\n");
+
+ rv = PR_Shutdown(stack, PR_SHUTDOWN_BOTH); PR_ASSERT(PR_SUCCESS == rv);
+
+ TestSSL_syncprintf("End ClientCallback\n");
+
+ return;
+}
+
+static PRFileDesc *PushLayer(PRFileDesc *stack)
+{
+ PRFileDesc *layer = PR_CreateIOLayerStub(identity, &myMethods);
+ PRStatus rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), layer);
+ TestSSL_syncprintf("Pushed layer(0x%x) onto stack(0x%x)\n", layer, stack);
+ PR_ASSERT(PR_SUCCESS == rv);
+
+ return stack;
+} /* PushLayer */
+
+
+static PRFileDesc *PopLayer(PRFileDesc *stack)
+{
+ PRFileDesc *popped = PR_PopIOLayer(stack, identity);
+ TestSSL_syncprintf("Popped layer(0x%x) from stack(0x%x)\n", popped, stack);
+ popped->dtor(popped);
+
+ return stack;
+} /* PopLayer */
+
+
+PRIntn
+main(PRIntn argc, char **argv)
+{
+ PRStatus rv;
+ PRFileDesc *client, *service;
+ const PRIOMethods *stubMethods;
+ PRThreadScope thread_scope = PR_GLOBAL_THREAD;
+ PRThread *client_thread, *server_thread;
+
+ PR_STDIO_INIT(); /* call this to init NSPR stdin/out/err */
+
+ identity = PR_GetUniqueIdentity("Dummy protocol");
+ stubMethods = PR_GetDefaultIOMethods();
+ /* are there any differences between file/socket methods? */
+
+ myMethods = *stubMethods; /* first get the entire batch */
+
+ myMethods.recv = MyRecv; /* then override the ones we care about */
+ myMethods.send = MySend; /* then override the ones we care about */
+
+ rv = PR_InitializeNetAddr(PR_IpAddrLoopback, default_port, &server_address);
+
+
+ {
+ TestSSL_syncprintf("Beginning non-layered test\n");
+ client = PR_NewTCPSocket(); PR_ASSERT(NULL != client);
+ service = PR_NewTCPSocket(); PR_ASSERT(NULL != service);
+
+ server_thread = PR_CreateThread(
+ PR_USER_THREAD, ServerCallback, service,
+ PR_PRIORITY_HIGH, thread_scope,
+ PR_JOINABLE_THREAD, 16 * 1024);
+ PR_ASSERT(NULL != server_thread);
+
+ client_thread = PR_CreateThread(
+ PR_USER_THREAD, ClientCallback, client,
+ PR_PRIORITY_NORMAL, thread_scope,
+ PR_JOINABLE_THREAD, 16 * 1024);
+ PR_ASSERT(NULL != client_thread);
+
+ rv = PR_JoinThread(client_thread);
+ PR_ASSERT(PR_SUCCESS == rv);
+ rv = PR_JoinThread(server_thread);
+ PR_ASSERT(PR_SUCCESS == rv);
+
+ rv = PR_Close(client); PR_ASSERT(PR_SUCCESS == rv);
+ rv = PR_Close(service); PR_ASSERT(PR_SUCCESS == rv);
+ TestSSL_syncprintf("Ending non-layered test\n");
+ }
+
+ TestSSL_syncprintf("----\n");
+
+ {
+ /* with layering */
+ minor_iterations = 5;
+ TestSSL_syncprintf("Beginning layered test\n");
+ client = PR_NewTCPSocket(); PR_ASSERT(NULL != client);
+ service = PR_NewTCPSocket(); PR_ASSERT(NULL != service);
+
+ server_thread = PR_CreateThread(
+ PR_USER_THREAD, ServerCallback, PushLayer(service),
+ PR_PRIORITY_HIGH, thread_scope,
+ PR_JOINABLE_THREAD, 16 * 1024);
+ PR_ASSERT(NULL != server_thread);
+
+ client_thread = PR_CreateThread(
+ PR_USER_THREAD, ClientCallback, PushLayer(client),
+ PR_PRIORITY_NORMAL, thread_scope,
+ PR_JOINABLE_THREAD, 16 * 1024);
+ PR_ASSERT(NULL != client_thread);
+
+ rv = PR_JoinThread(client_thread);
+ PR_ASSERT(PR_SUCCESS == rv);
+ rv = PR_JoinThread(server_thread);
+ PR_ASSERT(PR_SUCCESS == rv);
+
+ rv = PR_Close(client); PR_ASSERT(PR_SUCCESS == rv);
+ rv = PR_Close(service); PR_ASSERT(PR_SUCCESS == rv);
+ TestSSL_syncprintf("Ending layered test\n");
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/mozilla/netwerk/socket/tests/makefile.win b/mozilla/netwerk/socket/tests/makefile.win
new file mode 100644
index 00000000000..ac282c44f3c
--- /dev/null
+++ b/mozilla/netwerk/socket/tests/makefile.win
@@ -0,0 +1,53 @@
+#!nmake
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+#
+
+MODULE = necko
+
+DEPTH=..\..\..
+IGNORE_MANIFEST=1
+
+include <$(DEPTH)/config/config.mak>
+
+MAKE_OBJ_TYPE = EXE
+PROGRAM = .\$(OBJDIR)\TestSSL.exe
+
+LINCS = \
+ -I$(PUBLIC) \
+ -I..\ssl \
+ $(NULL)
+
+OBJS = \
+ .\$(OBJDIR)\TestSSL.obj \
+ $(NULL)
+
+LLIBS= \
+ $(DIST)\lib\nspr3.lib \
+ $(DIST)\lib\xpcom.lib \
+ $(NULL)
+
+include <$(DEPTH)\config\rules.mak>
+
+install:: $(PROGRAM)
+ $(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
+
+clobber::
+ rm -rf $(OBJDIR)
diff --git a/mozilla/xpfe/browser/resources/content/navigator.xul b/mozilla/xpfe/browser/resources/content/navigator.xul
index c251e959924..f3c659dafd4 100644
--- a/mozilla/xpfe/browser/resources/content/navigator.xul
+++ b/mozilla/xpfe/browser/resources/content/navigator.xul
@@ -25,6 +25,7 @@ Contributor(s): ______________________________________. -->
+
diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp
index affd83b4bcd..4073f6019ea 100644
--- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp
+++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp
@@ -120,7 +120,9 @@ PRBool isDoingHistory=PR_FALSE;
#endif
#ifdef DEBUG
+#ifndef DEBUG_pavlov
#define FORCE_CHECKIN_GUIDELINES
+#endif /* DEBUG_pavlov */
#endif /* DEBUG */
diff --git a/mozilla/xpfe/global/resources/content/MANIFEST b/mozilla/xpfe/global/resources/content/MANIFEST
index 657dd014ec5..1e91aab57f1 100644
--- a/mozilla/xpfe/global/resources/content/MANIFEST
+++ b/mozilla/xpfe/global/resources/content/MANIFEST
@@ -30,3 +30,4 @@ wizardOverlay.js
wizardOverlay.xul
treePopups.js
mozilla.html
+PSMTaskMenu.xul
diff --git a/mozilla/xpfe/global/resources/content/Makefile.in b/mozilla/xpfe/global/resources/content/Makefile.in
index 6af9f9215c1..bd5093db663 100644
--- a/mozilla/xpfe/global/resources/content/Makefile.in
+++ b/mozilla/xpfe/global/resources/content/Makefile.in
@@ -61,6 +61,7 @@ EXPORT_RESOURCE_CONTENT = \
$(srcdir)/wizardOverlay.js \
$(srcdir)/wizardOverlay.xul \
$(srcdir)/treePopups.js \
+ $(srcdir)/PSMTaskMenu.xul \
$(NULL)
include $(topsrcdir)/config/rules.mk
diff --git a/mozilla/xpfe/global/resources/content/PSMTaskMenu.xul b/mozilla/xpfe/global/resources/content/PSMTaskMenu.xul
new file mode 100644
index 00000000000..48879181694
--- /dev/null
+++ b/mozilla/xpfe/global/resources/content/PSMTaskMenu.xul
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/mozilla/xpfe/global/resources/content/makefile.win b/mozilla/xpfe/global/resources/content/makefile.win
index df037108469..a0458dd7c46 100644
--- a/mozilla/xpfe/global/resources/content/makefile.win
+++ b/mozilla/xpfe/global/resources/content/makefile.win
@@ -61,6 +61,7 @@ install::
$(MAKE_INSTALL) wizardOverlay.js $(DISTBROWSER)
$(MAKE_INSTALL) wizardOverlay.xul $(DISTBROWSER)
$(MAKE_INSTALL) treePopups.js $(DISTBROWSER)
+ $(MAKE_INSTALL) PSMTaskMenu.xul $(DISTBROWSER)
clobber::
rm -f $(DIST)\bin\chrome\global\content\default\*.*
diff --git a/mozilla/xpfe/global/resources/content/tasksOverlay.xul b/mozilla/xpfe/global/resources/content/tasksOverlay.xul
index d11d20cc30f..94fb0e26125 100644
--- a/mozilla/xpfe/global/resources/content/tasksOverlay.xul
+++ b/mozilla/xpfe/global/resources/content/tasksOverlay.xul
@@ -1,5 +1,6 @@
+
diff --git a/mozilla/xpfe/global/resources/locale/en-US/MANIFEST b/mozilla/xpfe/global/resources/locale/en-US/MANIFEST
index f5ef3a5084c..37c64fab8f3 100644
--- a/mozilla/xpfe/global/resources/locale/en-US/MANIFEST
+++ b/mozilla/xpfe/global/resources/locale/en-US/MANIFEST
@@ -9,3 +9,4 @@ wizardManager.properties
wizardOverlay.dtd
about.dtd
brand.properties
+PSMTaskMenu.dtd
diff --git a/mozilla/xpfe/global/resources/locale/en-US/Makefile.in b/mozilla/xpfe/global/resources/locale/en-US/Makefile.in
index add11c259a4..b24ccc871a1 100644
--- a/mozilla/xpfe/global/resources/locale/en-US/Makefile.in
+++ b/mozilla/xpfe/global/resources/locale/en-US/Makefile.in
@@ -40,6 +40,7 @@ EXPORT_RESOURCE_CONTENT = \
$(srcdir)/wizardManager.properties \
$(srcdir)/wizardOverlay.dtd \
$(srcdir)/about.dtd \
+ $(srcdir)/PSMTaskMenu.dtd \
$(NULL)
include $(topsrcdir)/config/rules.mk
diff --git a/mozilla/xpfe/global/resources/locale/en-US/PSMTaskMenu.dtd b/mozilla/xpfe/global/resources/locale/en-US/PSMTaskMenu.dtd
new file mode 100644
index 00000000000..06a2092e46c
--- /dev/null
+++ b/mozilla/xpfe/global/resources/locale/en-US/PSMTaskMenu.dtd
@@ -0,0 +1 @@
+
diff --git a/mozilla/xpfe/global/resources/locale/en-US/makefile.win b/mozilla/xpfe/global/resources/locale/en-US/makefile.win
index e4e9d48570e..dae72ff7aa0 100644
--- a/mozilla/xpfe/global/resources/locale/en-US/makefile.win
+++ b/mozilla/xpfe/global/resources/locale/en-US/makefile.win
@@ -40,6 +40,7 @@ install::
$(MAKE_INSTALL) wizardManager.properties $(DISTBROWSER)
$(MAKE_INSTALL) wizardOverlay.dtd $(DISTBROWSER)
$(MAKE_INSTALL) about.dtd $(DISTBROWSER)
+ $(MAKE_INSTALL) PSMTaskMenu.dtd $(DISTBROWSER)
clobber::
rm -f $(DIST)\bin\chrome\global\locale\en-US\*.*