Compare commits

..

1 Commits

Author SHA1 Message Date
(no author)
26bb77ccd0 This commit was manufactured by cvs2svn to create tag
'PSM11ProtocolMac_BASE'.

git-svn-id: svn://10.0.0.236/tags/PSM11ProtocolMac_BASE@67061 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-25 03:00:30 +00:00
294 changed files with 4598 additions and 43583 deletions

View File

@@ -0,0 +1,32 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 = public src res
include $(topsrcdir)/config/rules.mk

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,27 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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/config.mak>
DIRS = public src res
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,4 @@
nsIPSMComponent.idl
nsIPSMUIHandler.idl
nsISecureBrowserUI.idl
nsISSLSocketProvider.idl

View File

@@ -0,0 +1,45 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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):
# Hubbie Shaw
# Doug Turner <dougt@netscape.com>
# Terry Hayes <thayes@netscape.com>
#
MODULE = psmglue
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
XPIDLSRCS = \
nsIPSMComponent.idl \
nsIPSMUIHandler.idl \
nsISecureBrowserUI.idl \
nsIPSMSocketInfo.idl \
nsISSLSocketProvider.idl \
nsISecretDecoderRing.idl \
$(NULL)
PREF_JS_EXPORTS = $(srcdir)/psm-glue.js
include $(topsrcdir)/config/rules.mk

View File

@@ -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):
# Hubbie Shaw
# Doug Turner <dougt@netscape.com>
# Terry Hayes <thayes@netscape.com>
#
MODULE = psmglue
DEPTH=..\..\..
IGNORE_MANIFEST=1
DLLNAME = psmglue
PDBFILE = $(DLLNAME).pdb
MAPFILE = $(DLLNAME).map
DLL = .\$(OBJDIR)\$(DLLNAME).dll
MAKE_OBJ_TYPE = DLL
include <$(DEPTH)/config/config.mak>
XPIDL_INCLUDES=-I$(DEPTH)\..\mozilla\dist\idl
XPIDLSRCS= \
.\nsIPSMComponent.idl \
.\nsIPSMUIHandler.idl \
.\nsISecureBrowserUI.idl \
.\nsISSLSocketProvider.idl \
.\nsIPSMSocketInfo.idl \
.\nsISecretDecoderRing.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install::
$(MAKE_INSTALL) .\psm-glue.js $(DIST)\bin\defaults\pref

View File

@@ -0,0 +1,87 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
* Mitch Stoltz <mstoltz@netscape.com>
*/
#include "nsISupports.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( );
/**
* Display the Security Advisor. PickledStatus and hostName can be null.
* If they are, the "Selected Info" dialog will be empty.
*/
void displaySecurityAdvisor(in string pickledStatus, in string hostName);
/**
* This will send PSM all preferences that we know about.
*/
void passPrefs();
/* Sig Verification Error Codes */
const long VERIFY_OK = 0;
const long VERIFY_NOSIG = -2;
const long VERIFY_ERROR_UNKNOWN_CA = -8172;
/* Hash Algorithms (based on cmtcmn.h) */
const short MD2 = 1;
const short MD5 = 2;
const short SHA1 = 3;
const unsigned long MD2_LENGTH = 16;
const unsigned long MD5_LENGTH = 16;
const unsigned long SHA1_LENGTH = 20;
const unsigned long MAX_HASH_LENGTH = SHA1_LENGTH;
/* 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, out long result);
nsIPrincipal CreatePrincipalFromCert(in unsigned long certID);
};
%{C++
#define PSM_COMPONENT_PROGID "component://netscape/psm"
#define PSM_COMPONENT_CLASSNAME "Mozilla PSM Component"
%}

View File

@@ -0,0 +1,45 @@
/* -*- 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):
* Doug Turner <dougt@netscape.com>
*/
#include "nsISupports.idl"
%{C++
#include "cmtcmn.h"
#include "nsPSMShimLayer.h"
%}
[ptr] native psmtControlStar(CMT_CONTROL);
[ptr] native cmSocketStar(CMSocket);
[ptr] native nsFileDescStar(PRFileDesc);
[noscript, uuid(deeb8dfc-fb7a-11d3-ac84-00c04fa0d26b)]
interface nsIPSMSocketInfo : nsISupports {
readonly attribute string hostName;
readonly attribute psmtControlStar controlPtr;
readonly attribute cmSocketStar socketPtr;
readonly attribute nsFileDescStar fileDescPtr;
void getPickledStatus(out charStar pickledStatus);
};

View File

@@ -0,0 +1,36 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#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 wstring 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"
%}

View File

@@ -0,0 +1,35 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#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"
%}

View File

@@ -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 Netscape 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/NPL/
*
* 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):
* thayes@netscape.com
*
*/
#include "nsISupports.idl"
/* Buffer type - for storing 8-bit octet values */
[ptr] native buffer(unsigned char);
[scriptable, uuid(0EC80360-075C-11d4-9FD4-00C04F1B83D8)]
interface nsISecretDecoderRing: nsISupports {
/* Encrypt a buffer - callable only from C++ */
[noscript] long encrypt(in buffer data, in long dataLen, out buffer result);
/* Decrypt a buffer - callable only from C++ */
[noscript] long decrypt(in buffer data, in long dataLen, out buffer result);
/* Encrypt nul-terminated string to BASE64 output */
string encryptString(in string text);
/* Decrypt BASE64 input to nul-terminated string output */
/* There is no check for embedded nul values in the decrypted output */
string decryptString(in string crypt);
};
/*
* Configuration interface for the Secret Decoder Ring
* - this interface allows setting the window that will be
* used as parent for dialog windows (such as password prompts)
*/
[scriptable, uuid(01D8C0F0-0CCC-11d4-9FDD-000064657374)]
interface nsISecretDecoderRingConfig: nsISupports {
void setWindow(in nsISupports w);
};

View File

@@ -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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#include "nsISupports.idl"
interface nsIDOMWindow;
interface nsIDOMElement;
[scriptable, uuid(081e31e0-a144-11d3-8c7c-00609792278c)]
interface nsSecureBrowserUI : nsISupports
{
void init(in nsIDOMWindow window, in nsIDOMElement button);
void displayPageInfoUI();
};
%{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}}
%}

View File

@@ -0,0 +1,11 @@
pref("general.useragent.security", "U");
pref("security.enable_ssl2", true);
pref("security.enable_ssl3", true);
pref("security.default_personal_cert", "Select Automatically");
pref("security.ask_for_password", 0);
pref("security.password_lifetime", 30);
pref("security.warn_entering_secure", true);
pref("security.warn_leaving_secure", true);
pref("security.warn_viewing_mixed", true);
pref("security.warn_submit_insecure", true);

View File

@@ -0,0 +1,32 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 = content skin locale
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1 @@
PSMTaskMenu.xul

View File

@@ -0,0 +1,2 @@
NavSecurityOverlay.xul
NavSecurityUI.js

View File

@@ -0,0 +1,43 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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
include $(topsrcdir)/config/rules.mk
NAVIGATOR_CONTENT_DIR = $(DIST)/bin/chrome/navigator/content/
NAVIGATOR_EXPORT_CONTENT = \
$(srcdir)/NavSecurityOverlay.xul \
$(srcdir)/NavSecurityUI.js \
$(NULL)
GLOBAL_CONTENT_DIR = $(DIST)/bin/chrome/global/content/
GLOBAL_EXPORT_CONTENT = \
$(srcdir)/PSMTaskMenu.xul \
$(NULL)
install::
$(INSTALL) $(NAVIGATOR_EXPORT_CONTENT) $(NAVIGATOR_CONTENT_DIR)
$(INSTALL) $(GLOBAL_EXPORT_CONTENT) $(GLOBAL_CONTENT_DIR)

View File

@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<overlay id="NavSecurityOverlay"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xml-stylesheet href="chrome://navigator/skin/NavSecurityOverlay.css" type="text/css"?>
<html:script language="JavaScript" src="chrome://navigator/content/NavSecurityUI.js" />
<box id="state-box">
<titledbutton id="security-button" class="borderless" align="left" onclick="displayPageInfo()"/>
</box>
</overlay>

View File

@@ -0,0 +1,45 @@
/* -*- 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);
var securityUI;
function SetSecurityButton()
{
dump("in SetSecurityButton\n");
var ui = Components.classes["component://netscape/secure_browser_ui"].createInstance();
securityUI = ui.QueryInterface(Components.interfaces.nsSecureBrowserUI);
var button = document.getElementById('security-button');
if (button && window.content)
securityUI.init(window.content, button);
}
function displayPageInfo()
{
if (securityUI)
securityUI.displayPageInfoUI();
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE window SYSTEM "chrome://global/locale/PSMTaskMenu.dtd" >
<overlay id="psmTaskMenuID"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<html:script language="JavaScript">
function displaySecurityAdvisor()
{
var psm = Components.classes["component://netscape/psm"].getService();
psm = psm.QueryInterface(Components.interfaces.nsIPSMComponent);
psm.displaySecurityAdvisor( null, null );
}
</html:script>
<menupopup id="personalManagers">
<menuitem id="PSMMentItem" position="1" value="&PSMCmd.label;" oncommand="displaySecurityAdvisor()"/>
</menupopup>
</overlay>

View File

@@ -0,0 +1,37 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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/config.mak>
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) NavSecurityOverlay.xul $(DIST)\bin\chrome\navigator\content
$(MAKE_INSTALL) NavSecurityUI.js $(DIST)\bin\chrome\navigator\content
install:: $(DLL)
$(MAKE_INSTALL) PSMTaskMenu.xul $(DIST)\bin\chrome\global\content
clobber::
$(RM) $(DIST)\bin\chrome\navigator\content\NavSecurityOverlay.xul
$(RM) $(DIST)\bin\chrome\navigator\content\NavSecurityUI.js
$(RM) $(DIST)\bin\chrome\global\content\PSMTaskMenu.xul

View File

@@ -0,0 +1,32 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 = en-US
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1 @@
PSMTaskMenu.dtd

View File

@@ -0,0 +1 @@
security.properties

View File

@@ -0,0 +1,44 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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
EXPORT_RESOURCE_CONTENT = \
$(srcdir)/PSMTaskMenu.dtd \
$(NULL)
EXPORT_NAV_RESOURCE_CONTENT = \
$(srcdir)/security.properties \
$(NULL)
include $(topsrcdir)/config/rules.mk
install::
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/chrome/global/locale
$(INSTALL) $(EXPORT_NAV_RESOURCE_CONTENT) $(DIST)/bin/chrome/navigator/locale

View File

@@ -0,0 +1 @@
<!ENTITY PSMCmd.label "Security Manager">

View File

@@ -0,0 +1,36 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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>
GLOBAL_DIST=$(DIST)\bin\chrome\global\locale
NAV_DIST=$(DIST)\bin\chrome\navigator\locale
install::
$(MAKE_INSTALL) PSMTaskMenu.dtd $(GLOBAL_DIST)
$(MAKE_INSTALL) security.properties $(NAV_DIST)
clobber::
$(RM) -f $(DIST)\bin\chrome\global\locale\PSMTaskMenu.dtd
$(RM) -f $(DIST)\bin\chrome\navigator\locale\security.properties

View File

@@ -0,0 +1,28 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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):
#
Title=Security Warning
MixedContentMessage=You have requested a secure document that contains some insecure information.
LeaveSiteMessage=You have requested an insecure document. The document and any information you send back could be observed by a third party while in transit.
EnterSiteMessage=You have requested a secure document. The document and any information you send back are encrypted for privacy while in transit.
PostToInsecure=Although this document is secure, the information you have submitted is insecure and could be observed by a third party while in transit. If you are submitting passwords, credit card numbers, or other information you would like to keep private, it would be safer for you to cancel the submission.
DontShowAgain=Show Me This Alert Next Time.
FindText=Please find the Personal Security Manager application

View File

@@ -0,0 +1,27 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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=..\..\..\..
DIRS=en-US
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,27 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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/config.mak>
DIRS = skin content locale
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,4 @@
lock.gif
unlock.gif
broken.gif
NavSecurityOverlay.css

View File

@@ -0,0 +1,39 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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
include $(topsrcdir)/config/rules.mk
SKIN_DIR = $(DIST)/bin/chrome/navigator/skin/
EXPORT_SKINS = \
$(srcdir)/broken.gif \
$(srcdir)/lock.gif \
$(srcdir)/unlock.gif \
$(srcdir)/NavSecurityOverlay.css \
$(NULL)
install::
$(INSTALL) $(EXPORT_SKINS) $(SKIN_DIR)

View File

@@ -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");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

View File

@@ -0,0 +1,41 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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/config.mak>
include <$(DEPTH)\config\rules.mak>
install::
$(MAKE_INSTALL) broken.gif $(DIST)\bin\chrome\navigator\skin
$(MAKE_INSTALL) lock.gif $(DIST)\bin\chrome\navigator\skin
$(MAKE_INSTALL) unlock.gif $(DIST)\bin\chrome\navigator\skin
$(MAKE_INSTALL) NavSecurityOverlay.css $(DIST)\bin\chrome\navigator\skin
clobber::
$(RM) $(DIST)\bin\chrome\navigator\skin\broken.gif
$(RM) $(DIST)\bin\chrome\navigator\skin\lock.gif
$(RM) $(DIST)\bin\chrome\navigator\skin\unlock.gif
$(RM) $(DIST)\bin\chrome\navigator\skin\NavSecurityOverlay.css

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

View File

@@ -0,0 +1,63 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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):
# Hubbie Shaw
# Doug Turner <dougt@netscape.com>
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = psmglue
IS_COMPONENT = 1
LIBRARY_NAME = psmglue
CPPSRCS = \
nsPSMComponent.cpp \
nsPSMUICallbacks.cpp \
nsSSLSocketProvider.cpp \
nsPSMModule.cpp \
nsSSLIOLayer.cpp \
nsSecureBrowserUIImpl.cpp \
nsSDR.cpp \
$(NULL)
CSRCS = \
nsPSMMutex.c \
nsPSMShimLayer.c \
$(NULL)
EXTRA_DSO_LDOPTS = \
$(MOZ_COMPONENT_LIBS) \
-lcmt \
-lprotocol \
-lmozjs \
$(NULL)
include $(topsrcdir)/config/rules.mk
INCLUDES += \
-I$(srcdir) \
$(NULL)

View File

@@ -0,0 +1,68 @@
#!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):
# Hubbie Shaw
# Doug Turner <dougt@netscape.com>
#
MODULE = psmglue
DEPTH=..\..\..
IGNORE_MANIFEST=1
DLLNAME = psmglue
PDBFILE = $(DLLNAME).pdb
MAPFILE = $(DLLNAME).map
DLL = .\$(OBJDIR)\$(DLLNAME).dll
MAKE_OBJ_TYPE = DLL
include <$(DEPTH)/config/config.mak>
LINCS = $(LINCS) \
-I$(PUBLIC) \
-I$(PUBLIC)/security \
$(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)
OBJS = \
.\$(OBJDIR)\nsPSMMutex.obj \
.\$(OBJDIR)\nsPSMShimLayer.obj \
.\$(OBJDIR)\nsPSMComponent.obj \
.\$(OBJDIR)\nsPSMUICallbacks.obj \
.\$(OBJDIR)\nsPSMModule.obj \
.\$(OBJDIR)\nsSecureBrowserUIImpl.obj \
.\$(OBJDIR)\nsSSLIOLayer.obj \
.\$(OBJDIR)\nsSSLSocketProvider.obj \
.\$(OBJDIR)\nsSDR.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components

View File

@@ -0,0 +1,792 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
* Mitch Stoltz <mstoltz@netscape.com>
*/
#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 "rsrcids.h"
#include "nsPSMMutex.h"
#include "nsPSMShimLayer.h"
#include "nsPSMUICallbacks.h"
#include "nsISecureBrowserUI.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(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_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_THREADSAFE_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 void SaveAllPrefs(int number, CMTSetPrefElement* list)
{
nsCOMPtr<nsIPref> 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;
}
NS_IMETHODIMP
nsPSMComponent::PassPrefs()
{
// if we have not passed anything to psm yet, this function can just return.
if (!mControl)
return NS_OK;
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<nsIPref> 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 = 0; /* 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 = 30; /* 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<nsILocalFile> aPSMApp = do_CreateInstance(NS_LOCAL_FILE_PROGID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsILocalFileMac> 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))
{
NS_WITH_SERVICE(nsIStringBundleService, service, kCStringBundleServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsILocale* locale = nsnull;
nsCOMPtr<nsIStringBundle> stringBundle;
rv = service->CreateBundle(SECURITY_STRING_BUNDLE_URL, locale, getter_AddRefs(stringBundle));
if (NS_FAILED(rv)) return rv;
PRUnichar *ptrv = nsnull;
rv = stringBundle->GetStringFromName( nsString("FindText").GetUnicode(), &ptrv);
if (NS_FAILED(rv)) return rv;
handler->PromptForFile(ptrv, PSM_FILE_NAME, PR_TRUE, &filePath);
nsAllocator::Free(ptrv);
}
if (! filePath)
return NS_ERROR_FAILURE;
mControl = CMT_EstablishControlConnection(filePath, &nsPSMShimTbl, &nsPSMMutexTbl);
}
if (!mControl || InitPSMUICallbacks(mControl) != PR_SUCCESS)
goto failure;
nsFileSpec profileSpec;
PRUnichar* profileName;
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,
nsCAutoString(profileName),
(char*)profileSpec.GetNativePathCString());
if (psmStatus == CMTFailure)
{
PR_FREEIF(profileName);
goto failure;
}
if (NS_FAILED(PassPrefs()))
{
PR_FREEIF(profileName);
goto failure;
}
PR_FREEIF(profileName);
*_retval = mControl;
return NS_OK;
}
failure:
#ifdef DEBUG
printf("*** Failure setting up Cartman! \n");
#endif
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(const char *pickledStatus, const char *hostName)
{
CMT_CONTROL *controlConnection;
GetControlConnection( &controlConnection );
if (DisplayPSMUIDialog(controlConnection, pickledStatus, hostName) == 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 aKeepCert,
nsIPrincipal** aPrincipal,
PRInt32* aVerifyError)
{
*aVerifyError = -1;
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) return NS_ERROR_FAILURE;
if (!isSigned)
{
*aPrincipal = nsnull;
*aVerifyError = nsIPSMComponent::VERIFY_NOSIG;
return NS_OK;
}
// SHA1 hash the plaintext to compare it to the signature
CMUint32 hashId;
CMT_HashCreate(controlConnection, nsIPSMComponent::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(nsIPSMComponent::SHA1_LENGTH);
if (!hash) return NS_ERROR_OUT_OF_MEMORY;
CMUint32 hashLen;
result = CMT_HASH_End(controlConnection, hashId, hash,
&hashLen, nsIPSMComponent::SHA1_LENGTH);
NS_ASSERTION(hashLen == nsIPSMComponent::SHA1_LENGTH,
"PSMComponent: Hash too short.");
CMT_HASH_Destroy(controlConnection, hashId);
if (result != CMTSuccess)
{
PR_FREEIF(hash);
return NS_ERROR_FAILURE;
}
//-- Verify signature
CMTItemStr hashItem;
hashItem.data = hash;
hashItem.len = hashLen;
result = CMT_PKCS7VerifyDetachedSignature(controlConnection, contentInfo,
6 /* =Object Signing Cert */,
3 /* =SHA1 algorithm (MD5=2)*/,
(CMUint32)aKeepCert,
&hashItem, (CMInt32*)aVerifyError);
PR_FREEIF(hash);
if (result != CMTSuccess) return NS_ERROR_FAILURE;
//-- Did it verify?
if (*aVerifyError != 0)
*aPrincipal = nsnull;
else
{
//-- Generate a principal from the cert
CMUint32 certID;
result = CMT_GetRIDAttribute(controlConnection, contentInfo,
SSM_FID_P7CINFO_SIGNER_CERT, &certID);
if (result != CMTSuccess) return NS_ERROR_FAILURE;
if (NS_FAILED(CreatePrincipalFromCert(certID, aPrincipal)))
return NS_ERROR_FAILURE;
}
CMT_PKCS7DestroyContentInfo(controlConnection, contentInfo);
return NS_OK;
}
NS_IMETHODIMP
nsPSMComponent::CreatePrincipalFromCert(PRUint32 aCertID, nsIPrincipal** aPrincipal)
{
CMT_CONTROL *controlConnection;
if (NS_FAILED(GetControlConnection( &controlConnection )))
return NS_ERROR_FAILURE;
//-- Read cert info
CMTStatus result;
CMTItem issuerItem;
result = CMT_GetStringAttribute(controlConnection, aCertID,
SSM_FID_CERT_COMMON_NAME, &issuerItem);
if (result != CMTSuccess) return NS_ERROR_FAILURE;
CMTItemStr serialNumberItem;
result = CMT_GetStringAttribute(controlConnection, aCertID,
SSM_FID_CERT_SERIAL_NUMBER, &serialNumberItem);
if (result != CMTSuccess) return NS_ERROR_FAILURE;
CMTItemStr companyNameItem;
result = CMT_GetStringAttribute(controlConnection, aCertID,
SSM_FID_CERT_ORG_NAME, &companyNameItem);
if (result != CMTSuccess) return NS_ERROR_FAILURE;
//-- 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*)issuerItem.data,
(char*)serialNumberItem.data,
(char*)companyNameItem.data,
aPrincipal);
return rv;
}

