зеркало из https://github.com/mozilla/gecko-dev.git
Fix for #94974 - Provide an interface for embeddors to access security info
r=rpotts,thayes sr=rpotts
This commit is contained in:
Родитель
f45d5eacca
Коммит
d052302a1e
|
@ -67,6 +67,7 @@
|
|||
#include "BrowserImpl.h"
|
||||
#include "BrowserFrm.h"
|
||||
#include "Dialogs.h"
|
||||
#include "SecurityInfoDlg.h"
|
||||
|
||||
// Print Includes
|
||||
#include "PrintProgressDialog.h"
|
||||
|
@ -1042,5 +1043,13 @@ void CBrowserView::ShowSecurityInfo()
|
|||
return;
|
||||
}
|
||||
|
||||
::MessageBox(hParent, "To Be Done..........", "MfcEmbed", MB_OK);
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsISSLStatus> sslStatus = do_GetInterface(mWebBrowser, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
::MessageBox(hParent, "Unable to get nsISSLStatus", "MfcEmbed", MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
SecurityInfoDlg dlg(sslStatus, this);
|
||||
dlg.DoModal();
|
||||
}
|
||||
|
|
|
@ -349,6 +349,42 @@ BEGIN
|
|||
EDITTEXT IDC_EDIT_HOMEPAGE,53,95,211,14,ES_AUTOHSCROLL
|
||||
END
|
||||
|
||||
IDD_SECURITY_INFO_DIALOG DIALOG DISCARDABLE 0, 0, 248, 119
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Security Information"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CTEXT "",IDC_ENCRYPTION,37,7,174,13,SS_CENTERIMAGE | SS_SUNKEN
|
||||
LTEXT "This page was encrypted. This means it was difficult for other people to view this page when it was loaded.\n\nYou can examine your copy of the certificate for this page and check the identity of the web site.",
|
||||
IDC_STATIC,3,27,239,41
|
||||
LTEXT "To see the certificate for this web site, click View Certificate.",
|
||||
IDC_STATIC,5,78,233,8
|
||||
PUSHBUTTON "View Certificate",IDC_VIEW_CERT,66,99,57,14
|
||||
DEFPUSHBUTTON "OK",IDOK,132,99,50,14
|
||||
END
|
||||
|
||||
IDD_VIEWCERT_DIALOG DIALOG DISCARDABLE 0, 0, 347, 175
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Certificate Information"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,147,154,50,14
|
||||
LTEXT "This Certificate was issued by:",IDC_STATIC,5,9,96,8
|
||||
LTEXT "",IDC_CERT_OWNER,197,24,143,44
|
||||
LTEXT "This Certificate belongs to:",IDC_STATIC,187,9,84,8
|
||||
LTEXT "",IDC_CERT_ISSUER,13,24,143,44
|
||||
LTEXT "Serial Number:",IDC_STATIC,5,75,47,8
|
||||
LTEXT "",IDC_CERT_SERIAL,57,75,282,8
|
||||
LTEXT "Date Issued:",IDC_STATIC,5,90,41,8
|
||||
LTEXT "",IDC_CERT_ISSUE_DATE,57,90,282,8
|
||||
LTEXT "Date Expires:",IDC_STATIC,5,105,43,8
|
||||
LTEXT "",IDC_CERT_EXPIRY_DATE,57,105,282,8
|
||||
LTEXT "SHA1 Fingerprint:",IDC_STATIC,5,120,56,8
|
||||
LTEXT "",IDC_CERT_SHA1_FINGERPRINT,70,120,269,8
|
||||
LTEXT "MD5 Fingerprint:",IDC_STATIC,5,135,53,8
|
||||
LTEXT "",IDC_CERT_MD5_FINGERPRINT,70,135,269,8
|
||||
END
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
/* -*- 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):
|
||||
* Chak Nanga <chak@netscape.com>
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "SecurityInfoDlg.h"
|
||||
#include "nsIX509Cert.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SecurityInfoDlg dialog
|
||||
|
||||
SecurityInfoDlg::SecurityInfoDlg(nsISSLStatus* sslStatus, CWnd* pParent /*=NULL*/)
|
||||
: CDialog(SecurityInfoDlg::IDD, pParent)
|
||||
{
|
||||
m_ISSLStatus = sslStatus;
|
||||
}
|
||||
|
||||
|
||||
void SecurityInfoDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
|
||||
DDX_Control(pDX, IDC_ENCRYPTION, m_Encryption);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(SecurityInfoDlg, CDialog)
|
||||
ON_BN_CLICKED(IDC_VIEW_CERT, OnViewCert)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BOOL SecurityInfoDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
nsXPIDLCString encryptionAlgorithm;
|
||||
m_ISSLStatus->GetCipherName(getter_Copies(encryptionAlgorithm));
|
||||
|
||||
PRUint32 encryptionStrength = 0;
|
||||
m_ISSLStatus->GetSecretKeyLength(&encryptionStrength);
|
||||
|
||||
int iResID = IDS_ENCRYPTION_NONE;
|
||||
if (encryptionStrength >= 90)
|
||||
iResID = IDS_ENCRYPTION_HIGH_GRADE;
|
||||
else if (encryptionStrength > 0)
|
||||
iResID = IDS_ENCRYPTION_LOW_GRADE;
|
||||
|
||||
CString strEncryption;
|
||||
if(iResID == IDS_ENCRYPTION_NONE)
|
||||
strEncryption.LoadString(iResID);
|
||||
else
|
||||
strEncryption.FormatMessage(iResID, encryptionAlgorithm.get(),
|
||||
encryptionStrength);
|
||||
|
||||
m_Encryption.SetWindowText(strEncryption);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
void SecurityInfoDlg::OnOK()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void SecurityInfoDlg::OnViewCert()
|
||||
{
|
||||
OnOK();
|
||||
|
||||
ViewCertDlg dlg(m_ISSLStatus, this);
|
||||
dlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ViewCertDlg dialog
|
||||
|
||||
ViewCertDlg::ViewCertDlg(nsISSLStatus* sslStatus, CWnd* pParent /*=NULL*/)
|
||||
: CDialog(ViewCertDlg::IDD, pParent)
|
||||
{
|
||||
m_ISSLStatus = sslStatus;
|
||||
}
|
||||
|
||||
|
||||
void ViewCertDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
|
||||
DDX_Control(pDX, IDC_CERT_SERIAL, m_CertSerial);
|
||||
DDX_Control(pDX, IDC_CERT_ISSUE_DATE, m_CertIssued);
|
||||
DDX_Control(pDX, IDC_CERT_EXPIRY_DATE, m_CertExpires);
|
||||
DDX_Control(pDX, IDC_CERT_OWNER, m_CertOwner);
|
||||
DDX_Control(pDX, IDC_CERT_ISSUER, m_CertIssuer);
|
||||
DDX_Control(pDX, IDC_CERT_SHA1_FINGERPRINT, m_CertSha1Fingerprint);
|
||||
DDX_Control(pDX, IDC_CERT_MD5_FINGERPRINT, m_CertMd5Fingerprint);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(ViewCertDlg, CDialog)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BOOL ViewCertDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
nsCOMPtr<nsIX509Cert> serverCert;
|
||||
nsresult rv = m_ISSLStatus->GetServerCert(getter_AddRefs(serverCert));
|
||||
if (NS_FAILED(rv)) return TRUE;
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
// The cert issuer name and the subject names returned will be
|
||||
// in the "Distinguised Name(DN)" format specified in RFC 1779
|
||||
//
|
||||
// The following string Replaces attempt to convert the
|
||||
// DN into a user friendly name for our diplay purposes
|
||||
//
|
||||
// This is a quick and dirty version of the ldap_dn2ufn() function
|
||||
// in the Netscape's LDAP SDK
|
||||
|
||||
nsXPIDLString issuerName;
|
||||
serverCert->GetIssuerName(getter_Copies(issuerName));
|
||||
CString strIssuer = W2T(issuerName.get());
|
||||
strIssuer.Replace("OU=", "");
|
||||
strIssuer.Replace("O=", "\n");
|
||||
strIssuer.Replace("L=", "\n");
|
||||
strIssuer.Replace("E=", "");
|
||||
strIssuer.Replace("CN=", "");
|
||||
strIssuer.Replace(", ", "");
|
||||
strIssuer.Replace("ST=", ", ");
|
||||
strIssuer.Replace("C=", ", ");
|
||||
m_CertIssuer.SetWindowText(strIssuer);
|
||||
|
||||
nsXPIDLString subjectName;
|
||||
serverCert->GetSubjectName(getter_Copies(subjectName));
|
||||
CString strOwner = W2T(subjectName.get());
|
||||
strOwner.Replace("CN=", "");
|
||||
strOwner.Replace("OU=", "\n");
|
||||
strOwner.Replace("O=", "\n");
|
||||
strOwner.Replace("L=", "\n");
|
||||
strOwner.Replace(", ", "");
|
||||
strOwner.Replace("ST=", ", ");
|
||||
strOwner.Replace("C=", ", ");
|
||||
m_CertOwner.SetWindowText(strOwner);
|
||||
|
||||
nsXPIDLString serialNumber;
|
||||
serverCert->GetSerialNumber(getter_Copies(serialNumber));
|
||||
m_CertSerial.SetWindowText(W2T(serialNumber.get()));
|
||||
|
||||
nsXPIDLString issuedDate;
|
||||
serverCert->GetIssuedDate(getter_Copies(issuedDate));
|
||||
m_CertIssued.SetWindowText(W2T(issuedDate.get()));
|
||||
|
||||
nsXPIDLString expiresDate;
|
||||
serverCert->GetExpiresDate(getter_Copies(expiresDate));
|
||||
m_CertExpires.SetWindowText(W2T(expiresDate.get()));
|
||||
|
||||
nsXPIDLString sha1FingerPrint;
|
||||
serverCert->GetSha1Fingerprint(getter_Copies(sha1FingerPrint));
|
||||
m_CertSha1Fingerprint.SetWindowText(W2T(sha1FingerPrint.get()));
|
||||
|
||||
nsXPIDLString md5FingerPrint;
|
||||
serverCert->GetMd5Fingerprint(getter_Copies(md5FingerPrint));
|
||||
m_CertMd5Fingerprint.SetWindowText(W2T(md5FingerPrint.get()));
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- 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):
|
||||
* Chak Nanga <chak@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _SECURITY_INFO_DLG_H_
|
||||
#define _SECURITY_INFO_DLG_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SecurityInfoDlg dialog
|
||||
|
||||
class SecurityInfoDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
SecurityInfoDlg(nsISSLStatus* sslStatus, CWnd* pParent = NULL); // standard constructor
|
||||
nsCOMPtr<nsISSLStatus> m_ISSLStatus;
|
||||
|
||||
enum { IDD = IDD_SECURITY_INFO_DIALOG };
|
||||
CStatic m_Encryption;
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
protected:
|
||||
afx_msg void OnViewCert();
|
||||
virtual void OnOK();
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ViewCertDlg dialog
|
||||
|
||||
class ViewCertDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
ViewCertDlg(nsISSLStatus* sslStatus, CWnd* pParent = NULL); // standard constructor
|
||||
nsCOMPtr<nsISSLStatus> m_ISSLStatus;
|
||||
|
||||
enum { IDD = IDD_VIEWCERT_DIALOG };
|
||||
CStatic m_CertSerial;
|
||||
CStatic m_CertIssued;
|
||||
CStatic m_CertExpires;
|
||||
CStatic m_CertOwner;
|
||||
CStatic m_CertIssuer;
|
||||
CStatic m_CertSha1Fingerprint;
|
||||
CStatic m_CertMd5Fingerprint;
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
protected:
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
#endif // _SECURITY_INFO_DLG_H_
|
|
@ -102,12 +102,15 @@
|
|||
#include "nsIEmbeddingSiteWindow.h"
|
||||
#include "nsIWebBrowserFind.h"
|
||||
#include "nsIWebBrowserFocus.h"
|
||||
|
||||
|
||||
// Printer Includes
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
||||
// SSL Includes
|
||||
#include "nsISSLStatus.h"
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ OBJS = \
|
|||
.\$(OBJDIR)\MostRecentUrls.obj \
|
||||
.\$(OBJDIR)\PrintProgressDialog.obj \
|
||||
.\$(OBJDIR)\Preferences.obj \
|
||||
.\$(OBJDIR)\SecurityInfoDlg.obj \
|
||||
.\$(OBJDIR)\StdAfx.obj \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -146,6 +146,10 @@ SOURCE=.\ProfilesDlg.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SecurityInfoDlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -206,6 +210,10 @@ SOURCE=.\resource.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SecurityInfoDlg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define IDS_ENCRYPTION_HIGH_GRADE 147
|
||||
#define IDS_ENCRYPTION_LOW_GRADE 148
|
||||
#define IDS_ENCRYPTION_NONE 149
|
||||
#define IDD_SECURITY_INFO_DIALOG 150
|
||||
#define IDD_VIEWCERT_DIALOG 151
|
||||
#define ID_URL_BAR 1001
|
||||
#define ID_PROG_BAR 1002
|
||||
#define IDC_PROMPT_ANSWER 1003
|
||||
|
@ -53,6 +55,15 @@
|
|||
#define IDC_RADIO_BLANK_PAGE 1153
|
||||
#define IDC_RADIO_HOME_PAGE 1154
|
||||
#define IDC_EDIT_HOMEPAGE 1155
|
||||
#define IDC_VIEW_CERT 1156
|
||||
#define IDC_CERT_OWNER 1157
|
||||
#define IDC_CERT_ISSUER 1158
|
||||
#define IDC_CERT_SERIAL 1159
|
||||
#define IDC_CERT_ISSUE_DATE 1160
|
||||
#define IDC_CERT_EXPIRY_DATE 1161
|
||||
#define IDC_CERT_SHA1_FINGERPRINT 1162
|
||||
#define IDC_CERT_MD5_FINGERPRINT 1163
|
||||
#define IDC_ENCRYPTION 1164
|
||||
#define ID_NAV_BACK 32773
|
||||
#define ID_NAV_FORWARD 32774
|
||||
#define ID_NAV_HOME 32775
|
||||
|
|
Загрузка…
Ссылка в новой задаче