Commit c7fa1cee authored by kaie%netscape.com's avatar kaie%netscape.com
Browse files

#92131, enhanced client authentification prompter

r=javi@netscape.com sr=blizzard@mozilla.org
parent fec0a23b
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;

var dialogParams;
var itemCount = 0;

function onLoad()
{
@@ -49,24 +50,38 @@ function onLoad()
    setText("issuer", message2);

    var selectElement = document.getElementById("nicknames");
    for (var i=0; i < dialogParams.GetInt(1); i++) {
    itemCount = dialogParams.GetInt(1);
    for (var i=0; i < itemCount; i++) {
        var menuItemNode = document.createElement("menuitem");
        var nick = dialogParams.GetString(i+4);
        menuItemNode.setAttribute("value", nick);
        menuItemNode.setAttribute("label", nick);
        menuItemNode.setAttribute("value", i);
        menuItemNode.setAttribute("label", nick); // this is displayed
        selectElement.firstChild.appendChild(menuItemNode);
        if (i == 0) {
            selectElement.selectedItem = menuItemNode;
        }
    }

    setDetails();
}

function setDetails()
{
  var index = parseInt(document.getElementById("nicknames").value);
  details = dialogParams.GetString(index+itemCount+4);
  document.getElementById("details").setAttribute("value", details);
}

function onCertSelected()
{
  setDetails();
}

function doOK()
{
  var nicknameList = document.getElementById("nicknames");
  var nickname = nicknameList.value;
  dialogParams.SetInt(1,1);
  dialogParams.SetString(1, nickname);
  var index = parseInt(document.getElementById("nicknames").value);
  dialogParams.SetInt(2, index);
  window.close();
}

+14 −6
Original line number Diff line number Diff line
@@ -26,13 +26,12 @@
<window id="ssl_warning" title="&clientAuthAsk.title;"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"      
  height="360"
  width="400"
  onload="onLoad();">

<script type="application/x-javascript" src="chrome://global/content/strres.js"/>
<script type="application/x-javascript" src="chrome://pippki/content/pippki.js"/>
<script type="application/x-javascript" src="chrome://pippki/content/clientauthask.js"/>
<script type="application/x-javascript" src="chrome://help/content/help.js" />

<keyset id="keys">
  <key id="enter-key"  keycode="VK_ENTER"  oncommand="doOK();"/>
@@ -40,18 +39,25 @@
  <key id="esc-key"    keycode="VK_ESCAPE" oncommand="window.close();"/>
</keyset>

<vbox style="margin: 5px;" flex="1">
<vbox style="margin: 5px;">
    <groupbox orient="vertical">
    <html>&clientAuthAsk.message1;</html>
    <html style="font-weight: bold;">&clientAuthAsk.message1;</html>
    <html id="hostname"/>
    <html id="organization"/>
    <html id="issuer"/>
    </groupbox>
    <groupbox orient="vertical">
    <html>&clientAuthAsk.message2;</html>
    <menulist id="nicknames">
    <html style="font-weight: bold;">&clientAuthAsk.message2;</html>
    <broadcaster id="certSelected" oncommand="onCertSelected();"/>
    <!-- The items in this menulist must never be sorted,
         but remain in the order filled by the application
    -->
    <menulist id="nicknames" observes="certSelected">
        <menupopup/>
    </menulist>
    <html>&clientAuthAsk.message3;</html>
    <textbox readonly="true" id="details" multiline="true"
      style="height: 10em; width=80em;"/>
    </groupbox>
  <separator/>
  <hbox>
@@ -59,6 +65,8 @@
          oncommand="doOK();" disabled="false"/> 
  <button id="cancel-button" class="dialog" label="&cancel.label;"
          oncommand="doCancel();"/> 
  <button id="help-button" class="dialog" label="&help.label;"
     style="width: 10ex" oncommand="openHelp('chrome://help/content/help.xul?which_cert');" /> 
  </hbox>
</vbox>
</window>
+2 −1
Original line number Diff line number Diff line
@@ -76,8 +76,9 @@

<!-- Strings for the SSL client auth ask dialog -->
<!ENTITY clientAuthAsk.title "User Identification Request">
<!ENTITY clientAuthAsk.message1 "This site has requested that you identify yourself with a security certificate:">
<!ENTITY clientAuthAsk.message1 "This site has requested that you identify yourself with a certificate:">
<!ENTITY clientAuthAsk.message2 "Choose a certificate to present as identification:">
<!ENTITY clientAuthAsk.message3 "Details of selected certificate:">

<!ENTITY pkcs12.setpassword.title  "Choose a Certificate Backup Password">
<!ENTITY pkcs12.setpassword.message  "The certificate backup password you set here protects the backup file that you are about to create.  You must set this password to proceed with the backup.">
+7 −2
Original line number Diff line number Diff line
@@ -682,7 +682,7 @@ nsNSSDialogs::CACertExists(nsIInterfaceRequestor *ctx,PRBool *_canceled)


NS_IMETHODIMP
nsNSSDialogs::ChooseCertificate(nsIInterfaceRequestor *ctx, const PRUnichar *cn, const PRUnichar *organization, const PRUnichar *issuer, const PRUnichar **certNickList, PRUint32 count, PRUnichar **certNick, PRBool *canceled) 
nsNSSDialogs::ChooseCertificate(nsIInterfaceRequestor *ctx, const PRUnichar *cn, const PRUnichar *organization, const PRUnichar *issuer, const PRUnichar **certNickList, const PRUnichar **certDetailsList, PRUint32 count, PRInt32 *selectedIndex, PRBool *canceled) 
{
  nsresult rv;
  PRUint32 i;
@@ -712,6 +712,11 @@ nsNSSDialogs::ChooseCertificate(nsIInterfaceRequestor *ctx, const PRUnichar *cn,
	  if (NS_FAILED(rv)) return rv;
  }

  for (i = 0; i < count; i++) {
	  rv = block->SetString(i+count+4, certDetailsList[i]);
	  if (NS_FAILED(rv)) return rv;
  }

  rv = block->SetInt(1, count);
  if (NS_FAILED(rv)) return rv;

@@ -728,7 +733,7 @@ nsNSSDialogs::ChooseCertificate(nsIInterfaceRequestor *ctx, const PRUnichar *cn,
  *canceled = (status == 0)?PR_TRUE:PR_FALSE;
  if (!*canceled) {
    // retrieve the nickname
    rv = block->GetString(1, certNick);
    rv = block->GetInt(2, selectedIndex);
  }
  return rv;
}
+2 −1
Original line number Diff line number Diff line
@@ -151,8 +151,9 @@ interface nsIClientAuthDialogs : nsISupports
                        in wstring organization,
                        in wstring issuer,
                        [array, size_is(count)] in wstring certNickList,
                        [array, size_is(count)] in wstring certDetailsList,
                        in PRUint32 count,
                        out wstring certNick,
                        out PRInt32 selectedIndex,
                        out boolean canceled);
};

Loading