View File

@@ -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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#include "nscore.h"
#include "nsIPSMComponent.h"
#include "nsIStringBundle.h"
#define SECURITY_STRING_BUNDLE_URL "chrome://navigator/locale/security.properties"
#define NS_PSMCOMPONENT_CID {0xddcae170, 0x5412, 0x11d3, {0xbb, 0xc8, 0x00, 0x00, 0x86, 0x1d, 0x12, 0x37}}
// Implementation of the PSM 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<nsISupports> mSecureBrowserIU;
static nsPSMComponent* mInstance;
};

View File

@@ -0,0 +1,86 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#include "nsIModule.h"
#include "nsIGenericFactory.h"
#include "nsPSMUICallbacks.h"
#include "nsPSMComponent.h"
#include "nsISecureBrowserUI.h"
#include "nsSecureBrowserUIImpl.h"
#include "nsSSLSocketProvider.h"
#include "nsSDR.h"
// Define SDR object constructor
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSecretDecoderRing, init)
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_SECURE_BROWSER_UI_CLASSNAME,
NS_SECURE_BROWSER_UI_CID,
NS_SECURE_BROWSER_UI_PROGID,
nsSecureBrowserUIImpl::Create
},
{
NS_SECURE_BROWSER_DOCOBSERVER_CLASSNAME,
NS_SECURE_BROWSER_DOCOBSERVER_CID,
NS_SECURE_BROWSER_DOCOBSERVER_PROGID,
nsSecureBrowserUIImpl::Create
},
{
NS_ISSLSOCKETPROVIDER_CLASSNAME,
NS_SSLSOCKETPROVIDER_CID,
NS_ISSLSOCKETPROVIDER_PROGID,
nsSSLSocketProvider::Create
},
{
NS_SDR_CLASSNAME,
NS_SDR_CID,
NS_SDR_PROGID,
nsSecretDecoderRingConstructor
}
};
NS_IMPL_NSGETMODULE("PSMComponent", components);

View File

@@ -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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#include "prmon.h"
#include "prtypes.h"
#include "nsPSMMutex.h"
static PRMonitor *_nsPSMMutexVar;
PRStatus
nsPSMMutexInit()
{
if (!_nsPSMMutexVar)
_nsPSMMutexVar = PR_NewMonitor();
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
};

View File

@@ -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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#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

View File

@@ -0,0 +1,284 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#include "nspr.h"
#include "nsPSMShimLayer.h"
#ifdef XP_UNIX
#include <sys/stat.h>
#include <unistd.h>
#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 (!sock) return CMTFailure;
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;
struct stat statbuf;
cmSock = (CMSocket *)sock;
if (!cmSock || !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;
if (!sock) return CMTFailure;
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;
if (!socks) return NULL;
memset(readPDs, 0, sizeof(readPDs));
PR_ASSERT(NSPSMSHIMMAXFD >= numsocks);
for (i=0; i<numsocks; i++)
{
readPDs[i].fd = sockArr[i]->fd;
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; i<numsocks; i++)
{
if (readPDs[i].out_flags & PR_POLL_READ)
{
return (CMTSocket)sockArr[i];
}
}
}
return NULL;
}
size_t
nsPSMShimReceive(CMTSocket sock, void *buffer, size_t bufSize)
{
PRInt32 total;
CMSocket *cmSock = (CMSocket *)sock;
if (!sock) return CMTFailure;
total = PR_Recv(cmSock->fd, 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;
if (!sock) return CMTFailure;
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);
if (!sock) return CMTFailure;
rv = PR_Close(cmSock->fd);
cmSock->fd = NULL;
PR_Free(cmSock);
return (PR_SUCCESS == rv) ? CMTSuccess : CMTFailure;
}

View File

@@ -0,0 +1,67 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#ifndef _NSPSMSHIMLAYER_H_
#define _NSPSMSHIMLAYER_H_
#include "cmtcmn.h"
#include "prio.h"
PR_BEGIN_EXTERN_C
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_ */

View File

@@ -0,0 +1,332 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#include "nsProxiedService.h"
#include "nsIEventQueueService.h"
#include "nsPSMUICallbacks.h"
#include "nsINetSupportDialogService.h"
#include "nsIFilePicker.h"
#include "nsAppShellCIDs.h"
#include "prprf.h"
#include "prmem.h"
#include "nsSSLIOLayer.h" // for SSMSTRING_PADDED_LENGTH
#include "ssmdefs.h"
#include "rsrcids.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;
nsCOMPtr<nsIDOMWindow> hiddenWindow;
JSContext *jsContext;
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = appShell->GetHiddenWindowAndJSContext( getter_AddRefs( hiddenWindow ),
&jsContext );
if ( NS_SUCCEEDED( rv ) )
{
// Set up arguments for "window.open"
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;
hiddenWindow->Open(jsContext, argv, 3, &newWindow);
newWindow->ResizeTo(width, height);
JS_PopArguments(jsContext, stackPtr);
}
}
}
return rv;
}
NS_IMETHODIMP
nsPSMUIHandlerImpl::PromptForFile(const PRUnichar *prompt, const char *fileRegEx, PRBool shouldFileExist, char **outFile)
{
NS_ENSURE_ARG_POINTER(outFile);
nsCOMPtr<nsIFilePicker> fp = do_CreateInstance("component://mozilla/filepicker");
if (!fp)
return NS_ERROR_NULL_POINTER;
fp->Init(nsnull, prompt, nsIFilePicker::modeOpen);
fp->SetFilters(nsIFilePicker::filterAll);
fp->AppendFilter(nsAutoString(fileRegEx).GetUnicode(), nsAutoString(fileRegEx).GetUnicode());
PRInt16 mode;
nsresult rv = fp->Show(&mode);
if (NS_FAILED(rv) || (mode == nsIFilePicker::returnCancel))
return rv;
nsCOMPtr<nsILocalFile> file;
rv = fp->GetFile(getter_AddRefs(file));
if (file)
file->GetPath(outFile);
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, const char *pickledStatus, const char *hostName)
{
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));
if (hostName)
{
// if there is a hostName, than this request is about
// a webpage.
data.hostname = (char*) hostName;
data.infoContext = SSM_BROWSER;
if (pickledStatus)
{
CMTItem pickledResource = {0, NULL, 0};
CMUint32 socketStatus = 0;
pickledResource.len = *(int*)(pickledStatus);
pickledResource.data = (unsigned char*) PR_Malloc(SSMSTRING_PADDED_LENGTH(pickledResource.len));
if (! pickledResource.data) return PR_FAILURE;
memcpy(pickledResource.data, pickledStatus+sizeof(int), pickledResource.len);
/* Unpickle the SSL Socket Status */
if (CMT_UnpickleResource( control,
SSM_RESTYPE_SSL_SOCKET_STATUS,
pickledResource,
&socketStatus) == CMTSuccess)
{
data.infoContext = SSM_BROWSER;
data.resID = socketStatus;
}
PR_FREEIF(pickledResource.data);
}
}
/* 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, nsnull, width, height, (char*)urlItem.data, NULL);
//allocated by cmt, we can free with free:
free(urlItem.data);
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(), nsString(" ").GetUnicode(), &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(nsAutoString(prompt).GetUnicode(), fileRegEx, (PRBool)shouldFileExist, &filePath);
return filePath;
}

View File

@@ -0,0 +1,55 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#ifndef _NSPSMUICALLBACKS_H
#define _NSPSMUICALLBACKS_H
#include "prtypes.h"
#include "cmtcmn.h"
#include "nsIPSMUIHandler.h"
PRStatus InitPSMUICallbacks(PCMT_CONTROL gControl);
PRStatus DisplayPSMUIDialog(PCMT_CONTROL control, const char* pickledStatus, const char *hostName);
#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

View File

@@ -0,0 +1,332 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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):
* thayes@netscape.com
*/
/*
#include "nsIModule.h"
#include "nsIGenericFactory.h"
*/
#include "stdlib.h"
#include "plstr.h"
#include "nsIAllocator.h"
#include "nsIServiceManager.h"
#include "nsISecretDecoderRing.h"
#include "cmtcmn.h"
#include "nsIPSMComponent.h"
#include "nsSDR.h"
/* Test version */
static const char *kSuccess = "Success:";
static const char *kFailure = "Failure:";
#if 0
// ===============================================
// nsSecretDecoderRing - implementation of nsISecretDecoderRing
// ===============================================
#define NS_SDR_PROGID "netscape.security.sdr.1"
// {0D9A0341-0CE7-11d4-9FDD-000064657374}
#define NS_SDR_CID \
{ 0xd9a0341, 0xce7, 0x11d4, { 0x9f, 0xdd, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
class nsSecretDecoderRing : public nsISecretDecoderRing
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISECRETDECODERRING
nsSecretDecoderRing();
virtual ~nsSecretDecoderRing();
nsresult init();
private:
nsIPSMComponent *mPSM;
static const char *kPrefix;
static const char *kFailed;
static const char *kPSMComponentProgID;
nsresult encode(const unsigned char *data, PRInt32 dataLen, char **_retval);
nsresult decode(const char *data, unsigned char **result, PRInt32 * _retval);
};
#endif /* 0 */
NS_IMPL_ISUPPORTS1(nsSecretDecoderRing, nsISecretDecoderRing)
nsSecretDecoderRing::nsSecretDecoderRing()
{
NS_INIT_ISUPPORTS();
mPSM = NULL;
}
nsSecretDecoderRing::~nsSecretDecoderRing()
{
if (mPSM) mPSM->Release();
}
/* Init the new instance */
nsresult nsSecretDecoderRing::
init()
{
nsresult rv;
nsISupports *psm;
CMT_CONTROL *control;
rv = nsServiceManager::GetService(kPSMComponentProgID, NS_GET_IID(nsIPSMComponent),
&psm);
if (rv == NS_OK) mPSM = (nsIPSMComponent *)psm;
rv = mPSM->GetControlConnection(&control);
return NS_OK;
}
/* [noscript] long encrypt (in buffer data, in long dataLen, out buffer result); */
NS_IMETHODIMP nsSecretDecoderRing::
Encrypt(unsigned char * data, PRInt32 dataLen, unsigned char * *result, PRInt32 *_retval)
{
nsresult rv = NS_OK;
unsigned char *r = 0;
CMT_CONTROL *control;
CMTStatus status;
CMUint32 cLen;
rv = mPSM->GetControlConnection(&control);
if (rv != CMTSuccess) { rv = NS_ERROR_NULL_POINTER; goto loser; } /* XXX */
status = CMT_SDREncrypt(control, (const unsigned char *)0, 0,
data, dataLen, result, &cLen);
if (status != CMTSuccess) { rv = NS_ERROR_NULL_POINTER; goto loser; } /* XXX */
*_retval = cLen;
loser:
return rv;
}
/* [noscript] long decrypt (in buffer data, in long dataLen, out buffer result); */
NS_IMETHODIMP nsSecretDecoderRing::
Decrypt(unsigned char * data, PRInt32 dataLen, unsigned char * *result, PRInt32 *_retval)
{
nsresult rv = NS_OK;
CMTStatus status;
CMT_CONTROL *control;
CMUint32 len;
/* Get the control connection */
rv = mPSM->GetControlConnection(&control);
if (rv != NS_OK) goto loser;
/* Call PSM to decrypt the value */
status = CMT_SDRDecrypt(control, data, dataLen, result, &len);
if (status != CMTSuccess) { rv = NS_ERROR_NULL_POINTER; goto loser; }
*_retval = len;
loser:
return rv;
}
/* string encryptString (in string text); */
NS_IMETHODIMP nsSecretDecoderRing::
EncryptString(const char *text, char **_retval)
{
nsresult rv = NS_OK;
unsigned char *encrypted = 0;
PRInt32 eLen;
rv = Encrypt((unsigned char *)text, PL_strlen(text), &encrypted, &eLen);
if (rv != NS_OK) { goto loser; }
rv = encode(encrypted, eLen, _retval);
loser:
if (encrypted) nsAllocator::Free(encrypted);
return NS_OK;
}
/* string decryptString (in string crypt); */
NS_IMETHODIMP nsSecretDecoderRing::
DecryptString(const char *crypt, char **_retval)
{
nsresult rv = NS_OK;
char *r = 0;
unsigned char *decoded = 0;
PRInt32 decodedLen;
unsigned char *decrypted = 0;
PRInt32 decryptedLen;
rv = decode(crypt, &decoded, &decodedLen);
if (rv != NS_OK) goto loser;
rv = Decrypt(decoded, decodedLen, &decrypted, &decryptedLen);
if (rv != NS_OK) goto loser;
// Convert to NUL-terminated string
r = (char *)nsAllocator::Alloc(decryptedLen+1);
if (!r) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; }
memcpy(r, decrypted, decryptedLen);
r[decryptedLen] = 0;
*_retval = r;
r = 0;
loser:
if (r) nsAllocator::Free(r);
if (decrypted) nsAllocator::Free(decrypted);
if (decoded) nsAllocator::Free(decoded);
return rv;
}
nsresult nsSecretDecoderRing::
encode(const unsigned char *data, PRInt32 dataLen, char **_retval)
{
nsresult rv = NS_OK;
char *r = 0;
// Allocate space for encoded string (with NUL)
r = (char *)nsAllocator::Alloc(dataLen+1);
if (!r) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; }
memcpy(r, data, dataLen);
r[dataLen] = 0;
*_retval = r;
r = 0;
loser:
if (r) nsAllocator::Free(r);
return rv;
}
nsresult nsSecretDecoderRing::
decode(const char *data, unsigned char **result, PRInt32 * _retval)
{
nsresult rv = NS_OK;
unsigned char *r = 0;
PRInt32 rLen;
// Allocate space for decoded string (missing NUL)
rLen = PL_strlen(data);
r = (unsigned char *)nsAllocator::Alloc(rLen);
if (!r) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; }
memcpy(r, data, rLen);
*result = r;
r = 0;
*_retval = rLen;
loser:
if (r) nsAllocator::Free(r);
return rv;
}
const char * nsSecretDecoderRing::kPrefix = "PSMtest:";
const char * nsSecretDecoderRing::kFailed = "Failed:";
const char * nsSecretDecoderRing::kPSMComponentProgID = PSM_COMPONENT_PROGID;
#if 0
// *** MODULE *** ///
////////////////////////////////////////////////////////////////////////
// Define the contructor function for the object nsSampleImpl
//
// What this does is defines a function nsSampleImplConstructor which we
// will specific in the nsModuleComponentInfo table. This function will
// be used by the generic factory to create an instance of nsSampleImpl.
//
// NOTE: This creates an instance of nsSampleImpl by using the default
// constructor nsSampleImpl::nsSampleImpl()
//
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSecretDecoderRing, init)
////////////////////////////////////////////////////////////////////////
// Define a table of CIDs implemented by this module along with other
// information like the function to create an instance, progid, and
// class name.
//
// The Registration and Unregistration proc are optional in the structure.
//
static NS_METHOD nsSDRRegistrationProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType)
{
// Do any registration specific activity like adding yourself to a
// category. The Generic Module will take care of registering your
// component with xpcom. You dont need to do that. Only any component
// specific additional activity needs to be done here.
// This functions is optional. If you dont need it, dont add it to the structure.
return NS_OK;
}
static NS_METHOD nsSDRUnregistrationProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation)
{
// Undo any component specific registration like adding yourself to a
// category here. The Generic Module will take care of unregistering your
// component from xpcom. You dont need to do that. Only any component
// specific additional activity needs to be done here.
// This functions is optional. If you dont need it, dont add it to the structure.
// Return value is not used from this function.
return NS_OK;
}
static nsModuleComponentInfo components[] =
{
{ "SDR Component", NS_SDR_CID, NS_SDR_PROGID, nsSecretDecoderRingConstructor,
nsSDRRegistrationProc /* NULL if you dont need one */,
nsSDRUnregistrationProc /* NULL if you dont need one */
}
};
////////////////////////////////////////////////////////////////////////
// Implement the NSGetModule() exported function for your module
// and the entire implementation of the module object.
//
// NOTE: If you want to use the module shutdown to release any
// module specific resources, use the macro
// NS_IMPL_NSGETMODULE_WITH_DTOR() instead of the vanilla
// NS_IMPL_NSGETMODULE()
//
NS_IMPL_NSGETMODULE("nsSecretDecoderRing", components)
#endif /* 0 */

View File

@@ -0,0 +1,60 @@
/* -*- 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):
* Terry Hayes <thayes@netscape.com>
*/
#ifndef _NSSDR_H_
#define _NSSDR_H_
#include "nsISecretDecoderRing.h"
// ===============================================
// nsSecretDecoderRing - implementation of nsISecretDecoderRing
// ===============================================
#define NS_SDR_CLASSNAME "Secret Decoder Ring"
#define NS_SDR_CID \
{ 0xd9a0341, 0xce7, 0x11d4, { 0x9f, 0xdd, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
#define NS_SDR_PROGID "netscape.security.sdr"
class nsSecretDecoderRing : public nsISecretDecoderRing
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISECRETDECODERRING
nsSecretDecoderRing();
virtual ~nsSecretDecoderRing();
nsresult init();
private:
nsIPSMComponent *mPSM;
static const char *kPrefix;
static const char *kFailed;
static const char *kPSMComponentProgID;
nsresult encode(const unsigned char *data, PRInt32 dataLen, char **_retval);
nsresult decode(const char *data, unsigned char **result, PRInt32 * _retval);
};
#endif /* _NSSDR_H_ */

View File

@@ -0,0 +1,432 @@
/* -*- 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 "nsString.h"
#include "cmtcmn.h"
#include "nsIPSMComponent.h"
#include "nsIPSMSocketInfo.h"
#include "nsIServiceManager.h"
#include "nsPSMShimLayer.h"
#include "nsSSLIOLayer.h"
static PRDescIdentity nsSSLIOLayerIdentity;
static PRIOMethods nsSSLIOLayerMethods;
static nsIPSMComponent* gPSMService = nsnull;
class nsPSMSocketInfo : public nsIPSMSocketInfo
{
public:
nsPSMSocketInfo();
~nsPSMSocketInfo();
NS_DECL_ISUPPORTS
NS_DECL_NSIPSMSOCKETINFO
// internal functions to psm-glue.
nsresult SetSocketPtr(CMSocket *socketPtr);
nsresult SetControlPtr(CMT_CONTROL *aControlPtr);
nsresult SetFileDescPtr(PRFileDesc *aControlPtr);
nsresult SetHostName(char *aHostName);
protected:
CMT_CONTROL* mControl;
CMSocket* mSocket;
PRFileDesc* mFd;
nsString mHostName;
};
static PRStatus PR_CALLBACK
nsSSLIOLayerConnect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout)
{
nsresult result;
PRStatus rv = PR_SUCCESS;
CMTStatus status = CMTFailure;
char* hostName;
/* Set the error in case of failure. */
PR_SetError(PR_UNKNOWN_ERROR, status);
if (!fd || !addr || !fd->secret)
return PR_FAILURE;
if (gPSMService == nsnull)
{
result = nsServiceManager::GetService( PSM_COMPONENT_PROGID,
NS_GET_IID(nsIPSMComponent),
(nsISupports**)&gPSMService); //FIX leak one per app run
if (NS_FAILED(result))
return PR_FAILURE;
}
// Make the socket non-blocking...
PRSocketOptionData opt;
opt.option = PR_SockOpt_Nonblocking;
opt.value.non_blocking = PR_FALSE;
rv = PR_SetSocketOption(fd->lower, &opt);
if (PR_SUCCESS != rv)
return PR_FAILURE;
char ipBuffer[PR_NETDB_BUF_SIZE];
rv = PR_NetAddrToString(addr, (char*)&ipBuffer, PR_NETDB_BUF_SIZE);
if (rv != PR_SUCCESS)
return PR_FAILURE;
if (addr->raw.family == PR_AF_INET6 && PR_IsNetAddrType(addr, PR_IpAddrV4Mapped))
{
/* Chop off the leading "::ffff:" */
strcpy(ipBuffer, ipBuffer + 7);
}
CMSocket* cmsock = (CMSocket *)PR_Malloc(sizeof(CMSocket));
if (!cmsock)
return PR_FAILURE;
memset(cmsock, 0, sizeof(CMSocket));
CMT_CONTROL *control;
result = gPSMService->GetControlConnection(&control);
if (result != PR_SUCCESS)
{
PR_FREEIF(cmsock)
return PR_FAILURE;
}
cmsock->fd = fd->lower;
cmsock->isUnix = PR_FALSE;
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
infoObject->GetHostName(&hostName);
infoObject->SetControlPtr(control);
infoObject->SetSocketPtr(cmsock);
status = CMT_OpenSSLConnection(control,
cmsock,
SSM_REQUEST_SSL_DATA_SSL,
PR_ntohs(addr->inet.port),
ipBuffer,
(hostName ? hostName : ipBuffer),
CM_FALSE,
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;
}
return PR_FAILURE;
}
/* 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)
{
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
PRDescIdentity id = PR_GetLayersIdentity(fd);
if (infoObject && id == nsSSLIOLayerIdentity)
{
CMInt32 errorCode = PR_FAILURE;
CMT_CONTROL* control;
CMSocket* socket;
infoObject->GetControlPtr(&control);
infoObject->GetSocketPtr(&socket);
if (((PRStatus) CMT_GetSSLDataErrorCode(control, socket, &errorCode)) == PR_SUCCESS)
{
CMT_DestroyDataConnection(control, socket);
NS_RELEASE(infoObject);
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)
{
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
PRDescIdentity id = PR_GetLayersIdentity(fd);
if (infoObject && id == nsSSLIOLayerIdentity)
{
CMInt32 errorCode = PR_FAILURE;
CMT_CONTROL* control;
CMSocket* socket;
infoObject->GetControlPtr(&control);
infoObject->GetSocketPtr(&socket);
CMT_GetSSLDataErrorCode(control, socket, &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)
{
nsPSMSocketInfo *infoObject = (nsPSMSocketInfo *)fd->secret;
PRDescIdentity id = PR_GetLayersIdentity(fd);
if (infoObject && id == nsSSLIOLayerIdentity)
{
CMInt32 errorCode = PR_FAILURE;
CMT_CONTROL* control;
CMSocket* socket;
infoObject->GetControlPtr(&control);
infoObject->GetSocketPtr(&socket);
CMT_GetSSLDataErrorCode(control, socket, &errorCode);
PR_SetError(0, 0);
return errorCode;
}
}
return result;
}
nsPSMSocketInfo::nsPSMSocketInfo()
{
NS_INIT_REFCNT();
mControl = nsnull;
mSocket = nsnull;
}
nsPSMSocketInfo::~nsPSMSocketInfo()
{
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsPSMSocketInfo, nsIPSMSocketInfo);
NS_IMETHODIMP
nsPSMSocketInfo::GetControlPtr(CMT_CONTROL * *aControlPtr)
{
*aControlPtr = mControl;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetControlPtr(CMT_CONTROL *aControlPtr)
{
mControl = aControlPtr;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetSocketPtr(CMSocket * *socketPtr)
{
*socketPtr = mSocket;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetSocketPtr(CMSocket *socketPtr)
{
mSocket = socketPtr;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetFileDescPtr(PRFileDesc * *aFilePtr)
{
*aFilePtr = mFd;
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetFileDescPtr(PRFileDesc *aFilePtr)
{
mFd = aFilePtr;
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetHostName(char * *aHostName)
{
*aHostName = mHostName.ToNewCString();
return NS_OK;
}
nsresult
nsPSMSocketInfo::SetHostName(char *aHostName)
{
mHostName.Assign(aHostName);
return NS_OK;
}
NS_IMETHODIMP
nsPSMSocketInfo::GetPickledStatus(char * *pickledStatusString)
{
*pickledStatusString = nsnull;
if (mSocket && mControl)
{
long level;
CMTItem pickledStatus = {0, nsnull, 0};
unsigned char* ret = nsnull;
if (CMT_GetSSLSocketStatus(mControl, mSocket, &pickledStatus, &level) == PR_FAILURE)
return nsnull;
ret = (unsigned char*) PR_Malloc( (SSMSTRING_PADDED_LENGTH(pickledStatus.len) + sizeof(int)) );
if (!ret)
return NS_ERROR_OUT_OF_MEMORY;
*(int*)ret = pickledStatus.len;
memcpy(ret+sizeof(int), pickledStatus.data, *(int*)ret);
PR_FREEIF(pickledStatus.data);
*pickledStatusString = (char*) ret;
}
return NS_OK;
}
nsresult
nsSSLIOLayerNewSocket(const char* hostName, PRFileDesc **fd, nsISupports** info)
{
static PRBool firstTime = PR_TRUE;
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;
}
PRFileDesc * sock;
PRFileDesc * layer;
PRStatus rv;
/* Get a normal NSPR socket */
sock = PR_NewTCPSocket();
if (! sock) return NS_ERROR_OUT_OF_MEMORY;
layer = PR_CreateIOLayerStub(nsSSLIOLayerIdentity, &nsSSLIOLayerMethods);
if (! layer)
{
PR_Close(sock);
return NS_ERROR_FAILURE;
}
nsPSMSocketInfo *infoObject = new nsPSMSocketInfo();
if (!infoObject)
{
PR_Close(sock);
// clean up IOLayerStub.
return NS_ERROR_FAILURE;
}
NS_ADDREF(infoObject);
infoObject->SetHostName((char*)hostName);
layer->secret = (PRFilePrivate*) infoObject;
rv = PR_PushIOLayer(sock, PR_GetLayersIdentity(sock), layer);
if (rv == PR_SUCCESS)
{
*fd = sock;
*info = infoObject;
NS_ADDREF(*info);
return NS_OK;
}
PR_Close(sock);
return NS_ERROR_FAILURE;
}

View File

@@ -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"
#include "nsIPSMSocketInfo.h"
// define taken from 4.x cartman glue code.
#define SSMSTRING_PADDED_LENGTH(x) ((((x)+3)/4)*4)
nsresult nsSSLIOLayerNewSocket(const char* hostName, PRFileDesc **fd, nsISupports **securityInfo);
#endif /* _NSSSLIOLAYER_H */

View File

@@ -0,0 +1,83 @@
/* -*- 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_THREADSAFE_ISUPPORTS2(nsSSLSocketProvider, nsISocketProvider, nsISSLSocketProvider);
NS_METHOD
nsSSLSocketProvider::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsresult rv;
nsSSLSocketProvider * inst;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
NS_NEWXPCOM(inst, nsSSLSocketProvider);
if (NULL == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
return rv;
}
NS_IMETHODIMP
nsSSLSocketProvider::NewSocket(const char *hostName, PRFileDesc **_result, nsISupports **securityInfo)
{
nsresult rv = nsSSLIOLayerNewSocket(hostName, _result, securityInfo);
return (NS_FAILED(rv)) ? NS_ERROR_SOCKET_CREATE_FAILED : NS_OK;
}

View File

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

View File

@@ -0,0 +1,619 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#include "nspr.h"
#include "prlog.h"
#include "nsISecureBrowserUI.h"
#include "nsSecureBrowserUIImpl.h"
#include "nsIPSMComponent.h"
#include "nsPSMComponent.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 "nsIWebProgress.h"
#include "nsIChannel.h"
#include "nsIPSMSocketInfo.h"
#include "nsIURI.h"
#include "prmem.h"
#include "nsINetSupportDialogService.h"
#include "nsIPrompt.h"
#include "nsICommonDialogs.h"
#include "nsIPref.h"
#include "nsIFormSubmitObserver.h"
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_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"
#if defined(PR_LOGGING)
//
// Log module for nsSecureBroswerUI logging...
//
// To enable logging (see prlog.h for full details):
//
// set NSPR_LOG_MODULES=nsSecureBroswerUI:5
// set NSPR_LOG_FILE=nspr.log
//
// this enables PR_LOG_DEBUG level information and places all output in
// the file nspr.log
//
PRLogModuleInfo* gSecureDocLog = nsnull;
#endif /* PR_LOGGING */
NS_IMETHODIMP
nsSecureBrowserUIImpl::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsresult rv;
nsSecureBrowserUIImpl * inst;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
NS_NEWXPCOM(inst, nsSecureBrowserUIImpl);
if (NULL == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
return rv;
}
nsSecureBrowserUIImpl::nsSecureBrowserUIImpl()
{
NS_INIT_REFCNT();
#if defined(PR_LOGGING)
if (nsnull == gSecureDocLog) {
gSecureDocLog = PR_NewLogModule("nsSecureBroswerUI");
}
#endif /* PR_LOGGING */
mIsSecureDocument = mMixContentAlertShown = mIsDocumentBroken = PR_FALSE;
mLastPSMStatus = nsnull;
mCurrentURI = nsnull;
mSecurityButton = nsnull;
}
nsSecureBrowserUIImpl::~nsSecureBrowserUIImpl()
{
PR_FREEIF(mLastPSMStatus);
}
NS_IMPL_ISUPPORTS4(nsSecureBrowserUIImpl,
nsSecureBrowserUI,
nsIWebProgressListener,
nsIFormSubmitObserver,
nsIObserver);
NS_IMETHODIMP
nsSecureBrowserUIImpl::Init(nsIDOMWindow *window, nsIDOMElement *button)
{
mSecurityButton = button;
mWindow = window;
nsresult rv = nsServiceManager::GetService( kPrefCID,
NS_GET_IID(nsIPref),
getter_AddRefs(mPref));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIStringBundleService, service, kCStringBundleServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsILocale* locale = nsnull;
rv = service->CreateBundle(SECURITY_STRING_BUNDLE_URL, locale, getter_AddRefs(mStringBundle));
if (NS_FAILED(rv)) return rv;
// hook up to the form post notifications:
nsIObserverService *svc = 0;
rv = nsServiceManager::GetService(NS_OBSERVERSERVICE_PROGID,
NS_GET_IID(nsIObserverService),
(nsISupports**)&svc );
if ( NS_SUCCEEDED( rv ) && svc )
{
nsString topic; topic.AssignWithConversion(NS_FORMSUBMIT_SUBJECT);
rv = svc->AddObserver( this, topic.GetUnicode());
nsServiceManager::ReleaseService( NS_OBSERVERSERVICE_PROGID, svc );
}
// hook up to the webprogress notifications.
nsCOMPtr<nsIDocShell> docShell;
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(window);
if (!sgo) return NS_ERROR_NULL_POINTER;
sgo->GetDocShell(getter_AddRefs(docShell));
if (!docShell) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIWebProgress> wp = do_QueryInterface(docShell);
if (!wp) return NS_ERROR_NULL_POINTER;
wp->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*,this));
// Set up stuff the first time the window loads:
docShell->GetCurrentURI(getter_AddRefs(mCurrentURI));
return IsURLHTTPS(mCurrentURI, &mIsSecureDocument);
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::DisplayPageInfoUI()
{
nsresult res;
NS_WITH_SERVICE(nsIPSMComponent, psm, PSM_COMPONENT_PROGID, &res);
if (NS_FAILED(res))
return res;
nsXPIDLCString temp;
mCurrentURI->GetHost(getter_Copies(temp));
return psm->DisplaySecurityAdvisor(mLastPSMStatus, temp);
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::Observe(nsISupports*, const PRUnichar*, const PRUnichar*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::Notify(nsIContent* formNode, nsIDOMWindow* window, nsIURI* actionURL)
{
// Return NS_OK unless we want to prevent this form from submitting.
if (!window || (mWindow.get() != window) || !actionURL) {
return NS_OK;
}
PRBool okayToPost;
nsresult res = CheckPost(actionURL, &okayToPost);
// Return NS_OK unless we want to prevent this form from submitting.
if (NS_SUCCEEDED(res) && okayToPost)
return NS_OK;
return NS_ERROR_FAILURE;
}
// nsIWebProgressListener
NS_IMETHODIMP
nsSecureBrowserUIImpl::OnProgressChange(nsIChannel* aChannel,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
{
return NS_OK;
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::OnChildProgressChange(nsIChannel* aChannel,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress)
{
return NS_OK;
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::OnStatusChange(nsIChannel* aChannel,
PRInt32 aProgressStatusFlags)
{
nsresult res;
if (aChannel == nsnull || !mSecurityButton || !mPref)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIURI> loadingURI;
aChannel->GetURI(getter_AddRefs(loadingURI));
#if defined(DEBUG)
nsXPIDLCString temp;
loadingURI->GetSpec(getter_Copies(temp));
PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: OnStatusChange: %x :%s\n", this, aProgressStatusFlags,(const char*)temp));
#endif
if (aProgressStatusFlags & nsIWebProgress::flag_net_start)
{
// starting to load a webpage
PR_FREEIF(mLastPSMStatus); mLastPSMStatus = nsnull;
mIsSecureDocument = mMixContentAlertShown = mIsDocumentBroken = PR_FALSE;
res = CheckProtocolContextSwitch( loadingURI, mCurrentURI);
}
else if ((aProgressStatusFlags & nsIWebProgress::flag_net_stop) && mIsSecureDocument)
{
if (!mIsDocumentBroken) // and status is okay FIX
{
// qi for the psm information about this channel load.
nsCOMPtr<nsISupports> info;
aChannel->GetSecurityInfo(getter_AddRefs(info));
nsCOMPtr<nsIPSMSocketInfo> psmInfo = do_QueryInterface(info);
if ( psmInfo )
{
// Everything looks okay. Lets stash the picked status.
PR_FREEIF(mLastPSMStatus);
res = psmInfo->GetPickledStatus(&mLastPSMStatus);
if (NS_SUCCEEDED(res))
{
PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: Icon set to lock\n", this));
res = mSecurityButton->SetAttribute( "level", nsString("high") );
}
}
}
else
{
PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: Icon set to broken\n", this));
mIsDocumentBroken = PR_TRUE;
res = mSecurityButton->SetAttribute( "level", nsString("broken") );
}
}
else // if (aProgressStatusFlags == nsIWebProgress::flag_net_redirecting)
{
res = NS_ERROR_NOT_IMPLEMENTED;
// xxx need to fix.
}
return res;
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::OnChildStatusChange(nsIChannel* aChannel, PRInt32 aProgressStatusFlags)
{
nsresult rv;
if (aChannel == nsnull || !mSecurityButton || !mPref)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIURI> uri;
rv = aChannel->GetURI(getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
#if defined(DEBUG)
nsXPIDLCString temp;
uri->GetSpec(getter_Copies(temp));
PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: OnChildStatusChange: %x :%s\n", this, aProgressStatusFlags,(const char*)temp));
#endif
// don't need to do anything more if the page is broken or not secure...
if (!mIsSecureDocument || mIsDocumentBroken)
return NS_OK;
if (aProgressStatusFlags & nsIWebProgress::flag_net_start)
{ // check to see if we are going to mix content.
return CheckMixedContext(uri);
}
if (aProgressStatusFlags & nsIWebProgress::flag_net_stop)
{
if (1) // FIX status from the flag...
{
nsCOMPtr<nsISupports> info;
aChannel->GetSecurityInfo(getter_AddRefs(info));
nsCOMPtr<nsIPSMSocketInfo> psmInfo = do_QueryInterface(info, &rv);
// qi for the psm information about this channel load.
if ( psmInfo )
{
return NS_OK;
}
}
PR_LOG(gSecureDocLog, PR_LOG_DEBUG, ("SecureUI:%p: OnChildStatusChange - Icon set to broken\n", this));
mSecurityButton->SetAttribute( "level", nsString("broken") );
mIsDocumentBroken = PR_TRUE;
}
return NS_OK;
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::OnLocationChange(nsIURI* aLocation)
{
mCurrentURI = aLocation;
return NS_OK;
}
nsresult
nsSecureBrowserUIImpl::IsURLHTTPS(nsIURI* aURL, PRBool* value)
{
*value = PR_FALSE;
if (!aURL)
return NS_OK;
char* scheme;
aURL->GetScheme(&scheme);
if (scheme == nsnull)
return NS_ERROR_NULL_POINTER;
if ( PL_strncasecmp(scheme, "https", 5) == 0 )
*value = PR_TRUE;
nsAllocator::Free(scheme);
return NS_OK;
}
void nsSecureBrowserUIImpl::GetBundleString(const nsString& name, nsString &outString)
{
if (mStringBundle && name.Length() > 0)
{
PRUnichar *ptrv = nsnull;
if (NS_SUCCEEDED(mStringBundle->GetStringFromName(name.GetUnicode(), &ptrv)))
outString = ptrv;
else
outString = "";
nsAllocator::Free(ptrv);
}
else
{
outString = "";
}
}
nsresult
nsSecureBrowserUIImpl::CheckProtocolContextSwitch( nsIURI* newURI, nsIURI* oldURI)
{
nsresult res;
PRBool isNewSchemeSecure, isOldSchemeSecure, boolpref;
res = IsURLHTTPS(oldURI, &isOldSchemeSecure);
if (NS_FAILED(res))
return res;
res = IsURLHTTPS(newURI, &isNewSchemeSecure);
if (NS_FAILED(res))
return res;
// Check to see if we are going from a secure page to and insecure page
if ( !isNewSchemeSecure && isOldSchemeSecure)
{
mSecurityButton->RemoveAttribute( "level" );
if ((mPref->GetBoolPref(LEAVE_SITE_PREF, &boolpref) != 0))
boolpref = PR_TRUE;
if (boolpref)
{
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &res);
if (NS_FAILED(res))
return res;
nsAutoString windowTitle, message, dontShowAgain;
GetBundleString("Title", windowTitle);
GetBundleString("LeaveSiteMessage", message);
GetBundleString("DontShowAgain", dontShowAgain);
PRBool outCheckValue = PR_TRUE;
dialog->AlertCheck(mWindow,
windowTitle.GetUnicode(),
message.GetUnicode(),
dontShowAgain.GetUnicode(),
&outCheckValue);
if (!outCheckValue)
{
mPref->SetBoolPref(LEAVE_SITE_PREF, PR_FALSE);
NS_WITH_SERVICE(nsIPSMComponent, psm, PSM_COMPONENT_PROGID, &res);
if (NS_FAILED(res))
return res;
psm->PassPrefs();
}
}
}
// check to see if we are going from an insecure page to a secure one.
else if (isNewSchemeSecure && !isOldSchemeSecure)
{
if ((mPref->GetBoolPref(ENTER_SITE_PREF, &boolpref) != 0))
boolpref = PR_TRUE;
if (boolpref)
{
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &res);
if (NS_FAILED(res))
return res;
nsAutoString windowTitle, message, dontShowAgain;
GetBundleString("Title", windowTitle);
GetBundleString("EnterSiteMessage", message);
GetBundleString("DontShowAgain", dontShowAgain);
PRBool outCheckValue = PR_TRUE;
dialog->AlertCheck(mWindow,
windowTitle.GetUnicode(),
message.GetUnicode(),
dontShowAgain.GetUnicode(),
&outCheckValue);
if (!outCheckValue)
{
mPref->SetBoolPref(ENTER_SITE_PREF, PR_FALSE);
NS_WITH_SERVICE(nsIPSMComponent, psm, PSM_COMPONENT_PROGID, &res);
if (NS_FAILED(res))
return res;
psm->PassPrefs();
}
}
}
mIsSecureDocument = isNewSchemeSecure;
return NS_OK;
}
nsresult
nsSecureBrowserUIImpl::CheckMixedContext(nsIURI* nextURI)
{
PRBool secure;
nsresult rv = IsURLHTTPS(nextURI, &secure);
if (NS_FAILED(rv))
return rv;
if (!secure && mIsSecureDocument)
{
mIsDocumentBroken = PR_TRUE;
mSecurityButton->SetAttribute( "level", nsString("broken") );
if (!mPref) return NS_ERROR_NULL_POINTER;
PRBool boolpref;
if ((mPref->GetBoolPref(MIXEDCONTENT_PREF, &boolpref) != 0))
boolpref = PR_TRUE;
if (boolpref && !mMixContentAlertShown)
{
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString windowTitle, message, dontShowAgain;
GetBundleString("Title", windowTitle);
GetBundleString("MixedContentMessage", message);
GetBundleString("DontShowAgain", dontShowAgain);
PRBool outCheckValue = PR_TRUE;
dialog->AlertCheck(mWindow,
windowTitle.GetUnicode(),
message.GetUnicode(),
dontShowAgain.GetUnicode(),
&outCheckValue);
if (!outCheckValue)
{
mPref->SetBoolPref(MIXEDCONTENT_PREF, PR_FALSE);
NS_WITH_SERVICE(nsIPSMComponent, psm, PSM_COMPONENT_PROGID, &rv);
if (NS_FAILED(rv))
return rv;
psm->PassPrefs();
}
mMixContentAlertShown = PR_TRUE;
}
}
return NS_OK;
}
nsresult
nsSecureBrowserUIImpl::CheckPost(nsIURI *actionURL, PRBool *okayToPost)
{
PRBool secure;
nsresult rv = IsURLHTTPS(actionURL, &secure);
if (NS_FAILED(rv))
return rv;
if (!secure && mIsSecureDocument)
{
PRBool boolpref;
// posting to a non https URL.
if ((mPref->GetBoolPref(INSECURE_SUBMIT_PREF, &boolpref) != 0))
boolpref = PR_TRUE;
if (boolpref)
{
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString windowTitle, message, dontShowAgain;
GetBundleString("Title", windowTitle);
GetBundleString("PostToInsecure", message);
GetBundleString("DontShowAgain", dontShowAgain);
PRBool outCheckValue = PR_TRUE;
dialog->ConfirmCheck(mWindow,
windowTitle.GetUnicode(),
message.GetUnicode(),
dontShowAgain.GetUnicode(),
&outCheckValue,
okayToPost);
if (!outCheckValue)
{
mPref->SetBoolPref(INSECURE_SUBMIT_PREF, PR_FALSE);
NS_WITH_SERVICE(nsIPSMComponent, psm, PSM_COMPONENT_PROGID, &rv);
if (NS_FAILED(rv))
return rv;
psm->PassPrefs();
}
}
}
return NS_OK;
}

View File

@@ -0,0 +1,99 @@
/* -*- 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):
* Hubbie Shaw
* Doug Turner <dougt@netscape.com>
*/
#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 "nsIDOMWindow.h"
#include "nsIStringBundle.h"
#include "nsISecureBrowserUI.h"
#include "nsIDocShell.h"
#include "nsIPref.h"
#include "nsIWebProgressListener.h"
#include "nsIFormSubmitObserver.h"
#include "nsIURI.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 nsSecureBrowserUIImpl : public nsSecureBrowserUI,
public nsIWebProgressListener,
public nsIFormSubmitObserver,
public nsIObserver
{
public:
nsSecureBrowserUIImpl();
virtual ~nsSecureBrowserUIImpl();
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSSECUREBROWSERUI
// nsIObserver
NS_DECL_NSIOBSERVER
NS_IMETHOD Notify(nsIContent* formNode, nsIDOMWindow* window, nsIURI *actionURL);
protected:
nsCOMPtr<nsIDOMWindow> mWindow;
nsCOMPtr<nsIDOMElement> mSecurityButton;
nsCOMPtr<nsIDocumentLoaderObserver> mOldWebShellObserver;
nsCOMPtr<nsIPref> mPref;
nsCOMPtr<nsIStringBundle> mStringBundle;
nsCOMPtr<nsIURI> mCurrentURI;
PRBool mIsSecureDocument; // is https loaded
PRBool mIsDocumentBroken; //
PRBool mMixContentAlertShown;
char* mLastPSMStatus;
void GetBundleString(const nsString& name, nsString &outString);
nsresult CheckProtocolContextSwitch( nsIURI* newURI, nsIURI* oldURI);
nsresult CheckMixedContext(nsIURI* nextURI);
nsresult CheckPost(nsIURI *actionURL, PRBool *okayToPost);
nsresult IsURLHTTPS(nsIURI* aURL, PRBool *value);
};
#endif /* nsSecureBrowserUIImpl_h_ */

View File

@@ -1,5 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>

View File

@@ -1,69 +0,0 @@
<?php
/* SVN FILE: $Id: app_controller.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* Short description for file.
*
* This file is application-wide controller file. You can put all
* application-wide controller-related methods here.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake
* @since CakePHP v 0.2.9
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for class.
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.
*
* @package cake
* @subpackage cake.cake
*/
uses('Sanitize');
class AppController extends Controller {
/**
* This function is intended to be used with url parameters when passing them to
* a view. (This is useful when echoing values out in <input> tags, etc.
* Note that the keys to the arrays are escaped as well.
*
* @param array dirty parameters
* @return array cleaned values
*/
function decodeAndSanitize($params)
{
$clean = array();
foreach ($params as $var => $val) {
$var = $this->Sanitize->html(urldecode($var));
$val = $this->Sanitize->html(urldecode($val));
$clean[$var] = $val;
}
return $clean;
}
}
?>

View File

@@ -1,72 +0,0 @@
<?php
/* SVN FILE: $Id: app_model.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* Application model for Cake.
*
* This file is application-wide model file. You can put all
* application-wide model-related methods here.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake
* @since CakePHP v 0.2.9
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Application model for Cake.
*
* Add your application-wide methods in the class below, your models
* will inherit them.
*
* @package cake
* @subpackage cake.cake
*/
uses('sanitize');
class AppModel extends Model {
/**
* Will clean arrays for input into SQL.
* Note that the array keys are getting cleaned here as well. If you're using strings
* (with escapable characters in them) as keys to your array, be extra careful.
*
* @access public
* @param array to be cleaned
* @return array with sql escaped
*/
function cleanArrayForSql($array)
{
$sanitize = new Sanitize();
$clean = array();
foreach ($array as $var => $val)
{
$var = $sanitize->sql($var);
$val = $sanitize->sql($val);
$clean[$var] = $val;
}
return $clean;
}
}
?>

View File

@@ -1,76 +0,0 @@
;<?php die() ?>
; SVN FILE: $Id: acl.ini.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $
;/**
; * Short description for file.
; *
; *
; * PHP versions 4 and 5
; *
; * CakePHP : Rapid Development Framework <http://www.cakephp.org/>
; * Copyright (c) 2006, Cake Software Foundation, Inc.
; * 1785 E. Sahara Avenue, Suite 490-204
; * Las Vegas, Nevada 89104
; *
; * Licensed under The MIT License
; * Redistributions of files must retain the above copyright notice.
; *
; * @filesource
; * @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
; * @package cake
; * @subpackage cake.app.config
; * @since CakePHP v 0.10.0.1076
; * @version $Revision: 1.1.1.1 $
; * @modifiedby $LastChangedBy: phpnut $
; * @lastmodified $Date: 2006-05-24 19:14:24 $
; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
; */
; acl.ini.php - Cake ACL Configuration
; ---------------------------------------------------------------------
; Use this file to specify user permissions.
; aco = access control object (something in your application)
; aro = access request object (something requesting access)
;
; User records are added as follows:
;
; [uid]
; groups = group1, group2, group3
; allow = aco1, aco2, aco3
; deny = aco4, aco5, aco6
;
; Group records are added in a similar manner:
;
; [gid]
; allow = aco1, aco2, aco3
; deny = aco4, aco5, aco6
;
; The allow, deny, and groups sections are all optional.
; NOTE: groups names *cannot* ever be the same as usernames!
;
; ACL permissions are checked in the following order:
; 1. Check for user denies (and DENY if specified)
; 2. Check for user allows (and ALLOW if specified)
; 3. Gather user's groups
; 4. Check group denies (and DENY if specified)
; 5. Check group allows (and ALLOW if specified)
; 6. If no aro, aco, or group information is found, DENY
;
; ---------------------------------------------------------------------
;-------------------------------------
;Users
;-------------------------------------
[username-goes-here]
groups = group1, group2
deny = aco1, aco2
allow = aco3, aco4
;-------------------------------------
;Groups
;-------------------------------------
[groupname-goes-here]
deny = aco5, aco6
allow = aco7, aco8

View File

@@ -1,50 +0,0 @@
<?php
/* SVN FILE: $Id: bootstrap.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 0.10.8.2117
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
*
* This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php is loaded
* This is an application wide file to load any function that is not used within a class define.
* You can also use this to include or require any files in your application.
*
*/
/**
* The settings below can be used to set additional paths to models, views and controllers.
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
*
* $modelPaths = array('full path to models', 'second full path to models', 'etc...');
* $viewPaths = array('this path to views', 'second full path to views', 'etc...');
* $controllerPaths = array('this path to controllers', 'second full path to controllers', 'etc...');
*
*/
//EOF
?>

View File

@@ -1,153 +0,0 @@
<?php
/* SVN FILE: $Id: core.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* This is core configuration file.
*
* Use it to configure core behaviour ofCake.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 0.2.9
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* If you do not have mod rewrite on your system
* or if you prefer to use CakePHP pretty urls.
* uncomment the line below.
* Note: If you do have mod rewrite but prefer the
* CakePHP pretty urls, you also have to remove the
* .htaccess files
* release/.htaccess
* release/app/.htaccess
* release/app/webroot/.htaccess
*/
//define ('BASE_URL', env('SCRIPT_NAME'));
/**
* Set debug level here:
* - 0: production
* - 1: development
* - 2: full debug with sql
* - 3: full debug with sql and dump of the current object
*
* In production, the "flash messages" redirect after a time interval.
* With the other debug levels you get to click the "flash message" to continue.
*
*/
define('DEBUG', 0);
/**
* Turn of caching checking wide.
* You must still use the controller var cacheAction inside you controller class.
* You can either set it controller wide, or in each controller method.
* use var $cacheAction = true; or in the controller method $this->cacheAction = true;
*/
define ('CACHE_CHECK', false);
/**
* Error constant. Used for differentiating error logging and debugging.
* Currently PHP supports LOG_DEBUG
*/
define ('LOG_ERROR', 2);
/**
* CakePHP includes 3 types of session saves
* database or file. Set this to your preferred method.
* If you want to use your own save handler place it in
* app/config/name.php DO NOT USE file or database as the name.
* and use just the name portion below.
*
* Setting this to cake will save files to /cakedistro/tmp directory
* Setting it to php will use the php default save path
* Setting it to database will use the database
*
*
*/
define('CAKE_SESSION_SAVE', 'php');
/**
* Set a random string of used in session.
*
*/
define('CAKE_SESSION_STRING', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
/**
* Set the name of session cookie
*
*/
define('CAKE_SESSION_COOKIE', 'CAKEPHP');
/**
* Set level of Cake security.
*
*/
define('CAKE_SECURITY', 'high');
/**
* Set Cake Session time out.
* If CAKE_SECURITY define is set
* high: multiplied by 10
* medium: is multiplied by 100
* low is: multiplied by 300
*
* Number below is seconds.
*/
define('CAKE_SESSION_TIMEOUT', '120');
/**
* Uncomment the define below to use cake built in admin routes.
* You can set this value to anything you want.
* All methods related to the admin route should be prefixed with the
* name you set CAKE_ADMIN to.
* For example: admin_index, admin_edit
*/
//define('CAKE_ADMIN', 'admin');
/**
* The define below is used to turn cake built webservices
* on or off. Default setting is off.
*/
define('WEBSERVICES', 'off');
/**
* Compress output CSS (removing comments, whitespace, repeating tags etc.)
* This requires a/var/cache directory to be writable by the web server (caching).
* To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag().
*/
define('COMPRESS_CSS', false);
/**
* If set to true, helpers would output data instead of returning it.
*/
define('AUTO_OUTPUT', false);
/**
* If set to false, session would not automatically be started.
*/
define('AUTO_SESSION', true);
/**
* Set the max size of file to use md5() .
*/
define('MAX_MD5SIZE', (5*1024)*1024 );
/**
* To use Access Control Lists with Cake...
*/
define('ACL_CLASSNAME', 'DB_ACL');
define('ACL_FILENAME', 'dbacl'.DS.'db_acl');
?>

View File

@@ -1,79 +0,0 @@
<?php
/* SVN FILE: $Id: database.php.default,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* This is core configuration file.
*
* Use it to configure core behaviour ofCake.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 0.2.9
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* In this file you set up your database connection details.
*
* @package cake
* @subpackage cake.config
*/
/**
* Database configuration class.
* You can specify multiple configurations for production, development and testing.
*
* driver =>
* mysql, postgres, sqlite, adodb-drivername, pear-drivername
*
* connect =>
* MySQL set the connect to either mysql_pconnect of mysql_connect
* PostgreSQL set the connect to either pg_pconnect of pg_connect
* SQLite set the connect to sqlite_popen sqlite_open
* ADOdb set the connect to one of these
* (http://phplens.com/adodb/supported.databases.html) and
* append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent)
*
* host =>
* the host you connect to the database
* MySQL 'localhost' to add a port number use 'localhost:port#'
* PostgreSQL 'localhost' to add a port number use 'localhost port=5432'
*
*/
class DATABASE_CONFIG
{
var $default = array('driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'project_name',
'prefix' => '');
var $test = array('driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'project_name-test',
'prefix' => '');
}
?>

View File

@@ -1,74 +0,0 @@
<?php
/* SVN FILE: $Id: inflections.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* Custom Inflected Words.
*
* This file is used to hold words that are not matched in the normail Inflector::pluralize() and
* Inflector::singularize()
*
* PHP versions 4 and %
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 1.0.0.2312
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* This is a key => value array of regex used to match words.
* If key matches then the value is returned.
*
* $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
*/
$pluralRules = array();
/**
* This is a key only array of plural words that should not be inflected.
* Notice the last comma
*
* $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
*/
$uninflectedPlural = array();
/**
* This is a key => value array of plural irregular words.
* If key matches then the value is returned.
*
* $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
*/
$irregularPlural = array();
/**
* This is a key => value array of regex used to match words.
* If key matches then the value is returned.
*
* $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
*/
$singularRules = array();
/**
* This is a key only array of singular words that should not be inflected.
* You should not have to change this value below if you do change it use same format
* as the $uninflectedPlural above.
*/
$uninflectedSingular = $uninflectedPlural;
/**
* This is a key => value array of singular irregular words.
* Most of the time this will be a reverse of the above $irregularPlural array
* You should not have to change this value below if you do change it use same format
*
* $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
*/
$irregularSingular = array_flip($irregularPlural);
?>

View File

@@ -1,51 +0,0 @@
<?php
/* SVN FILE: $Id: routes.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* Short description for file.
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP v 0.2.9
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/views/pages/home.thtml)...
*/
$Route->connect ('/', array('controller'=>'results', 'action'=>'', ''));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
$Route->connect ('/pages/*', array('controller'=>'pages', 'action'=>'display'));
/**
* Then we connect url '/test' to our test controller. This is helpfull in
* developement.
*/
$Route->connect ('/tests', array('controller'=>'tests', 'action'=>'index'));
?>

View File

@@ -1,30 +0,0 @@
CREATE TABLE `acos` (
`id` int(11) NOT NULL auto_increment,
`model` varchar(255) NOT NULL default '',
`object_id` int(11) default NULL,
`alias` varchar(255) NOT NULL default '',
`lft` int(11) default NULL,
`rght` int(11) default NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `aros` (
`id` int(11) NOT NULL auto_increment,
`model` varchar(255) NOT NULL default '',
`user_id` int(11) default NULL,
`alias` varchar(255) NOT NULL default '',
`lft` int(11) default NULL,
`rght` int(11) default NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `aros_acos` (
`id` int(11) NOT NULL auto_increment,
`aro_id` int(11) default NULL,
`aco_id` int(11) default NULL,
`_create` int(1) NOT NULL default '0',
`_read` int(1) NOT NULL default '0',
`_update` int(1) NOT NULL default '0',
`_delete` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
);

View File

@@ -1,11 +0,0 @@
-- @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
-- @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
-- @since CakePHP v 0.10.8.1997
-- @version $Revision: 1.1.1.1 $
CREATE TABLE cake_sessions (
id varchar(255) NOT NULL default '',
data text,
expires int(11) default NULL,
PRIMARY KEY (id)
);

View File

@@ -1,7 +0,0 @@
<?php
class ApplicationsController extends AppController {
var $name = 'Applications';
}
?>

View File

@@ -1,7 +0,0 @@
<?php
class IntentionsController extends AppController {
var $name = 'Intentions';
}
?>

View File

@@ -1,7 +0,0 @@
<?php
class IssuesController extends AppController {
var $name = 'Issues';
}
?>

View File

@@ -1,122 +0,0 @@
<?php
/* Include the CSV library. It would be nice to make this OO sometime */
vendor('csv/csv');
class ResultsController extends AppController {
var $name = 'Results';
/**
* Model's this controller uses
* @var array
*/
var $uses = array('Application','Result');
/**
* Cake Helpers
* @var array
*/
var $helpers = array('Html', 'Javascript', 'Export', 'Pagination','Time');
/**
* Pagination helper variable array
* @access public
* @var array
*/
var $pagination_parameters = array();
/**
* Will hold a sanitize object
* @var object
*/
var $Sanitize;
/**
* Constructor - sets up the sanitizer and the pagination
*/
function ResultsController()
{
parent::AppController();
$this->Sanitize = new Sanitize();
// Pagination Stuff
$this->pagination_parameters['show'] = empty($_GET['show'])? '10' : $this->Sanitize->paranoid($_GET['show']);
$this->pagination_parameters['sortBy'] = empty($_GET['sort'])? 'created' : $this->Sanitize->paranoid($_GET['sort']);
$this->pagination_parameters['direction'] = empty($_GET['direction'])? 'desc': $this->Sanitize->paranoid($_GET['direction']);
$this->pagination_parameters['page'] = empty($_GET['page'])? '1': $this->Sanitize->paranoid($_GET['page']);
$this->pagination_parameters['order'] = $this->modelClass.'.'.$this->pagination_parameters['sortBy'].' '.strtoupper($this->pagination_parameters['direction']);
}
/**
* Front page will show the graph
*/
function index()
{
// Products dropdown
$this->set('products', $this->Application->getApplications());
// Fill in all the data passed in $_GET
$this->set('url_params',$this->decodeAndSanitize($this->params['url']));
// We'll need to include the graphing libraries
$this->set('include_graph_libraries', true);
// Core data to show on page
$this->set('descriptionAndTotalsData',$this->Result->getDescriptionAndTotalsData($this->params['url']));
}
/**
* Display a table of user comments
*/
function comments()
{
// Products dropdown
$this->set('products', $this->Application->getApplications());
// Fill in all the data passed in $_GET
$this->set('url_params',$this->decodeAndSanitize($this->params['url']));
// Pagination settings
$paging['style'] = 'html';
$paging['link'] = "/results/comments/?product=".urlencode($this->params['url']['product'])."&start_date=".urlencode($this->params['url']['start_date'])."&end_date=".urlencode($this->params['url']['end_date'])."&show={$this->pagination_parameters['show']}&sort={$this->pagination_parameters['sortBy']}&direction={$this->pagination_parameters['direction']}&page=";
$paging['count'] = $this->Result->getCommentCount($this->params['url']);
$paging['page'] = $this->pagination_parameters['page'];
$paging['limit'] = $this->pagination_parameters['show'];
$paging['show'] = array('10','25','50');
// No point in showing them an error if they click on "show 50" but they are
// already on the last page.
if ($paging['count'] < ($this->pagination_parameters['page'] * ($this->pagination_parameters['show']/2))) {
$this->pagination_parameters['page'] = $paging['page'] = 1;
}
// Set pagination array
$this->set('paging',$paging);
// Core data to show on page
$this->set('commentsData',$this->Result->getComments($this->params['url'], $this->pagination_parameters));
}
/**
* Display a csv
*/
function csv()
{
// Get rid of the header/footer/etc.
$this->layout = null;
// Our CSV library sends headers and everything. Keep the view empty!
csv_send_csv($this->Result->getCsvExportData($this->params['url']));
// I'm not exiting here in case someone is going to use post callback stuff.
// In development, that means extra lines get added to our CSVs, but in
// production it should be clean.
}
}
?>

View File

@@ -1,27 +0,0 @@
<?php
/* SVN FILE: $Id: index.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app
* @since CakePHP v 0.10.0.1076
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
require 'webroot'.DIRECTORY_SEPARATOR.'index.php';
?>

View File

@@ -1,24 +0,0 @@
<?php
class Application extends AppModel {
var $name = 'Application';
var $hasOne = array('Result');
var $hasAndBelongsToMany = array(
'Intention' => array('className' => 'Intention'),
'Issue' => array('className' => 'Issue')
);
/**
* This was added because running findAll() on this model does a left join on the
* results table which takes around 10 seconds to grab all the data. All I want
* is a list of the applications...
*
* @return array rows representing each application
*/
function getApplications()
{
return $this->query('SELECT * FROM `applications` ORDER BY `id`');
}
}
?>

View File

@@ -1,12 +0,0 @@
<?php
class Intention extends AppModel {
var $name = 'Intention';
var $hasOne = array('Result');
var $hasAndBelongsToMany = array('Application' =>
array('className' => 'Application')
);
}
?>

View File

@@ -1,10 +0,0 @@
<?php
class Issue extends AppModel {
var $name = 'Issue';
var $hasAndBelongsToMany = array(
'Application' => array('className' => 'Application'),
'Result' => array('className' => 'Result')
);
}
?>

View File

@@ -1,339 +0,0 @@
<?php
class Result extends AppModel {
var $name = 'Result';
var $belongsTo = array('Application', 'Intention');
var $hasAndBelongsToMany = array('Issue' =>
array('className' => 'Issue')
);
/**
* Count's all the comments, according to the parameters.
* @param array URL parameters
* @return Cake's findCount() value
*/
function getCommentCount($params)
{
// Clean parameters
$params = $this->cleanArrayForSql($params);
// We only want to see rows with comments
$_conditions = array("comments NOT LIKE ''");
if (!empty($params['start_date'])) {
$_timestamp = strtotime($params['start_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
array_push($_conditions, "`created` >= '{$_date}'");
}
}
if (!empty($params['end_date'])) {
$_timestamp = strtotime($params['end_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
array_push($_conditions, "`created` <= '{$_date}'");
}
}
if (!empty($params['product'])) {
// product's come in looking like:
// Mozilla Firefox 1.5.0.1
$_exp = explode(' ',urldecode($params['product']));
if(count($_exp) == 3) {
$_product = $_exp[0].' '.$_exp[1];
$_version = $_exp[2];
/* Note that 'Application' is not the actual name of the table! You can
* thank cake for that.*/
array_push($_conditions, "`Application`.`name` LIKE '%{$_product}%'");
array_push($_conditions, "`Application`.`version` LIKE '%{$_version}%'");
} else {
// defaults I guess?
array_push($_conditions, "`Application`.`name` LIKE 'Mozilla Firefox'");
array_push($_conditions, "`Application`.`version` LIKE '1.5'");
}
} else {
// I'm providing a default here, because otherwise all results will be
// returned (across all applications) and that is not desired
array_push($_conditions, "`Application`.`name` LIKE 'Mozilla Firefox'");
array_push($_conditions, "`Application`.`version` LIKE '1.5'");
}
// Do the actual query
$comments = $this->findCount($_conditions);
return $comments;
}
/**
* Will retrieve all the comments within param's and pagination's parameters
* @param array URL parameters
* @param array pagination values from the controller
* @param boolean if privacy is true phone numbers and email addresses will be
* masked
* @return cake result set
*/
function getComments($params, $pagination, $privacy=true)
{
$params = $this->cleanArrayForSql($params);
// We only want to see rows with comments
$_conditions = array("comments NOT LIKE ''");
if (!empty($params['start_date'])) {
$_timestamp = strtotime($params['start_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
array_push($_conditions, "`created` >= '{$_date}'");
}
}
if (!empty($params['end_date'])) {
$_timestamp = strtotime($params['end_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
array_push($_conditions, "`created` <= '{$_date}'");
}
}
if (!empty($params['product'])) {
// product's come in looking like:
// Mozilla Firefox 1.5.0.1
$_exp = explode(' ',urldecode($params['product']));
if(count($_exp) == 3) {
$_product = $_exp[0].' '.$_exp[1];
$_version = $_exp[2];
/* Note that 'Application' is not the actual name of the table! You can
* thank cake for that.*/
array_push($_conditions, "`Application`.`name` LIKE '%{$_product}%'");
array_push($_conditions, "`Application`.`version` LIKE '%{$_version}%'");
} else {
// defaults I guess?
array_push($_conditions, "`Application`.`name` LIKE 'Mozilla Firefox'");
array_push($_conditions, "`Application`.`version` LIKE '1.5'");
}
} else {
// I'm providing a default here, because otherwise all results will be
// returned (across all applications) and that is not desired
array_push($_conditions, "`Application`.`name` LIKE 'Mozilla Firefox'");
array_push($_conditions, "`Application`.`version` LIKE '1.5'");
}
$comments = $this->findAll($_conditions, null, $pagination['order'], $pagination['show'], $pagination['page']);
if ($privacy) {
// Pull out all the email addresses and phone numbers
foreach ($comments as $var => $val) {
// Handle foo@bar.com
$_email_regex = '/\ ?(.+)?@(.+)?\.(.+)?\ ?/';
$comments[$var]['Result']['comments'] = preg_replace($_email_regex,'$1@****.$3',$comments[$var]['Result']['comments']);
$comments[$var]['Result']['intention_text'] = preg_replace($_email_regex,'$1@****.$3',$comments[$var]['Result']['intention_text']);
// Handle xxx-xxx-xxxx
$_phone_regex = '/([0-9]{3})[ .-]?[0-9]{4}/';
$comments[$var]['Result']['comments'] = preg_replace($_phone_regex,'$1-****',$comments[$var]['Result']['comments']);
$comments[$var]['Result']['intention_text'] = preg_replace($_phone_regex,'$1-****',$comments[$var]['Result']['intention_text']);
}
}
return $comments;
}
/**
* This function runs the query to get the export data for the CSV file.
*
* @param array URL parameters
* @param boolean if privacy is true phone numbers and email addresses will be
* masked
* @return array two dimensional array that should be pretty easy to transform
* into a CSV.
*/
function getCsvExportData($params, $privacy=true)
{
$params = $this->cleanArrayForSql($params);
// We have to use a left join here because there isn't always an intention
$_query = "
SELECT
`results`.`id`,
`results`.`created`,
`results`.`intention_text` as `intention_other`,
`results`.`comments`,
`intentions`.`description` as `intention`
FROM `results`
LEFT JOIN `intentions` ON `results`.`intention_id`=`intentions`.`id`
INNER JOIN `applications` ON `applications`.`id` = `results`.`application_id`
WHERE
1=1
";
if (!empty($params['start_date'])) {
$_timestamp = strtotime($params['start_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
$_query .= " AND `results`.`created` >= '{$_date}'";
}
}
if (!empty($params['end_date'])) {
$_timestamp = strtotime($params['end_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
$_query .= " AND `results`.`created` <= '{$_date}'";
}
}
if (!empty($params['product'])) {
// product's come in looking like:
// Mozilla Firefox 1.5.0.1
$_exp = explode(' ',urldecode($params['product']));
if(count($_exp) == 3) {
$_product = $_exp[0].' '.$_exp[1];
$_version = $_exp[2];
$_query .= " AND `applications`.`name` LIKE '{$_product}'";
$_query .= " AND `applications`.`version` LIKE '{$_version}'";
} else {
// defaults I guess?
$_query .= " AND `applications`.`name` LIKE 'Mozilla Firefox'";
$_query .= " AND `applications`.`version` LIKE '1.5'";
}
} else {
// I'm providing a default here, because otherwise all results will be
// returned (across all applications) and that is not desired
$_query .= " AND `applications`.`name` LIKE 'Mozilla Firefox'";
$_query .= " AND `applications`.`version` LIKE '1.5'";
}
$_query .= " ORDER BY `results`.`created` ASC";
$res = $this->query($_query);
// Since we're exporting to a CSV, we need to flatten the results into a 2
// dimensional table array
$newdata = array();
foreach ($res as $result) {
$newdata[] = array_merge($result['results'], $result['intentions']);
}
if ($privacy) {
// Pull out all the email addresses and phone numbers
foreach ($newdata as $var => $val) {
// Handle foo@bar.com
$_email_regex = '/\ ?(.+)?@(.+)?\.(.+)?\ ?/';
$newdata[$var]['comments'] = preg_replace($_email_regex,'$1@****.$3',$newdata[$var]['comments']);
$newdata[$var]['intention_other'] = preg_replace($_email_regex,'$1@****.$3',$newdata[$var]['intention_other']);
// Handle xxx-xxx-xxxx
$_phone_regex = '/([0-9]{3})[ .-]?[0-9]{4}/';
$newdata[$var]['comments'] = preg_replace($_phone_regex,'$1-****',$newdata[$var]['comments']);
$newdata[$var]['intention_other'] = preg_replace($_phone_regex,'$1-****',$newdata[$var]['intention_other']);
}
}
// Our CSV library just prints out everything in order, so we have to put the
// column labels on here ourselves
$newdata = array_merge(array(array_keys($newdata[0])), $newdata);
return $newdata;
}
/**
* Will retrieve the information used for graphing.
* @param the url parameters (unescaped)
* @return a result set
*/
function getDescriptionAndTotalsData($params)
{
// Clean parameters for inserting into SQL
$params = $this->cleanArrayForSql($params);
/* It would be nice to drop something like this in the SELECT:
*
* CONCAT(COUNT(*)/(SELECT COUNT(*) FROM our_giant_query_all_over_again)*100,'%') AS `percentage`
*/
$_query = "
SELECT
issues.description,
COUNT( DISTINCT results.id ) AS total
FROM
issues
LEFT JOIN
issues_results ON issues_results.issue_id=issues.id
LEFT JOIN results ON results.id=issues_results.result_id AND results.application_id=applications.id
JOIN applications_issues ON applications_issues.issue_id=issues.id
JOIN applications ON applications.id=applications_issues.application_id
WHERE 1=1
";
if (!empty($params['start_date'])) {
$_timestamp = strtotime($params['start_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
$_query.= " AND `results`.`created` >= '{$_date}'";
}
}
if (!empty($params['end_date'])) {
$_timestamp = strtotime($params['end_date']);
if (!($_timestamp == -1) || $_timestamp == false) {
$_date = date('Y-m-d H:i:s', $_timestamp);//sql format
$_query .= " AND `results`.`created` <= '{$_date}'";
}
}
if (!empty($params['product'])) {
// product's come in looking like:
// Mozilla Firefox 1.5.0.1
$_exp = explode(' ',urldecode($params['product']));
if(count($_exp) == 3) {
$_product = $_exp[0].' '.$_exp[1];
$_version = $_exp[2];
$_query .= " AND `applications`.`name` LIKE '{$_product}'";
$_query .= " AND `applications`.`version` LIKE '{$_version}'";
} else {
// defaults I guess?
$_query .= " AND `applications`.`name` LIKE 'Mozilla Firefox'";
$_query .= " AND `applications`.`version` LIKE '1.5'";
}
} else {
// I'm providing a default here, because otherwise all results will be
// returned (across all applications) and that is not desired
$_query .= " AND `applications`.`name` LIKE 'Mozilla Firefox'";
$_query .= " AND `applications`.`version` LIKE '1.5'";
}
$_query .= " GROUP BY `issues`.`description`
ORDER BY `issues`.`description` DESC";
return $this->query($_query);
}
}
?>

View File

@@ -1,188 +0,0 @@
<?php
/**
* Functions that take a db result and export it to CSV.
* Usage example:
* <code>
* if ($_GET['csv'])
* {
* $res=db_query("SELECT * FROM fic_courses");
* csv_send_csv($res);
* exit;
* }
* </code>
* @package libs
* @subpackage csv
* @author Richard Faaberg <faabergr@onid.orst.edu>
* @author Mike Morgan <mike.morgan@oregonstate.edu>
*/
/**
* Use a resource or two dimensional array, then send the CSV results to user.
* @param mixed $res MySQL resource / result, or a two dimensional array
* @param string $name name of the export file
* @return bool true if file sent, false otherwise
*/
function csv_send_csv($res,$name=null)
{
// set name of the export file
$filename=(is_null($name))?'export-'.date('Y-m-d').'.csv':$name.'.csv';
// check for valid resource
if ( is_resource($res) )
{
$csv=csv_export_to_csv($res);
}
elseif( is_array($res) && !empty($res) )
{
foreach ($res as $row)
{
if ( !is_array($row) )
;
else
$csv[] = csv_array_to_csv($row)."\n";
}
}
if ( is_array($csv) )
{
// stream csv to user
header("Content-type: application/x-csv");
header('Content-disposition: inline; filename="'.$filename.'"');
header('Cache-Control: private');
header('Pragma: public');
foreach ($csv as $row)
{
echo $row;
}
return true;
}
return false;
}
/**
* Replace quotes inside of a field with double quotes, which is something CSV requires.
* @param string $string unquoted quotes
* @return string $string quoted quotes
*/
function csv_fix_quotes($string)
{
return preg_replace('/"/','""',$string);
}
/**
* Replace line breaks with commas trailed by a space.
* @param string $string string containing line breaks
* @param string string without line breaks
*/
function csv_fix_line_breaks($string)
{
return preg_replace('/(\n\r|\r)/','\n',$string);
}
/**
* Replaces instances of double quotes in a string with a single quote.
* @param string $string the string to perform the replacement on
* @return string the string with "" replaced by "
*/
function csv_unfix_quotes($string)
{
return preg_replace('/""/', '"', $string);
}
/**
* Place quotes outside of every field, which inherently solves space, line break issues.
* @param string $string
* @return string $string with quotes around it
*/
function csv_add_quotes($string)
{
return '"'.$string.'"';
}
/**
* Removes quotes from the beginning and the end of a string.
* @param string $string the string to remove the quotes from
* @return string the string, sans quotes at the beginning and end
*/
function csv_remove_quotes($string)
{
$pattern = "/^\"(.*)\"$/";
$replacement = "$1";
return preg_replace($pattern, $replacement, $string);
}
/**
* Convert an array into a CSV string with quotes around each value.
* @param array $array
* @return string the values in $array surrounded by quotes and separated by commas
*/
function csv_array_to_csv($array)
{
$csv_arr = array();
foreach ($array as $value)
{
$csv_arr[]=csv_add_quotes(csv_fix_quotes(csv_fix_line_breaks($value)));
}
$csv_string=implode(',',$csv_arr);
return $csv_string;
}
/**
* Convert a CSV string into an array.
* Please use sparingly - this creates temp files
* @param string $string the CSV string
* @return array the elements from the CSV string in an array
*/
function csv_csv_to_array($string)
{
$return = array();
$length = strlen($string);
// create a temp file and write the string to it
$tmpfname = tempnam('/tmp', 'csvlib');
$fh = fopen($tmpfname, 'w');
fwrite($fh, $string);
fclose($fh);
// open the file for csv parsing
$csvh = fopen($tmpfname, 'r');
while (($arraydata = fgetcsv($csvh, $length, ',')) !== false)
{
$return = array_merge($return, $arraydata);
}
fclose($csvh);
unlink($tmpfname);
return $return;
}
/**
* Read a CSV file into a two dimensional array
* It returns all the rows in the file, so if the first row are headers, you'd need to take care of that in the returned array
* @param string $filepath the path to the csv file
* @param string $delimiter delimiter, default to ','
* @param string $enclosure enclosure character, default to '"'
* @return &array the two dimensional array with the csv file content, or an empty if an error occured
*/
function &csv_csv_file_to_array($filepath, $delimiter=',', $enclosure='"')
{
$return = array();
if (!file_exists($filepath) || !is_readable($filepath))
return $return;
$fh =& fopen($filepath, 'r');
$size = filesize($filepath)+1;
while ($data =& fgetcsv($fh, $size, $delimiter, $enclosure))
{
$return[] = $data;
}
fclose($fh);
return $return;
}
?>

View File

@@ -1,11 +0,0 @@
<div id="t_footer">
</div>
<!-- t_wrapper -->
</div>
<!-- t_border -->
</div>
</body>
</html>

View File

@@ -1,26 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Mozilla Uninstall Survey Data</title>
<meta name="author" content="Mozilla Corporation" />
<meta name="copyright" content="Mozilla Corporation" />
<?php echo $html->charset('UTF-8'); ?>
<?php echo $html->css('screen'); ?>
<?php if (isset($include_graph_libraries) && $include_graph_libraries):
echo $javascript->link('mochikit/MochiKit.js');
echo $javascript->link('plotkit/Base.js');
echo $javascript->link('plotkit/Layout.js');
echo $javascript->link('plotkit/Canvas.js');
echo $javascript->link('plotkit/SweetCanvas.js');
endif; ?>
</head>
<body>
<div id="t_border">
<div id="t_wrapper">
<a class="skipnav" href="#t_content">Skip Navigation Links</a>
<div id="t_header">
<div id="t_title">
<h1>Mozilla Firefox Uninstall Survey Data</h1>
</div>
</div>

View File

@@ -1,6 +0,0 @@
<div id="t_nav">
<ul>
<li><?php echo $html->link('Results', '/results'); ?></li>
<li><?php echo $html->link('Comments', '/results/comments'); ?></li>
</ul>
</div>

View File

@@ -1,36 +0,0 @@
<?php
/**
* When we're exporting data, we end up having to pass all the parameters
* via $_GET. Since we're doing this a few times per page (each graph, and the
* export hrefs) this helper should make that easier.
*/
class ExportHelper
{
/**
* Method to collect the current $_GET parameters and build another string from
* them.
*
* @param string cake URL that you want prepended to the result. eg: reports/graph/
* @param array the array of GET variables to add. These need to be
* pre-sanitized to print in html! This is designed to
* be used from the calling controller like:
* $params = $this->sanitize->html($url_parameters);
* @param string string to put between url and arguments (probably either '?' or
* '&')
* @param array array of strings which will be ignored
* @return string string with the url variables appeneded to it
*/
function buildUrlString($url, $params, $seperator='?', $ignore=array('url'))
{
$arguments = '';
foreach ($params as $var => $val) {
if (!in_array($var, $ignore)) {
$arguments .= empty($arguments) ? "{$var}={$val}" : "&amp;{$var}={$val}";
}
}
return "{$url}{$seperator}{$arguments}";
}
}
?>

View File

@@ -1,196 +0,0 @@
<?php
class PaginationHelper {
var $helpers = array('Html','Ajax');
var $_pageDetails = array();
var $link = '';
var $show = array();
var $page;
var $style;
/**
* Sets the default pagination options.
*
* @param array $paging an array detailing the page options
*/
function setPaging($paging)
{
if(!empty($paging))
{
$this->link = $paging['link'];
$this->show = $paging['show'];
$this->page = $paging['page'];
$this->style = $paging['style'];
$pageCount = ceil($paging['count'] / $paging['limit'] );
$this->_pageDetails = array(
'page'=>$paging['page'],
'recordCount'=>$paging['count'],
'pageCount' =>$pageCount,
'nextPage'=> ($paging['page'] < $pageCount) ? $paging['page']+1 : '',
'previousPage'=> ($paging['page']>1) ? $paging['page']-1 : '',
'limit'=>$paging['limit']
);
return true;
}
return false;
}
/**
* Displays limits for the query
*
* @param string $text - text to display before limits
* @param string $separator - display a separate between limits
*
**/
function show($text=null, $separator=null)
{
if (empty($this->_pageDetails)) { return false; }
if ( !empty($this->_pageDetails['recordCount']) )
{
$t = '';
if(is_array($this->show))
{
$t = $text.$separator;
foreach($this->show as $value)
{
$link = preg_replace('/show=(.*?)&/','show='.$value.'&',$this->link);
if($this->_pageDetails['limit'] == $value)
{
$t .= '<em>'.$value.'</em>'.$separator;
}
else
{
if($this->style == 'ajax')
{
$t .= $this->Ajax->linkToRemote($value, array("fallback"=>$this->action."#","url" => $link.$this->_pageDetails['page'],"update" => "ajax_update","method"=>"get")).$separator;
}
else
{
$t .= $this->Html->link($value,$link.$this->_pageDetails['page']).$separator;
}
}
}
}
return $t;
}
return false;
}
/**
* Displays current result information
*
* @param string $text - text to preceeding the number of results
*
**/
function result($text)
{
if (empty($this->_pageDetails)) { return false; }
if ( !empty($this->_pageDetails['recordCount']) )
{
if($this->_pageDetails['recordCount'] > $this->_pageDetails['limit'])
{
$start_row = $this->_pageDetails['page'] > 1 ? (($this->_pageDetails['page']-1)*$this->_pageDetails['limit'])+1:'1';
$end_row = ($this->_pageDetails['recordCount'] < ($start_row + $this->_pageDetails['limit']-1)) ? $this->_pageDetails['recordCount'] : ($start_row + $this->_pageDetails['limit']-1);
$t = $text.$start_row.'-'.$end_row.' of '.$this->_pageDetails['recordCount'];
}
else
{
$t = $text.$this->_pageDetails['recordCount'];
}
return $t;
}
return false;
}
/**
* Returns a list of page numbers separated by $separator
*
* @param string $separator - defaults to null
*
**/
function pageNumbers($separator=null)
{
if (empty($this->_pageDetails) || $this->_pageDetails['pageCount'] == 1) { return false; }
$t = array();
$text = '';
$pc = 1;
do
{
if($pc == $this->_pageDetails['page'])
{
$text = '<em>'.$pc.'</em>';
}
else
{
if($this->style == 'ajax')
{
$text = $this->Ajax->linkToRemote($pc, array("fallback"=>$this->action."#","url" =>$this->link.$pc,"update" => "ajax_update","method"=>"get"));
}
else
{
$text = $this->Html->link($pc,$this->link.$pc);
}
}
$t[] = $text;
$pc++;
}
while ($pc<=$this->_pageDetails['pageCount']);
$t = implode($separator, $t);
return $t;
}
/**
* Displays a link to the previous page, where the page doesn't exist then
* display the $text
*
* @param string $text - text display: defaults to next
*
**/
function prevPage($text='prev')
{
if (empty($this->_pageDetails)) { return false; }
if ( !empty($this->_pageDetails['previousPage']) )
{
if($this->style == 'ajax')
{
$t = $this->Ajax->linkToRemote($text, array("fallback"=>$this->action."#","url" => $this->link.$this->_pageDetails['previousPage'],"update" => "ajax_update","method"=>"get"));
}
else
{
$t = $this->Html->link($text,$this->link.$this->_pageDetails['previousPage']);
}
return $t;
}
return false;
}
/**
* Displays a link to the next page, where the page doesn't exist then
* display the $text
*
* @param string $text - text to display: defaults to next
*
**/
function nextPage($text='next')
{
if (empty($this->_pageDetails)) { return false; }
if (!empty($this->_pageDetails['nextPage']))
{
if($this->style == 'ajax')
{
$t = $this->Ajax->linkToRemote($text, array("fallback"=>$this->action."#","url" => $this->link.$this->_pageDetails['nextPage'],"update" => "ajax_update","method"=>"get"));
}
else
{
$t = $this->Html->link($text,$this->link.$this->_pageDetails['nextPage']);
}
return $t;
}
return false;
}
}
?>

View File

@@ -1,8 +0,0 @@
<?php echo $this->renderElement( 'header' ); ?>
<?php echo $this->renderElement( 'nav' ); ?>
<div id="t_content_container">
<div id="t_content">
<?php echo $content_for_layout;?>
</div>
</div>
<?php echo $this->renderElement( 'footer'); ?>

View File

@@ -1,51 +0,0 @@
<h1><?php echo Inflector::humanize($this->name); ?></h1>
<div id="queryform">
<?php echo $html->formTag('/results/comments/','get'); ?>
<span>
<label for="start_date">Start Date:</label>
<input type="text" name="start_date" id="start_date" value="<? echo isset($url_params['start_date']) ? $url_params['start_date'] : ''; ?>" />
<label for="end_date">End Date:</label>
<input type="text" name="end_date" id="end_date" value="<? echo isset($url_params['end_date']) ? $url_params['end_date'] : ''; ?>" />
</span>
<label for="product">Product:</label>
<select name="product" id="product">
<?php
foreach ($products as $select) :
$product = $select['applications']['name'].' '.$select['applications']['version'];
$selected = ($product == trim($url_params['product'])) ? ' selected="selected" ' : '';
?>
<option<?=$selected?>><?=$product?></option>
<?php endforeach; ?>
</select>
<input type="submit" name="submit" id="submit" value="Go" />
</form>
<br />
<span><small>Date format is yyyy-mm-dd. A blank date will use the largest possible range.</small></span>
</div>
<?php if (!empty($commentsData)) : ?>
<table class="comments" summary="User submitted comments.">
<tr><th>Date Recorded</th><th>Comment</th></tr>
<?php foreach ($commentsData as $var => $val) : ?>
<tr><td><?php echo $time->niceShort($val['Result']['created']); ?></td><td><?php echo nl2br(htmlspecialchars($val['Result']['comments'])); ?></td></tr>
<?php endforeach; ?>
</table>
<?php if($pagination->setPaging($paging)):?>
<ul id="page-numbers">
<li><?php echo $pagination->show('Show ', ' '); ?></li>
<li><?php echo $pagination->result('Results: '); ?></li>
<li><?php echo $pagination->pageNumbers(' '); ?></li>
</ul>
<?php endif;?>
<?php else: ?>
<div id="notice">There is no data available for your parameters. Please review your search criteria.</div>
<?php endif; ?>

View File

@@ -1,91 +0,0 @@
<h1><?php echo Inflector::humanize($this->name); ?></h1>
<div id="queryform">
<?php echo $html->formTag('/results/','get'); ?>
<span>
<label for="start_date">Start Date:</label>
<input type="text" name="start_date" id="start_date" value="<? echo isset($url_params['start_date']) ? $url_params['start_date'] : ''; ?>" />
<label for="end_date">End Date:</label>
<input type="text" name="end_date" id="end_date" value="<? echo isset($url_params['end_date']) ? $url_params['end_date'] : ''; ?>" />
</span>
<label for="product">Product:</label>
<select name="product" id="product">
<?php
foreach ($products as $select) :
$product = $select['applications']['name'].' '.$select['applications']['version'];
$selected = ($product == trim($url_params['product'])) ? ' selected="selected" ' : '';
?>
<option<?=$selected?>><?=$product?></option>
<?php endforeach; ?>
</select>
<input type="submit" name="submit" id="submit" value="Go" />
</form>
<br />
<span><small>Date format is yyyy-mm-dd. A blank date will use the largest possible range.</small></span>
</div>
<?php if (!empty($descriptionAndTotalsData)) : ?>
<?php
/* Prepare data for graphing */
$_dataset = '';
$_count = 0;
$_total = 0;
/* We've got to do 2 loops here because I need the totals to calculate
* percentages.
*/
foreach ($descriptionAndTotalsData as $var => $val) {
$_total += $val[0]['total'];
}
foreach ($descriptionAndTotalsData as $var => $val) {
// We're putting this in a js string, so escape the double quotes
$_description = str_replace('"','\"',$val['issues']['description']);
$_percentage = intval(($val[0]['total'] / $_total)*100);
$_dataset .= "[{$_count}, {$val[0]['total']}, \"{$_description} (n={$val[0]['total']}, {$_percentage}%)\"], ";
$_count++;
}
$_dataset = "[{$_dataset}]";
?>
<div id="graphcontainer">
<canvas id="graph" height="400" width="800">
<table class="results" summary="Firefox Uninstallation results.">
<tr><th>Reason for uninstalling</th><th>Total</th></tr>
<?php foreach ($descriptionAndTotalsData as $var => $val) : ?>
<tr><td><?=$val['issues']['description']?></td><td><?=$val[0]['total']?></td></tr>
<?php endforeach; ?>
</table>
</canvas>
</div>
<script type="text/javascript">
var layout = new PlotKit.Layout("bar", {"barOrientation":"horizontal"});
layout.addDataset("results", <?=$_dataset?>);
layout.evaluate();
var canvas = MochiKit.DOM.getElement("graph");
var plotter = new PlotKit.SweetCanvasRenderer(canvas, layout,
{
"drawYAxis" : false,
"drawXAxis" : false,
"backgroundColor" : Color.fromHexString('#78c'),
"strokeColor" : Color.fromHexString('#777'),
"strokeWidth" : 1.0,
"enableEvents" : false
});
plotter.render();
</script>
<div id="exportbox">
<a href="<?php echo $export->buildUrlString('results/comments/',$url_params); ?>">View Any Associated Comments»</a><br />
<a href="<?php echo $export->buildUrlString('results/csv/',$url_params); ?>">Download this Data»</a>
</div>
<?php else: ?>
<div id="notice">There is no data available for your parameters. Please review your search criteria.</div>
<?php endif; ?>

View File

@@ -1,6 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

View File

@@ -1,116 +0,0 @@
<?php
/* SVN FILE: $Id: css.php,v 1.1.1.1 2006-05-24 19:14:24 uid815 Exp $ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.app.webroot
* @since CakePHP v 0.2.9
* @version $Revision: 1.1.1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2006-05-24 19:14:24 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*/
require(CONFIGS.'paths.php');
require(CAKE.'basics.php');
require(LIBS.'folder.php');
require(LIBS.'file.php');
require(LIBS.'legacy.php');
/**
* Enter description here...
*
* @param unknown_type $path
* @param unknown_type $name
* @return unknown
*/
function make_clean_css ($path, $name)
{
require(VENDORS.'csspp'.DS.'csspp.php');
$data = file_get_contents($path);
$csspp = new csspp();
$output = $csspp->compress($data);
$ratio = 100-(round(strlen($output)/strlen($data), 3)*100);
$output = " /* file: $name, ratio: $ratio% */ " . $output;
return $output;
}
/**
* Enter description here...
*
* @param unknown_type $path
* @param unknown_type $content
* @return unknown
*/
function write_css_cache ($path, $content)
{
if (!is_dir(dirname($path)))
mkdir(dirname($path));
$cache = new File($path);
return $cache->write($content);
}
if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs))
die('Wrong file name.');
$filename = 'css/'.$regs[1];
$filepath = CSS.$regs[1];
$cachepath = CACHE.'css'.DS.str_replace(array('/','\\'), '-', $regs[1]);
if (!file_exists($filepath))
die('Wrong file name.');
if (file_exists($cachepath))
{
$templateModified = filemtime($filepath);
$cacheModified = filemtime($cachepath);
if ($templateModified > $cacheModified)
{
$output = make_clean_css ($filepath, $filename);
write_css_cache ($cachepath, $output);
}
else
{
$output = file_get_contents($cachepath);
}
}
else
{
$output = make_clean_css ($filepath, $filename);
write_css_cache ($cachepath, $output);
}
header("Date: ".date("D, j M Y G:i:s ", $templateModified).'GMT');
header("Content-Type: text/css");
header("Expires: ".gmdate("D, j M Y H:i:s", time()+DAY)." GMT");
header("Cache-Control: cache");// HTTP/1.1
header("Pragma: cache");// HTTP/1.0
print $output;
?>

View File

@@ -1,195 +0,0 @@
/* CSS Document */
@import url("cake.forms.css");
* {
padding:0;
margin:0;
}
body {
font: 76% Verdana, Arial, Sans-serif;
color: #333;
}
img {
border:0;
}
#wrapper {
text-align:left;
}
#header {
height: 101px;
background: #0D5087 url(../img/cake.header_bg.png) repeat-x left top;
border-bottom: 1px solid #000;
}
#content {
min-height:400px;
background-color: #fff;
padding:2em 4em;
}
#footer {
text-align:center;
padding:1em 0;
font-size:smaller;
border-top:1px solid #333;
background-color: #063260;
color:#fff;
line-height:1.5;
}
#footer a {
color:#fff;
}
h1, h2, h3, h4 {
padding-bottom:0.5em;
}
h1 {
font-family:"Trebuchet MS",Verdana,Arial,Sans-serif;
}
h1, a {
color:#DB8101;
}
h1 em, a em {
color:#008BCC;
font-style: normal;
}
ul.colored a em
h2 {
font-style: italic;
font-weight: bold;
color:#666;
}
a:hover, a:hover em {
color:#A22424;
text-decoration:none;
}
#content p, #content ul, #content ol {
line-height:1.5;
padding-bottom:1em;
}
ul, ol {
margin-left:3em;
}
/* tables */
table {
width: 100%;
background-color: #fff;
border: 1px solid #333;
clear:both;
margin: 0 0 2em 0;
white-space: normal;
}
th {
background-color: #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #666;
border-bottom: 1px solid #666;
text-align: center;
padding:3px;
}
table tr td {
border-right: 1px solid #ccc;
padding:4px 4px;
vertical-align:top;
text-align: center;
}
table tr.altRow td {
background: #f4f4f4;
}
/* scaffold show */
div.related {
clear:both;
display:block;
}
dl {
line-height:2em;
margin:1em;
}
dt {
font-weight: bold;
vertical-align:top;
}
dd {
margin-left:10em;
margin-top:-2em;
vertical-align:top;
}
/* scaffold buttons */
.notice {
color: #DB8101;
background-color: #ddd;
display: block;
padding: 1em;
}
.tip {
color: #DB8101;
background-color: #ddd;
display: block;
padding: 1em;
}
ul.actions {
list-style: none;
text-align:left;
margin:2em 0;
padding: 0;
}
ul.actions li {
margin-left:1em;
list-style: none;
display: inline;
}
ul.actions li a, ul.actions li input {
padding: 2px 12px;
color: #DB8101;
background-color:#ccc;
text-decoration: none;
border: 1px solid #666;
line-height: 24px;
font-weight: bold;
text-align:center;
text-decoration: none;
}
ul.actions li a:hover {
color: #DB8101;
background-color:#fff;
text-decoration: none;
}
td.listactions {
width: 14em;
text-align: center;
white-space: nowrap;
}
td.listactions a {
padding: 0px 8px;
text-align:center;
font-weight: bold;
color: #DB8101;
background-color:#ccc;
text-decoration: none;
border: 1px solid #666;
white-space: nowrap;
}
td.listactions a:hover {
color: #fff;
background-color:#DB8101;
}
/* index links */
ul.colored a {
}
ul.colored a em {
}
a {
font-weight: bold;
}

View File

@@ -1,279 +0,0 @@
/* form.css */
form {
margin: 0 4px;
font-size: 120%;
border-width: 0px 0px 0px 0px;
border-style: solid;
border-color: #DB8101;
}
form fieldset {
font-size: 100%;
border-color: #000000;
border-width: 1px 0px 0px 0px;
border-style: solid none none none;
padding: 10px;
}
form fieldset legend {
font-size: 150%;
font-weight: normal;
color: #000;
padding: 0px 5px;
}
label {
font-size: 150%;
}
label u {
font-style: normal;
text-decoration: underline;
}
input, select, textarea {
font-family: Tahoma, Arial, sans-serif;
font-size: 100%;
color: #000;
}
textarea {
overflow: auto;
}
form div {
clear: left;
display: block;
margin: 5px 0px 0px 0px;
padding: 1px 3px;
}
form fieldset div.notes {
float: right;
width: 158px;
height: auto;
margin: 0px 0px 10px 10px;
padding: 5px;
border: 1px solid #666;
background-color: #ffffe1;
color: #666;
font-size: 88%;
}
form fieldset div.notes h4 {
background-image: url(/images/icon_info.gif);
background-repeat: no-repeat;
background-position: top left;
padding: 3px 0px 3px 27px;
border-width: 0px 0px 1px 0px;
border-style: solid;
border-color: #666;
color: #666;
font-size: 110%;
}
form fieldset div.notes p {
margin: 0em 0em 1.2em 0em;
color: #666;
}
form fieldset div.notes p.last {
margin: 0em;
}
form div fieldset {
clear: none;
border-width: 0px 1px 0px 1px;
border-style: solid;
border-color: #666;
margin: 0px 0px 0px 142px;
padding: 0px 5px 5px 5px;
}
form div fieldset legend {
font-size: 100%;
padding: 0px 3px 0px 9px;
}
form div.required fieldset legend {
font-weight: bold;
}
form div label {
display: block;
float: left;
width: 200px;
background-color: #f4f4f4;
font-size: 16px;
padding: 3px 5px;
margin: 0px 0px 5px 0px;
text-align: right;
}
form div.optional label, label.optional {
font-weight: normal;
}
form div.required label, label.required {
font-weight: bold;
}
form div label.labelCheckbox, form div label.labelRadio {
float: none;
display: block;
margin: 0px 0px 5px 142px;
text-align: left;
}
form div fieldset label.labelCheckbox, form div fieldset label.labelRadio {
margin: 0px 0px 5px 0px;
}
p.error {
color: #DB8101;
background-color: #DBA941;
font-size: 14px;
padding: 1em;
}
form div input, form div select, form div textarea {
padding: 1px 3px;
margin: 0px 0px 0px 0px;
}
form div input.inputFile {
width: 211px;
}
form div select.selectOne, form div select.selectMultiple {
width: 211px;
padding: 1px 3px;
}
form div input.inputCheckbox, form div input.inputRadio, input.inputCheckbox, input.inputRadio {
display: inline;
height: 14px;
width: 14px;
background-color: transparent;
border-width: 0px;
}
form div.submit {
padding: 0px 0px 0px 140px;
clear:both;
display:block;
}
div.submit input {
padding: 2px 12px;
color: #DB8101;
background-color:#ccc;
text-decoration: none;
border: 1px solid #666;
font-size: 14px;
font-weight: bold;
text-align:center;
text-decoration: none;
width: auto;
}
div.submit input:hover {
padding: 2px 12px;
color: #fff;
background-color:#DB8101;
text-decoration: none;
border: 1px solid #666;
font-size: 14px;
font-weight: bold;
text-align:center;
text-decoration: none;
width: auto;
}
form div.submit div input.inputSubmit, form div.submit div input.inputButton {
float: right;
margin: 0px 0px 0px 5px;
}
form div small {
display: block;
margin: 0px 0px 5px 142px;
padding: 1px 3px;
font-size: 88%;
}
/* form.import.css */
form fieldset legend {
line-height: 150%;
}
form input, form select, form textarea {
background-color: #fff;
}
div.optional label:before {
content: '';
}
div.required label:before {
content: '';
}
form div label.labelCheckbox, form div label.labelRadio, label.labelCheckbox, label.labelRadio {
display: block;
width: 190px;
padding: 4px 0px 0px 18px;
text-indent: -18px;
line-height: 120%;
}
form div label.labelCheckbox input.inputCheckbox, form div label.labelRadio input.inputRadio, label.labelCheckbox input.inputCheckbox, label.labelRadio input.inputRadio {
margin: 0;
}
form div fieldset input.inputText, form div fieldset input.inputPassword, form div fieldset input.inputFile, form div fieldset textarea.inputTextarea {
width: 160px;
margin: 0px 0px 0px 18px;
}
form div label.compact {
display: inline;
width: auto;
padding: 4px 10px 0px 0px;
text-indent: 0px;
margin: 0;
}
form div.wide label {
float: none;
display: block;
}
form div label.wide {
width: 348px;
}
form div.wide input.inputText, form div.wide input.inputPassword, form div.wide input.inputFile, form div.wide select, form div.wide textarea {
width: 344px;
margin: 0;
}
form div.notes p, form div small {
line-height: 125%;
}
form div.wide small {
margin: 0px 0px 5px 0px;
}
div.date select {
width:auto;
}
select.autoWidth {
width:auto;
}
option {
padding-left:1em;
}

View File

@@ -1,9 +0,0 @@
form div,
form div label.labelCheckbox, form div label.labelRadio,
form div small,
form div label.labelCheckbox, form div label.labelRadio, label.labelCheckbox, label.labelRadio {
height: expression('1%');
}
form div fieldset input.inputText, form div fieldset input.inputPassword, form div fieldset input.inputFile, form div fieldset textarea.inputTextarea {
margin: expression('0px 0px 0px -124px');
}

View File

@@ -1,133 +0,0 @@
/* Screen Stylesheet */
/* This is temporary while we use the scaffolding */
@import url("cake.default.css");
table { clear:none; }
/* CORE STYLES */
body{
background-color:#788;
}
div#t_title{
background-color:#ddd;
height:50px;
padding-left:8px;
}
div#t_title h1{
font-size:1.7em;
padding-top:10px;
color:#677;
}
div#t_content_container{
}
div#t_content{
padding: 20px 10px 100px 10px;
margin-left:151px;
background-image:url('../img/bg.jpg');
background-position:bottom right;
background-repeat:no-repeat;
min-height:200px;
}
div#t_wrapper{
margin:0px;
padding:0px;
background-color:#fff;
}
div#t_border{
border-left:1px solid #111;
border-right:1px solid #111;
border-bottom:1px solid #111;
margin:0px 30px 0px 30px;
}
div#t_nav {
padding:20px 0px 50px 0px;
float:left;
width:151px;
}
div#t_nav ul {
list-style-type:none;
padding:2px 0px 0px 0px;
margin:0px;
}
div#t_nav ul li{
padding:2px 0px 2px 0px;
}
div#t_nav ul li a{
text-decoration:none;
font-size:.8em;
padding:6px 0px 6px 8px;
margin:0px 0px 0px 0px;
color:#566;
border:none;
}
div#t_nav ul li a:hover{
color:#f80;
}
div#t_nav h3 {
padding:5px 0px 0px 5px;
font-size:.9em;
}
div#t_footer {
clear:both;
border-top:1px solid #111;
}
div#t_content h1 {
margin-bottom:100px;
font-size:1.6em;
}
a.skipnav {
position:absolute;
visibility:hidden;
}
div#queryform {
margin: 5px 20px 5px 20px;
padding-bottom:20px;
width:700px;
}
div#queryform label {
font-size:.8em;
font-weight:bold;
}
div#queryform input[type="text"]{
width:7em;
}
div#exportbox {
}
/* Classes for graph/table data. (Generally just padding) */
.results {
padding: 5px 5px 5px 5px;
margin: 5px 5px 5px 5px;
}
div#notice {
background-color:#ecc;
border:1px dashed #daa;
text-align:center;
padding:6px 6px 6px 6px;
margin:6px 20px 6px 20px;
}
table.comments tr {
}
table.comments tr td{
text-align:left;
border-bottom: 1px solid #222;
}
div.bar_chart_label {
position: absolute;
text-align: left;
font-size: small;
color: #fff;
overflow: hidden;
z-index: 10;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -1,244 +0,0 @@
2006-04-29 v1.3.1 (bug fix release)
- Fix sendXMLHttpRequest sendContent regression
- Internet Explorer fix in MochiKit.Logging (printfire exception)
- Internet Explorer XMLHttpRequest object leak fixed in MochiKit.Async
2006-04-26 v1.3 "warp zone"
- IMPORTANT: Renamed MochiKit.Base.forward to forwardCall (for export)
- IMPORTANT: Renamed MochiKit.Base.find to findValue (for export)
- New MochiKit.Base.method as a convenience form of bind that takes the
object before the method
- New MochiKit.Base.flattenArguments for flattening a list of arguments to
a single Array
- Refactored MochiRegExp example to use MochiKit.Signal
- New key_events example demonstrating use of MochiKit.Signal's key handling
capabilities.
- MochiKit.DOM.createDOM API change for convenience: if attrs is a string,
null is used and the string will be considered the first node. This
allows for the more natural P("foo") rather than P(null, "foo").
- MochiKit Interpreter example refactored to use MochiKit.Signal and now
provides multi-line input and a help() function to get MochiKit function
signature from the documentation.
- Native Console Logging for the default MochiKit.Logging logger
- New MochiKit.Async.DeferredList, gatherResults, maybeDeferred
- New MochiKit.Signal example: draggable
- Added sanity checking to Deferred to ensure that errors happen when chaining
is used incorrectly
- Opera sendXMLHttpRequest fix (sends empty string instead of null by default)
- Fix a bug in MochiKit.Color that incorrectly generated hex colors for
component values smaller than 16/255.
- Fix a bug in MochiKit.Logging that prevented logs from being capped at a
maximum size
- MochiKit.Async.Deferred will now wrap thrown objects that are not instanceof
Error, so that the errback chain is used instead of the callback chain.
- MochiKit.DOM.appendChildNodes and associated functions now append iterables
in the correct order.
- New MochiKit-based SimpleTest test runner as a replacement for Test.Simple
- MochiKit.Base.isNull no longer matches undefined
- example doctypes changed to HTML4
- isDateLike no longer throws error on null
- New MochiKit.Signal module, modeled after the slot/signal mechanism in Qt
- updated elementDimensions to calculate width from offsetWidth instead
of clientWidth
- formContents now works with FORM tags that have a name attribute
- Documentation now uses MochiKit to generate a function index
2006-01-26 v1.2 "the ocho"
- Fixed MochiKit.Color.Color.lighterColorWithLevel
- Added new MochiKit.Base.findIdentical function to find the index of an
element in an Array-like object. Uses === for identity comparison.
- Added new MochiKit.Base.find function to find the index of an element in
an Array-like object. Uses compare for rich comparison.
- MochiKit.Base.bind will accept a string for func, which will be immediately
looked up as self[func].
- MochiKit.DOM.formContents no longer skips empty form elements for Zope
compatibility
- MochiKit.Iter.forEach will now catch StopIteration to break
- New MochiKit.DOM.elementDimensions(element) for determining the width and
height of an element in the document
- MochiKit.DOM's initialization is now compatible with
HTMLUnit + JWebUnit + Rhino
- MochiKit.LoggingPane will now re-use a ``_MochiKit_LoggingPane`` DIV element
currently in the document instead of always creating one.
- MochiKit.Base now has operator.mul
- MochiKit.DOM.formContents correctly handles unchecked checkboxes that have
a custom value attribute
- Added new MochiKit.Color constructors fromComputedStyle and fromText
- MochiKit.DOM.setNodeAttribute should work now
- MochiKit.DOM now has a workaround for an IE bug when setting the style
property to a string
- MochiKit.DOM.createDOM now has workarounds for IE bugs when setting the
name and for properties
- MochiKit.DOM.scrapeText now walks the DOM tree in-order
- MochiKit.LoggingPane now sanitizes the window name to work around IE bug
- MochiKit.DOM now translates usemap to useMap to work around IE bug
- MochiKit.Logging is now resistant to Prototype's dumb Object.prototype hacks
- Added new MochiKit.DOM documentation on element visibility
- New MochiKit.DOM.elementPosition(element[, relativeTo={x: 0, y: 0}])
for determining the position of an element in the document
- Added new MochiKit.DOM createDOMFunc aliases: CANVAS, STRONG
2005-11-14 v1.1
- Fixed a bug in numberFormatter with large numbers
- Massively overhauled documentation
- Fast-path for primitives in MochiKit.Base.compare
- New groupby and groupby_as_array in MochiKit.Iter
- Added iterator factory adapter for objects that implement iterateNext()
- Fixed isoTimestamp to handle timestamps with time zone correctly
- Added new MochiKit.DOM createDOMFunc aliases: SELECT, OPTION, OPTGROUP,
LEGEND, FIELDSET
- New MochiKit.DOM formContents and enhancement to queryString to support it
- Updated view_source example to use dp.SyntaxHighlighter 1.3.0
- MochiKit.LoggingPane now uses named windows based on the URL so that
a given URL will get the same LoggingPane window after a reload
(at the same position, etc.)
- MochiKit.DOM now has currentWindow() and currentDocument() context
variables that are set with withWindow() and withDocument(). These
context variables affect all MochiKit.DOM functionality (getElement,
createDOM, etc.)
- MochiKit.Base.items will now catch and ignore exceptions for properties
that are enumerable but not accessible (e.g. permission denied)
- MochiKit.Async.Deferred's addCallback/addErrback/addBoth
now accept additional arguments that are used to create a partially
applied function. This differs from Twisted in that the callback/errback
result becomes the *last* argument, not the first when this feature
is used.
- MochiKit.Async's doSimpleXMLHttpRequest will now accept additional
arguments which are used to create a GET query string
- Did some refactoring to reduce the footprint of MochiKit by a few
kilobytes
- escapeHTML to longer escapes ' (apos) and now uses
String.replace instead of iterating over every char.
- Added DeferredLock to Async
- Renamed getElementsComputedStyle to computedStyle and moved
it from MochiKit.Visual to MochiKit.DOM
- Moved all color support out of MochiKit.Visual and into MochiKit.Color
- Fixed range() to accept a negative step
- New alias to MochiKit.swapDOM called removeElement
- New MochiKit.DOM.setNodeAttribute(node, attr, value) which sets
an attribute on a node without raising, roughly equivalent to:
updateNodeAttributes(node, {attr: value})
- New MochiKit.DOM.getNodeAttribute(node, attr) which gets the value of
a node's attribute or returns null without raising
- Fixed a potential IE memory leak if using MochiKit.DOM.addToCallStack
directly (addLoadEvent did not leak, since it clears the handler)
2005-10-24 v1.0
- New interpreter example that shows usage of MochiKit.DOM to make
an interactive JavaScript interpreter
- New MochiKit.LoggingPane for use with the MochiKit.Logging
debuggingBookmarklet, with logging_pane example to show its usage
- New mochiregexp example that demonstrates MochiKit.DOM and MochiKit.Async
in order to provide a live regular expression matching tool
- Added advanced number formatting capabilities to MochiKit.Format:
numberFormatter(pattern, placeholder="", locale="default") and
formatLocale(locale="default")
- Added updatetree(self, obj[, ...]) to MochiKit.Base, and changed
MochiKit.DOM's updateNodeAttributes(node, attrs) to use it when appropiate.
- Added new MochiKit.DOM createDOMFunc aliases: BUTTON, TT, PRE
- Added truncToFixed(aNumber, precision) and roundToFixed(aNumber, precision)
to MochiKit.Format
- MochiKit.DateTime can now handle full ISO 8601 timestamps, specifically
isoTimestamp(isoString) will convert them to Date objects, and
toISOTimestamp(date, true) will return an ISO 8601 timestamp in UTC
- Fixed missing errback for sendXMLHttpRequest when the server does not
respond
- Fixed infinite recusion bug when using roundClass("DIV", ...)
- Fixed a bug in MochiKit.Async wait (and callLater) that prevented them
from being cancelled properly
- Workaround in MochiKit.Base bind (and partial) for functions that don't
have an apply method, such as alert
- Reliably return null from the string parsing/manipulation functions if
the input can't be coerced to a string (s + "") or the input makes no sense;
e.g. isoTimestamp(null) and isoTimestamp("") return null
2005-10-08 v0.90
- Fixed ISO compliance with toISODate
- Added missing operator.sub
- Placated Mozilla's strict warnings a bit
- Added JSON serialization and unserialization support to MochiKit.Base:
serializeJSON, evalJSON, registerJSON. This is very similar to the repr
API.
- Fixed a bug in the script loader that failed in some scenarios when a script
tag did not have a "src" attribute (thanks Ian!)
- Added new MochiKit.DOM createDOMFunc aliases: H1, H2, H3, BR, HR, TEXTAREA,
P, FORM
- Use encodeURIComponent / decodeURIComponent for MochiKit.Base urlEncode
and parseQueryString, when available.
2005-08-12 v0.80
- Source highlighting in all examples, moved to a view-source example
- Added some experimental syntax highlighting for the Rounded Corners example,
via the LGPL dp.SyntaxHighlighter 1.2.0 now included in examples/common/lib
- Use an indirect binding for the logger conveniences, so that the global
logger could be replaced by setting MochiKit.Logger.logger to something else
(though an observer is probably a better choice).
- Allow MochiKit.DOM.getElementsByTagAndClassName to take a string for parent,
which will be looked up with getElement
- Fixed bug in MochiKit.Color.fromBackground (was using node.parent instead of
node.parentNode)
- Consider a 304 (NOT_MODIFIED) response from XMLHttpRequest to be success
- Disabled Mozilla map(...) fast-path due to Deer Park compatibility issues
- Possible workaround for Safari issue with swapDOM, where it would get
confused because two elements were in the DOM at the same time with the
same id
- Added missing THEAD convenience function to MochiKit.DOM
- Added lstrip, rstrip, strip to MochiKit.Format
- Added updateNodeAttributes, appendChildNodes, replaceChildNodes to
MochiKit.DOM
- MochiKit.Iter.iextend now has a fast-path for array-like objects
- Added HSV color space support to MochiKit.Visual
- Fixed a bug in the sortable_tables example, it now converts types
correctly
- Fixed a bug where MochiKit.DOM referenced MochiKit.Iter.next from global
scope
2005-08-04 v0.70
- New ajax_tables example, which shows off XMLHttpRequest, ajax, json, and
a little TAL-ish DOM templating attribute language.
- sendXMLHttpRequest and functions that use it (loadJSONDoc, etc.) no longer
ignore requests with status == 0, which seems to happen for cached or local
requests
- Added sendXMLHttpRequest to MochiKit.Async.EXPORT, d'oh.
- Changed scrapeText API to return a string by default. This is API-breaking!
It was dumb to have the default return value be the form you almost never
want. Sorry.
- Added special form to swapDOM(dest, src). If src is null, dest is removed
(where previously you'd likely get a DOM exception).
- Added three new functions to MochiKit.Base for dealing with URL query
strings: urlEncode, queryString, parseQueryString
- MochiKit.DOM.createDOM will now use attr[k] = v for all browsers if the name
starts with "on" (e.g. "onclick"). If v is a string, it will set it to
new Function(v).
- Another workaround for Internet "worst browser ever" Explorer's setAttribute
usage in MochiKit.DOM.createDOM (checked -> defaultChecked).
- Added UL, OL, LI convenience createDOM aliases to MochiKit.DOM
- Packing is now done by Dojo's custom Rhino interpreter, so it's much smaller
now!
2005-07-29 v0.60
- Beefed up the MochiKit.DOM test suite
- Fixed return value for MochiKit.DOM.swapElementClass, could return
false unexpectedly before
- Added an optional "parent" argument to
MochiKit.DOM.getElementsByTagAndClassName
- Added a "packed" version in packed/MochiKit/MochiKit.js
- Changed build script to rewrite the URLs in tests to account for the
JSAN-required reorganization
- MochiKit.Compat to potentially work around IE 5.5 issues
(5.0 still not supported). Test.Simple doesn't seem to work there,
though.
- Several minor documentation corrections
2005-07-27 v0.50
- Initial Release

View File

@@ -1,69 +0,0 @@
MochiKit is dual-licensed software. It is available under the terms of the
MIT License, or the Academic Free License version 2.1. The full text of
each license is included below.
MIT License
===========
Copyright (c) 2005 Bob Ippolito. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Academic Free License v. 2.1
============================
Copyright (c) 2005 Bob Ippolito. All rights reserved.
This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work:
Licensed under the Academic Free License version 2.1
1) Grant of Copyright License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license to do the following:
a) to reproduce the Original Work in copies;
b) to prepare derivative works ("Derivative Works") based upon the Original Work;
c) to distribute copies of the Original Work and Derivative Works to the public;
d) to perform the Original Work publicly; and
e) to display the Original Work publicly.
2) Grant of Patent License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, to make, use, sell and offer for sale the Original Work and Derivative Works.
3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor hereby agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work, and by publishing the address of that information repository in a notice immediately following the copyright notice that applies to the Original Work.
4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior written permission of the Licensor. Nothing in this License shall be deemed to grant any rights to trademarks, copyrights, patents, trade secrets or any other intellectual property of Licensor except as expressly stated herein. No patent license is granted to make, use, sell or offer to sell embodiments of any patent claims other than the licensed claims defined in Section 2. No right is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under different terms from this License any Original Work that Licensor otherwise would have a right to license.
5) This section intentionally omitted.
6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately proceeding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to Original Work is granted hereunder except under this disclaimer.
8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to any person for any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to liability for death or personal injury resulting from Licensor's negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
9) Acceptance and Termination. If You distribute copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. Nothing else but this License (or another written agreement between Licensor and You) grants You permission to create Derivative Works based upon the Original Work or to exercise any of the rights granted in Section 1 herein, and any attempt to do so except under the terms of this License (or another written agreement between Licensor and You) is expressly prohibited by U.S. copyright law, the equivalent laws of other countries, and by international treaty. Therefore, by exercising any of the rights granted to You in Section 1 herein, You indicate Your acceptance of this License and all of its terms and conditions.
10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et seq., the equivalent laws of other countries, and international treaty. This section shall survive the termination of this License.
12) Attorneys Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
13) Miscellaneous. This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved. Permission is hereby granted to copy and distribute this license without modification. This license may not be modified without the express written permission of its copyright owner.

View File

@@ -1,115 +0,0 @@
Changes
META.json
MANIFEST This list of files
LICENSE.txt
doc/html/MochiKit/Async.html
doc/html/MochiKit/Base.html
doc/html/MochiKit/Color.html
doc/html/MochiKit/DateTime.html
doc/html/MochiKit/DOM.html
doc/html/MochiKit/Format.html
doc/html/MochiKit/index.html
doc/html/MochiKit/Iter.html
doc/html/MochiKit/Logging.html
doc/html/MochiKit/LoggingPane.html
doc/html/MochiKit/Signal.html
doc/html/MochiKit/VersionHistory.html
doc/html/MochiKit/Visual.html
doc/js/toc.js
doc/rst/MochiKit/Async.rst
doc/rst/MochiKit/Base.rst
doc/rst/MochiKit/Color.rst
doc/rst/MochiKit/DateTime.rst
doc/rst/MochiKit/DOM.rst
doc/rst/MochiKit/Format.rst
doc/rst/MochiKit/index.rst
doc/rst/MochiKit/Iter.rst
doc/rst/MochiKit/Logging.rst
doc/rst/MochiKit/LoggingPane.rst
doc/rst/MochiKit/Signal.rst
doc/rst/MochiKit/VersionHistory.rst
doc/rst/MochiKit/Visual.rst
examples/ajax_tables/ajax_tables.css
examples/ajax_tables/ajax_tables.js
examples/ajax_tables/domains.json
examples/ajax_tables/domains.xml
examples/ajax_tables/index.html
examples/color_wheel/color_wheel.css
examples/color_wheel/color_wheel.js
examples/color_wheel/index.html
examples/draggable/draggable.css
examples/draggable/draggable.js
examples/draggable/index.html
examples/interpreter/index.html
examples/interpreter/interpreter.css
examples/interpreter/interpreter.js
examples/key_events/index.html
examples/key_events/key_events.css
examples/key_events/key_events.js
examples/logging_pane/index.html
examples/logging_pane/logging_pane.css
examples/logging_pane/logging_pane.js
examples/mochiregexp/index.html
examples/mochiregexp/mochiregexp.css
examples/mochiregexp/mochiregexp.js
examples/rounded_corners/index.html
examples/rounded_corners/rounded_corners.css
examples/rounded_corners/rounded_corners.js
examples/sortable_tables/index.html
examples/sortable_tables/sortable_tables.css
examples/sortable_tables/sortable_tables.js
examples/view-source/view-source.css
examples/view-source/view-source.html
examples/view-source/view-source.js
examples/view-source/lib/SyntaxHighlighter/shBrushCSharp.js
examples/view-source/lib/SyntaxHighlighter/shBrushDelphi.js
examples/view-source/lib/SyntaxHighlighter/shBrushJScript.js
examples/view-source/lib/SyntaxHighlighter/shBrushPhp.js
examples/view-source/lib/SyntaxHighlighter/shBrushPython.js
examples/view-source/lib/SyntaxHighlighter/shBrushSql.js
examples/view-source/lib/SyntaxHighlighter/shBrushVb.js
examples/view-source/lib/SyntaxHighlighter/shBrushXml.js
examples/view-source/lib/SyntaxHighlighter/shCore.js
examples/view-source/lib/SyntaxHighlighter/SyntaxHighlighter.css
examples/view-source/lib/SyntaxHighlighter/Tests.html
include/css/documentation.css
include/css/general.css
MochiKit/__package__.js
MochiKit/Async.js
MochiKit/Base.js
MochiKit/Color.js
MochiKit/DateTime.js
MochiKit/DOM.js
MochiKit/Format.js
MochiKit/Iter.js
MochiKit/Logging.js
MochiKit/LoggingPane.js
MochiKit/MochiKit.js
MochiKit/MockDOM.js
MochiKit/Signal.js
MochiKit/Test.js
MochiKit/Visual.js
packed/MochiKit/__package__.js
packed/MochiKit/MochiKit.js
tests/index.html
tests/test_Base.js
tests/test_Color.js
tests/test_DateTime.js
tests/test_Format.js
tests/test_Iter.js
tests/test_Logging.js
tests/test_MochiKit-Async.html
tests/test_MochiKit-Base.html
tests/test_MochiKit-Color.html
tests/test_MochiKit-DateTime.html
tests/test_MochiKit-DOM.html
tests/test_MochiKit-Format.html
tests/test_MochiKit-Iter.html
tests/test_MochiKit-JSAN.html
tests/test_MochiKit-Logging.html
tests/test_MochiKit-MochiKit.html
tests/test_MochiKit-Signal.html
tests/test_Signal.js
tests/SimpleTest/SimpleTest.js
tests/SimpleTest/test.css
tests/SimpleTest/TestRunner.js

Some files were not shown because too many files have changed in this diff Show More