summaryrefslogtreecommitdiffstats
path: root/pki/linux/tps-ui/shared/docroot/esc
diff options
context:
space:
mode:
Diffstat (limited to 'pki/linux/tps-ui/shared/docroot/esc')
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/AdminEsc.html58
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/AdvancePopup.html1714
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/EnrollPopup.html1718
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/GenericAuth.html537
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/SettingsEsc.html738
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/TokenManager.html1706
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/TokenPin.html77
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/demo/EnrollSuccess.html52
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/demo/GenericAuth.html538
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/demo/logo.jpgbin0 -> 429 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/demo/style.css214
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/demo/util.js1504
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/home/EnrollSuccess.html47
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/home/GenericAuth.html539
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/home/logo.jpgbin0 -> 429 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/home/style.css214
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/home/util.js1504
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/BannerBackground.gifbin0 -> 335 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/CancelButton.gifbin0 -> 1337 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/CloseButton.gifbin0 -> 1309 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/ContinueButton.gifbin0 -> 1457 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/HelpButton.gifbin0 -> 1279 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/NetKey-Small.gifbin0 -> 135 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/NetKeyInsert.gifbin0 -> 1622 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/NetKeyLogo.gifbin0 -> 426 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/NetKeyPair.gifbin0 -> 1451 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/NetKeyProgress.gifbin0 -> 7018 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/NetKeyQuestionMark.gifbin0 -> 1707 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/OKButton.gifbin0 -> 1237 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/PadLock.gifbin0 -> 136 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/PurchaseButton.gifbin0 -> 1878 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/ReactivateButton.gifbin0 -> 1482 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/ReleaseButton.gifbin0 -> 1413 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/SecureButton.gifbin0 -> 1340 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/SuspendButton.gifbin0 -> 1425 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/TryAgainButton.gifbin0 -> 1441 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/images/bg.jpgbin0 -> 519 bytes
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/images/logo.gifbin0 -> 2866 bytes
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/so/EnrollSuccess.html45
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/so/GenericAuth.html539
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/so/logo.jpgbin0 -> 429 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/so/style.css214
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/so/util.js1507
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/sow/EnrollSuccess.html52
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/sow/GenericAuth.html539
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/sow/images/logo.gifbin0 -> 2866 bytes
-rw-r--r--pki/linux/tps-ui/shared/docroot/esc/sow/logo.jpgbin0 -> 429 bytes
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/sow/style.css214
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/sow/util.js1698
-rwxr-xr-xpki/linux/tps-ui/shared/docroot/esc/style.css197
50 files changed, 16165 insertions, 0 deletions
diff --git a/pki/linux/tps-ui/shared/docroot/esc/AdminEsc.html b/pki/linux/tps-ui/shared/docroot/esc/AdminEsc.html
new file mode 100755
index 000000000..997de8e54
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/AdminEsc.html
@@ -0,0 +1,58 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<html>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<head>
+<title>Enterprise Security Administration Page</title>
+
+<link rel=stylesheet href="/style.css" type="text/css">
+
+</head>
+<body>
+
+<table width="100%">
+ <tr>
+ <td>
+<img src="../images/logo.gif"> </td>
+ <td>
+ <p class="headerText"><a href="esc.cgi?screenname=">Enterprise Security Client</a></p>
+ </td>
+ <tr>
+</table>
+
+<br>
+<br>
+<table width=100%>
+<tr>
+ <td class="bodyText">
+Welcome to the Enterprise Security Administration Page.
+</p>
+<p>Below are some useful links that take you directly to some of
+<br>the useful pages provided by the Enterprise Security program.
+</p>
+ </td>
+ </tr>
+</table>
+<br>
+<li><a class=linkText href="esc.cgi?action=enrollmentpage&screenname=">Key Enrollment Page</a></li>
+<li><a class=linkText href="esc.cgi?action=advancepage&screenname=">Advanced Function Page</a></li>
+<li><a class=linkText href="esc.cgi?action=tokenmanagerpage&screenname=">Token Manager Page</a></li>
+<li><a class=linkText href="esc.cgi?action=settingspage&screenname=">Settings Page</a></li>
+</body>
+</html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/AdvancePopup.html b/pki/linux/tps-ui/shared/docroot/esc/AdvancePopup.html
new file mode 100755
index 000000000..c2698d45e
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/AdvancePopup.html
@@ -0,0 +1,1714 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<html>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+<head>
+<link rel=stylesheet href="/style.css" type="text/css">
+
+<script language="JavaScript">
+
+//
+// initialize netkey globals
+var netkey;
+var isMSHTML;
+
+
+var keyUITable = new Array();
+var keyTypeTable = new Array();
+var curChildWindow = null;
+
+function getUIForKey(aKeyID)
+{
+ return keyUITable[aKeyID];
+
+}
+
+function getTypeForKey(aKeyID)
+{
+ return keyTypeTable[aKeyID];
+}
+
+//
+// Determine if we are running MSHTML or GECKO
+//
+if (navigator.userAgent.indexOf("MSIE") != -1) {
+ isMSHTML = true;
+} else {
+ isMSHTML = false;
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData,strData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ alert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+if (!isMSHTML) {
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+ gNotify = new jsNotify;
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+} else {
+ // MSHTML only initialization
+ netkey = external;
+}
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+ if (!isMSHTML) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+ }
+}
+
+var gScreenName = "";
+var gKeyEnrollmentType = "userKey";
+
+var gCurrentSelectedRow = null;
+
+
+var gCurKeyType = null;
+var gCurKeyID = null;
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+
+// List of Error Messages to be printed out
+
+var Status_Messages = new Array(
+
+"Operation Completed Successfully.",
+ "Server Error.",
+ "Problem communicating with the token.",
+ "Problem communicating with the token.",
+ "Problem resetting token's pin.",
+ "Internal Server Error.",
+ "Internal Server Error",
+ "Token Enrollment Error.",
+ "Problem communicating with the token.",
+ "Internal Server Error",
+ "Error communicating with the Certificate Authority, try again later.",
+ "Internal Server Error.",
+ "Error resetting the token's pin.",
+ "Internal Server Error.",
+ "Authentication Failure, Try Again.",
+ "Internal Server Error",
+ "Token is disabled, contact technical support.",
+ "Problem communicating with the token.",
+ "Internal Server Error.",
+ "Cannot upgrade token software.",
+ "Internal Server Error.",
+ "Problem communicating with the token.",
+ "Invalid token type.",
+ "Invalid token type",
+ "Cannot publish.",
+ "Cannot communicate with token database, try again later.",
+ "Token is disabled, contact techincal support.",
+ "Cannot reset pin value for the token, contact technical support.",
+ "Connection to server lost.",
+ "Cannot create entry for token in database, contact technical support.",
+ "No such token state, contact technical support.",
+ "Invalid lost token reason, contact technical support.",
+ "Token unusable due to compromise,contact technical support.",
+ "No such inactive token, contact technical support.",
+ "Cannot process more than one active token.",
+ "Internal Server Error,contact technical support.",
+ "Key Recovery has been processed.",
+ "Key Recovery failed, contact technical support.",
+ "Cannot operate on token reported lost, contact technical support.",
+ "Key archival error, contact technical support.",
+ "Problem connecting to the TKS, contact technical support.",
+ "Failed to update token database, contact technical support.",
+ "Internal certificate revocation error,contact technical support.",
+ "User does not own this token, contact technical support."
+);
+
+function GetAuthDataFromPopUp(aKeyType,aKeyID,aUiData)
+{
+
+ keyUITable[aKeyID] = aUiData;
+ keyTypeTable[aKeyID] = aKeyType;
+
+ //alert("GetAuthDataFromPopUp data " + aUiData);
+ var child = window.open("/GenericAuth.html",aKeyID,"height=400,width=400");
+
+ //alert("Attempted to create child window " + child);
+
+ curChildWindow = child;
+
+}
+
+function COOLKeySetDataValue(aKeyType,aKeyID,name,value)
+{
+ //alert("In COOLKeySetDataValue aKeyType " + aKeyType + " aKeyID " + aKeyID + " name " + name + " value " + value);
+ if(netkey)
+ {
+ try {
+ if(!isMSHTML)
+ {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+
+ netkey.SetCoolKeyDataValue(aKeyType,aKeyID,name,value);
+
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+ }
+
+}
+
+function COOLKeySetTokenPin(pin)
+{
+ if(!isMSHTML)
+ {
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"TokenPin",pin);
+
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+ }
+ }
+}
+
+function COOLKeySetUidPassword(uid,pwd)
+{
+
+ if(!isMSHTML)
+ {
+ if(netkey)
+ {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"UserId",uid);
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"Password",pwd);
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+
+ }
+
+ }
+
+}
+
+
+function MyGetErrorMessage(status_code)
+{
+
+ var result = "Internal Server Error";
+
+ if(status_code < 0 && status_code >= Status_Messages.length)
+ {
+ return result;
+
+ }
+
+ return Status_Messages[status_code];
+
+}
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function ReportException(msg, e)
+{
+ alert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetCOOLKeyStatus(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyStatus(keyType, keyID);
+ } catch (e) {
+ ReportException("netkey.GetCoolKeyStatus() failed!", e);
+ return 0;
+ }
+}
+
+function GetCOOLKeyPolicy(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyPolicy(keyType, keyID);
+ } catch (e) {
+ // ReportException("netkey.GetCoolKeyPolicy() failed!", e);
+ return "";
+ }
+}
+
+function GetCOOLKeyRequiresAuth(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyRequiresAuthentication(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyRequiresAuthentication() failed!", e);
+ return false;
+ }
+}
+
+function GetCOOLKeyIsAuthed(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyIsAuthenticated(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsAuthenticated() failed!", e);
+ return false;
+ }
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ } else {
+ keyArr = ConvertVariantArrayToJScriptArray(netkey.GetAvailableCoolKeys());
+
+ var i;
+ for (i=0; i < keyArr.length; i++)
+ keyArr[i] = ConvertVariantArrayToJScriptArray(keyArr[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableCoolKeys() failed!", e);
+ return [];
+ }
+}
+
+function ChallengeCOOLKey(keyType, keyID, data)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return ConvertVariantArrayToJScriptArray(netkey.ChallengeCoolKey(keyType, keyID, data));
+ } catch(e) {
+ ReportException("netkey.ChallengeCoolKey() failed!", e);
+ return [];
+ }
+}
+
+function EnrollCOOLKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.EnrollCoolKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.EnrollCoolKey() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+function GetCOOLKeyIsEnrolled(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyIsEnrolled(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsEnrolled() failed!", e);
+ return false;
+ }
+}
+
+function ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.ResetCoolKeyPIN(keyType, keyID, screenname, pin,screennamepwd);
+ } catch(e) {
+ ReportException("netkey.ResetCoolKeyPIN() failed! Make sure token is properly Enrolled.", e);
+ return false;
+ }
+ return true;
+}
+function FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.FormatCoolKey() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function CancelCOOLKeyOperation(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.CancelCoolKeyOperation(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.CancelCoolKeyOperation() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function BlinkCOOLKey(keyType, keyID, rate, duration)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.BlinkCoolKey(keyType, keyID, rate, duration);
+ } catch(e) {
+ ReportException("netkey.BlinkCoolKey() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function RequestServiceTicket(screenName, serviceName)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.RequestServiceTicket(screenName, serviceName);
+ } catch(e) {
+ ReportException("netkey..RequestServiceTicket() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ if (isMSHTML) {
+ row.removeNode(row);
+ } else {
+ table.deleteRow(row.rowIndex);
+ }
+}
+
+function GetCell(row, index)
+{
+ var cell;
+
+ if (isMSHTML) {
+ cell = row.cells(index);
+ } else {
+ cell = row.cells[index];
+ }
+ return cell;
+}
+
+function GetNode(parent, index)
+{
+ var node;
+ if (isMSHTML) {
+ node = parent.childNodes(index);
+ } else {
+ node = parent.childNodes[index];
+ }
+ return node;
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ if (isMSHTML) {
+ row = table.insertRow();
+ } else {
+ row = table.insertRow(table.rows.length);
+ }
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ if (isMSHTML) {
+ cell = row.insertCell();
+ } else {
+ cell = row.insertCell(row.cells.length);
+ }
+ return cell;
+}
+
+function RemoveAllChildNodes(parent)
+{
+ var numChildren = parent.childNodes.length;
+ var i;
+
+ i = numChildren;
+ while (numChildren)
+ {
+ parent.removeChild(GetNode(parent,0));
+ numChildren--;
+ }
+
+}
+
+
+function UpdateInfoForKeyID(keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return;
+
+ var cell = GetCell(row,1)
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+ // cell = GetCell(row,2);
+ // RemoveAllChildNodes(cell);
+ //cell.appendChild(document.createTextNode(reqAuth));
+
+ //cell = GetCell(row,3);
+ //RemoveAllChildNodes(cell);
+ //cell.appendChild(document.createTextNode(isAuthed));
+}
+
+function GetStatusForKeyID(keyType, keyID)
+{
+ var keyStatus = "BLANK";
+
+ var status;
+
+ try {
+ status = GetCOOLKeyStatus(keyType, keyID);
+ } catch(e) {
+ status = 0;
+ }
+
+ switch (status) {
+ case 0: // Unavailable
+ keyStatus = "UNAVAILABLE";
+ break;
+ case 1: // AppletNotFound
+ keyStatus = "NO APPLET";
+ break;
+ case 2: // Uninitialized
+ keyStatus = "UNINITIALIZED";
+ break;
+ case 3: // Unknown
+ keyStatus = "UNKNOWN";
+ break;
+ case 4: // Available
+ case 6: // UnblockInProgress
+ case 7: // PINResetInProgress
+ case 8: // RenewInProgress
+ keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ break;
+ case 5: // EnrollmentInProgress
+ keyStatus = "BUSY";
+ break;
+ break;
+ case 9: // FormatInProgress
+ keyStatus = "BUSY";
+ break;
+ }
+
+ return keyStatus;
+}
+
+function GetKeyStatusForKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return "UNKNOWN";
+
+ var cell = GetCell(row,1);
+ return GetNode(cell,0).data;
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ {
+ var table = document.getElementById("BindingTable");
+ if (table)
+ {
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ row = CreateTableRow(table, keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ }
+
+ if (!row)
+ return null;
+ }
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ {
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(arr[i][0], arr[i][1]);
+ }
+}
+
+function InitializeBindingTable()
+{
+ UpdateBindingTableAvailability();
+ UpdateButtonStates();
+ // document.getElementById("snametf").value = gScreenName;
+}
+
+function KeyIsPresent(keyType, keyID)
+{
+ row = document.all.item(keyType, keyID);
+
+ if (!row)
+ return false;
+
+ return true;
+}
+
+function SetStatusMessage(str)
+{
+ var cell = document.getElementById("statusMsg");
+
+ if (!cell)
+ return;
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(str));
+}
+
+function UpdateButtonStates()
+{
+ if (gKeyEnrollmentType == "deviceKey")
+ {
+ // document.getElementById("snametf").disabled = true;
+ // document.getElementById("pintf").disabled = true;
+ // document.getElementById("reenterpintf").disabled = true;
+ // document.getElementById("snamepwd").disabled = true;
+ }
+ else
+ {
+ // document.getElementById("snametf").disabled = false;
+ // document.getElementById("pintf").disabled = false;
+ // document.getElementById("reenterpintf").disabled = false;
+ // document.getElementById("snamepwd").disabled = false;
+ }
+
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ var keyStatus = GetKeyStatusForKeyID(keyType, keyID);
+
+ var validKey = (keyStatus == "NETKEY" || keyStatus == "HOUSEKEY");
+ // document.getElementById("challengebtn").disabled = !validKey;
+ document.getElementById("blinkbtn").disabled = false;
+ //document.getElementById("enrollbtn").disabled = false;
+ // document.getElementById("formatbtn").disabled = false;
+// document.getElementById("resetpinbtn").disabled = !((keyStatus == "NETKEY") && (gKeyEnrollmentType == "userKey"));
+document.getElementById("resetpinbtn").disabled = !((gKeyEnrollmentType == "userKey"));
+ }
+ else
+ {
+ //document.getElementById("enrollbtn").disabled = true;
+ document.getElementById("resetpinbtn").disabled = true;
+ // document.getElementById("formatbtn").disabled = true;
+ // document.getElementById("challengebtn").disabled = true;
+ document.getElementById("blinkbtn").disabled = true;
+ }
+
+ refresh();
+}
+
+function SetEnrollmentType(type)
+{
+ gKeyEnrollmentType = type;
+ UpdateButtonStates();
+}
+
+function FindRow(node)
+{
+ while (node && node.tagName != "TR")
+ {
+ node = node.parentNode;
+ }
+
+ return node;
+}
+
+function SelectRow(row)
+{
+ if (!row || gCurrentSelectedRow == row)
+ return;
+
+ if (gCurrentSelectedRow)
+ gCurrentSelectedRow.removeAttribute("style");
+
+ gCurrentSelectedRow = row;
+ gCurrentSelectedRow.style.backgroundColor="rgb(200,200,200)";
+ UpdateButtonStates();
+}
+
+function SelectRowByKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ SelectRow(row);
+}
+
+function DoSelectRow(event)
+{
+ var row;
+
+ if (isMSHTML) {
+ row = FindRow(window.event.srcElement);
+ } else {
+ row = FindRow(event.parentNode);
+ }
+ SelectRow(row);
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+
+
+function CreateTableRow(table, keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+
+ if (isMSHTML) {
+ row.onclick = DoSelectRow;
+ }
+
+ // Create the key ID cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(KeyToUIString(keyType, keyID)));
+
+ cell.setAttribute("onClick", "DoSelectRow(this);");
+
+ // Create the keyStatus cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+ // Create the requires auth cell.
+ // cell = InsertCell(row);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ // Create the is auth'ed cell.
+ // cell = InsertCell(row);
+ // cell.appendChild(document.createTextNode(isAuthed));
+
+ // Create the status bar cell
+ cell = InsertCell(row);
+
+ var progressMeter = document.createElement("div");
+ progressMeter.setAttribute("id", KeyToProgressBarID(keyType, keyID));
+ progressMeter.className = "ProgressMeter";
+ progressMeter.style.width = "100px";
+ progressMeter.style.height = "1.5em";
+ progressMeter.setAttribute("value", 0);
+
+ var progressBar = document.createElement("div");
+ progressBar.className = "ProgressBar";
+ progressBar.style.width = "0px";
+ progressBar.style.height = "100%";
+ progressBar.style.visibility = "hidden";
+
+ var progressBarStatus = document.createElement("div");
+ progressBarStatus.className = "ProgressBarStatus";
+ progressBarStatus.appendChild(document.createTextNode(""));
+
+ progressMeter.appendChild(progressBar);
+ progressMeter.appendChild(progressBarStatus);
+ cell.appendChild(progressMeter);
+
+ return row;
+}
+
+gAnimationMSecs = 1000/30;
+
+function SetCylonTimer(cylonID, cylonEyeID)
+{
+ setTimeout("AnimateCylonStatusBar(\"" + cylonID +
+ "\", \"" + cylonEyeID + "\");", gAnimationMSecs);
+}
+
+function AnimateCylonStatusBar(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID);
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ return;
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (!eye)
+ return;
+
+ var dir = eye.getAttribute("direction");
+ var wid = parseInt(eye.style.width);
+ var cywid = parseInt(cylon.style.width);
+ var left = parseInt(eye.style.left);
+
+ var dx = 10;
+
+ if (!dir || dir >= 0)
+ {
+ left += dx;
+
+ if (left + wid > cywid)
+ {
+ left = cywid - wid;
+ eye.setAttribute("direction", "-1");
+ }
+ }
+ else
+ {
+ left -= dx;
+
+ if (left < 0)
+ {
+ left = 0;
+ eye.setAttribute("direction", "1");
+ }
+ }
+
+ eye.style.left = left + "px";
+
+ SetCylonTimer(cylonID, cylonEyeID);
+}
+
+function StartCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ {
+ cylon.setAttribute("cylonactive", "true");
+
+ var eye = document.getElementById(cylonEyeID);
+ if (eye)
+ {
+ eye.style.left = "0px";
+ eye.style.visibility = "visible";
+ }
+
+ SetCylonTimer(cylonID, cylonEyeID);
+ }
+}
+
+function StopCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (cylon)
+ cylon.removeAttribute("cylonactive");
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (eye)
+ eye.style.visibility = "hidden";
+}
+
+function GetProgressMeterValue(progMeterID)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return -1;
+
+ return parseInt(progMeter.getAttribute("value"));
+}
+
+function SetProgressMeterValue(progMeterID, value)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter || value < 0)
+ return;
+
+ if (value > 100)
+ value = 100;
+
+ var progBar = progMeter.firstChild;
+
+ if (value == 0)
+ {
+ progBar.style.width = "0px";
+ progBar.style.visibility = "hidden";
+ progMeter.setAttribute("value", 0);
+ return;
+ }
+
+ progBar.style.visibility = "visible";
+
+ var newWidth = parseInt(progMeter.style.width) * value / 100 - 2;
+
+ progBar.style.width = newWidth + "px";
+ progMeter.setAttribute("value", value);
+}
+
+function SetProgressMeterStatus(progMeterID, statusMsg)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return;
+
+ var progBar = progMeter.firstChild;
+
+ // If it exists, the meter status should be
+ // div that is the next sibling of the progressMeter.
+
+ var meterStatus = progBar.nextSibling;
+
+ // Just replace the data in the text node, it's much faster,
+ // and reduces flashing!
+
+ meterStatus.firstChild.replaceData(0, meterStatus.firstChild.length, statusMsg);
+}
+
+function ClearProgressBar(progMeterID)
+{
+ SetProgressMeterValue(progMeterID, 0);
+ SetProgressMeterStatus(progMeterID, "");
+}
+
+function KeyToProgressBarID(keyType, keyID)
+{
+ return "PM" + keyType + "-" + keyID;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ASC native code.
+//
+// ASC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.EnrollCOOLKey(keyType, keyID, enrollmentType, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass "houseKey" as the enrollmentType, and null values for both
+// screenName and pin. For a NetKey, use "netKey" as the enrollmentType,
+// and pass a valid screenName and pin.
+//
+// netkey.ChallengeCOOLKey(keyType, keyID, data)
+//
+// - Signs some data with the specified key, and returns the results
+// in an AcviteX Variant SafeArray. Before accessing any data in
+// this array, you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray(). The elements in the
+// array are as follows:
+//
+// array[0] --> Length of the signed challenge data in binary form.
+// array[1] --> The signed challenge data as hex.
+// array[0] --> Length of the nonce data in binary form.
+// array[0] --> The nonce data as hex.
+//
+// netkey.BlinkCOOLKey(keyType, keyID, rate, duration)
+//
+// - Make a specific key blink at a given rate for a given duration.
+// rate and duration are specified in milliseconds.
+//
+////////////////////////////////////////////////////////////////
+
+function GetScreenNameValue()
+{
+ var sname = document.getElementById("snametf").value;
+
+ if (! sname)
+ {
+ alert("You must provide a valid screen name!");
+ return null;
+ }
+
+ return sname;
+}
+
+function GetPINValue()
+{
+ var pinVal = document.getElementById("pintf").value;
+ var rpinVal = document.getElementById("reenterpintf").value;
+
+ if (! pinVal)
+ {
+ alert("You must provide a valid PIN!");
+ return null;
+ }
+
+ if ( pinVal != rpinVal)
+ {
+ alert("The PIN values you entered don't match!");
+ return null;
+ }
+
+ return pinVal;
+}
+
+function GetScreenNamePwd()
+{
+
+ var pwd = document.getElementById("snamepwd").value;
+
+ if(!pwd)
+ {
+ alert("You must provide a valid User Password!");
+ return null;
+ }
+ return pwd;
+}
+
+function GetTokenCode()
+{
+
+ return null;
+}
+function DoEnrollCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ {
+ alert("Please select a key.");
+ return;
+ }
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = GetPINValue();
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = null; //GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = null; // GetScreenNamePwd();
+
+
+ tokencode = GetTokenCode();
+
+ SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+ }
+ else
+ SetStatusMessage("Enrolling DeviceKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!EnrollCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+
+function DoResetSelectedCOOLKeyPIN()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate())
+ return;
+
+ //alert("In DoResetSelectedCOOLKeyPIN!");
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var screenname = null;
+ var pin = GetPINValue() ;
+ var screennamepwd = null;
+
+ if (GetCOOLKeyIsEnrolled(keyType, keyID))
+ {
+
+ SetStatusMessage("Resetting PIN for \"" + keyID + "\"...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+ }
+ else
+ {
+
+ alert("Your key must be enrolled before attempting a Pin Reset.");
+ }
+}
+
+function DoFormatCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+
+ if(!Validate())
+ return;
+
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+function DoCancelOperation()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ SetStatusMessage("Cancel operation for \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ CancelCOOLKeyOperation(keyType, keyID);
+
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+}
+
+function DoChallengeSelectedKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Generating Challenge ...");
+
+ var challengeArray = ChallengeCOOLKey(keyType, keyID, document.forms[0].challengedata.value);
+
+ if (challengeArray.length != 4)
+ {
+ alert("Challenge for key \"" + KeyToUIString(keyType, keyID) + "\" failed!");
+ SetStatusMessage("");
+ return;
+ }
+
+ alert("ChallengeCOOLKey(\""+ KeyToUIString(keyType, keyID) + "\") returned:\n\n" +
+ "challenge[0]: " + challengeArray[0] + "\n" +
+ "challenge[1]: " + challengeArray[1] + "\n" +
+ "challenge[2]: " + challengeArray[2] + "\n" +
+ "challenge[3]: " + challengeArray[3] + "\n");
+
+ SetStatusMessage("");
+}
+
+function DoBlinkCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Blinking \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+}
+
+function OnCOOLKeyBlinkComplete(keyType,keyID)
+{
+ //StopCylonAnimation("cylon1", "eye1");
+ //SetStatusMessage(" ");
+}
+
+function DoHelp()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ var policy = GetCOOLKeyPolicy(keyType, keyID);
+ var type = PolicyToKeyType(policy);
+ alert("Policy: " + policy + "\n" + "Type: " + type);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions called directly from ASC native code.
+//
+////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(keyType, keyID);
+}
+
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("BindingTable");
+
+ if (row && table)
+ {
+ RemoveRow(table,row);
+
+ if (row == gCurrentSelectedRow)
+ gCurrentSelectedRow = null;
+ }
+
+ UpdateButtonStates();
+}
+
+var gKnownPolicies = [
+
+ // OID Value, precedence, name value
+
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4", 4, "NETKEY" ], // Platinum - MyDoctor
+
+ // XXX: Remove the Old OIDs below, after the RA starts generating
+ // certificates with the OIDs listed above!
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.4", 4, "NETKEY" ] // Platinum - MyDoctor
+];
+
+function PolicyToKeyType(policy)
+{
+ return "ENROLLED";
+}
+
+function OldPolicyToKeyType(policy)
+{
+ var i, j;
+
+ var knownPoliciesIndex = -1;
+
+
+ var policies;
+
+
+ if (policy.indexOf(",")== -1)
+ {
+ policies = new Array(1);
+ policies[0] = policy;
+ }
+ else
+ {
+ policies = policy.split(",");
+ }
+
+ for (j = 0; j < policies.length; j++)
+ {
+ for (i = 0; i < gKnownPolicies.length; i++)
+ {
+ if (gKnownPolicies[i][0] == policies[j])
+ {
+ if (knownPoliciesIndex < gKnownPolicies[i][1])
+ knownPoliciesIndex = i;
+ }
+ }
+ }
+
+ if (knownPoliciesIndex == -1)
+ return "INITIALIZED";
+
+ return gKnownPolicies[knownPoliciesIndex][2];
+}
+
+function BoolToYesNoStr(b)
+{
+ if (b)
+ return "YES";
+ return "NO";
+}
+
+function OnCOOLKeyEnrollmentComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("Enrollment for \"" + KeyToUIString(keyType, keyID) + "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyPINResetComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("PIN Reset was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyFormatComplete(keyType, keyID)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("Format of \"" + KeyToUIString(keyType, keyID)+ "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStateError(keyType, keyID, keyState, errorCode)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+
+ }
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+
+ var typeStr = "Error(" + errorCode + ")";
+
+ var messageStr = " \n\n Server Response: " + MyGetErrorMessage(errorCode) ;
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (keyState == 1004)
+ typeStr = "Enrollment of key (" + keyIDStr + ") failed. " + typeStr + messageStr ;
+ else if (keyState == 1016)
+ typeStr = "Formatting of key (" + keyIDStr + ") failed. " + typeStr + messageStr;
+ else if (keyState == 1010)
+ typeStr = "PIN Reset for key (" + keyIDStr + ") failed. " + typeStr + messageStr;
+ else if (keyState == 1020)
+ typeStr = "Operation for key (" + keyIDStr + ") canceled.";
+
+ alert(typeStr);
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStatusUpdate(progMeterID, statusUpdate)
+{
+ SetProgressMeterValue(progMeterID, statusUpdate);
+ SetProgressMeterStatus(progMeterID, statusUpdate + "%");
+}
+
+function Validate()
+{
+
+ var type = gKeyEnrollmentType;
+ var pin = null;
+
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+
+ pin = GetPINValue();
+
+ if (! pin)
+ return 0;
+
+ }
+
+ return 1;
+}
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data,strData)
+{
+ // alert("KeyID: " + keyID + "\n" +
+ // "KeyState: " + keyState + "\n" +
+ // "Data: " + data);
+ //alert("State Change ="+keyState);
+
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ // OnCOOLKeyEnrollmentStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ OnCOOLKeyEnrollmentComplete(keyType, keyID);
+ break;
+ case 1004: // EnrollmentError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1008: // PINResetStart
+ // OnCOOLKeyPINResetStart(keyType, keyID);
+ break;
+ case 1009: // PINResetComplete
+ OnCOOLKeyPINResetComplete(keyType, keyID);
+ break;
+ case 1010: // PINResetError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1014: // FormatStart
+ // OnCOOLKeyFormatStart(keyType, keyID);
+ break;
+ case 1015: // FormatComplete
+ OnCOOLKeyFormatComplete(keyType, keyID);
+ break;
+ case 1016: // FormatError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1017: // BlinkStatus Update?
+ //OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1018:
+ OnCOOLKeyBlinkComplete(keyType, keyID);
+ break;
+ case 1020: // OperationCancelled
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1021: // OperationStatusUpdate
+ OnCOOLKeyStatusUpdate(KeyToProgressBarID(keyType, keyID), data);
+ break;
+
+ case 1022: //Need Auth
+
+
+ gCurKeyID = keyID;
+ gCurKeyType = keyType;
+
+ GetAuthDataFromPopUp(keyType,keyID,strData);
+
+ break;
+
+ }
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+</script>
+
+</head>
+<body onload="InitializeBindingTable();" onunload=cleanup()>
+
+<table width="100%">
+ <tr>
+ <td>
+<img src="../images/logo.gif"> </td>
+ <td>
+ <p class="headerText"><a href="esc.cgi?screenname=">Enterprise Security Client</a></p>
+ </td>
+ <tr>
+</table>
+
+ <br>
+ <table id="BindingTable" width="100%"><tbody>
+ <tr id="HeaderRow">
+ <th><p class="titleText">Key ID</p></th>
+ <th><p class="titleText">Key Status</p></th>
+<!-- <th><p class="titleText">Requires Auth</p></th>
+ <th><p class="titleText">Did Auth</p></th>
+-->
+ <th width="100"><p class="titleText">Progress</p></th>
+ </tr>
+ </tbody></table>
+ <form action="esc.cgi">
+ <input type="hidden" id="action" name="action" value="bind">
+ <input type="hidden" id="screenname" name="screenname" value="">
+ <input type="hidden" id="challengedata" name="challengedata" value="QVNDIHJvY2tzIHRoZSBwYXJ0eSE=">
+ <input type="hidden" id="signedchallenge" name="signedchallenge" value="">
+ <input type="hidden" id="signedchallengelength" name="signedchallengelength" value="">
+ <input type="hidden" id="nonce" name="nonce" value="">
+ <input type="hidden" id="noncelength" name="noncelength" value="">
+ <input type="hidden" id="keytype" name="keytype" value="">
+ <input type="hidden" id="keyid" name="keyid" value="">
+ <input type="hidden" id="keylabel" name="keylabel" value="">
+ <table width=100%>
+ <tr>
+ <td class="bodyText">
+ Select enrollment type: <input checked type="radio" id="keytype" name="keytype" value="userKey" onClick="SetEnrollmentType('userKey');">UserKey
+ </td>
+ </tr>
+ </table>
+ <table>
+ <tr>
+ <td><p class="bodyText">Token PIN:</p></td>
+ <td><input type="password" id="pintf" id="pintf" name="pintf" value=""></td>
+ <td><p class="bodyText">Re-Enter PIN:</p></td>
+ <td><input type="password" id="reenterpintf" id="reenterpintf" name="reenterpintf" value=""></td>
+ </tr>
+ </table>
+ <br>
+ <table width="100%">
+ <tr>
+ <td valign="center" align="left">
+ <input type="button" id="resetpinbtn" name="resetpinbtn" value="Reset PIN" onClick="DoResetSelectedCOOLKeyPIN();">
+ <!-- <input type="button" id="formatbtn" name="formatbtn" value="Format" onClick="DoFormatCOOLKey();"> -->
+ <!-- <input type="button" id="challengebtn" name="challengebtn" value="Challenge" onClick="DoChallengeSelectedKey();"> -->
+ <input type="button" id="blinkbtn" name="blinkbtn" value="Blink" onClick="DoBlinkCOOLKey();">
+ <input type="button" id="canclebtn" name="canclebtn" value="Cancel" onClick="DoCancelOperation();">
+
+ <!-- <input type="button" id="helpbtn" name="helpbtn" value="Help" onClick="DoHelp();"> -->
+ </td>
+ </tr>
+ </table>
+ <table width="100%">
+ <tr>
+ <!-- <td valign="center" align="right">
+ <h5><a href="esc.cgi?">Enterprise Security Admin Page</a></h5>
+ </td> -->
+ </tr>
+ </table>
+ </form>
+ <table width="100%">
+ <tr>
+ <td valign="center" align="left" style="width: 200px;">
+ <div id="cylon1" class="cylon" style="width: 200px; height: 10px;">
+ <div id="eye1" class="cylonEye" style="top: 0px; left: 0px; width: 28px; height: 8px; visibility: hidden;"></div>
+ </div>
+ </td>
+ <td valign="center" align="left" id="statusMsg"></td>
+ </tr>
+ </table>
+</body></html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/EnrollPopup.html b/pki/linux/tps-ui/shared/docroot/esc/EnrollPopup.html
new file mode 100755
index 000000000..46cd6d450
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/EnrollPopup.html
@@ -0,0 +1,1718 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<html>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+<head>
+<link rel=stylesheet href="/style.css" type="text/css">
+
+<script language="JavaScript">
+
+//
+// initialize netkey globals
+var netkey;
+var isMSHTML;
+
+
+var keyUITable = new Array();
+var keyTypeTable = new Array();
+var curChildWindow = null;
+
+function getUIForKey(aKeyID)
+{
+ return keyUITable[aKeyID];
+
+}
+
+function getTypeForKey(aKeyID)
+{
+ return keyTypeTable[aKeyID];
+}
+
+//
+// Determine if we are running MSHTML or GECKO
+//
+if (navigator.userAgent.indexOf("MSIE") != -1) {
+ isMSHTML = true;
+} else {
+ isMSHTML = false;
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData,strData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ alert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+if (!isMSHTML) {
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+ gNotify = new jsNotify;
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+} else {
+ // MSHTML only initialization
+ netkey = external;
+}
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+ if (!isMSHTML) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+ }
+}
+
+var gScreenName = "";
+var gKeyEnrollmentType = "userKey";
+
+var gCurrentSelectedRow = null;
+
+
+var gCurKeyType = null;
+var gCurKeyID = null;
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+
+// List of Error Messages to be printed out
+
+var Status_Messages = new Array(
+
+"Operation Completed Successfully.",
+ "Server Error.",
+ "Problem communicating with the token.",
+ "Problem communicating with the token.",
+ "Problem resetting token's pin.",
+ "Internal Server Error.",
+ "Internal Server Error",
+ "Token Enrollment Error.",
+ "Problem communicating with the token.",
+ "Internal Server Error",
+ "Error communicating with the Certificate Authority, try again later.",
+ "Internal Server Error.",
+ "Error resetting the token's pin.",
+ "Internal Server Error.",
+ "Authentication Failure, Try Again.",
+ "Internal Server Error",
+ "Token is disabled, contact technical support.",
+ "Problem communicating with the token.",
+ "Internal Server Error.",
+ "Cannot upgrade token software.",
+ "Internal Server Error.",
+ "Problem communicating with the token.",
+ "Invalid token type.",
+ "Invalid token type",
+ "Cannot publish.",
+ "Cannot communicate with token database, try again later.",
+ "Token is disabled, contact techincal support.",
+ "Cannot reset pin value for the token, contact technical support.",
+ "Connection to server lost.",
+ "Cannot create entry for token in database, contact technical support.",
+ "No such token state, contact technical support.",
+ "Invalid lost token reason, contact technical support.",
+ "Token unusable due to compromise,contact technical support.",
+ "No such inactive token, contact technical support.",
+ "Cannot process more than one active token.",
+ "Internal Server Error,contact technical support.",
+ "Key Recovery has been processed.",
+ "Key Recovery failed, contact technical support.",
+ "Cannot operate on token reported lost, contact technical support.",
+ "Key archival error, contact technical support.",
+ "Problem connecting to the TKS, contact technical support.",
+ "Failed to update token database, contact technical support.",
+ "Internal certificate revocation error,contact technical support.",
+ "User does not own this token, contact technical support."
+);
+
+function GetAuthDataFromPopUp(aKeyType,aKeyID,aUiData)
+{
+
+ keyUITable[aKeyID] = aUiData;
+ keyTypeTable[aKeyID] = aKeyType;
+
+ //alert("GetAuthDataFromPopUp data " + aUiData);
+ var child = window.open("/GenericAuth.html",aKeyID,"height=400,width=400");
+
+ //alert("Attempted to create child window " + child);
+
+ curChildWindow = child;
+
+}
+
+function COOLKeySetDataValue(aKeyType,aKeyID,name,value)
+{
+ //alert("In COOLKeySetDataValue aKeyType " + aKeyType + " aKeyID " + aKeyID + " name " + name + " value " + value);
+ if(netkey)
+ {
+ try {
+ if(!isMSHTML)
+ {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+
+ netkey.SetCoolKeyDataValue(aKeyType,aKeyID,name,value);
+
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+ }
+
+}
+
+function COOLKeySetTokenPin(pin)
+{
+ if(!isMSHTML)
+ {
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"TokenPin",pin);
+
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+ }
+ }
+}
+
+function COOLKeySetUidPassword(uid,pwd)
+{
+
+ if(!isMSHTML)
+ {
+ if(netkey)
+ {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"UserId",uid);
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"Password",pwd);
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+
+ }
+
+ }
+
+}
+
+
+function MyGetErrorMessage(status_code)
+{
+
+ var result = "Internal Server Error";
+
+ if(status_code < 0 && status_code >= Status_Messages.length)
+ {
+ return result;
+
+ }
+
+ return Status_Messages[status_code];
+
+}
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function ReportException(msg, e)
+{
+ alert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetCOOLKeyStatus(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyStatus(keyType, keyID);
+ } catch (e) {
+ ReportException("netkey.GetCOOLKeyStatus() failed!", e);
+ return 0;
+ }
+}
+
+function GetCOOLKeyPolicy(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyPolicy(keyType, keyID);
+ } catch (e) {
+ // ReportException("netkey.GetCOOLKeyPolicy() failed!", e);
+ return "";
+ }
+}
+
+function GetCOOLKeyRequiresAuth(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyRequiresAuthentication(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyRequiresAuthentication() failed!", e);
+ return false;
+ }
+}
+
+function GetCOOLKeyIsAuthed(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyIsAuthenticated(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsAuthenticated() failed!", e);
+ return false;
+ }
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ } else {
+ keyArr = ConvertVariantArrayToJScriptArray(netkey.GetAvailableCoolKeys());
+
+ var i;
+ for (i=0; i < keyArr.length; i++)
+ keyArr[i] = ConvertVariantArrayToJScriptArray(keyArr[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableCoolKeys() failed!", e);
+ return [];
+ }
+}
+
+function ChallengeCOOLKey(keyType, keyID, data)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return ConvertVariantArrayToJScriptArray(netkey.ChallengeCoolKey(keyType, keyID, data));
+ } catch(e) {
+ ReportException("netkey.ChallengeCoolKey() failed!", e);
+ return [];
+ }
+}
+
+function EnrollCOOLKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.EnrollCoolKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.EnrollCoolKey() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+function GetCOOLKeyIsEnrolled(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyIsEnrolled(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsEnrolled() failed!", e);
+ return false;
+ }
+}
+
+function ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.ResetCoolKeyPIN(keyType, keyID, screenname, pin,screennamepwd);
+ } catch(e) {
+ ReportException("netkey.ResetCoolKeyPIN() failed! Make sure token is properly Enrolled.", e);
+ return false;
+ }
+ return true;
+}
+function FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.FormatCoolKey() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function CancelCOOLKeyOperation(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.CancelCoolKeyOperation(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.CancelCoolKeyOperation() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function BlinkCOOLKey(keyType, keyID, rate, duration)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.BlinkCoolKey(keyType, keyID, rate, duration);
+ } catch(e) {
+ ReportException("netkey.BlinkCoolKey() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function RequestServiceTicket(screenName, serviceName)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.RequestServiceTicket(screenName, serviceName);
+ } catch(e) {
+ ReportException("netkey..RequestServiceTicket() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ if (isMSHTML) {
+ row.removeNode(row);
+ } else {
+ table.deleteRow(row.rowIndex);
+ }
+}
+
+function GetCell(row, index)
+{
+ var cell;
+
+ if (isMSHTML) {
+ cell = row.cells(index);
+ } else {
+ cell = row.cells[index];
+ }
+ return cell;
+}
+
+function GetNode(parent, index)
+{
+ var node;
+ if (isMSHTML) {
+ node = parent.childNodes(index);
+ } else {
+ node = parent.childNodes[index];
+ }
+ return node;
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ if (isMSHTML) {
+ row = table.insertRow();
+ } else {
+ row = table.insertRow(table.rows.length);
+ }
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ if (isMSHTML) {
+ cell = row.insertCell();
+ } else {
+ cell = row.insertCell(row.cells.length);
+ }
+ return cell;
+}
+
+function RemoveAllChildNodes(parent)
+{
+ var numChildren = parent.childNodes.length;
+ var i;
+
+ i = numChildren;
+ while (numChildren)
+ {
+ parent.removeChild(GetNode(parent,0));
+ numChildren--;
+ }
+
+}
+
+
+function UpdateInfoForKeyID(keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return;
+
+ var cell = GetCell(row,1)
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+// cell = GetCell(row,2);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ // cell = GetCell(row,3);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(isAuthed));
+}
+
+function GetStatusForKeyID(keyType, keyID)
+{
+ var keyStatus = "BLANK";
+
+ var status;
+
+ try {
+ status = GetCOOLKeyStatus(keyType, keyID);
+ } catch(e) {
+ status = 0;
+ }
+
+ switch (status) {
+ case 0: // Unavailable
+ keyStatus = "UNAVAILABLE";
+ break;
+ case 1: // AppletNotFound
+ keyStatus = "NO APPLET";
+ break;
+ case 2: // Uninitialized
+ keyStatus = "UNINITIALIZED";
+ break;
+ case 3: // Unknown
+ keyStatus = "UNKNOWN";
+ break;
+ case 4: // Available
+ case 6: // UnblockInProgress
+ case 7: // PINResetInProgress
+ case 8: // RenewInProgress
+ keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ break;
+ case 5: // EnrollmentInProgress
+ keyStatus = "BUSY";
+ break;
+ break;
+ case 9: // FormatInProgress
+ keyStatus = "BUSY";
+ break;
+ }
+
+ return keyStatus;
+}
+
+function GetKeyStatusForKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return "UNKNOWN";
+
+ var cell = GetCell(row,1);
+ return GetNode(cell,0).data;
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ {
+ var table = document.getElementById("BindingTable");
+ if (table)
+ {
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ row = CreateTableRow(table, keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ }
+
+ if (!row)
+ return null;
+ }
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ {
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(arr[i][0], arr[i][1]);
+ }
+}
+
+function InitializeBindingTable()
+{
+ UpdateBindingTableAvailability();
+ UpdateButtonStates();
+ // document.getElementById("snametf").value = gScreenName;
+}
+
+function KeyIsPresent(keyType, keyID)
+{
+ row = document.all.item(keyType, keyID);
+
+ if (!row)
+ return false;
+
+ return true;
+}
+
+function SetStatusMessage(str)
+{
+ var cell = document.getElementById("statusMsg");
+
+ if (!cell)
+ return;
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(str));
+}
+
+function UpdateButtonStates()
+{
+ if (gKeyEnrollmentType == "deviceKey")
+ {
+ // document.getElementById("snametf").disabled = true;
+ // document.getElementById("pintf").disabled = true;
+ // document.getElementById("reenterpintf").disabled = true;
+ // document.getElementById("snamepwd").disabled = true;
+ }
+ else
+ {
+ // document.getElementById("snametf").disabled = false;
+ // document.getElementById("pintf").disabled = false;
+ // document.getElementById("reenterpintf").disabled = false;
+ // document.getElementById("snamepwd").disabled = false;
+ }
+
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ var keyStatus = GetKeyStatusForKeyID(keyType, keyID);
+
+ var validKey = (keyStatus == "NETKEY" || keyStatus == "HOUSEKEY");
+ // document.getElementById("challengebtn").disabled = !validKey;
+ // document.getElementById("blinkbtn").disabled = false;
+ document.getElementById("enrollbtn").disabled = false;
+ //document.getElementById("formatbtn").disabled = false;
+// document.getElementById("resetpinbtn").disabled = !((keyStatus == "NETKEY") && (gKeyEnrollmentType == "userKey"));
+//document.getElementById("resetpinbtn").disabled = !((gKeyEnrollmentType == "userKey"));
+ }
+ else
+ {
+ document.getElementById("enrollbtn").disabled = true;
+ //document.getElementById("resetpinbtn").disabled = true;
+ //document.getElementById("formatbtn").disabled = true;
+ // document.getElementById("challengebtn").disabled = true;
+ //document.getElementById("blinkbtn").disabled = true;
+ }
+
+ refresh();
+}
+
+function SetEnrollmentType(type)
+{
+ gKeyEnrollmentType = type;
+ UpdateButtonStates();
+}
+
+function FindRow(node)
+{
+ while (node && node.tagName != "TR")
+ {
+ node = node.parentNode;
+ }
+
+ return node;
+}
+
+function SelectRow(row)
+{
+ if (!row || gCurrentSelectedRow == row)
+ return;
+
+ if (gCurrentSelectedRow)
+ gCurrentSelectedRow.removeAttribute("style");
+
+ gCurrentSelectedRow = row;
+ gCurrentSelectedRow.style.backgroundColor="rgb(200,200,200)";
+ UpdateButtonStates();
+}
+
+function SelectRowByKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ SelectRow(row);
+}
+
+function DoSelectRow(event)
+{
+ var row;
+
+ if (isMSHTML) {
+ row = FindRow(window.event.srcElement);
+ } else {
+ row = FindRow(event.parentNode);
+ }
+ SelectRow(row);
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+
+
+function CreateTableRow(table, keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+
+ if (isMSHTML) {
+ row.onclick = DoSelectRow;
+ }
+
+ // Create the key ID cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(KeyToUIString(keyType, keyID)));
+
+ cell.setAttribute("onClick", "DoSelectRow(this);");
+
+ // Create the keyStatus cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+ // Create the requires auth cell.
+ // cell = InsertCell(row);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ // Create the is auth'ed cell.
+ // cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(isAuthed));
+
+ // Create the status bar cell
+ cell = InsertCell(row);
+
+ var progressMeter = document.createElement("div");
+ progressMeter.setAttribute("id", KeyToProgressBarID(keyType, keyID));
+ progressMeter.className = "ProgressMeter";
+ progressMeter.style.width = "100px";
+ progressMeter.style.height = "1.5em";
+ progressMeter.setAttribute("value", 0);
+
+ var progressBar = document.createElement("div");
+ progressBar.className = "ProgressBar";
+ progressBar.style.width = "0px";
+ progressBar.style.height = "100%";
+ progressBar.style.visibility = "hidden";
+
+ var progressBarStatus = document.createElement("div");
+ progressBarStatus.className = "ProgressBarStatus";
+ progressBarStatus.appendChild(document.createTextNode(""));
+
+ progressMeter.appendChild(progressBar);
+ progressMeter.appendChild(progressBarStatus);
+ cell.appendChild(progressMeter);
+
+ return row;
+}
+
+gAnimationMSecs = 1000/30;
+
+function SetCylonTimer(cylonID, cylonEyeID)
+{
+ setTimeout("AnimateCylonStatusBar(\"" + cylonID +
+ "\", \"" + cylonEyeID + "\");", gAnimationMSecs);
+}
+
+function AnimateCylonStatusBar(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID);
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ return;
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (!eye)
+ return;
+
+ var dir = eye.getAttribute("direction");
+ var wid = parseInt(eye.style.width);
+ var cywid = parseInt(cylon.style.width);
+ var left = parseInt(eye.style.left);
+
+ var dx = 10;
+
+ if (!dir || dir >= 0)
+ {
+ left += dx;
+
+ if (left + wid > cywid)
+ {
+ left = cywid - wid;
+ eye.setAttribute("direction", "-1");
+ }
+ }
+ else
+ {
+ left -= dx;
+
+ if (left < 0)
+ {
+ left = 0;
+ eye.setAttribute("direction", "1");
+ }
+ }
+
+ eye.style.left = left + "px";
+
+ SetCylonTimer(cylonID, cylonEyeID);
+}
+
+function StartCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ {
+ cylon.setAttribute("cylonactive", "true");
+
+ var eye = document.getElementById(cylonEyeID);
+ if (eye)
+ {
+ eye.style.left = "0px";
+ eye.style.visibility = "visible";
+ }
+
+ SetCylonTimer(cylonID, cylonEyeID);
+ }
+}
+
+function StopCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (cylon)
+ cylon.removeAttribute("cylonactive");
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (eye)
+ eye.style.visibility = "hidden";
+}
+
+function GetProgressMeterValue(progMeterID)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return -1;
+
+ return parseInt(progMeter.getAttribute("value"));
+}
+
+function SetProgressMeterValue(progMeterID, value)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter || value < 0)
+ return;
+
+ if (value > 100)
+ value = 100;
+
+ var progBar = progMeter.firstChild;
+
+ if (value == 0)
+ {
+ progBar.style.width = "0px";
+ progBar.style.visibility = "hidden";
+ progMeter.setAttribute("value", 0);
+ return;
+ }
+
+ progBar.style.visibility = "visible";
+
+ var newWidth = parseInt(progMeter.style.width) * value / 100 - 2;
+
+ progBar.style.width = newWidth + "px";
+ progMeter.setAttribute("value", value);
+}
+
+function SetProgressMeterStatus(progMeterID, statusMsg)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return;
+
+ var progBar = progMeter.firstChild;
+
+ // If it exists, the meter status should be
+ // div that is the next sibling of the progressMeter.
+
+ var meterStatus = progBar.nextSibling;
+
+ // Just replace the data in the text node, it's much faster,
+ // and reduces flashing!
+
+ meterStatus.firstChild.replaceData(0, meterStatus.firstChild.length, statusMsg);
+}
+
+function ClearProgressBar(progMeterID)
+{
+ SetProgressMeterValue(progMeterID, 0);
+ SetProgressMeterStatus(progMeterID, "");
+}
+
+function KeyToProgressBarID(keyType, keyID)
+{
+ return "PM" + keyType + "-" + keyID;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ASC native code.
+//
+// ASC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.EnrollCOOLKey(keyType, keyID, enrollmentType, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass "houseKey" as the enrollmentType, and null values for both
+// screenName and pin. For a NetKey, use "netKey" as the enrollmentType,
+// and pass a valid screenName and pin.
+//
+// netkey.ChallengeCOOLKey(keyType, keyID, data)
+//
+// - Signs some data with the specified key, and returns the results
+// in an AcviteX Variant SafeArray. Before accessing any data in
+// this array, you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray(). The elements in the
+// array are as follows:
+//
+// array[0] --> Length of the signed challenge data in binary form.
+// array[1] --> The signed challenge data as hex.
+// array[0] --> Length of the nonce data in binary form.
+// array[0] --> The nonce data as hex.
+//
+// netkey.BlinkCOOLKey(keyType, keyID, rate, duration)
+//
+// - Make a specific key blink at a given rate for a given duration.
+// rate and duration are specified in milliseconds.
+//
+////////////////////////////////////////////////////////////////
+
+function GetScreenNameValue()
+{
+ var sname = document.getElementById("snametf").value;
+
+ if (! sname)
+ {
+ alert("You must provide a valid screen name!");
+ return null;
+ }
+
+ return sname;
+}
+
+function GetPINValue()
+{
+ var pinVal = document.getElementById("pintf").value;
+ var rpinVal = document.getElementById("reenterpintf").value;
+
+ if (! pinVal)
+ {
+ alert("You must provide a valid Token PIN!");
+ return null;
+ }
+
+ if ( pinVal != rpinVal)
+ {
+ alert("The PIN values you entered don't match!");
+ return null;
+ }
+
+ return pinVal;
+}
+
+function GetScreenNamePwd()
+{
+
+ var pwd = document.getElementById("snamepwd").value;
+
+ if(!pwd)
+ {
+ alert("You must provide a valid User Password!");
+ return null;
+ }
+ return pwd;
+}
+
+function GetTokenCode()
+{
+
+ return null;
+}
+function DoEnrollCOOLKey()
+{
+
+ if (!gCurrentSelectedRow)
+ {
+ alert("Please select a key.");
+ return;
+ }
+
+ if(!Validate())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = null; //GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = null; // GetScreenNamePwd();
+
+
+ tokencode = GetTokenCode();
+
+ SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+ }
+ else
+ SetStatusMessage("Enrolling DeviceKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!EnrollCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+
+function DoResetSelectedCOOLKeyPIN()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate())
+ return;
+
+ //alert("In DoResetSelectedCOOLKeyPIN!");
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var screenname = null;
+ var pin = null;
+ var screennamepwd = null;
+
+ if (GetCOOLKeyIsEnrolled(keyType, keyID))
+ {
+
+ SetStatusMessage("Resetting PIN for \"" + keyID + "\"...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+ }
+}
+
+function DoFormatCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+
+ if(!Validate())
+ return;
+
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+function DoCancelOperation()
+{
+
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ SetStatusMessage("Cancel operation for \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ CancelCOOLKeyOperation(keyType, keyID);
+
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+}
+
+function DoChallengeSelectedKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Generating Challenge ...");
+
+ var challengeArray = ChallengeCOOLKey(keyType, keyID, document.forms[0].challengedata.value);
+
+ if (challengeArray.length != 4)
+ {
+ alert("Challenge for key \"" + KeyToUIString(keyType, keyID) + "\" failed!");
+ SetStatusMessage("");
+ return;
+ }
+
+ alert("ChallengeCOOLKey(\""+ KeyToUIString(keyType, keyID) + "\") returned:\n\n" +
+ "challenge[0]: " + challengeArray[0] + "\n" +
+ "challenge[1]: " + challengeArray[1] + "\n" +
+ "challenge[2]: " + challengeArray[2] + "\n" +
+ "challenge[3]: " + challengeArray[3] + "\n");
+
+ SetStatusMessage("");
+}
+
+function DoBlinkCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Blinking \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+}
+
+function OnCOOLKeyBlinkComplete(keyType,keyID)
+{
+ //StopCylonAnimation("cylon1", "eye1");
+ //SetStatusMessage(" ");
+}
+
+function DoHelp()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ var policy = GetCOOLKeyPolicy(keyType, keyID);
+ var type = PolicyToKeyType(policy);
+ alert("Policy: " + policy + "\n" + "Type: " + type);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions called directly from ASC native code.
+//
+////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(keyType, keyID);
+}
+
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("BindingTable");
+
+ if (row && table)
+ {
+ RemoveRow(table,row);
+
+ if (row == gCurrentSelectedRow)
+ gCurrentSelectedRow = null;
+ }
+
+ UpdateButtonStates();
+}
+
+var gKnownPolicies = [
+
+ // OID Value, precedence, name value
+
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4", 4, "NETKEY" ], // Platinum - MyDoctor
+
+ // XXX: Remove the Old OIDs below, after the RA starts generating
+ // certificates with the OIDs listed above!
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.4", 4, "NETKEY" ] // Platinum - MyDoctor
+];
+
+function PolicyToKeyType(policy)
+{
+ return "ENROLLED";
+}
+
+function OldPolicyToKeyType(policy)
+{
+ var i, j;
+
+ var knownPoliciesIndex = -1;
+
+
+ var policies;
+
+
+ if (policy.indexOf(",")== -1)
+ {
+ policies = new Array(1);
+ policies[0] = policy;
+ }
+ else
+ {
+ policies = policy.split(",");
+ }
+
+ for (j = 0; j < policies.length; j++)
+ {
+ for (i = 0; i < gKnownPolicies.length; i++)
+ {
+ if (gKnownPolicies[i][0] == policies[j])
+ {
+ if (knownPoliciesIndex < gKnownPolicies[i][1])
+ knownPoliciesIndex = i;
+ }
+ }
+ }
+
+ if (knownPoliciesIndex == -1)
+ return "INITIALIZED";
+
+ return gKnownPolicies[knownPoliciesIndex][2];
+}
+
+function BoolToYesNoStr(b)
+{
+ if (b)
+ return "YES";
+ return "NO";
+}
+
+function OnCOOLKeyEnrollmentComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("Enrollment for \"" + KeyToUIString(keyType, keyID) + "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyPINResetComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("PIN Reset was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyFormatComplete(keyType, keyID)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("Format of \"" + KeyToUIString(keyType, keyID)+ "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStateError(keyType, keyID, keyState, errorCode)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+
+ }
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+
+ var typeStr = "Error(" + errorCode + ")";
+
+ var messageStr = " \n\n Server Response: " + MyGetErrorMessage(errorCode) ;
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (keyState == 1004)
+ typeStr = "Enrollment of key (" + keyIDStr + ") failed. " + typeStr + messageStr ;
+ else if (keyState == 1016)
+ typeStr = "Formatting of key (" + keyIDStr + ") failed. " + typeStr + messageStr;
+ else if (keyState == 1010)
+ typeStr = "PIN Reset for key (" + keyIDStr + ") failed. " + typeStr + messageStr;
+ else if (keyState == 1020)
+ typeStr = "Operation for key (" + keyIDStr + ") canceled.";
+
+ alert(typeStr);
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStatusUpdate(progMeterID, statusUpdate)
+{
+ SetProgressMeterValue(progMeterID, statusUpdate);
+ SetProgressMeterStatus(progMeterID, statusUpdate + "%");
+}
+
+function Validate()
+{
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+// screenname = GetScreenNameValue();
+// if (! screenname)
+ // return 0;
+
+ pin = GetPINValue();
+
+ if (! pin)
+ return 0;
+
+// screennamepwd = GetScreenNamePwd();
+
+// if(! screennamepwd)
+ // return 0;
+
+ }
+
+ return 1;
+}
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data,strData)
+{
+ // alert("KeyID: " + keyID + "\n" +
+ // "KeyState: " + keyState + "\n" +
+ // "Data: " + data);
+ //alert("State Change ="+keyState);
+
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ // OnCOOLKeyEnrollmentStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ OnCOOLKeyEnrollmentComplete(keyType, keyID);
+ break;
+ case 1004: // EnrollmentError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1008: // PINResetStart
+ // OnCOOLKeyPINResetStart(keyType, keyID);
+ break;
+ case 1009: // PINResetComplete
+ OnCOOLKeyPINResetComplete(keyType, keyID);
+ break;
+ case 1010: // PINResetError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1014: // FormatStart
+ // OnCOOLKeyFormatStart(keyType, keyID);
+ break;
+ case 1015: // FormatComplete
+ OnCOOLKeyFormatComplete(keyType, keyID);
+ break;
+ case 1016: // FormatError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1017: // BlinkStatus Update?
+ //OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1018:
+ OnCOOLKeyBlinkComplete(keyType, keyID);
+ break;
+ case 1020: // OperationCancelled
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1021: // OperationStatusUpdate
+ OnCOOLKeyStatusUpdate(KeyToProgressBarID(keyType, keyID), data);
+ break;
+
+ case 1022: //Need Auth
+
+
+ gCurKeyID = keyID;
+ gCurKeyType = keyType;
+
+ GetAuthDataFromPopUp(keyType,keyID,strData);
+
+ break;
+
+ }
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+</script>
+
+</head>
+<body onload="InitializeBindingTable();" onunload=cleanup()>
+<table width="100%">
+ <tr>
+ <td>
+<img src="../images/logo.gif">
+ </td>
+ <td>
+ <p class="headerText"><a href="esc.cgi?screenname=">Enterprise Security Client</a></p>
+ </td>
+ <tr>
+</table>
+ <br>
+ <table id="BindingTable" width="100%"><tbody>
+ <tr id="HeaderRow">
+ <th><p class="titleText">Key ID</p></th>
+ <th><p class="titleText">Key Status</p></th>
+<!-- <th><p class="titleText">Requires Auth</p></th>
+ <th><p class="titleText">Did Auth</p></th>
+-->
+ <th width="100"><p class="titleText">Progress</p></th>
+ </tr>
+ </tbody></table>
+ <form action="esc.cgi">
+ <input type="hidden" id="action" name="action" value="bind">
+ <input type="hidden" id="screenname" name="screenname" value="">
+ <input type="hidden" id="challengedata" name="challengedata" value="QVNDIHJvY2tzIHRoZSBwYXJ0eSE=">
+ <input type="hidden" id="signedchallenge" name="signedchallenge" value="">
+ <input type="hidden" id="signedchallengelength" name="signedchallengelength" value="">
+ <input type="hidden" id="nonce" name="nonce" value="">
+ <input type="hidden" id="noncelength" name="noncelength" value="">
+ <input type="hidden" id="keytype" name="keytype" value="">
+ <input type="hidden" id="keyid" name="keyid" value="">
+ <input type="hidden" id="keylabel" name="keylabel" value="">
+ <table width=100%>
+ <tr>
+ <td class="bodyText">
+ Select enrollment type: <input checked type="radio" id="keytype" name="keytype" value="userKey" onClick="SetEnrollmentType('userKey');">UserKey
+ </td>
+ </tr>
+ </table>
+ <table>
+ <tr>
+ <td><p class="bodyText">Token PIN:</p></td>
+ <td><input type="password" id="pintf" id="pintf" name="pintf" value=""></td>
+ <td><p class="bodyText">Re-Enter PIN:</p></td>
+ <td><input type="password" id="reenterpintf" id="reenterpintf" name="reenterpintf" value=""></td>
+ </tr>
+ </table>
+ <br>
+ <table width="100%">
+ <tr>
+ <td valign="center" align="left">
+ <input type="button" id="enrollbtn" name="enrollbtn" value="Enroll" onClick="DoEnrollCOOLKey();">
+ <input type="button" id="canclebtn" name="canclebtn" value="Cancel" onClick="DoCancelOperation();">
+ </td>
+ </tr>
+ </table>
+ <table width="100%">
+ <tr>
+ <!-- <td valign="center" align="right">
+ <h5><a href="esc.cgi?">Enterprise Security Admin Page</a></h5>
+ </td> -->
+ </tr>
+ </table>
+ </form>
+ <table width="100%">
+ <tr>
+ <td valign="center" align="left" style="width: 200px;">
+ <div id="cylon1" class="cylon" style="width: 200px; height: 10px;">
+ <div id="eye1" class="cylonEye" style="top: 0px; left: 0px; width: 28px; height: 8px; visibility: hidden;"></div>
+ </div>
+ </td>
+ <td valign="center" align="left" id="statusMsg"></td>
+ </tr>
+ </table>
+</body></html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/GenericAuth.html b/pki/linux/tps-ui/shared/docroot/esc/GenericAuth.html
new file mode 100755
index 000000000..0e857c5da
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/GenericAuth.html
@@ -0,0 +1,537 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<html>
+<head>
+<style>
+
+body {
+background: #ffffff url(../images/bg.jpg) repeat-x;
+ font-family: arial;
+ font-size: 7pt;
+
+}
+
+h1
+{
+ text-align: left;
+
+ font-weight: bold;
+
+ font-size: 13pt;
+
+
+}
+
+
+h2 {
+
+ text-align: left;
+ font-size: 10pt;
+
+ font-weight: lighter;
+}
+
+</style>
+<script language = "Javascript">
+
+var test_ui = "id=USER_ID&name=User ID&desc=User ID&type=string&option=option1,option2,option3&&id=USER_PWD&name=User Password&desc=User Password&type=password&option=&&id=USER_PIN&name=PIN&desc=One time PIN received via mail&type=password&option=";
+
+var theForm = null;
+var curKeyID = null;
+var curKeyType = 0;
+
+
+var gTitle = null;
+var gDescription = null;
+
+
+
+function ConfirmPassword(password_element)
+{
+
+ if(!password_element)
+ return 0;
+
+ password_id = password_element.id;
+
+ if(!password_id)
+ return 0;
+
+ confirm_id = "RE_" + password_element.id;
+
+ var size = theForm.length;
+
+ if(theForm)
+ {
+ for(i = 0; i < size ; i++)
+ {
+ var cur_element = theForm.elements[i];
+
+ if(cur_element.id == confirm_id)
+ {
+ if(cur_element.value != password_element.value)
+ {
+ alert("Value " + password_element.name + " must match " + cur_element.name);
+ return 0;
+
+ }
+ else
+ {
+ return 1;
+ }
+
+ }
+
+ }
+
+ }
+
+ return 1;
+}
+
+function Validate()
+{
+ if(theForm)
+ {
+ var size = theForm.length;
+
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ if(element.type == "text" )
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+ }
+
+ if(element.type == "password")
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+
+ if(!ConfirmPassword(element))
+ {
+ return 0;
+ }
+
+ }
+ }
+
+ }
+
+ return 1;
+}
+
+function FormSubmit()
+{
+ var result = Validate();
+
+ var thisParent = window.opener;
+
+ if(!parent)
+ {
+ alert("No parent window.");
+ window.close();
+ return;
+ }
+
+ if(!result)
+ {
+ return;
+ }
+
+ if(theForm)
+ {
+ var size = theForm.length;
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ var value = element.value;
+
+ if(element.type == "text" )
+ {
+ var id = element.id;
+ value = element.value;
+
+ if(thisParent)
+ {
+ //alert("about to set data value key " + curKeyID + " id " + id + " value " + value);
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,id,value);
+
+ }
+ }
+
+ if(element.type == "password")
+ {
+ var p_id = new String(element.id);
+
+ if(p_id.indexOf("RE_") == -1)
+ {
+ if(thisParent)
+ {
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,p_id,value);
+ }
+ }
+ }
+ }
+
+ }
+
+ window.close();
+}
+
+function GetUIObjectList(uiData)
+{
+ var str = new String(uiData);
+ var splits = str.split("&&");
+
+// alert("Get " + splits + " len " + splits.length);
+
+ var params = new Array();
+ var size = splits.length;
+
+ for(i = 0 ; i < size ; i++)
+ {
+ params[i] = splits[i].split("&");
+ }
+
+ size = params.length;
+ var name_value_objects = new Array();
+
+ for(i = 0 ; i < size; i++)
+ {
+ var name_values = new Array();
+
+ pISize = params[i].length;
+ for(j = 0 ; j < pISize ; j ++)
+ {
+ var pair = params[i][j].split("=");
+
+ //alert(" pair " + pair[0] + " pair1 " + pair[1]);
+
+ if(pair[0] == "option")
+ {
+ var options = pair[1].split(",");
+ }
+
+ name_values[pair[0]] = pair[1];
+ }
+
+ name_value_objects[i] = name_values;
+ }
+
+ return name_value_objects;
+
+}
+
+function AddBRToNode(theNode)
+{
+
+ if(!theNode)
+ return;
+
+ var br = document.createElement("br");
+
+ theNode.appendChild(br);
+
+}
+
+function AddTextToNode(theNode,theText)
+{
+
+ if(!theNode || !theText)
+ return;
+
+
+ var text = document.createTextNode(theText);
+
+ theNode.appendChild(text);
+
+
+
+
+}
+function AddTextToDocument(theText)
+{
+ if(!theText)
+ return;
+
+ var p = document.createElement("p");
+
+ if(p)
+ {
+ p.appendChild(document.createTextNode(theText));
+ }
+
+ document.body.appendChild(p);
+}
+
+function CreateForm()
+{
+ var form = document.createElement("form");
+ document.body.appendChild(form);
+ return form;
+}
+
+function CreateTable()
+{
+ var table = document.createElement("table");
+ document.body.appendChild(table);
+ tbody = document.createElement("tbody");
+ table.appendChild(tbody);
+
+ return table;
+}
+
+function AddRowToTable(table)
+{
+ if(!table)
+ return null;
+
+ var tr = document.createElement("tr");
+ (table.tBodies[0]).appendChild(tr);
+
+ return tr;
+}
+
+function AddColumnToRow(row)
+{
+ if(!row)
+ return null;
+
+ var td = document.createElement("td");
+ row.appendChild(td);
+
+ return td;
+}
+
+function AddTextToColumn(column,text)
+{
+ if(!column || !text)
+ return;
+
+ var text_node = document.createTextNode(text);
+ column.appendChild(text_node);
+
+ return text_node;
+}
+
+function AddInputField(type,id, name,value)
+{
+ var field = document.createElement("input");
+
+ if(!field)
+ return null;
+
+ field.type = type;
+ field.id =id;
+ field.name =name;
+ field.value =value;
+
+ return field;
+}
+
+function ConstructUI(aKeyType,aKeyID,uiData)
+{
+
+ //alert("Construct UI data " + uiData);
+ var name_value_objects = GetUIObjectList(uiData);
+ var len = name_value_objects.length;
+
+ gTitle = document.createElement("h1");
+
+ gDescription = document.createElement("h2");
+
+
+ document.body.appendChild(gTitle);
+
+
+ document.body.appendChild(gDescription);
+
+
+ form = CreateForm();
+ theForm = form;
+ curKeyID = aKeyID;
+ curKeyType = aKeyType;
+
+ table = CreateTable();
+
+ form.appendChild(table);
+
+ for(i = 0 ; i < len ; i ++)
+ {
+ curParameter = name_value_objects[i];
+
+ if(curParameter)
+ {
+
+ title = curParameter["title"];
+
+
+ if(title)
+ {
+ //alert("title " + title);
+
+ AddTextToNode(gTitle,title);
+
+
+ }
+
+ description = curParameter["description"];
+
+ if(description)
+ {
+ AddBRToNode(document.body);
+ AddBRToNode(document.body);
+
+ AddTextToNode(gDescription,description);
+
+ AddBRToNode(document.body);
+
+ }
+
+ id = curParameter["id"];
+ name = curParameter["name"];
+ type = curParameter["type"];
+ desc = curParameter["desc"];
+
+ //alert(" id " + id + " name " + name + " type " + type + " desc " + desc);
+
+ if(id)
+ {
+ if(table)
+ {
+ row = AddRowToTable(table);
+ }
+
+ if(row)
+ {
+ column = AddColumnToRow(row);
+ }
+
+ if(column)
+ {
+ AddTextToColumn(column,name);
+ }
+
+ if(type == "string" || type == "integer")
+ {
+ field = AddInputField("text",id,name,"");
+ }
+
+ re_field = null;
+
+ if(type == "password")
+ {
+ field = AddInputField("password",id,name,"");
+ }
+
+ if(type == "hidden")
+ {
+ field = AddInputField("hidden",id,name,"");
+ }
+
+ if(field)
+ {
+ field_col = AddColumnToRow(row);
+ if(field_col)
+ {
+ field_col.appendChild(field);
+ }
+ }
+
+ if(re_field)
+ {
+ re_text = AddColumnToRow(row);
+
+ if(re_text)
+ {
+ AddTextToColumn(re_text,"Confirm " + name);
+ re_field_col = AddColumnToRow(row);
+ if(re_field_col)
+ {
+ re_field_col.appendChild(re_field);
+ }
+
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ var last_row = AddRowToTable(table);
+
+ if(last_row)
+ {
+ var button_field = AddColumnToRow(last_row);
+
+ if(button_field)
+ {
+ var button = AddInputField("button","Submit","Submit","Submit");
+ button.onclick = FormSubmit;
+ button_field.appendChild(button);
+
+ }
+
+ }
+}
+
+function UiLoad()
+{
+
+
+ var thisParent = window.opener;
+
+
+ if(!thisParent)
+ {
+ alert("Auth dialog has no parent!");
+ return;
+ }
+
+ var keyID = this.name;
+
+ var ui = thisParent.getUIForKey(keyID);
+
+ var type = thisParent.getTypeForKey(keyID);
+
+ //alert("UiLoad " + ui);
+
+ if(ui)
+ {
+ ConstructUI(type,keyID,ui);
+ }
+}
+
+</script>
+</head>
+<body onload = "UiLoad()">
+</body>
+</html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/SettingsEsc.html b/pki/linux/tps-ui/shared/docroot/esc/SettingsEsc.html
new file mode 100755
index 000000000..9ffeb69a3
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/SettingsEsc.html
@@ -0,0 +1,738 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<html>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<head>
+
+<link rel=stylesheet href="/style.css" type="text/css">
+
+<script lang="JavaScript">
+//
+// initialize netkey globals
+var netkey;
+var gNotify = null;
+var isMSHTML;
+
+//
+// Determine if we are running MSHTML or GECKO
+//
+if (navigator.userAgent.indexOf("MSIE") != -1) {
+ isMSHTML = true;
+} else {
+ isMSHTML = false;
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ alert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+if (!isMSHTML) {
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+
+ gNotify = new jsNotify;
+
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+} else {
+ // MSHTML only initialization
+ netkey = external;
+}
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+ if (!isMSHTML) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+ }
+}
+
+
+////////////////////////////////////////////////////////////////
+//
+// Host will be responsible for generating the gBindingsArray.
+//
+////////////////////////////////////////////////////////////////
+
+var gBindingsArray = [
+ <!-- SECURECOOL_BINDINGS_ARRAY -->
+];
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+var gKeyBusyArray = [ ];
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function LoadBindingsIntoTable()
+{
+ var table = document.getElementById("KeyTable");
+
+ if (table)
+ {
+ var i;
+ for (i=0; i < gBindingsArray.length; i++)
+ {
+ CreateTableRow(table, gBindingsArray[i][0], gBindingsArray[i][1], false,
+ gBindingsArray[i][2], true);
+ }
+ }
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ {
+ var table = document.getElementById("KeyTable");
+ if (table)
+ {
+ // The assumption here is that if the key isn't already
+ // listed in the table, then it must be a new unbound key!
+
+ row = CreateTableRow(table, keyType, keyID, true, keyID, false);
+ }
+
+ if (!row)
+ return null;
+ }
+ else if (IsKeyBound(keyType, keyID))
+ SetKeyIsVisible(row, true);
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function ReportException(msg, e)
+{
+ alert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ } else {
+ keyArr = ConvertVariantArrayToJScriptArray(netkey.GetAvailableCoolKeys());
+
+ var i;
+ for (i=0; i < keyArr.length; i++)
+ keyArr[i] = ConvertVariantArrayToJScriptArray(keyArr[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableCoolKeys() failed!", e);
+ return [];
+ }
+}
+
+function BlinkCOOLKey(keyType, keyID, rate, duration)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.BlinkCoolKey(keyType, keyID, rate, duration);
+ } catch(e) {
+ ReportException("netkey.BlinkCoolKey() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ if (isMSHTML) {
+ row.removeNode(row);
+ } else {
+ table.deleteRow(row.rowIndex);
+ }
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ if (isMSHTML) {
+ row = table.insertRow();
+ } else {
+ row = table.insertRow(table.rows.length);
+ }
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ if (isMSHTML) {
+ cell = row.insertCell();
+ } else {
+ cell = row.insertCell(row.cells.length);
+ }
+ return cell;
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+}
+
+function InitializeBindingTable()
+{
+ LoadBindingsIntoTable();
+ UpdateBindingTableAvailability();
+}
+
+function IsKeyBound(keyType, keyID)
+{
+
+ for (i=0; i < gBindingsArray.length; i++)
+ {
+ if (keyType == gBindingsArray[i][0] && keyID == gBindingsArray[i][1])
+ return true;
+ }
+
+ return false;
+}
+
+function COOLKeyIsBusy(keyType, keyID)
+{
+ for (i=0; i < gKeyBusyArray.length; i++)
+ {
+ if (keyType == gKeyBusyArray[i][0] && keyID == gKeyBusyArray[i][1])
+ return true;
+ }
+
+ return false;
+}
+
+function AddKeyToBusyArray(keyType, keyID)
+{
+ // If key is already in our array, nothing to do.
+ if (COOLKeyIsBusy(keyType, keyID))
+ return;
+
+ gKeyBusyArray.push(new Array(keyType, keyID));
+}
+
+function RemoveKeyFromBusyArray(keyType, keyID)
+{
+ for (i=0; i < gKeyBusyArray.length; i++)
+ {
+ if (keyType == gKeyBusyArray[i][0] && keyID == gKeyBusyArray[i][1])
+ gKeyBusyArray.splice(i, 1);
+ }
+}
+
+function SetKeyIsVisible(row, isVisible)
+{
+ if (!row) return;
+ var cell = row.cells(0);
+ if (!cell) return;
+
+ var v = "inherit";
+ if (!isVisible)
+ v = "hidden";
+ cell.firstChild.style.visibility = v;
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+function CreateTableRow(table, keyType, keyID, isAvailable, label, isSecured)
+{
+
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (label == keyID)
+ label = keyIDStr;
+
+ // Add a tooltip to the row so that it displays more info.
+ var title = keyType + " - " + keyIDStr;
+ if (isSecured && label)
+ title += " - " + label;
+ row.setAttribute("title", title);
+
+ // Create the isAvailable cell:
+ cell = InsertCell(row);
+ cell.setAttribute("align", "center");
+ var a = document.createElement("a");
+ a.setAttribute("href", "javascript:DoBlinkCOOLKey(" + keyType + ", '" + keyID + "');");
+ if (! isAvailable)
+ a.style.visibility = "hidden";
+ var img = document.createElement("img");
+ img.setAttribute("src", "../images/NetKey-Small.gif");
+ a.appendChild(img);
+ cell.appendChild(a);
+
+ // Create the label cell. Make sure we truncate long
+ // labels so that they fit nicely into the window.
+ cell = InsertCell(row);
+ if (label.length > 24)
+ label = label.substr(0, 24) + "...";
+ cell.appendChild(document.createTextNode(label));
+
+ // Create the action cell:
+ cell = InsertCell(row);
+ a = document.createElement("a");
+ if (isSecured)
+ {
+ // a.setAttribute("href", "javascript:UnbindCOOLKey(" + keyType + ", '" + keyID + "');");
+ a.appendChild(document.createTextNode("Release"));
+ }
+ else
+ {
+ // a.setAttribute("href", "javascript:BindCOOLKey(" + keyType + ", '" + keyID + "');");
+ a.appendChild(document.createTextNode("Secure"));
+ }
+ cell.appendChild(a);
+
+ // Create the secured cell:
+ cell = InsertCell(row);
+ cell.setAttribute("align", "center");
+ img = document.createElement("img");
+ img.setAttribute("src", "../images/PadLock.gif");
+ if (!isSecured)
+ img.style.visibility = "hidden";
+ cell.appendChild(img);
+
+ return row;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ASC native code.
+//
+// ASC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.GetCOOLKeyStatus(keyType, keyID)
+//
+// - Returns an integer describing the status of the COOLKey. Possible
+// values are:
+//
+// 0 // Unavailable
+// 1 // AppletNotFound
+// 2 // Uninitialized
+// 3 // Unknown
+// 4 // Available
+// 5 // EnrollmentInProgress
+// 6 // UnblockInProgress
+// 7 // PINResetInProgress
+// 8 // RenewInProgress
+// 9 // FormatInProgress
+// 10 // BlinkInProgress
+//
+// netkey.GetCOOLKeyPolicy(keyType, keyID)
+//
+// - Retrieves the Certificate Policy Extension Object Identifier (OID)
+// as a string. This can be useful for distinguishing between types of
+// COOLKeys. The list of currently defined OIDS are:
+//
+// Bronze Member - Phase 1: OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1
+// Silver Member - Phase 2: OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2
+// Gold Associate - Phase 2: OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3
+// Platinum MyDoctor - Phase 2: OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4
+//
+// netkey.GetCOOLKeyRequiresAuthentication(keyType, keyID)
+//
+// - Returns a bool value that indicates whether or not the COOLKey
+// requires a PIN to access crypto functionality.
+//
+// netkey.AuthenticateCOOLKey(keyType, keyID, pin)
+//
+// - Attempts to authenticates to the COOLKey using the supplied
+// pin string.
+//
+// netkey.InitCOOLKey(keyType, keyID, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass null values for both screenName and pin, otherwise, the key.
+// is formatted as a NetKey.
+//
+// netkey.ChallengeCOOLKey(keyType, keyID, data)
+//
+// - Signs some data with the specified key, and returns the results
+// in an AcviteX Variant SafeArray. Before accessing any data in
+// this array, you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray(). The elements in the
+// array are as follows:
+//
+// array[0] --> Length of the signed challenge data in binary form.
+// array[1] --> The signed challenge data as hex.
+// array[0] --> Length of the nonce data in binary form.
+// array[0] --> The nonce data as hex.
+//
+// netkey.BlinkCOOLKey(keyType, keyID, rate, duration)
+//
+// - Make a specific key blink at a given rate for a given duration.
+// rate and duration are specified in milliseconds.
+//
+// netkey.RequestServiceTicket(screenName, serviceName)
+//
+// - Makes an async ticket request for a specific service.
+// The ticket is returned via the OnTicketRequestSuccess()
+// callback.
+//
+// netkey.CancelServiceTicketRequest(screenName, serviceName)
+//
+// - Cancels a specific service ticket request that may be pending.
+//
+////////////////////////////////////////////////////////////////
+
+function BindCOOLKey(keyType, keyID)
+{
+ if (COOLKeyIsBusy(keyType, keyID))
+ {
+ alert("COOLKey '" + keyID + "' is busy!");
+ return;
+ }
+
+ document.forms[0].action.value = "setlabelpage";
+ document.forms[0].keytype.value = keyType;
+ document.forms[0].keyid.value = keyID;
+ document.forms[0].submit();
+}
+
+function UnbindCOOLKey(keyType, keyID)
+{
+ if (COOLKeyIsBusy(keyType, keyID))
+ {
+ alert("COOLKey '" + keyID + "' is busy!");
+ return;
+ }
+
+ document.forms[0].action.value = "unbindprogresspage";
+ document.forms[0].keytype.value = keyType;
+ document.forms[0].keyid.value = keyID;
+ document.forms[0].submit();
+}
+
+function PurchaseMoreKeys()
+{
+}
+
+function LoadHelp()
+{
+ alert("- Click on the key icon for a specific key to make it blink.\n");
+}
+
+function DoBlinkCOOLKey(keyType, keyID)
+{
+ if (!keyID)
+ return;
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+}
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ refresh();
+}
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("KeyTable");
+ if (row && table)
+ {
+ if (IsKeyBound(keyType, keyID))
+ SetKeyIsVisible(row, false);
+ else
+ RemoveRow(table, row)
+ }
+
+ refresh();
+}
+
+function OnCOOLKeyBusyStart(keyType, keyID)
+{
+ AddKeyToBusyArray(keyType, keyID);
+}
+
+function OnCOOLKeyBusyEnd(keyType, keyID)
+{
+ RemoveKeyFromBusyArray(keyType, keyID);
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+////////////////////////////////////////////////////////////////////////////
+//
+// Notification functions called directly from ASC native code. These
+// functions will only be called if they exist in the current running
+// JavaScript context.
+//
+// OnCOOLKeyStateChange(keyType, keyID, keyState, data)
+//
+// - Called when the state of the COOLKey changes. Values for key
+//
+// keyState Description data
+// -------------------------------------------------------
+// 1000 Key Inserted <none>
+// 1001 Key Removed <none>
+// 1002 Enrollment Start <0=Phase1, 1=Phase2>
+// 1003 Enrollment Complete <none>
+// 1004 Enrollment Error Integer Error Code
+// 1005 Unblock Start <none>
+// 1006 Unblock Complete <none>
+// 1007 Unblock Error Integer Error Code
+// 1008 PIN Reset Start <none>
+// 1009 PIN Reset Complete <none>
+// 1010 PIN Reset Error Integer Error Code
+// 1011 Renew Start <none>
+// 1012 Renew Complete <none>
+// 1013 Renew Error Integer Error Code
+// 1014 Format Start <none>
+// 1015 Format Complete <none>
+// 1016 Format Error Integer Error Code
+// 1017 Blink Start <none>
+// 1018 Blink Complete <none>
+// 1019 Blink Error Integer Error Code
+// 1020 Operation Cancelled Integer Error Code
+//
+// OnTicketRequestSuccess(serviceName, ticket, authenticator)
+//
+// - Called when a service ticket request made with
+// netkey.RequestServiceTicket() completes successfully.
+// ticket is the Base64 encoded Kerberos ticket. authenticator
+// is the Base64 encoded authenticator.
+//
+// OnTicketRequestException(serviceName, errCode, errSubSystem, errMsg)
+//
+// - Called when a service ticket request made with
+// netkey.RequestServiceTicket() fails. serviceName is the service
+// name used when the request was made. errCode is the error code
+// defined by CLC. errSubSystem is the sub system defined by CLC.
+// errMsg is the string containing the error message to display. This
+// string is provided by UAS or CLC.
+//
+////////////////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data)
+{
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ case 1005: // UnblockStart
+ case 1008: // PINResetStart
+ case 1011: // RenewStart
+ case 1014: // FormatStart
+ OnCOOLKeyBusyStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ case 1004: // EnrollmentError
+ case 1006: // UnblockComplete
+ case 1007: // UnblockError
+ case 1009: // PINResetComplete
+ case 1010: // PINResetError
+ case 1012: // RenewComplete
+ case 1013: // RenewError
+ case 1015: // FormatComplete
+ case 1016: // FormatError
+ OnCOOLKeyBusyEnd(keyType, keyID);
+ break;
+ }
+}
+
+</script>
+</head>
+<body onLoad="InitializeBindingTable();" onUnload="cleanup();">
+
+<table width="100%">
+ <tr>
+ <td>
+<img src="../images/logo.gif"> </td>
+ <td>
+ <p class="headerText"><a href="esc.cgi?screenname=">Enterprise Security Client</a></p>
+ </td>
+ <tr>
+</table>
+
+<form method="post" action="esc.cgi">
+<input type="hidden" name="action" value="settingspage">
+<input type="hidden" name="screenname" value="<!-- SECURECOOL_SCREENNAME -->">
+<input type="hidden" name="keytype" value="">
+<input type="hidden" name="keyid" value="">
+<table class="PageHeader">
+</table>
+<table class="ContentTable">
+<tbody>
+<tr><td colspan="2">
+<b>Coolkey</b> (Enterprise Security Key) helps users perform various cryptographic operations.
+<br>
+Your Coolkey(s) and any other Coolkey(s) plugged into this computer are shown here.
+<br>
+<br>
+<div class="TableTitle">Coolkey(s) <!-- SECURECOOL_SCREENNAME --></div>
+</td></tr>
+<tr>
+ <td width="55%" valign="top">
+ <table id="KeyTable">
+ <tbody>
+ <tr class="KeyTableHeader">
+ <th></th>
+ <th><p class="titleText">Name</p></th>
+ <th></th>
+ <th><p class="titleText">Secured</p></th>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+</tr>
+</tbody>
+</table>
+</form>
+</body>
+</html>
+
diff --git a/pki/linux/tps-ui/shared/docroot/esc/TokenManager.html b/pki/linux/tps-ui/shared/docroot/esc/TokenManager.html
new file mode 100755
index 000000000..2f28889ef
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/TokenManager.html
@@ -0,0 +1,1706 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<html>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+<head>
+<link rel=stylesheet href="/style.css" type="text/css">
+
+<script language="JavaScript">
+
+//
+// initialize netkey globals
+var netkey;
+var isMSHTML;
+
+
+var keyUITable = new Array();
+var keyTypeTable = new Array();
+var curChildWindow = null;
+
+function getUIForKey(aKeyID)
+{
+ return keyUITable[aKeyID];
+
+}
+
+function getTypeForKey(aKeyID)
+{
+ return keyTypeTable[aKeyID];
+}
+
+//
+// Determine if we are running MSHTML or GECKO
+//
+if (navigator.userAgent.indexOf("MSIE") != -1) {
+ isMSHTML = true;
+} else {
+ isMSHTML = false;
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData,strData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ alert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+if (!isMSHTML) {
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+ gNotify = new jsNotify;
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+} else {
+ // MSHTML only initialization
+ netkey = external;
+}
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+ if (!isMSHTML) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ alert("Can't get UniversalXPConnect: " + e);
+ }
+ }
+}
+
+var gScreenName = "";
+var gKeyEnrollmentType = "userKey";
+
+var gCurrentSelectedRow = null;
+
+
+var gCurKeyType = null;
+var gCurKeyID = null;
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+
+// List of Error Messages to be printed out
+
+var Status_Messages = new Array(
+
+"Operation Completed Successfully.",
+ "Server Error.",
+ "Problem communicating with the token.",
+ "Problem communicating with the token.",
+ "Problem resetting token's pin.",
+ "Internal Server Error.",
+ "Internal Server Error",
+ "Token Enrollment Error.",
+ "Problem communicating with the token.",
+ "Internal Server Error",
+ "Error communicating with the Certificate Authority, try again later.",
+ "Internal Server Error.",
+ "Error resetting the token's pin.",
+ "Internal Server Error.",
+ "Authentication Failure, Try Again.",
+ "Internal Server Error",
+ "Token is disabled, contact technical support.",
+ "Problem communicating with the token.",
+ "Internal Server Error.",
+ "Cannot upgrade token software.",
+ "Internal Server Error.",
+ "Problem communicating with the token.",
+ "Invalid token type.",
+ "Invalid token type",
+ "Cannot publish.",
+ "Cannot communicate with token database, try again later.",
+ "Token is disabled, contact techincal support.",
+ "Cannot reset pin value for the token, contact technical support.",
+ "Connection to server lost.",
+ "Cannot create entry for token in database, contact technical support.",
+ "No such token state, contact technical support.",
+ "Invalid lost token reason, contact technical support.",
+ "Token unusable due to compromise,contact technical support.",
+ "No such inactive token, contact technical support.",
+ "Cannot process more than one active token.",
+ "Internal Server Error,contact technical support.",
+ "Key Recovery has been processed.",
+ "Key Recovery failed, contact technical support.",
+ "Cannot operate on token reported lost, contact technical support.",
+ "Key archival error, contact technical support.",
+ "Problem connecting to the TKS, contact technical support.",
+ "Failed to update token database, contact technical support.",
+ "Internal certificate revocation error,contact technical support.",
+ "User does not own this token, contact technical support."
+);
+
+function GetAuthDataFromPopUp(aKeyType,aKeyID,aUiData)
+{
+
+ keyUITable[aKeyID] = aUiData;
+ keyTypeTable[aKeyID] = aKeyType;
+
+ //alert("GetAuthDataFromPopUp data " + aUiData);
+ var child = window.open("/GenericAuth.html",aKeyID,"height=400,width=400");
+
+ //alert("Attempted to create child window " + child);
+
+ curChildWindow = child;
+
+}
+
+function COOLKeySetDataValue(aKeyType,aKeyID,name,value)
+{
+ //alert("In COOLKeySetDataValue aKeyType " + aKeyType + " aKeyID " + aKeyID + " name " + name + " value " + value);
+ if(netkey)
+ {
+ try {
+ if(!isMSHTML)
+ {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+
+ netkey.SetCoolKeyDataValue(aKeyType,aKeyID,name,value);
+
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+ }
+
+}
+
+function COOLKeySetTokenPin(pin)
+{
+ if(!isMSHTML)
+ {
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"TokenPin",pin);
+
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+ }
+ }
+}
+
+function COOLKeySetUidPassword(uid,pwd)
+{
+
+ if(!isMSHTML)
+ {
+ if(netkey)
+ {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"UserId",uid);
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"Password",pwd);
+
+ } catch(e) {
+ alert("Error Setting data values: " + e);
+ }
+
+ }
+
+ }
+
+}
+
+
+function MyGetErrorMessage(status_code)
+{
+
+ var result = "Internal Server Error";
+
+ if(status_code < 0 && status_code >= Status_Messages.length)
+ {
+ return result;
+
+ }
+
+ return Status_Messages[status_code];
+
+}
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function ReportException(msg, e)
+{
+ alert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetCOOLKeyStatus(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyStatus(keyType, keyID);
+ } catch (e) {
+ ReportException("netkey.GetESCKeyStatus() failed!", e);
+ return 0;
+ }
+}
+
+function GetCOOLKeyPolicy(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyPolicy(keyType, keyID);
+ } catch (e) {
+ // ReportException("netkey.GetESCKeyPolicy() failed!", e);
+ return "";
+ }
+}
+
+function GetCOOLKeyRequiresAuth(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyRequiresAuthentication(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetESCKeyRequiresAuthentication() failed!", e);
+ return false;
+ }
+}
+
+function GetCOOLKeyIsAuthed(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyIsAuthenticated(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetESCKeyIsAuthenticated() failed!", e);
+ return false;
+ }
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ } else {
+ keyArr = ConvertVariantArrayToJScriptArray(netkey.GetAvailableCoolKeys());
+
+ var i;
+ for (i=0; i < keyArr.length; i++)
+ keyArr[i] = ConvertVariantArrayToJScriptArray(keyArr[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableESCKeys() failed!", e);
+ return [];
+ }
+}
+
+function ChallengeCOOLKey(keyType, keyID, data)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return ConvertVariantArrayToJScriptArray(netkey.ChallengeCoolKey(keyType, keyID, data));
+ } catch(e) {
+ ReportException("netkey.ChallengeESCKey() failed!", e);
+ return [];
+ }
+}
+
+function EnrollCOOLKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.EnrollCoolKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.EnrollESCKey() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+function GetCOOLKeyIsEnrolled(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ return netkey.GetCoolKeyIsEnrolled(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetESCKeyIsEnrolled() failed!", e);
+ return false;
+ }
+}
+
+function ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.ResetCoolKeyPIN(keyType, keyID, screenname, pin,screennamepwd);
+ } catch(e) {
+ ReportException("netkey.ResetESCKeyPIN() failed! Make sure token is properly Enrolled.", e);
+ return false;
+ }
+ return true;
+}
+function FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.FormatESCKey() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function CancelCOOLKeyOperation(keyType, keyID)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.CancelCoolKeyOperation(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.CancelESCKeyOperation() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function BlinkCOOLKey(keyType, keyID, rate, duration)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.BlinkCoolKey(keyType, keyID, rate, duration);
+ } catch(e) {
+ ReportException("netkey.BlinkESCKey() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function RequestServiceTicket(screenName, serviceName)
+{
+ try {
+ if (!isMSHTML) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+ netkey.RequestServiceTicket(screenName, serviceName);
+ } catch(e) {
+ ReportException("netkey..RequestServiceTicket() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ if (isMSHTML) {
+ row.removeNode(row);
+ } else {
+ table.deleteRow(row.rowIndex);
+ }
+}
+
+function GetCell(row, index)
+{
+ var cell;
+
+ if (isMSHTML) {
+ cell = row.cells(index);
+ } else {
+ cell = row.cells[index];
+ }
+ return cell;
+}
+
+function GetNode(parent, index)
+{
+ var node;
+ if (isMSHTML) {
+ node = parent.childNodes(index);
+ } else {
+ node = parent.childNodes[index];
+ }
+ return node;
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ if (isMSHTML) {
+ row = table.insertRow();
+ } else {
+ row = table.insertRow(table.rows.length);
+ }
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ if (isMSHTML) {
+ cell = row.insertCell();
+ } else {
+ cell = row.insertCell(row.cells.length);
+ }
+ return cell;
+}
+
+function RemoveAllChildNodes(parent)
+{
+ var numChildren = parent.childNodes.length;
+ var i;
+
+ i = numChildren;
+ while (numChildren)
+ {
+ parent.removeChild(GetNode(parent,0));
+ numChildren--;
+ }
+
+}
+
+
+function UpdateInfoForKeyID(keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return;
+
+ var cell = GetCell(row,1)
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+ // cell = GetCell(row,2);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ //cell = GetCell(row,3);
+ //RemoveAllChildNodes(cell);
+ //cell.appendChild(document.createTextNode(isAuthed));
+}
+
+function GetStatusForKeyID(keyType, keyID)
+{
+ var keyStatus = "BLANK";
+
+ var status;
+
+ try {
+ status = GetCOOLKeyStatus(keyType, keyID);
+ } catch(e) {
+ status = 0;
+ }
+
+ switch (status) {
+ case 0: // Unavailable
+ keyStatus = "UNAVAILABLE";
+ break;
+ case 1: // AppletNotFound
+ keyStatus = "NO APPLET";
+ break;
+ case 2: // Uninitialized
+ keyStatus = "UNINITIALIZED";
+ break;
+ case 3: // Unknown
+ keyStatus = "UNKNOWN";
+ break;
+ case 4: // Available
+ case 6: // UnblockInProgress
+ case 7: // PINResetInProgress
+ case 8: // RenewInProgress
+ keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ break;
+ case 5: // EnrollmentInProgress
+ keyStatus = "BUSY";
+ break;
+ break;
+ case 9: // FormatInProgress
+ keyStatus = "BUSY";
+ break;
+ }
+
+ return keyStatus;
+}
+
+function GetKeyStatusForKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return "UNKNOWN";
+
+ var cell = GetCell(row,1);
+ return GetNode(cell,0).data;
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ {
+ var table = document.getElementById("BindingTable");
+ if (table)
+ {
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ row = CreateTableRow(table, keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ }
+
+ if (!row)
+ return null;
+ }
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ {
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(arr[i][0], arr[i][1]);
+ }
+}
+
+function InitializeBindingTable()
+{
+ UpdateBindingTableAvailability();
+ UpdateButtonStates();
+ // document.getElementById("snametf").value = gScreenName;
+}
+
+function KeyIsPresent(keyType, keyID)
+{
+ row = document.all.item(keyType, keyID);
+
+ if (!row)
+ return false;
+
+ return true;
+}
+
+function SetStatusMessage(str)
+{
+ var cell = document.getElementById("statusMsg");
+
+ if (!cell)
+ return;
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(str));
+}
+
+function UpdateButtonStates()
+{
+ if (gKeyEnrollmentType == "deviceKey")
+ {
+ // document.getElementById("snametf").disabled = true;
+ // document.getElementById("pintf").disabled = true;
+ // document.getElementById("reenterpintf").disabled = true;
+ // document.getElementById("snamepwd").disabled = true;
+ }
+ else
+ {
+ // document.getElementById("snametf").disabled = false;
+ // document.getElementById("pintf").disabled = false;
+ // document.getElementById("reenterpintf").disabled = false;
+ // document.getElementById("snamepwd").disabled = false;
+ }
+
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ var keyStatus = GetKeyStatusForKeyID(keyType, keyID);
+
+ var validKey = (keyStatus == "NETKEY" || keyStatus == "HOUSEKEY");
+ // document.getElementById("challengebtn").disabled = !validKey;
+ document.getElementById("blinkbtn").disabled = false;
+// document.getElementById("enrollbtn").disabled = false;
+ document.getElementById("formatbtn").disabled = false;
+// document.getElementById("resetpinbtn").disabled = !((keyStatus == "NETKEY") && (gKeyEnrollmentType == "userKey"));
+//document.getElementById("resetpinbtn").disabled = !((gKeyEnrollmentType == "userKey"));
+ }
+ else
+ {
+ //document.getElementById("enrollbtn").disabled = true;
+ // document.getElementById("resetpinbtn").disabled = true;
+ document.getElementById("formatbtn").disabled = true;
+ // document.getElementById("challengebtn").disabled = true;
+ document.getElementById("blinkbtn").disabled = true;
+ }
+
+ refresh();
+}
+
+function SetEnrollmentType(type)
+{
+ gKeyEnrollmentType = type;
+ UpdateButtonStates();
+}
+
+function FindRow(node)
+{
+ while (node && node.tagName != "TR")
+ {
+ node = node.parentNode;
+ }
+
+ return node;
+}
+
+function SelectRow(row)
+{
+ if (!row || gCurrentSelectedRow == row)
+ return;
+
+ if (gCurrentSelectedRow)
+ gCurrentSelectedRow.removeAttribute("style");
+
+ gCurrentSelectedRow = row;
+ gCurrentSelectedRow.style.backgroundColor="rgb(200,200,200)";
+ UpdateButtonStates();
+}
+
+function SelectRowByKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ SelectRow(row);
+}
+
+function DoSelectRow(event)
+{
+ var row;
+
+ if (isMSHTML) {
+ row = FindRow(window.event.srcElement);
+ } else {
+ row = FindRow(event.parentNode);
+ }
+ SelectRow(row);
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+
+
+function CreateTableRow(table, keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+
+ if (isMSHTML) {
+ row.onclick = DoSelectRow;
+ }
+
+ // Create the key ID cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(KeyToUIString(keyType, keyID)));
+
+ cell.setAttribute("onClick", "DoSelectRow(this);");
+
+ // Create the keyStatus cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+ // Create the requires auth cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(reqAuth));
+
+ // Create the is auth'ed cell.
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode(isAuthed));
+
+ // Create the status bar cell
+ cell = InsertCell(row);
+
+ var progressMeter = document.createElement("div");
+ progressMeter.setAttribute("id", KeyToProgressBarID(keyType, keyID));
+ progressMeter.className = "ProgressMeter";
+ progressMeter.style.width = "100px";
+ progressMeter.style.height = "1.5em";
+ progressMeter.setAttribute("value", 0);
+
+ var progressBar = document.createElement("div");
+ progressBar.className = "ProgressBar";
+ progressBar.style.width = "0px";
+ progressBar.style.height = "100%";
+ progressBar.style.visibility = "hidden";
+
+ var progressBarStatus = document.createElement("div");
+ progressBarStatus.className = "ProgressBarStatus";
+ progressBarStatus.appendChild(document.createTextNode(""));
+
+ progressMeter.appendChild(progressBar);
+ progressMeter.appendChild(progressBarStatus);
+ cell.appendChild(progressMeter);
+
+ return row;
+}
+
+gAnimationMSecs = 1000/30;
+
+function SetCylonTimer(cylonID, cylonEyeID)
+{
+ setTimeout("AnimateCylonStatusBar(\"" + cylonID +
+ "\", \"" + cylonEyeID + "\");", gAnimationMSecs);
+}
+
+function AnimateCylonStatusBar(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID);
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ return;
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (!eye)
+ return;
+
+ var dir = eye.getAttribute("direction");
+ var wid = parseInt(eye.style.width);
+ var cywid = parseInt(cylon.style.width);
+ var left = parseInt(eye.style.left);
+
+ var dx = 10;
+
+ if (!dir || dir >= 0)
+ {
+ left += dx;
+
+ if (left + wid > cywid)
+ {
+ left = cywid - wid;
+ eye.setAttribute("direction", "-1");
+ }
+ }
+ else
+ {
+ left -= dx;
+
+ if (left < 0)
+ {
+ left = 0;
+ eye.setAttribute("direction", "1");
+ }
+ }
+
+ eye.style.left = left + "px";
+
+ SetCylonTimer(cylonID, cylonEyeID);
+}
+
+function StartCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ {
+ cylon.setAttribute("cylonactive", "true");
+
+ var eye = document.getElementById(cylonEyeID);
+ if (eye)
+ {
+ eye.style.left = "0px";
+ eye.style.visibility = "visible";
+ }
+
+ SetCylonTimer(cylonID, cylonEyeID);
+ }
+}
+
+function StopCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (cylon)
+ cylon.removeAttribute("cylonactive");
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (eye)
+ eye.style.visibility = "hidden";
+}
+
+function GetProgressMeterValue(progMeterID)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return -1;
+
+ return parseInt(progMeter.getAttribute("value"));
+}
+
+function SetProgressMeterValue(progMeterID, value)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter || value < 0)
+ return;
+
+ if (value > 100)
+ value = 100;
+
+ var progBar = progMeter.firstChild;
+
+ if (value == 0)
+ {
+ progBar.style.width = "0px";
+ progBar.style.visibility = "hidden";
+ progMeter.setAttribute("value", 0);
+ return;
+ }
+
+ progBar.style.visibility = "visible";
+
+ var newWidth = parseInt(progMeter.style.width) * value / 100 - 2;
+
+ progBar.style.width = newWidth + "px";
+ progMeter.setAttribute("value", value);
+}
+
+function SetProgressMeterStatus(progMeterID, statusMsg)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return;
+
+ var progBar = progMeter.firstChild;
+
+ // If it exists, the meter status should be
+ // div that is the next sibling of the progressMeter.
+
+ var meterStatus = progBar.nextSibling;
+
+ // Just replace the data in the text node, it's much faster,
+ // and reduces flashing!
+
+ meterStatus.firstChild.replaceData(0, meterStatus.firstChild.length, statusMsg);
+}
+
+function ClearProgressBar(progMeterID)
+{
+ SetProgressMeterValue(progMeterID, 0);
+ SetProgressMeterStatus(progMeterID, "");
+}
+
+function KeyToProgressBarID(keyType, keyID)
+{
+ return "PM" + keyType + "-" + keyID;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ASC native code.
+//
+// ASC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.EnrollCOOLKey(keyType, keyID, enrollmentType, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass "houseKey" as the enrollmentType, and null values for both
+// screenName and pin. For a NetKey, use "netKey" as the enrollmentType,
+// and pass a valid screenName and pin.
+//
+// netkey.ChallengeCOOLKey(keyType, keyID, data)
+//
+// - Signs some data with the specified key, and returns the results
+// in an AcviteX Variant SafeArray. Before accessing any data in
+// this array, you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray(). The elements in the
+// array are as follows:
+//
+// array[0] --> Length of the signed challenge data in binary form.
+// array[1] --> The signed challenge data as hex.
+// array[0] --> Length of the nonce data in binary form.
+// array[0] --> The nonce data as hex.
+//
+// netkey.BlinkCOOLKey(keyType, keyID, rate, duration)
+//
+// - Make a specific key blink at a given rate for a given duration.
+// rate and duration are specified in milliseconds.
+//
+////////////////////////////////////////////////////////////////
+
+function GetScreenNameValue()
+{
+ var sname = document.getElementById("snametf").value;
+
+ if (! sname)
+ {
+ alert("You must provide a valid screen name!");
+ return null;
+ }
+
+ return sname;
+}
+
+function GetPINValue()
+{
+ var pinVal = document.getElementById("pintf").value;
+ var rpinVal = document.getElementById("reenterpintf").value;
+
+ if (! pinVal)
+ {
+ alert("You must provide a valid PIN!");
+ return null;
+ }
+
+ if ( pinVal != rpinVal)
+ {
+ alert("The PIN values you entered don't match!");
+ return null;
+ }
+
+ return pinVal;
+}
+
+function GetScreenNamePwd()
+{
+
+ var pwd = document.getElementById("snamepwd").value;
+
+ if(!pwd)
+ {
+ alert("You must provide a valid User Password!");
+ return null;
+ }
+ return pwd;
+}
+
+function GetTokenCode()
+{
+
+ return null;
+}
+function DoEnrollCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ {
+ alert("Please select a key.");
+ return;
+ }
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = null; //GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = null; // GetScreenNamePwd();
+
+
+ tokencode = GetTokenCode();
+
+ SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+ }
+ else
+ SetStatusMessage("Enrolling DeviceKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!EnrollCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+
+function DoResetSelectedCOOLKeyPIN()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ // if(!Validate())
+ // return;
+
+ //alert("In DoResetSelectedCOOLKeyPIN!");
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var screenname = null;
+ var pin = null;
+ var screennamepwd = null;
+
+ if (GetCOOLKeyIsEnrolled(keyType, keyID))
+ {
+
+ SetStatusMessage("Resetting PIN for \"" + keyID + "\"...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+ }
+}
+
+function DoFormatCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+
+ // if(!Validate())
+ // return;
+
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+function DoCancelOperation()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ SetStatusMessage("Cancel operation for \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ CancelCOOLKeyOperation(keyType, keyID);
+
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+}
+
+function DoChallengeSelectedKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Generating Challenge ...");
+
+ var challengeArray = ChallengeCOOLKey(keyType, keyID, document.forms[0].challengedata.value);
+
+ if (challengeArray.length != 4)
+ {
+ alert("Challenge for key \"" + KeyToUIString(keyType, keyID) + "\" failed!");
+ SetStatusMessage("");
+ return;
+ }
+
+ alert("ChallengeCOOLKey(\""+ KeyToUIString(keyType, keyID) + "\") returned:\n\n" +
+ "challenge[0]: " + challengeArray[0] + "\n" +
+ "challenge[1]: " + challengeArray[1] + "\n" +
+ "challenge[2]: " + challengeArray[2] + "\n" +
+ "challenge[3]: " + challengeArray[3] + "\n");
+
+ SetStatusMessage("");
+}
+
+function DoBlinkCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Blinking \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+}
+
+function OnCOOLKeyBlinkComplete(keyType,keyID)
+{
+ //StopCylonAnimation("cylon1", "eye1");
+ //SetStatusMessage(" ");
+}
+
+function DoHelp()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ var policy = GetCOOLKeyPolicy(keyType, keyID);
+ var type = PolicyToKeyType(policy);
+ alert("Policy: " + policy + "\n" + "Type: " + type);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions called directly from ASC native code.
+//
+////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(keyType, keyID);
+}
+
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("BindingTable");
+
+ if (row && table)
+ {
+ RemoveRow(table,row);
+
+ if (row == gCurrentSelectedRow)
+ gCurrentSelectedRow = null;
+ }
+
+ UpdateButtonStates();
+}
+
+var gKnownPolicies = [
+
+ // OID Value, precedence, name value
+
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4", 4, "NETKEY" ], // Platinum - MyDoctor
+
+ // XXX: Remove the Old OIDs below, after the RA starts generating
+ // certificates with the OIDs listed above!
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.4", 4, "NETKEY" ] // Platinum - MyDoctor
+];
+
+function PolicyToKeyType(policy)
+{
+ return "ENROLLED";
+}
+
+function OldPolicyToKeyType(policy)
+{
+ var i, j;
+
+ var knownPoliciesIndex = -1;
+
+
+ var policies;
+
+
+ if (policy.indexOf(",")== -1)
+ {
+ policies = new Array(1);
+ policies[0] = policy;
+ }
+ else
+ {
+ policies = policy.split(",");
+ }
+
+ for (j = 0; j < policies.length; j++)
+ {
+ for (i = 0; i < gKnownPolicies.length; i++)
+ {
+ if (gKnownPolicies[i][0] == policies[j])
+ {
+ if (knownPoliciesIndex < gKnownPolicies[i][1])
+ knownPoliciesIndex = i;
+ }
+ }
+ }
+
+ if (knownPoliciesIndex == -1)
+ return "INITIALIZED";
+
+ return gKnownPolicies[knownPoliciesIndex][2];
+}
+
+function BoolToYesNoStr(b)
+{
+ if (b)
+ return "YES";
+ return "NO";
+}
+
+function OnCOOLKeyEnrollmentComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("Enrollment for \"" + KeyToUIString(keyType, keyID) + "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyPINResetComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("PIN Reset was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyFormatComplete(keyType, keyID)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ alert("Format of \"" + KeyToUIString(keyType, keyID)+ "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStateError(keyType, keyID, keyState, errorCode)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+
+ }
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+
+ var typeStr = "Error(" + errorCode + ")";
+
+ var messageStr = " \n\n Server Response: " + MyGetErrorMessage(errorCode) ;
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (keyState == 1004)
+ typeStr = "Enrollment of key (" + keyIDStr + ") failed. " + typeStr + messageStr ;
+ else if (keyState == 1016)
+ typeStr = "Formatting of key (" + keyIDStr + ") failed. " + typeStr + messageStr;
+ else if (keyState == 1010)
+ typeStr = "PIN Reset for key (" + keyIDStr + ") failed. " + typeStr + messageStr;
+ else if (keyState == 1020)
+ typeStr = "Operation for key (" + keyIDStr + ") canceled.";
+
+ alert(typeStr);
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStatusUpdate(progMeterID, statusUpdate)
+{
+ SetProgressMeterValue(progMeterID, statusUpdate);
+ SetProgressMeterStatus(progMeterID, statusUpdate + "%");
+}
+
+function Validate()
+{
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+// screenname = GetScreenNameValue();
+// if (! screenname)
+ // return 0;
+
+ pin = GetPINValue();
+
+ if (! pin)
+ return 0;
+
+// screennamepwd = GetScreenNamePwd();
+
+// if(! screennamepwd)
+ // return 0;
+
+ }
+
+ return 1;
+}
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data,strData)
+{
+ // alert("KeyID: " + keyID + "\n" +
+ // "KeyState: " + keyState + "\n" +
+ // "Data: " + data);
+ //alert("State Change ="+keyState);
+
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ // OnCOOLKeyEnrollmentStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ OnCOOLKeyEnrollmentComplete(keyType, keyID);
+ break;
+ case 1004: // EnrollmentError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1008: // PINResetStart
+ // OnCOOLKeyPINResetStart(keyType, keyID);
+ break;
+ case 1009: // PINResetComplete
+ OnCOOLKeyPINResetComplete(keyType, keyID);
+ break;
+ case 1010: // PINResetError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1014: // FormatStart
+ // OnCOOLKeyFormatStart(keyType, keyID);
+ break;
+ case 1015: // FormatComplete
+ OnCOOLKeyFormatComplete(keyType, keyID);
+ break;
+ case 1016: // FormatError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1017: // BlinkStatus Update?
+ //OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1018:
+ OnCOOLKeyBlinkComplete(keyType, keyID);
+ break;
+ case 1020: // OperationCancelled
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1021: // OperationStatusUpdate
+ OnCOOLKeyStatusUpdate(KeyToProgressBarID(keyType, keyID), data);
+ break;
+
+ case 1022: //Need Auth
+
+
+ gCurKeyID = keyID;
+ gCurKeyType = keyType;
+
+ GetAuthDataFromPopUp(keyType,keyID,strData);
+
+ break;
+
+ }
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+</script>
+
+</head>
+<body onload="InitializeBindingTable();" onunload=cleanup()>
+
+<table width="100%">
+ <tr>
+ <td>
+<img src="../images/logo.gif"> </td>
+ <td>
+ <p class="headerText"><a href="esc.cgi?screenname=">Enterprise Security Client</a></p>
+ </td>
+ <tr>
+</table>
+
+ <br>
+ <table id="BindingTable" width="100%"><tbody>
+ <tr id="HeaderRow">
+ <th><p class="titleText">Key ID</p></th>
+ <th><p class="titleText">Key Status</p></th>
+<!-- <th><p class="titleText">Requires Auth</p></th>
+ <th><p class="titleText">Did Auth</p></th>
+
+-->
+ <th width="100"><p class="titleText">Progress</p></th>
+ </tr>
+ </tbody></table>
+ <form action="esc.cgi">
+ <input type="hidden" id="action" name="action" value="bind">
+ <input type="hidden" id="screenname" name="screenname" value="">
+ <input type="hidden" id="challengedata" name="challengedata" value="QVNDIHJvY2tzIHRoZSBwYXJ0eSE=">
+ <input type="hidden" id="signedchallenge" name="signedchallenge" value="">
+ <input type="hidden" id="signedchallengelength" name="signedchallengelength" value="">
+ <input type="hidden" id="nonce" name="nonce" value="">
+ <input type="hidden" id="noncelength" name="noncelength" value="">
+ <input type="hidden" id="keytype" name="keytype" value="">
+ <input type="hidden" id="keyid" name="keyid" value="">
+ <input type="hidden" id="keylabel" name="keylabel" value="">
+ <br>
+ <table width="100%">
+ <tr>
+ <td valign="center" align="left">
+ <input type="button" id="formatbtn" name="formatbtn" value="Format" onClick="DoFormatCOOLKey();">
+ <!-- <input type="button" id="challengebtn" name="challengebtn" value="Challenge" onClick="DoChallengeSelectedKey();"> -->
+ <input type="button" id="blinkbtn" name="blinkbtn" value="Blink" onClick="DoBlinkCOOLKey();">
+
+ <input type="button" id="canclebtn" name="canclebtn" value="Cancel" onClick="DoCancelOperation();">
+
+
+ <!-- <input type="button" id="helpbtn" name="helpbtn" value="Help" onClick="DoHelp();"> -->
+ </td>
+ </tr>
+ </table>
+ <table width="100%">
+ <tr>
+ <!-- <td valign="center" align="right">
+ <h5><a href="esc.cgi?">Enterprise Security Admin Page</a></h5>
+ </td> -->
+ </tr>
+ </table>
+ </form>
+ <table width="100%">
+ <tr>
+ <td valign="center" align="left" style="width: 200px;">
+ <div id="cylon1" class="cylon" style="width: 200px; height: 10px;">
+ <div id="eye1" class="cylonEye" style="top: 0px; left: 0px; width: 28px; height: 8px; visibility: hidden;"></div>
+ </div>
+ </td>
+ <td valign="center" align="left" id="statusMsg"></td>
+ </tr>
+ </table>
+</body></html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/TokenPin.html b/pki/linux/tps-ui/shared/docroot/esc/TokenPin.html
new file mode 100755
index 000000000..c73d6f108
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/TokenPin.html
@@ -0,0 +1,77 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<html>
+<head>
+<style>
+body {
+ background-color: rgb(32%,71%,75%);
+ font-family: "Arial";
+ font-size: 8pt; }
+</style>
+
+<script language = "Javascript">
+function DoSubmitData()
+{
+ var pin = document.getElementById("tokenpin").value;
+
+ var pin_confirm = document.getElementById("tokenpincf").value;
+
+ if(!pin || !pin_confirm )
+ {
+ alert("Please Enter Valid Token Pin and confirmation value!");
+
+ return;
+ }
+ var parent = window.opener;
+
+ if(parent)
+ {
+ parent.COOLKeySetTokenPin(pin);
+
+ }
+ window.close();
+}
+</script>
+</head>
+<body>
+<b>Please Enter Your Token Pin:</b>
+<form>
+<table>
+<TR>
+<TD align="left">
+<font size=-2>Token Pin:</font><BR>
+<INPUT input type="password" id="tokenpin" name="tokenpin" value="" size=25><BR>
+</TD>
+</TR>
+<TR>
+<TD align="left">
+<font size=-2>Token Pin:(Confirm)</font><br>
+<INPUT type="password" id="tokenpincf" name="tokenpincf" value="" size=25><BR>
+</TD>
+</TR>
+<BR>
+<TR>
+<TD>
+<INPUT type ="button" id="Submit" value="Submit" onClick="DoSubmitData();"
+</TD>
+</TR>
+</table>
+</form>
+</body>
+</html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/demo/EnrollSuccess.html b/pki/linux/tps-ui/shared/docroot/esc/demo/EnrollSuccess.html
new file mode 100644
index 000000000..c266efef4
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/demo/EnrollSuccess.html
@@ -0,0 +1,52 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<link rel=stylesheet href="/demo/style.css" type="text/css">
+<title>Success!</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
+<table width="100%" border="0" cellspacing="0" cellpadding="0" class="logobar">
+ <tr>
+ <td bgcolor="#000000">&nbsp;&nbsp;&nbsp;<img src="/demo/logo.jpg" width="250" height="50"></td>
+ </tr>
+</table>
+
+<p class="bodyText" >
+Congratulations! You have successfully Enrolled your Veracity Investments Security Smartcard! Now that you have enrolled, you will be able to use your smartcard to allow you and only you to log onto the Vercacity Investments On-Line Account Manager.
+
+</p>
+<p class="bodyText">
+
+Begin your journey into the world of safe and secure account access by logging on to the Veracity Investments On-Line Account Manager.
+
+</p>
+
+<!--
+<a href="https://veracity.test.com/login.cgi?">Veracity Investments Account Manager</a></p>
+
+-->
+
+</body>
+
+</html>
+
diff --git a/pki/linux/tps-ui/shared/docroot/esc/demo/GenericAuth.html b/pki/linux/tps-ui/shared/docroot/esc/demo/GenericAuth.html
new file mode 100755
index 000000000..7c3189a10
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/demo/GenericAuth.html
@@ -0,0 +1,538 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<style>
+
+body {
+background: #ffffff url(../images/bg.jpg) repeat-x;
+ font-family: arial;
+ font-size: 7pt;
+
+}
+
+h1
+{
+ text-align: left;
+
+ font-weight: bold;
+
+ font-size: 13pt;
+
+
+}
+
+
+h2 {
+
+ text-align: left;
+ font-size: 10pt;
+
+ font-weight: lighter;
+}
+
+</style>
+<script language = "Javascript">
+
+var test_ui = "id=USER_ID&name=User ID&desc=User ID&type=string&option=option1,option2,option3&&id=USER_PWD&name=User Password&desc=User Password&type=password&option=&&id=USER_PIN&name=PIN&desc=One time PIN received via mail&type=password&option=";
+
+var theForm = null;
+var curKeyID = null;
+var curKeyType = 0;
+
+
+var gTitle = null;
+var gDescription = null;
+
+
+
+function ConfirmPassword(password_element)
+{
+
+ if(!password_element)
+ return 0;
+
+ password_id = password_element.id;
+
+ if(!password_id)
+ return 0;
+
+ confirm_id = "RE_" + password_element.id;
+
+ var size = theForm.length;
+
+ if(theForm)
+ {
+ for(i = 0; i < size ; i++)
+ {
+ var cur_element = theForm.elements[i];
+
+ if(cur_element.id == confirm_id)
+ {
+ if(cur_element.value != password_element.value)
+ {
+ alert("Value " + password_element.name + " must match " + cur_element.name);
+ return 0;
+
+ }
+ else
+ {
+ return 1;
+ }
+
+ }
+
+ }
+
+ }
+
+ return 1;
+}
+
+function Validate()
+{
+ if(theForm)
+ {
+ var size = theForm.length;
+
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ if(element.type == "text" )
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+ }
+
+ if(element.type == "password")
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+
+ if(!ConfirmPassword(element))
+ {
+ return 0;
+ }
+
+ }
+ }
+
+ }
+
+ return 1;
+}
+
+function FormSubmit()
+{
+ var result = Validate();
+
+ var thisParent = window.opener;
+
+ if(!parent)
+ {
+ alert("No parent window.");
+ window.close();
+ return;
+ }
+
+ if(!result)
+ {
+ return;
+ }
+
+ if(theForm)
+ {
+ var size = theForm.length;
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ var value = element.value;
+
+ if(element.type == "text" )
+ {
+ var id = element.id;
+ value = element.value;
+
+ if(thisParent)
+ {
+ //alert("about to set data value key " + curKeyID + " id " + id + " value " + value);
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,id,value);
+
+ }
+ }
+
+ if(element.type == "password")
+ {
+ var p_id = new String(element.id);
+
+ if(p_id.indexOf("RE_") == -1)
+ {
+ if(thisParent)
+ {
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,p_id,value);
+ }
+ }
+ }
+ }
+
+ }
+
+ window.close();
+}
+
+function GetUIObjectList(uiData)
+{
+ var str = new String(uiData);
+ var splits = str.split("&&");
+
+// alert("Get " + splits + " len " + splits.length);
+
+ var params = new Array();
+ var size = splits.length;
+
+ for(i = 0 ; i < size ; i++)
+ {
+ params[i] = splits[i].split("&");
+ }
+
+ size = params.length;
+ var name_value_objects = new Array();
+
+ for(i = 0 ; i < size; i++)
+ {
+ var name_values = new Array();
+
+ pISize = params[i].length;
+ for(j = 0 ; j < pISize ; j ++)
+ {
+ var pair = params[i][j].split("=");
+
+ //alert(" pair " + pair[0] + " pair1 " + pair[1]);
+
+ if(pair[0] == "option")
+ {
+ var options = pair[1].split(",");
+ }
+
+ name_values[pair[0]] = pair[1];
+ }
+
+ name_value_objects[i] = name_values;
+ }
+
+ return name_value_objects;
+
+}
+
+function AddBRToNode(theNode)
+{
+
+ if(!theNode)
+ return;
+
+ var br = document.createElement("br");
+
+ theNode.appendChild(br);
+
+}
+
+function AddTextToNode(theNode,theText)
+{
+
+ if(!theNode || !theText)
+ return;
+
+
+ var text = document.createTextNode(theText);
+
+ theNode.appendChild(text);
+
+
+
+
+}
+function AddTextToDocument(theText)
+{
+ if(!theText)
+ return;
+
+ var p = document.createElement("p");
+
+ if(p)
+ {
+ p.appendChild(document.createTextNode(theText));
+ }
+
+ document.body.appendChild(p);
+}
+
+function CreateForm()
+{
+ var form = document.createElement("form");
+ document.body.appendChild(form);
+ return form;
+}
+
+function CreateTable()
+{
+ var table = document.createElement("table");
+ document.body.appendChild(table);
+ tbody = document.createElement("tbody");
+ table.appendChild(tbody);
+
+ return table;
+}
+
+function AddRowToTable(table)
+{
+ if(!table)
+ return null;
+
+ var tr = document.createElement("tr");
+ (table.tBodies[0]).appendChild(tr);
+
+ return tr;
+}
+
+function AddColumnToRow(row)
+{
+ if(!row)
+ return null;
+
+ var td = document.createElement("td");
+ row.appendChild(td);
+
+ return td;
+}
+
+function AddTextToColumn(column,text)
+{
+ if(!column || !text)
+ return;
+
+ var text_node = document.createTextNode(text);
+ column.appendChild(text_node);
+
+ return text_node;
+}
+
+function AddInputField(type,id, name,value)
+{
+ var field = document.createElement("input");
+
+ if(!field)
+ return null;
+
+ field.type = type;
+ field.id =id;
+ field.name =name;
+ field.value =value;
+
+ return field;
+}
+
+function ConstructUI(aKeyType,aKeyID,uiData)
+{
+
+ //alert("Construct UI data " + uiData);
+ var name_value_objects = GetUIObjectList(uiData);
+ var len = name_value_objects.length;
+
+ gTitle = document.createElement("h1");
+
+ gDescription = document.createElement("h2");
+
+
+ document.body.appendChild(gTitle);
+
+
+ document.body.appendChild(gDescription);
+
+
+ form = CreateForm();
+ theForm = form;
+ curKeyID = aKeyID;
+ curKeyType = aKeyType;
+
+ table = CreateTable();
+
+ form.appendChild(table);
+
+ for(i = 0 ; i < len ; i ++)
+ {
+ curParameter = name_value_objects[i];
+
+ if(curParameter)
+ {
+
+ title = curParameter["title"];
+
+
+ if(title)
+ {
+ //alert("title " + title);
+
+ AddTextToNode(gTitle,title);
+
+
+ }
+
+ description = curParameter["description"];
+
+ if(description)
+ {
+ AddBRToNode(document.body);
+ AddBRToNode(document.body);
+
+ AddTextToNode(gDescription,description);
+
+ AddBRToNode(document.body);
+
+ }
+
+ id = curParameter["id"];
+ name = curParameter["name"];
+ type = curParameter["type"];
+ desc = curParameter["desc"];
+
+ //alert(" id " + id + " name " + name + " type " + type + " desc " + desc);
+
+ if(id)
+ {
+ if(table)
+ {
+ row = AddRowToTable(table);
+ }
+
+ if(row)
+ {
+ column = AddColumnToRow(row);
+ }
+
+ if(column)
+ {
+ AddTextToColumn(column,name);
+ }
+
+ if(type == "string" || type == "integer")
+ {
+ field = AddInputField("text",id,name,"");
+ }
+
+ re_field = null;
+
+ if(type == "password")
+ {
+ field = AddInputField("password",id,name,"");
+ }
+
+ if(type == "hidden")
+ {
+ field = AddInputField("hidden",id,name,"");
+ }
+
+ if(field)
+ {
+ field_col = AddColumnToRow(row);
+ if(field_col)
+ {
+ field_col.appendChild(field);
+ }
+ }
+
+ if(re_field)
+ {
+ re_text = AddColumnToRow(row);
+
+ if(re_text)
+ {
+ AddTextToColumn(re_text,"Confirm " + name);
+ re_field_col = AddColumnToRow(row);
+ if(re_field_col)
+ {
+ re_field_col.appendChild(re_field);
+ }
+
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ var last_row = AddRowToTable(table);
+
+ if(last_row)
+ {
+ var button_field = AddColumnToRow(last_row);
+
+ if(button_field)
+ {
+ var button = AddInputField("button","Submit","Submit","Submit");
+ button.onclick = FormSubmit;
+ button_field.appendChild(button);
+
+ }
+
+ }
+}
+
+function UiLoad()
+{
+
+
+ var thisParent = window.opener;
+
+
+ if(!thisParent)
+ {
+ alert("Auth dialog has no parent!");
+ return;
+ }
+
+ var keyID = this.name;
+
+ var ui = thisParent.getUIForKey(keyID);
+
+ var type = thisParent.getTypeForKey(keyID);
+
+ //alert("UiLoad " + ui);
+
+ if(ui)
+ {
+ ConstructUI(type,keyID,ui);
+ }
+}
+
+</script>
+</head>
+<body onload = "UiLoad()">
+</body>
+</html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/demo/logo.jpg b/pki/linux/tps-ui/shared/docroot/esc/demo/logo.jpg
new file mode 100644
index 000000000..7cb31affc
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/demo/logo.jpg
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/demo/style.css b/pki/linux/tps-ui/shared/docroot/esc/demo/style.css
new file mode 100755
index 000000000..e9d7d9bf7
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/demo/style.css
@@ -0,0 +1,214 @@
+/* --- BEGIN COPYRIGHT BLOCK ---
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Copyright (C) 2007 Red Hat, Inc.
+ * All rights reserved.
+ * --- END COPYRIGHT BLOCK ---
+ */
+
+body {
+background-color: grey;
+ font-family: arial;
+ font-size: 7p
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+h2 {
+ font-size: 12pt;
+}
+
+.logobar {
+
+ background-color:black;
+ font-family: "Arial";
+ font-size: 7p;
+
+}
+
+.headerText {
+ font-family: "Arial";
+ font-size: 14pt;
+ font-weight: bold;
+ color: white;
+}
+
+.titleText {
+ font-family: "Arial";
+ font-size: 10pt;
+}
+
+.bodyText {
+ font-family: "Arial";
+ font-size: 10pt;
+ color: white;
+}
+
+.formText {
+ font-family: "Arial";
+ font-size: 9pt;
+ color: black;
+
+}
+
+.linkText {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+#BindingTable {
+ background-color: #ffffff ;
+ font-size: 7pt;
+}
+
+#BindingTable th {
+ color: rgb(0, 0, 0);
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+#BindingTable tr {
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+tr [COOLKeyPresent="yes"]{
+ background-color: rgb(255, 0, 0);
+}
+
+.cylon {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+}
+
+.cylonEye {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+}
+
+#statusMsg {
+ font-weight: bold;
+}
+
+.ProgressMeter {
+ position: relative;
+ padding: 0px;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+ text-align: center;
+}
+
+.ProgressBar {
+ position: absolute;
+ z-index: 0;
+ top: 0px;
+ left: 0px;
+ border-right: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+ margin: 0px;
+}
+
+.ProgressBarStatus {
+ position: relative;
+ z-index: 10;
+ margin: 0px;
+ padding: 0px;
+
+}
+
+.KeyTableHeader {
+ color: rgb(0,0, 0);
+ background-color: #ffffff;
+ text-align: left;
+}
+
+#KeyTable td {
+ background-color: #ffffff;
+ padding-left: 3px;
+ padding-right: 3px;
+};
+
+.TableDescriptionPanel {
+ background-color: #ffffff);
+ margin-right: 5px;
+ margin-left: 5px;
+ margin-bottom: 0px;
+ margin-bottom: 5px;
+ padding: 5px;
+}
+
+.PurchasePanel {
+ width: 100%;
+ text-align: center;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+
+.NeedQuestionText {
+ font-size: 16pt;
+ font-weight: bold;
+}
+
+.COOLHeaderText {
+ font-family: "Arial";
+ font-size: 20pt;
+ font-weight: bold;
+}
+
+.ContentTable {
+ background-color: #ffffff;
+ margin: 0px;
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+
+table {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+.TableTitle {
+ font-size: 12pt;
+ font-weight: bold;
+}
+
+.PageHeader {
+ width: 100%;
+ border-bottom: solid black 1px;
+ vertical-align: center;
+ background-color: #ffffff;
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/demo/util.js b/pki/linux/tps-ui/shared/docroot/esc/demo/util.js
new file mode 100755
index 000000000..f4a854fd3
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/demo/util.js
@@ -0,0 +1,1504 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA
+//
+// Copyright (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+//
+// initialize netkey globals
+var netkey;
+
+
+var keyUITable = new Array();
+var keyTypeTable = new Array();
+var curChildWindow = null;
+
+var gWindow = null;
+
+const ErrorText = "For additional assistance contact Veracify Investments Technical Support at 1-555-555-VERACI";
+
+
+function getUIForKey(aKeyID)
+{
+ return keyUITable[aKeyID];
+
+}
+
+function getTypeForKey(aKeyID)
+{
+ return keyTypeTable[aKeyID];
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData,strData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ MyAlert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+ gNotify = new jsNotify;
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+}
+
+var gScreenName = "";
+var gKeyEnrollmentType = "userKey";
+
+var gCurrentSelectedRow = null;
+
+
+var gCurKeyType = null;
+var gCurKeyID = null;
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+
+// List of Error Messages to be printed out
+
+var Status_Messages = new Array(
+
+ "Operation Completed Successfully.",
+ "Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Problem communicating with the smartcard.",
+ "Problem resetting smartcard's pin.",
+ "Internal Smartcard Server error.",
+ "Internal Smartcard Server error.",
+ "Smartcard enrollment error.",
+ "Can not communicate with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the Certificattion Authority.",
+ "Internal Smartcard Server error.",
+ "Error resetting the smartcard's password.",
+ "Internal Smartcard Server error.",
+ "Smartcard Server authentication failure.",
+ "Internal Smartcard Server error.",
+ "Your Smartcard is listed as disabled.",
+ "Problem communicating with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Cannot upgrade smartcard software.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Invalid smartcard type.",
+ "Invalid smartcard type.",
+ "Cannot publish smartcard information.",
+ "Cannot communicate with smartcard database.",
+ "Smartcard is disabled.",
+ "Cannot reset password value for the smartcard.",
+ "Connection to Smartcard Server lost.",
+ "Cannot create entry for smartcard in smartcard database.",
+ "Smartcard found to be in an inconsistent state.",
+ "Invalid reason for lost smartcard submitted.",
+ "Smartcard found to be unusable due to compromise.",
+ "No such inactive smartcard found.",
+ "Cannot process more than one active smartcard.",
+ "Internal Smartcard Server error.",
+ "Smartcard key recovery has been processed.",
+ "Smartcard key recovery failed.",
+ "Cannot process this smartcard, which has been reported lost.",
+ "Smartcard key archival error.",
+ "Problem connecting to the Smartcard TKS Server.",
+ "Failed to update smartcard database.",
+ "Internal certificate revocation error discovered.",
+ "User does not own this smartcard.",
+ "Smart Card Manager has been misconfigured.",
+ "Smart Card Manager can not talk to smart card reader.",
+ "Smart Card Manager can not establish a session with the smart card.",
+ "Smart Card Manager can not talk to Smart Card Server.",
+ "Smart Card Manager can not talk to smart card reader."
+ );
+
+function GetAuthDataFromPopUp(aKeyType,aKeyID,aUiData)
+{
+
+ keyUITable[aKeyID] = aUiData;
+ keyTypeTable[aKeyID] = aKeyType;
+
+ //alert("GetAuthDataFromPopUp data " + aUiData);
+ var child = window.open("/GenericAuth.html",aKeyID,"height=400,width=400");
+
+ //alert("Attempted to create child window " + child);
+
+ curChildWindow = child;
+
+}
+
+function COOLKeySetDataValue(aKeyType,aKeyID,name,value)
+{
+ //alert("In COOLKeySetDataValue aKeyType " + aKeyType + " aKeyID " + aKeyID + " name " + name + " value " + value);
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(aKeyType,aKeyID,name,value);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+
+}
+
+function COOLKeySetTokenPin(pin)
+{
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"TokenPin",pin);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+}
+
+function COOLKeySetUidPassword(uid,pwd)
+{
+
+ if(netkey)
+ {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"UserId",uid);
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"Password",pwd);
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+
+ }
+
+}
+
+
+function MyGetErrorMessage(status_code)
+{
+
+ var result = "Internal Server Error";
+
+ if(status_code < 0 && status_code >= Status_Messages.length)
+ {
+ return result;
+
+ }
+
+ return Status_Messages[status_code];
+
+}
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function ReportException(msg, e)
+{
+ MyAlert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetCOOLKeyStatus(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyStatus(keyType, keyID);
+ } catch (e) {
+ ReportException("netkey.GetCOOLKeyStatus() failed!", e);
+ return 0;
+ }
+}
+
+function GetCOOLKeyPolicy(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyPolicy(keyType, keyID);
+ } catch (e) {
+ // ReportException("netkey.GetCOOLKeyPolicy() failed!", e);
+ return "";
+ }
+}
+
+function GetCOOLKeyRequiresAuth(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyRequiresAuthentication(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyRequiresAuthentication() failed!", e);
+ return false;
+ }
+}
+
+function GetCOOLKeyIsAuthed(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsAuthenticated(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsAuthenticated() failed!", e);
+ return false;
+ }
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableCoolKeys() failed!", e);
+ return [];
+ }
+}
+
+function EnrollCOOLKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.EnrollCoolKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.EnrollCoolKey() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+function GetCOOLKeyIsEnrolled(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsEnrolled(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsEnrolled() failed!", e);
+ return false;
+ }
+}
+
+function CancelCOOLKeyOperation(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.CancelCoolKeyOperation(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.CancelCoolKeyOperation() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function MyAlert(message)
+{
+ if(message)
+ DoMyAlert(message,"Veracify Investments");
+
+}
+function DoMyAlert(message,title)
+{
+
+ if(!message || !title)
+ return;
+
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+
+
+ prompts.alert(window,title,message);
+
+ } catch(e) {
+
+
+ alert("Problem with nsIPromptService " + e);
+ }
+
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ table.deleteRow(row.rowIndex);
+}
+
+function GetCell(row, index)
+{
+ var cell;
+
+ cell = row.cells[index];
+ return cell;
+}
+
+function GetNode(parent, index)
+{
+ var node;
+ node = parent.childNodes[index];
+ return node;
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ row = table.insertRow(table.rows.length);
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ cell = row.insertCell(row.cells.length);
+ return cell;
+}
+
+function RemoveAllChildNodes(parent)
+{
+ var numChildren = parent.childNodes.length;
+ var i;
+
+ i = numChildren;
+ while (numChildren)
+ {
+ parent.removeChild(GetNode(parent,0));
+ numChildren--;
+ }
+
+}
+
+
+function UpdateInfoForKeyID(keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return;
+
+ var cell = GetCell(row,1)
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+// cell = GetCell(row,2);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ // cell = GetCell(row,3);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(isAuthed));
+}
+
+function GetStatusForKeyID(keyType, keyID)
+{
+ var keyStatus = "BLANK";
+
+ var status;
+
+ try {
+ status = GetCOOLKeyStatus(keyType, keyID);
+ } catch(e) {
+ status = 0;
+ }
+
+ switch (status) {
+ case 0: // Unavailable
+ keyStatus = "UNAVAILABLE";
+ break;
+ case 1: // AppletNotFound
+ keyStatus = "NO APPLET";
+ break;
+ case 2: // Uninitialized
+ keyStatus = "UNINITIALIZED";
+ break;
+ case 3: // Unknown
+ keyStatus = "UNKNOWN";
+ break;
+ case 4: // Available
+ case 6: // UnblockInProgress
+ case 7: // PINResetInProgress
+ case 8: // RenewInProgress
+ keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ break;
+ case 5: // EnrollmentInProgress
+ keyStatus = "BUSY";
+ break;
+ break;
+ case 9: // FormatInProgress
+ keyStatus = "BUSY";
+ break;
+ }
+
+ return keyStatus;
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ gWindow = window;
+ if (!row)
+ {
+ var table = document.getElementById("BindingTable");
+ if (table)
+ {
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ row = CreateTableRow(table, keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ }
+
+ if (!row)
+ return null;
+ }
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ {
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(arr[i][0], arr[i][1]);
+ }
+}
+
+function InitializeBindingTable()
+{
+ UpdateBindingTableAvailability();
+ UpdateButtonStates();
+}
+
+function KeyIsPresent(keyType, keyID)
+{
+ row = document.all.item(keyType, keyID);
+
+ if (!row)
+ return false;
+
+ return true;
+}
+
+function SetStatusMessage(str)
+{
+ var cell = document.getElementById("statusMsg");
+
+ if (!cell)
+ return;
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(str));
+}
+
+function UpdateButtonStates()
+{
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+
+ document.getElementById("enrollbtn").disabled = false;
+ }
+ else
+ {
+ document.getElementById("enrollbtn").disabled = true;
+ }
+
+ refresh();
+}
+
+function SetEnrollmentType(type)
+{
+ gKeyEnrollmentType = type;
+ UpdateButtonStates();
+}
+
+function FindRow(node)
+{
+ while (node && node.tagName != "TR")
+ {
+ node = node.parentNode;
+ }
+
+ return node;
+}
+
+function SelectRow(row)
+{
+ if (!row || gCurrentSelectedRow == row)
+ return;
+
+ if (gCurrentSelectedRow)
+ gCurrentSelectedRow.removeAttribute("style");
+
+ gCurrentSelectedRow = row;
+ gCurrentSelectedRow.style.backgroundColor="rgb(200,200,200)";
+ UpdateButtonStates();
+}
+
+function SelectRowByKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ SelectRow(row);
+}
+
+function DoSelectRow(event)
+{
+ var row;
+
+ row = FindRow(event.parentNode);
+ SelectRow(row);
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+
+
+function CreateTableRow(table, keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+ row.onclick = DoSelectRow;
+
+ // Create the key ID cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(KeyToUIString(keyType, keyID)));
+
+ //cell.setAttribute("onClick", "DoSelectRow(this);");
+
+ // Create the keyStatus cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(keyStatus));
+
+ // Create the requires auth cell.
+ // cell = InsertCell(row);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode("Enrollment Progress"));
+
+ // Create the status bar cell
+
+ cell = InsertCell(row);
+
+ var progressMeter = document.createElement("div");
+ progressMeter.setAttribute("id", KeyToProgressBarID(keyType, keyID));
+ progressMeter.className = "ProgressMeter";
+ progressMeter.style.width = "100px";
+ progressMeter.style.height = "1.5em";
+// progressMeter.style.visibility = "hidden";
+ progressMeter.setAttribute("value", 0);
+
+ var progressBar = document.createElement("div");
+ progressBar.className = "ProgressBar";
+ progressBar.style.width = "0px";
+ progressBar.style.height = "100%";
+// progressBar.style.visibility = "hidden";
+
+ var progressBarStatus = document.createElement("div");
+ progressBarStatus.className = "ProgressBarStatus";
+ progressBarStatus.appendChild(document.createTextNode(""));
+
+ progressMeter.appendChild(progressBar);
+ progressMeter.appendChild(progressBarStatus);
+ cell.appendChild(progressMeter);
+
+ //row.style.display ="none";
+
+ return row;
+}
+
+gAnimationMSecs = 1000/30;
+
+function SetCylonTimer(cylonID, cylonEyeID)
+{
+ setTimeout("AnimateCylonStatusBar(\"" + cylonID +
+ "\", \"" + cylonEyeID + "\");", gAnimationMSecs);
+}
+
+function AnimateCylonStatusBar(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID);
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ return;
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (!eye)
+ return;
+
+ var dir = eye.getAttribute("direction");
+ var wid = parseInt(eye.style.width);
+ var cywid = parseInt(cylon.style.width);
+ var left = parseInt(eye.style.left);
+
+ var dx = 10;
+
+ if (!dir || dir >= 0)
+ {
+ left += dx;
+
+ if (left + wid > cywid)
+ {
+ left = cywid - wid;
+ eye.setAttribute("direction", "-1");
+ }
+ }
+ else
+ {
+ left -= dx;
+
+ if (left < 0)
+ {
+ left = 0;
+ eye.setAttribute("direction", "1");
+ }
+ }
+
+ eye.style.left = left + "px";
+
+ SetCylonTimer(cylonID, cylonEyeID);
+}
+
+function StartCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ {
+ cylon.setAttribute("cylonactive", "true");
+
+ var eye = document.getElementById(cylonEyeID);
+ if (eye)
+ {
+ eye.style.left = "0px";
+ eye.style.visibility = "visible";
+ }
+
+ SetCylonTimer(cylonID, cylonEyeID);
+ }
+}
+
+function StopCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (cylon)
+ cylon.removeAttribute("cylonactive");
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (eye)
+ eye.style.visibility = "hidden";
+}
+
+function GetProgressMeterValue(progMeterID)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return -1;
+
+ return parseInt(progMeter.getAttribute("value"));
+}
+
+function SetProgressMeterValue(progMeterID, value)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter || value < 0)
+ return;
+
+ if (value > 100)
+ value = 100;
+
+ var progBar = progMeter.firstChild;
+
+ if (value == 0)
+ {
+ progBar.style.width = "0px";
+ progBar.style.visibility = "hidden";
+ progMeter.setAttribute("value", 0);
+ return;
+ }
+
+ progBar.style.visibility = "visible";
+
+ var newWidth = parseInt(progMeter.style.width) * value / 100 - 2;
+
+ progBar.style.width = newWidth + "px";
+ progMeter.setAttribute("value", value);
+}
+
+function SetProgressMeterStatus(progMeterID, statusMsg)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return;
+
+ var progBar = progMeter.firstChild;
+
+ // If it exists, the meter status should be
+ // div that is the next sibling of the progressMeter.
+
+ var meterStatus = progBar.nextSibling;
+
+ // Just replace the data in the text node, it's much faster,
+ // and reduces flashing!
+
+ meterStatus.firstChild.replaceData(0, meterStatus.firstChild.length, statusMsg);
+}
+
+function ClearProgressBar(progMeterID)
+{
+ SetProgressMeterValue(progMeterID, 0);
+ SetProgressMeterStatus(progMeterID, "");
+}
+
+function KeyToProgressBarID(keyType, keyID)
+{
+ return "PM" + keyType + "-" + keyID;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ESC native code.
+//
+// ESC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.EnrollCOOLKey(keyType, keyID, enrollmentType, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass "houseKey" as the enrollmentType, and null values for both
+// screenName and pin. For a NetKey, use "netKey" as the enrollmentType,
+// and pass a valid screenName and pin.
+//
+//
+////////////////////////////////////////////////////////////////
+
+function GetScreenNameValue()
+{
+ var sname = document.getElementById("snametf").value;
+
+ if (! sname)
+ {
+ MyAlert("You must provide a valid Veracify Account Name!");
+ return null;
+ }
+
+ return sname;
+}
+
+function GetPINValue()
+{
+ var pinVal = document.getElementById("pintf").value;
+ var rpinVal = document.getElementById("reenterpintf").value;
+
+ if (! pinVal)
+ {
+ MyAlert("You must provide a valid Veracify Key Password!");
+ return null;
+ }
+
+ if ( pinVal != rpinVal)
+ {
+ MyAlert("The Veracify Key Password values you entered do not match!");
+ return null;
+ }
+
+ return pinVal;
+}
+
+function GetScreenNamePwd()
+{
+
+ var pwd = document.getElementById("snamepwd").value;
+
+ if(!pwd)
+ {
+ MyAlert("You must provide a valid Veracify Account Number !");
+ return null;
+ }
+ return pwd;
+}
+
+function GetTokenCode()
+{
+
+ return null;
+}
+function DoEnrollCOOLKey()
+{
+
+ if (!gCurrentSelectedRow)
+ {
+ MyAlert("Please select a key.");
+ return;
+ }
+
+
+ if(!Validate())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = GetScreenNamePwd();
+
+ tokencode = GetTokenCode();
+
+ //SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+ }
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ var doShow = true;
+
+ ShowProgressBar(keyType,keyID,doShow );
+
+ if (!EnrollCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(aKeyType,aKeyID,doShow );
+ }
+}
+
+function DoResetSelectedCOOLKeyPIN()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate())
+ return;
+
+ //alert("In DoResetSelectedCOOLKeyPIN!");
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var screenname = null;
+ var pin = null;
+ var screennamepwd = null;
+
+ if (GetCOOLKeyIsEnrolled(keyType, keyID))
+ {
+
+ SetStatusMessage("Resetting PIN for \"" + keyID + "\"...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+ }
+}
+
+function DoFormatCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+
+ if(!Validate())
+ return;
+
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+function DoCancelOperation()
+{
+
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ SetStatusMessage("Cancel operation for \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ CancelCOOLKeyOperation(keyType, keyID);
+
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+}
+
+function DoChallengeSelectedKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Generating Challenge ...");
+
+ var challengeArray = ChallengeCOOLKey(keyType, keyID, document.forms[0].challengedata.value);
+
+ if (challengeArray.length != 4)
+ {
+ MyAlert("Challenge for key \"" + KeyToUIString(keyType, keyID) + "\" failed!");
+ SetStatusMessage("");
+ return;
+ }
+
+ MyAlert("ChallengeCOOLKey(\""+ KeyToUIString(keyType, keyID) + "\") returned:\n\n" +
+ "challenge[0]: " + challengeArray[0] + "\n" +
+ "challenge[1]: " + challengeArray[1] + "\n" +
+ "challenge[2]: " + challengeArray[2] + "\n" +
+ "challenge[3]: " + challengeArray[3] + "\n");
+
+ SetStatusMessage("");
+}
+
+function DoBlinkCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Blinking \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+}
+
+function OnCOOLKeyBlinkComplete(keyType,keyID)
+{
+ //StopCylonAnimation("cylon1", "eye1");
+ //SetStatusMessage(" ");
+}
+
+function DoHelp()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ var policy = GetCOOLKeyPolicy(keyType, keyID);
+ var type = PolicyToKeyType(policy);
+ MyAlert("Policy: " + policy + "\n" + "Type: " + type);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions called directly from ASC native code.
+//
+////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(keyType, keyID);
+}
+
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("BindingTable");
+
+ if (row && table)
+ {
+ RemoveRow(table,row);
+
+ if (row == gCurrentSelectedRow)
+ gCurrentSelectedRow = null;
+ }
+
+ UpdateButtonStates();
+}
+
+var gKnownPolicies = [
+
+ // OID Value, precedence, name value
+
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4", 4, "NETKEY" ], // Platinum - MyDoctor
+
+ // XXX: Remove the Old OIDs below, after the RA starts generating
+ // certificates with the OIDs listed above!
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.4", 4, "NETKEY" ] // Platinum - MyDoctor
+];
+
+function PolicyToKeyType(policy)
+{
+ return "ENROLLED";
+}
+
+function OldPolicyToKeyType(policy)
+{
+ var i, j;
+
+ var knownPoliciesIndex = -1;
+
+
+ var policies;
+
+
+ if (policy.indexOf(",")== -1)
+ {
+ policies = new Array(1);
+ policies[0] = policy;
+ }
+ else
+ {
+ policies = policy.split(",");
+ }
+
+ for (j = 0; j < policies.length; j++)
+ {
+ for (i = 0; i < gKnownPolicies.length; i++)
+ {
+ if (gKnownPolicies[i][0] == policies[j])
+ {
+ if (knownPoliciesIndex < gKnownPolicies[i][1])
+ knownPoliciesIndex = i;
+ }
+ }
+ }
+
+ if (knownPoliciesIndex == -1)
+ return "INITIALIZED";
+
+ return gKnownPolicies[knownPoliciesIndex][2];
+}
+
+function BoolToYesNoStr(b)
+{
+ if (b)
+ return "YES";
+ return "NO";
+}
+
+function OnCOOLKeyEnrollmentComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+ SetStatusMessage("");
+ MyAlert("Enrollment of smartcard complete!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+
+ window.setTimeout("loadSuccessPage()",4);
+}
+
+function OnCOOLKeyPINResetComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Password Reset was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyFormatComplete(keyType, keyID)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Format of \"" + KeyToUIString(keyType, keyID)+ "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStateError(keyType, keyID, keyState, errorCode)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+
+ }
+
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+
+ var typeStr = "Error(" + errorCode + ")";
+
+ var messageStr = " \n\n Error Response: " + MyGetErrorMessage(errorCode) ;
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (keyState == 1004)
+ typeStr = "Enrollment of key failed. " + typeStr + messageStr ;
+ else if (keyState == 1016)
+ typeStr = "Formatting of key failed. " + typeStr + messageStr;
+ else if (keyState == 1010)
+ typeStr = "PIN Reset for key failed. " + typeStr + messageStr;
+ else if (keyState == 1020)
+ typeStr = "Operation for key canceled.";
+
+ typeStr += " \n " + ErrorText;
+ MyAlert(typeStr);
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStatusUpdate(progMeterID, statusUpdate)
+{
+ SetProgressMeterValue(progMeterID, statusUpdate);
+ SetProgressMeterStatus(progMeterID, statusUpdate + "%");
+}
+
+function Validate()
+{
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = GetScreenNameValue();
+ if (! screenname)
+ return 0;
+
+ screennamepwd = GetScreenNamePwd();
+
+ if(! screennamepwd)
+ return 0;
+
+ pin = GetPINValue();
+
+ if (! pin)
+ return 0;
+
+ }
+
+ return 1;
+}
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data,strData)
+{
+ // alert("KeyID: " + keyID + "\n" +
+ // "KeyState: " + keyState + "\n" +
+ // "Data: " + data);
+ //alert("State Change ="+keyState);
+
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ // OnCOOLKeyEnrollmentStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ OnCOOLKeyEnrollmentComplete(keyType, keyID);
+ break;
+ case 1004: // EnrollmentError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1008: // PINResetStart
+ // OnCOOLKeyPINResetStart(keyType, keyID);
+ break;
+ case 1009: // PINResetComplete
+ OnCOOLKeyPINResetComplete(keyType, keyID);
+ break;
+ case 1010: // PINResetError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1014: // FormatStart
+ // OnCOOLKeyFormatStart(keyType, keyID);
+ break;
+ case 1015: // FormatComplete
+ OnCOOLKeyFormatComplete(keyType, keyID);
+ break;
+ case 1016: // FormatError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1017: // BlinkStatus Update?
+ //OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1018:
+ OnCOOLKeyBlinkComplete(keyType, keyID);
+ break;
+ case 1020: // OperationCancelled
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1021: // OperationStatusUpdate
+ OnCOOLKeyStatusUpdate(KeyToProgressBarID(keyType, keyID), data);
+ break;
+
+ case 1022: //Need Auth
+
+
+ gCurKeyID = keyID;
+ gCurKeyType = keyType;
+
+ GetAuthDataFromPopUp(keyType,keyID,strData);
+
+ break;
+
+ }
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+function loadSuccessPage()
+{
+ window.location="/demo/EnrollSuccess.html";
+}
+
+function ShowProgressBar(aKeyType,aKeyID, doShow)
+{
+ if(!gCurrentSelectedRow)
+ return;
+
+ if(doShow)
+ gCurrentSelectedRow.style.display="table-row";
+ else
+ {
+ gCurrentSelectedRow.style.display="none";
+ }
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/home/EnrollSuccess.html b/pki/linux/tps-ui/shared/docroot/esc/home/EnrollSuccess.html
new file mode 100644
index 000000000..57fd1053c
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/home/EnrollSuccess.html
@@ -0,0 +1,47 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<link rel=stylesheet href="/home/style.css" type="text/css">
+<title>Success!</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
+<table width="100%" border="0" cellspacing="0" cellpadding="0" class="logobar">
+ <tr>
+ <td bgcolor="#000000">&nbsp;&nbsp;&nbsp;<img src="/home/logo.jpg" width="250" height="50"></td>
+ </tr>
+</table>
+
+<p class="bodyText" >
+Congratulations! You have successfully Enrolled your Smartcard! Now that you have enrolled, you will be able to use your smartcard to allow you and only you to log onto the available Smartcard-protected services.
+
+</p>
+<p class="bodyText">
+
+Begin your journey into the world of safe and secure account access by logging on to the available Smartcard-protected services.
+
+</p>
+
+</body>
+
+</html>
+
diff --git a/pki/linux/tps-ui/shared/docroot/esc/home/GenericAuth.html b/pki/linux/tps-ui/shared/docroot/esc/home/GenericAuth.html
new file mode 100755
index 000000000..5660a7c50
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/home/GenericAuth.html
@@ -0,0 +1,539 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<style>
+
+body {
+background: #ffffff url(../images/bg.jpg) repeat-x;
+ font-family: arial;
+ font-size: 7pt;
+
+}
+
+h1
+{
+ text-align: left;
+
+ font-weight: bold;
+
+ font-size: 13pt;
+
+
+}
+
+
+h2 {
+
+ text-align: left;
+ font-size: 10pt;
+
+ font-weight: lighter;
+}
+
+</style>
+<script language = "Javascript">
+
+var test_ui = "id=USER_ID&name=User ID&desc=User ID&type=string&option=option1,option2,option3&&id=USER_PWD&name=User Password&desc=User Password&type=password&option=&&id=USER_PIN&name=PIN&desc=One time PIN received via mail&type=password&option=";
+
+var theForm = null;
+var curKeyID = null;
+var curKeyType = 0;
+
+
+var gTitle = null;
+var gDescription = null;
+
+
+
+function ConfirmPassword(password_element)
+{
+
+ if(!password_element)
+ return 0;
+
+ password_id = password_element.id;
+
+ if(!password_id)
+ return 0;
+
+ confirm_id = "RE_" + password_element.id;
+
+ var size = theForm.length;
+
+ if(theForm)
+ {
+ for(i = 0; i < size ; i++)
+ {
+ var cur_element = theForm.elements[i];
+
+ if(cur_element.id == confirm_id)
+ {
+ if(cur_element.value != password_element.value)
+ {
+ alert("Value " + password_element.name + " must match " + cur_element.name);
+ return 0;
+
+ }
+ else
+ {
+ return 1;
+ }
+
+ }
+
+ }
+
+ }
+
+ return 1;
+}
+
+function Validate()
+{
+ if(theForm)
+ {
+ var size = theForm.length;
+
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ if(element.type == "text" )
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+ }
+
+ if(element.type == "password")
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+
+ if(!ConfirmPassword(element))
+ {
+ return 0;
+ }
+
+ }
+ }
+
+ }
+
+ return 1;
+}
+
+function FormSubmit()
+{
+ var result = Validate();
+
+ var thisParent = window.opener;
+
+ if(!parent)
+ {
+ alert("No parent window.");
+ window.close();
+ return;
+ }
+
+ if(!result)
+ {
+ return;
+ }
+
+ if(theForm)
+ {
+ var size = theForm.length;
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ var value = element.value;
+
+ if(element.type == "text" )
+ {
+ var id = element.id;
+ value = element.value;
+
+ if(thisParent)
+ {
+ //alert("about to set data value key " + curKeyID + " id " + id + " value " + value);
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,id,value);
+
+ }
+ }
+
+ if(element.type == "password")
+ {
+ var p_id = new String(element.id);
+
+ if(p_id.indexOf("RE_") == -1)
+ {
+ if(thisParent)
+ {
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,p_id,value);
+ }
+ }
+ }
+ }
+
+ }
+
+ window.close();
+}
+
+function GetUIObjectList(uiData)
+{
+ var str = new String(uiData);
+ var splits = str.split("&&");
+
+// alert("Get " + splits + " len " + splits.length);
+
+ var params = new Array();
+ var size = splits.length;
+
+ for(i = 0 ; i < size ; i++)
+ {
+ params[i] = splits[i].split("&");
+ }
+
+ size = params.length;
+ var name_value_objects = new Array();
+
+ for(i = 0 ; i < size; i++)
+ {
+ var name_values = new Array();
+
+ pISize = params[i].length;
+ for(j = 0 ; j < pISize ; j ++)
+ {
+ var pair = params[i][j].split("=");
+
+ //alert(" pair " + pair[0] + " pair1 " + pair[1]);
+
+ if(pair[0] == "option")
+ {
+ var options = pair[1].split(",");
+ }
+
+ name_values[pair[0]] = pair[1];
+ }
+
+ name_value_objects[i] = name_values;
+ }
+
+ return name_value_objects;
+
+}
+
+function AddBRToNode(theNode)
+{
+
+ if(!theNode)
+ return;
+
+ var br = document.createElement("br");
+
+ theNode.appendChild(br);
+
+}
+
+function AddTextToNode(theNode,theText)
+{
+
+ if(!theNode || !theText)
+ return;
+
+
+ var text = document.createTextNode(theText);
+
+ theNode.appendChild(text);
+
+
+
+
+}
+function AddTextToDocument(theText)
+{
+ if(!theText)
+ return;
+
+ var p = document.createElement("p");
+
+ if(p)
+ {
+ p.appendChild(document.createTextNode(theText));
+ }
+
+ document.body.appendChild(p);
+}
+
+function CreateForm()
+{
+ var form = document.createElement("form");
+ document.body.appendChild(form);
+ return form;
+}
+
+function CreateTable()
+{
+ var table = document.createElement("table");
+ document.body.appendChild(table);
+ tbody = document.createElement("tbody");
+ table.appendChild(tbody);
+
+ return table;
+}
+
+function AddRowToTable(table)
+{
+ if(!table)
+ return null;
+
+ var tr = document.createElement("tr");
+ (table.tBodies[0]).appendChild(tr);
+
+ return tr;
+}
+
+function AddColumnToRow(row)
+{
+ if(!row)
+ return null;
+
+ var td = document.createElement("td");
+ row.appendChild(td);
+
+ return td;
+}
+
+function AddTextToColumn(column,text)
+{
+ if(!column || !text)
+ return;
+
+ var text_node = document.createTextNode(text);
+ column.appendChild(text_node);
+
+ return text_node;
+}
+
+function AddInputField(type,id, name,value)
+{
+ var field = document.createElement("input");
+
+ if(!field)
+ return null;
+
+ field.type = type;
+ field.id =id;
+ field.name =name;
+ field.value =value;
+
+ return field;
+}
+
+function ConstructUI(aKeyType,aKeyID,uiData)
+{
+
+ //alert("Construct UI data " + uiData);
+ var name_value_objects = GetUIObjectList(uiData);
+ var len = name_value_objects.length;
+
+ gTitle = document.createElement("h1");
+
+ gDescription = document.createElement("h2");
+
+
+ document.body.appendChild(gTitle);
+
+
+ document.body.appendChild(gDescription);
+
+
+ form = CreateForm();
+ theForm = form;
+ curKeyID = aKeyID;
+ curKeyType = aKeyType;
+
+ table = CreateTable();
+
+ form.appendChild(table);
+
+ for(i = 0 ; i < len ; i ++)
+ {
+ curParameter = name_value_objects[i];
+
+ if(curParameter)
+ {
+
+ title = curParameter["title"];
+
+
+ if(title)
+ {
+ //alert("title " + title);
+
+ AddTextToNode(gTitle,title);
+
+
+ }
+
+ description = curParameter["description"];
+
+ if(description)
+ {
+ AddBRToNode(document.body);
+ AddBRToNode(document.body);
+
+ AddTextToNode(gDescription,description);
+
+ AddBRToNode(document.body);
+
+ }
+
+ id = curParameter["id"];
+ name = curParameter["name"];
+ type = curParameter["type"];
+ desc = curParameter["desc"];
+
+ //alert(" id " + id + " name " + name + " type " + type + " desc " + desc);
+
+ if(id)
+ {
+ if(table)
+ {
+ row = AddRowToTable(table);
+ }
+
+ if(row)
+ {
+ column = AddColumnToRow(row);
+ }
+
+ if(column)
+ {
+ AddTextToColumn(column,name);
+ }
+
+ if(type == "string" || type == "integer")
+ {
+ field = AddInputField("text",id,name,"");
+ }
+
+ re_field = null;
+
+ if(type == "password")
+ {
+ field = AddInputField("password",id,name,"");
+ }
+
+ if(type == "hidden")
+ {
+ field = AddInputField("hidden",id,name,"");
+ }
+
+ if(field)
+ {
+ field_col = AddColumnToRow(row);
+ if(field_col)
+ {
+ field_col.appendChild(field);
+ }
+ }
+
+ if(re_field)
+ {
+ re_text = AddColumnToRow(row);
+
+ if(re_text)
+ {
+ AddTextToColumn(re_text,"Confirm " + name);
+ re_field_col = AddColumnToRow(row);
+ if(re_field_col)
+ {
+ re_field_col.appendChild(re_field);
+ }
+
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ var last_row = AddRowToTable(table);
+
+ if(last_row)
+ {
+ var button_field = AddColumnToRow(last_row);
+
+ if(button_field)
+ {
+ var button = AddInputField("button","Submit","Submit","Submit");
+ button.onclick = FormSubmit;
+ button_field.appendChild(button);
+
+ }
+
+ }
+}
+
+function UiLoad()
+{
+
+
+ var thisParent = window.opener;
+
+
+ if(!thisParent)
+ {
+ alert("Auth dialog has no parent!");
+ return;
+ }
+
+ var keyID = this.name;
+
+ var ui = thisParent.getUIForKey(keyID);
+
+ var type = thisParent.getTypeForKey(keyID);
+
+ //alert("UiLoad " + ui);
+
+ if(ui)
+ {
+ ConstructUI(type,keyID,ui);
+ }
+}
+
+</script>
+</head>
+<body onload = "UiLoad()">
+</body>
+</html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/home/logo.jpg b/pki/linux/tps-ui/shared/docroot/esc/home/logo.jpg
new file mode 100644
index 000000000..7cb31affc
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/home/logo.jpg
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/home/style.css b/pki/linux/tps-ui/shared/docroot/esc/home/style.css
new file mode 100755
index 000000000..e9d7d9bf7
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/home/style.css
@@ -0,0 +1,214 @@
+/* --- BEGIN COPYRIGHT BLOCK ---
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Copyright (C) 2007 Red Hat, Inc.
+ * All rights reserved.
+ * --- END COPYRIGHT BLOCK ---
+ */
+
+body {
+background-color: grey;
+ font-family: arial;
+ font-size: 7p
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+h2 {
+ font-size: 12pt;
+}
+
+.logobar {
+
+ background-color:black;
+ font-family: "Arial";
+ font-size: 7p;
+
+}
+
+.headerText {
+ font-family: "Arial";
+ font-size: 14pt;
+ font-weight: bold;
+ color: white;
+}
+
+.titleText {
+ font-family: "Arial";
+ font-size: 10pt;
+}
+
+.bodyText {
+ font-family: "Arial";
+ font-size: 10pt;
+ color: white;
+}
+
+.formText {
+ font-family: "Arial";
+ font-size: 9pt;
+ color: black;
+
+}
+
+.linkText {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+#BindingTable {
+ background-color: #ffffff ;
+ font-size: 7pt;
+}
+
+#BindingTable th {
+ color: rgb(0, 0, 0);
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+#BindingTable tr {
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+tr [COOLKeyPresent="yes"]{
+ background-color: rgb(255, 0, 0);
+}
+
+.cylon {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+}
+
+.cylonEye {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+}
+
+#statusMsg {
+ font-weight: bold;
+}
+
+.ProgressMeter {
+ position: relative;
+ padding: 0px;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+ text-align: center;
+}
+
+.ProgressBar {
+ position: absolute;
+ z-index: 0;
+ top: 0px;
+ left: 0px;
+ border-right: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+ margin: 0px;
+}
+
+.ProgressBarStatus {
+ position: relative;
+ z-index: 10;
+ margin: 0px;
+ padding: 0px;
+
+}
+
+.KeyTableHeader {
+ color: rgb(0,0, 0);
+ background-color: #ffffff;
+ text-align: left;
+}
+
+#KeyTable td {
+ background-color: #ffffff;
+ padding-left: 3px;
+ padding-right: 3px;
+};
+
+.TableDescriptionPanel {
+ background-color: #ffffff);
+ margin-right: 5px;
+ margin-left: 5px;
+ margin-bottom: 0px;
+ margin-bottom: 5px;
+ padding: 5px;
+}
+
+.PurchasePanel {
+ width: 100%;
+ text-align: center;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+
+.NeedQuestionText {
+ font-size: 16pt;
+ font-weight: bold;
+}
+
+.COOLHeaderText {
+ font-family: "Arial";
+ font-size: 20pt;
+ font-weight: bold;
+}
+
+.ContentTable {
+ background-color: #ffffff;
+ margin: 0px;
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+
+table {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+.TableTitle {
+ font-size: 12pt;
+ font-weight: bold;
+}
+
+.PageHeader {
+ width: 100%;
+ border-bottom: solid black 1px;
+ vertical-align: center;
+ background-color: #ffffff;
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/home/util.js b/pki/linux/tps-ui/shared/docroot/esc/home/util.js
new file mode 100755
index 000000000..7bc627b44
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/home/util.js
@@ -0,0 +1,1504 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA
+//
+// Copyright (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+//
+// initialize netkey globals
+var netkey;
+
+
+var keyUITable = new Array();
+var keyTypeTable = new Array();
+var curChildWindow = null;
+
+var gWindow = null;
+
+const ErrorText = "For additional assistance contact your Technical Support";
+
+
+function getUIForKey(aKeyID)
+{
+ return keyUITable[aKeyID];
+
+}
+
+function getTypeForKey(aKeyID)
+{
+ return keyTypeTable[aKeyID];
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData,strData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ MyAlert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+ gNotify = new jsNotify;
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+}
+
+var gScreenName = "";
+var gKeyEnrollmentType = "userKey";
+
+var gCurrentSelectedRow = null;
+
+
+var gCurKeyType = null;
+var gCurKeyID = null;
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+
+// List of Error Messages to be printed out
+
+var Status_Messages = new Array(
+
+ "Operation Completed Successfully.",
+ "Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Problem communicating with the smartcard.",
+ "Problem resetting smartcard's pin.",
+ "Internal Smartcard Server error.",
+ "Internal Smartcard Server error.",
+ "Smartcard enrollment error.",
+ "Can not communicate with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the Certificattion Authority.",
+ "Internal Smartcard Server error.",
+ "Error resetting the smartcard's password.",
+ "Internal Smartcard Server error.",
+ "Smartcard Server authentication failure.",
+ "Internal Smartcard Server error.",
+ "Your Smartcard is listed as disabled.",
+ "Problem communicating with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Cannot upgrade smartcard software.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Invalid smartcard type.",
+ "Invalid smartcard type.",
+ "Cannot publish smartcard information.",
+ "Cannot communicate with smartcard database.",
+ "Smartcard is disabled.",
+ "Cannot reset password value for the smartcard.",
+ "Connection to Smartcard Server lost.",
+ "Cannot create entry for smartcard in smartcard database.",
+ "Smartcard found to be in an inconsistent state.",
+ "Invalid reason for lost smartcard submitted.",
+ "Smartcard found to be unusable due to compromise.",
+ "No such inactive smartcard found.",
+ "Cannot process more than one active smartcard.",
+ "Internal Smartcard Server error.",
+ "Smartcard key recovery has been processed.",
+ "Smartcard key recovery failed.",
+ "Cannot process this smartcard, which has been reported lost.",
+ "Smartcard key archival error.",
+ "Problem connecting to the Smartcard TKS Server.",
+ "Failed to update smartcard database.",
+ "Internal certificate revocation error discovered.",
+ "User does not own this smartcard.",
+ "Smart Card Manager has been misconfigured.",
+ "Smart Card Manager can not talk to smart card reader.",
+ "Smart Card Manager can not establish a session with the smart card.",
+ "Smart Card Manager can not talk to Smart Card Server.",
+ "Smart Card Manager can not talk to smart card reader."
+ );
+
+function GetAuthDataFromPopUp(aKeyType,aKeyID,aUiData)
+{
+
+ keyUITable[aKeyID] = aUiData;
+ keyTypeTable[aKeyID] = aKeyType;
+
+ //alert("GetAuthDataFromPopUp data " + aUiData);
+ var child = window.open("/GenericAuth.html",aKeyID,"height=400,width=400");
+
+ //alert("Attempted to create child window " + child);
+
+ curChildWindow = child;
+
+}
+
+function COOLKeySetDataValue(aKeyType,aKeyID,name,value)
+{
+ //alert("In COOLKeySetDataValue aKeyType " + aKeyType + " aKeyID " + aKeyID + " name " + name + " value " + value);
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(aKeyType,aKeyID,name,value);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+
+}
+
+function COOLKeySetTokenPin(pin)
+{
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"TokenPin",pin);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+}
+
+function COOLKeySetUidPassword(uid,pwd)
+{
+
+ if(netkey)
+ {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"UserId",uid);
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"Password",pwd);
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+
+ }
+
+}
+
+
+function MyGetErrorMessage(status_code)
+{
+
+ var result = "Internal Server Error";
+
+ if(status_code < 0 && status_code >= Status_Messages.length)
+ {
+ return result;
+
+ }
+
+ return Status_Messages[status_code];
+
+}
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function ReportException(msg, e)
+{
+ MyAlert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetCOOLKeyStatus(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyStatus(keyType, keyID);
+ } catch (e) {
+ ReportException("netkey.GetCOOLKeyStatus() failed!", e);
+ return 0;
+ }
+}
+
+function GetCOOLKeyPolicy(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyPolicy(keyType, keyID);
+ } catch (e) {
+ // ReportException("netkey.GetCOOLKeyPolicy() failed!", e);
+ return "";
+ }
+}
+
+function GetCOOLKeyRequiresAuth(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyRequiresAuthentication(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyRequiresAuthentication() failed!", e);
+ return false;
+ }
+}
+
+function GetCOOLKeyIsAuthed(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsAuthenticated(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsAuthenticated() failed!", e);
+ return false;
+ }
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableCoolKeys() failed!", e);
+ return [];
+ }
+}
+
+function EnrollCOOLKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.EnrollCoolKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.EnrollCoolKey() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+function GetCOOLKeyIsEnrolled(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsEnrolled(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsEnrolled() failed!", e);
+ return false;
+ }
+}
+
+function CancelCOOLKeyOperation(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.CancelCoolKeyOperation(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.CancelCoolKeyOperation() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function MyAlert(message)
+{
+ if(message)
+ DoMyAlert(message,"Smart Card Manager");
+
+}
+function DoMyAlert(message,title)
+{
+
+ if(!message || !title)
+ return;
+
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+
+
+ prompts.alert(window,title,message);
+
+ } catch(e) {
+
+
+ alert("Problem with nsIPromptService " + e);
+ }
+
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ table.deleteRow(row.rowIndex);
+}
+
+function GetCell(row, index)
+{
+ var cell;
+
+ cell = row.cells[index];
+ return cell;
+}
+
+function GetNode(parent, index)
+{
+ var node;
+ node = parent.childNodes[index];
+ return node;
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ row = table.insertRow(table.rows.length);
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ cell = row.insertCell(row.cells.length);
+ return cell;
+}
+
+function RemoveAllChildNodes(parent)
+{
+ var numChildren = parent.childNodes.length;
+ var i;
+
+ i = numChildren;
+ while (numChildren)
+ {
+ parent.removeChild(GetNode(parent,0));
+ numChildren--;
+ }
+
+}
+
+
+function UpdateInfoForKeyID(keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return;
+
+ var cell = GetCell(row,1)
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+// cell = GetCell(row,2);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ // cell = GetCell(row,3);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(isAuthed));
+}
+
+function GetStatusForKeyID(keyType, keyID)
+{
+ var keyStatus = "BLANK";
+
+ var status;
+
+ try {
+ status = GetCOOLKeyStatus(keyType, keyID);
+ } catch(e) {
+ status = 0;
+ }
+
+ switch (status) {
+ case 0: // Unavailable
+ keyStatus = "UNAVAILABLE";
+ break;
+ case 1: // AppletNotFound
+ keyStatus = "NO APPLET";
+ break;
+ case 2: // Uninitialized
+ keyStatus = "UNINITIALIZED";
+ break;
+ case 3: // Unknown
+ keyStatus = "UNKNOWN";
+ break;
+ case 4: // Available
+ case 6: // UnblockInProgress
+ case 7: // PINResetInProgress
+ case 8: // RenewInProgress
+ keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ break;
+ case 5: // EnrollmentInProgress
+ keyStatus = "BUSY";
+ break;
+ break;
+ case 9: // FormatInProgress
+ keyStatus = "BUSY";
+ break;
+ }
+
+ return keyStatus;
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ gWindow = window;
+ if (!row)
+ {
+ var table = document.getElementById("BindingTable");
+ if (table)
+ {
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ row = CreateTableRow(table, keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ }
+
+ if (!row)
+ return null;
+ }
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ {
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(arr[i][0], arr[i][1]);
+ }
+}
+
+function InitializeBindingTable()
+{
+ UpdateBindingTableAvailability();
+ UpdateButtonStates();
+}
+
+function KeyIsPresent(keyType, keyID)
+{
+ row = document.all.item(keyType, keyID);
+
+ if (!row)
+ return false;
+
+ return true;
+}
+
+function SetStatusMessage(str)
+{
+ var cell = document.getElementById("statusMsg");
+
+ if (!cell)
+ return;
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(str));
+}
+
+function UpdateButtonStates()
+{
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+
+ document.getElementById("enrollbtn").disabled = false;
+ }
+ else
+ {
+ document.getElementById("enrollbtn").disabled = true;
+ }
+
+ refresh();
+}
+
+function SetEnrollmentType(type)
+{
+ gKeyEnrollmentType = type;
+ UpdateButtonStates();
+}
+
+function FindRow(node)
+{
+ while (node && node.tagName != "TR")
+ {
+ node = node.parentNode;
+ }
+
+ return node;
+}
+
+function SelectRow(row)
+{
+ if (!row || gCurrentSelectedRow == row)
+ return;
+
+ if (gCurrentSelectedRow)
+ gCurrentSelectedRow.removeAttribute("style");
+
+ gCurrentSelectedRow = row;
+ gCurrentSelectedRow.style.backgroundColor="rgb(200,200,200)";
+ UpdateButtonStates();
+}
+
+function SelectRowByKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ SelectRow(row);
+}
+
+function DoSelectRow(event)
+{
+ var row;
+
+ row = FindRow(event.parentNode);
+ SelectRow(row);
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+
+
+function CreateTableRow(table, keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+ row.onclick = DoSelectRow;
+
+ // Create the key ID cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(KeyToUIString(keyType, keyID)));
+
+ //cell.setAttribute("onClick", "DoSelectRow(this);");
+
+ // Create the keyStatus cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(keyStatus));
+
+ // Create the requires auth cell.
+ // cell = InsertCell(row);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode("Enrollment Progress"));
+
+ // Create the status bar cell
+
+ cell = InsertCell(row);
+
+ var progressMeter = document.createElement("div");
+ progressMeter.setAttribute("id", KeyToProgressBarID(keyType, keyID));
+ progressMeter.className = "ProgressMeter";
+ progressMeter.style.width = "100px";
+ progressMeter.style.height = "1.5em";
+// progressMeter.style.visibility = "hidden";
+ progressMeter.setAttribute("value", 0);
+
+ var progressBar = document.createElement("div");
+ progressBar.className = "ProgressBar";
+ progressBar.style.width = "0px";
+ progressBar.style.height = "100%";
+// progressBar.style.visibility = "hidden";
+
+ var progressBarStatus = document.createElement("div");
+ progressBarStatus.className = "ProgressBarStatus";
+ progressBarStatus.appendChild(document.createTextNode(""));
+
+ progressMeter.appendChild(progressBar);
+ progressMeter.appendChild(progressBarStatus);
+ cell.appendChild(progressMeter);
+
+ //row.style.display ="none";
+
+ return row;
+}
+
+gAnimationMSecs = 1000/30;
+
+function SetCylonTimer(cylonID, cylonEyeID)
+{
+ setTimeout("AnimateCylonStatusBar(\"" + cylonID +
+ "\", \"" + cylonEyeID + "\");", gAnimationMSecs);
+}
+
+function AnimateCylonStatusBar(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID);
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ return;
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (!eye)
+ return;
+
+ var dir = eye.getAttribute("direction");
+ var wid = parseInt(eye.style.width);
+ var cywid = parseInt(cylon.style.width);
+ var left = parseInt(eye.style.left);
+
+ var dx = 10;
+
+ if (!dir || dir >= 0)
+ {
+ left += dx;
+
+ if (left + wid > cywid)
+ {
+ left = cywid - wid;
+ eye.setAttribute("direction", "-1");
+ }
+ }
+ else
+ {
+ left -= dx;
+
+ if (left < 0)
+ {
+ left = 0;
+ eye.setAttribute("direction", "1");
+ }
+ }
+
+ eye.style.left = left + "px";
+
+ SetCylonTimer(cylonID, cylonEyeID);
+}
+
+function StartCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ {
+ cylon.setAttribute("cylonactive", "true");
+
+ var eye = document.getElementById(cylonEyeID);
+ if (eye)
+ {
+ eye.style.left = "0px";
+ eye.style.visibility = "visible";
+ }
+
+ SetCylonTimer(cylonID, cylonEyeID);
+ }
+}
+
+function StopCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (cylon)
+ cylon.removeAttribute("cylonactive");
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (eye)
+ eye.style.visibility = "hidden";
+}
+
+function GetProgressMeterValue(progMeterID)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return -1;
+
+ return parseInt(progMeter.getAttribute("value"));
+}
+
+function SetProgressMeterValue(progMeterID, value)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter || value < 0)
+ return;
+
+ if (value > 100)
+ value = 100;
+
+ var progBar = progMeter.firstChild;
+
+ if (value == 0)
+ {
+ progBar.style.width = "0px";
+ progBar.style.visibility = "hidden";
+ progMeter.setAttribute("value", 0);
+ return;
+ }
+
+ progBar.style.visibility = "visible";
+
+ var newWidth = parseInt(progMeter.style.width) * value / 100 - 2;
+
+ progBar.style.width = newWidth + "px";
+ progMeter.setAttribute("value", value);
+}
+
+function SetProgressMeterStatus(progMeterID, statusMsg)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return;
+
+ var progBar = progMeter.firstChild;
+
+ // If it exists, the meter status should be
+ // div that is the next sibling of the progressMeter.
+
+ var meterStatus = progBar.nextSibling;
+
+ // Just replace the data in the text node, it's much faster,
+ // and reduces flashing!
+
+ meterStatus.firstChild.replaceData(0, meterStatus.firstChild.length, statusMsg);
+}
+
+function ClearProgressBar(progMeterID)
+{
+ SetProgressMeterValue(progMeterID, 0);
+ SetProgressMeterStatus(progMeterID, "");
+}
+
+function KeyToProgressBarID(keyType, keyID)
+{
+ return "PM" + keyType + "-" + keyID;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ESC native code.
+//
+// ESC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.EnrollCOOLKey(keyType, keyID, enrollmentType, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass "houseKey" as the enrollmentType, and null values for both
+// screenName and pin. For a NetKey, use "netKey" as the enrollmentType,
+// and pass a valid screenName and pin.
+//
+//
+////////////////////////////////////////////////////////////////
+
+function GetScreenNameValue()
+{
+ var sname = document.getElementById("snametf").value;
+
+ if (! sname)
+ {
+ MyAlert("You must provide a valid LDAP User ID!");
+ return null;
+ }
+
+ return sname;
+}
+
+function GetPINValue()
+{
+ var pinVal = document.getElementById("pintf").value;
+ var rpinVal = document.getElementById("reenterpintf").value;
+
+ if (! pinVal)
+ {
+ MyAlert("You must provide a valid Key Password!");
+ return null;
+ }
+
+ if ( pinVal != rpinVal)
+ {
+ MyAlert("The Key Password values you entered do not match!");
+ return null;
+ }
+
+ return pinVal;
+}
+
+function GetScreenNamePwd()
+{
+
+ var pwd = document.getElementById("snamepwd").value;
+
+ if(!pwd)
+ {
+ MyAlert("You must provide a valid LDAP User ID !");
+ return null;
+ }
+ return pwd;
+}
+
+function GetTokenCode()
+{
+
+ return null;
+}
+function DoEnrollCOOLKey()
+{
+
+ if (!gCurrentSelectedRow)
+ {
+ MyAlert("Please select a key.");
+ return;
+ }
+
+
+ if(!Validate())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = GetScreenNamePwd();
+
+ tokencode = GetTokenCode();
+
+ //SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+ }
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ var doShow = true;
+
+ ShowProgressBar(keyType,keyID,doShow );
+
+ if (!EnrollCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(aKeyType,aKeyID,doShow );
+ }
+}
+
+function DoResetSelectedCOOLKeyPIN()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate())
+ return;
+
+ //alert("In DoResetSelectedCOOLKeyPIN!");
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var screenname = null;
+ var pin = null;
+ var screennamepwd = null;
+
+ if (GetCOOLKeyIsEnrolled(keyType, keyID))
+ {
+
+ SetStatusMessage("Resetting PIN for \"" + keyID + "\"...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+ }
+}
+
+function DoFormatCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+
+ if(!Validate())
+ return;
+
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+function DoCancelOperation()
+{
+
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ SetStatusMessage("Cancel operation for \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ CancelCOOLKeyOperation(keyType, keyID);
+
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+}
+
+function DoChallengeSelectedKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Generating Challenge ...");
+
+ var challengeArray = ChallengeCOOLKey(keyType, keyID, document.forms[0].challengedata.value);
+
+ if (challengeArray.length != 4)
+ {
+ MyAlert("Challenge for key \"" + KeyToUIString(keyType, keyID) + "\" failed!");
+ SetStatusMessage("");
+ return;
+ }
+
+ MyAlert("ChallengeCOOLKey(\""+ KeyToUIString(keyType, keyID) + "\") returned:\n\n" +
+ "challenge[0]: " + challengeArray[0] + "\n" +
+ "challenge[1]: " + challengeArray[1] + "\n" +
+ "challenge[2]: " + challengeArray[2] + "\n" +
+ "challenge[3]: " + challengeArray[3] + "\n");
+
+ SetStatusMessage("");
+}
+
+function DoBlinkCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Blinking \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+}
+
+function OnCOOLKeyBlinkComplete(keyType,keyID)
+{
+ //StopCylonAnimation("cylon1", "eye1");
+ //SetStatusMessage(" ");
+}
+
+function DoHelp()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ var policy = GetCOOLKeyPolicy(keyType, keyID);
+ var type = PolicyToKeyType(policy);
+ MyAlert("Policy: " + policy + "\n" + "Type: " + type);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions called directly from ASC native code.
+//
+////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(keyType, keyID);
+}
+
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("BindingTable");
+
+ if (row && table)
+ {
+ RemoveRow(table,row);
+
+ if (row == gCurrentSelectedRow)
+ gCurrentSelectedRow = null;
+ }
+
+ UpdateButtonStates();
+}
+
+var gKnownPolicies = [
+
+ // OID Value, precedence, name value
+
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4", 4, "NETKEY" ], // Platinum - MyDoctor
+
+ // XXX: Remove the Old OIDs below, after the RA starts generating
+ // certificates with the OIDs listed above!
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.4", 4, "NETKEY" ] // Platinum - MyDoctor
+];
+
+function PolicyToKeyType(policy)
+{
+ return "ENROLLED";
+}
+
+function OldPolicyToKeyType(policy)
+{
+ var i, j;
+
+ var knownPoliciesIndex = -1;
+
+
+ var policies;
+
+
+ if (policy.indexOf(",")== -1)
+ {
+ policies = new Array(1);
+ policies[0] = policy;
+ }
+ else
+ {
+ policies = policy.split(",");
+ }
+
+ for (j = 0; j < policies.length; j++)
+ {
+ for (i = 0; i < gKnownPolicies.length; i++)
+ {
+ if (gKnownPolicies[i][0] == policies[j])
+ {
+ if (knownPoliciesIndex < gKnownPolicies[i][1])
+ knownPoliciesIndex = i;
+ }
+ }
+ }
+
+ if (knownPoliciesIndex == -1)
+ return "INITIALIZED";
+
+ return gKnownPolicies[knownPoliciesIndex][2];
+}
+
+function BoolToYesNoStr(b)
+{
+ if (b)
+ return "YES";
+ return "NO";
+}
+
+function OnCOOLKeyEnrollmentComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+ SetStatusMessage("");
+ MyAlert("Enrollment of smartcard complete!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+
+ window.setTimeout("loadSuccessPage()",4);
+}
+
+function OnCOOLKeyPINResetComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Password Reset was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyFormatComplete(keyType, keyID)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Format of \"" + KeyToUIString(keyType, keyID)+ "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStateError(keyType, keyID, keyState, errorCode)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+
+ }
+
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+
+ var typeStr = "Error(" + errorCode + ")";
+
+ var messageStr = " \n\n Error Response: " + MyGetErrorMessage(errorCode) ;
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (keyState == 1004)
+ typeStr = "Enrollment of key failed. " + typeStr + messageStr ;
+ else if (keyState == 1016)
+ typeStr = "Formatting of key failed. " + typeStr + messageStr;
+ else if (keyState == 1010)
+ typeStr = "PIN Reset for key failed. " + typeStr + messageStr;
+ else if (keyState == 1020)
+ typeStr = "Operation for key canceled.";
+
+ typeStr += " \n " + ErrorText;
+ MyAlert(typeStr);
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStatusUpdate(progMeterID, statusUpdate)
+{
+ SetProgressMeterValue(progMeterID, statusUpdate);
+ SetProgressMeterStatus(progMeterID, statusUpdate + "%");
+}
+
+function Validate()
+{
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = GetScreenNameValue();
+ if (! screenname)
+ return 0;
+
+ screennamepwd = GetScreenNamePwd();
+
+ if(! screennamepwd)
+ return 0;
+
+ pin = GetPINValue();
+
+ if (! pin)
+ return 0;
+
+ }
+
+ return 1;
+}
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data,strData)
+{
+ // alert("KeyID: " + keyID + "\n" +
+ // "KeyState: " + keyState + "\n" +
+ // "Data: " + data);
+ //alert("State Change ="+keyState);
+
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ // OnCOOLKeyEnrollmentStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ OnCOOLKeyEnrollmentComplete(keyType, keyID);
+ break;
+ case 1004: // EnrollmentError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1008: // PINResetStart
+ // OnCOOLKeyPINResetStart(keyType, keyID);
+ break;
+ case 1009: // PINResetComplete
+ OnCOOLKeyPINResetComplete(keyType, keyID);
+ break;
+ case 1010: // PINResetError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1014: // FormatStart
+ // OnCOOLKeyFormatStart(keyType, keyID);
+ break;
+ case 1015: // FormatComplete
+ OnCOOLKeyFormatComplete(keyType, keyID);
+ break;
+ case 1016: // FormatError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1017: // BlinkStatus Update?
+ //OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1018:
+ OnCOOLKeyBlinkComplete(keyType, keyID);
+ break;
+ case 1020: // OperationCancelled
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1021: // OperationStatusUpdate
+ OnCOOLKeyStatusUpdate(KeyToProgressBarID(keyType, keyID), data);
+ break;
+
+ case 1022: //Need Auth
+
+
+ gCurKeyID = keyID;
+ gCurKeyType = keyType;
+
+ GetAuthDataFromPopUp(keyType,keyID,strData);
+
+ break;
+
+ }
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+function loadSuccessPage()
+{
+ window.location="/home/EnrollSuccess.html";
+}
+
+function ShowProgressBar(aKeyType,aKeyID, doShow)
+{
+ if(!gCurrentSelectedRow)
+ return;
+
+ if(doShow)
+ gCurrentSelectedRow.style.display="table-row";
+ else
+ {
+ gCurrentSelectedRow.style.display="none";
+ }
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/BannerBackground.gif b/pki/linux/tps-ui/shared/docroot/esc/images/BannerBackground.gif
new file mode 100755
index 000000000..55d41f6ea
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/BannerBackground.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/CancelButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/CancelButton.gif
new file mode 100755
index 000000000..5b2f7e53a
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/CancelButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/CloseButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/CloseButton.gif
new file mode 100755
index 000000000..f0a8230a1
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/CloseButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/ContinueButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/ContinueButton.gif
new file mode 100755
index 000000000..3a6867258
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/ContinueButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/HelpButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/HelpButton.gif
new file mode 100755
index 000000000..43e55dce2
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/HelpButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/NetKey-Small.gif b/pki/linux/tps-ui/shared/docroot/esc/images/NetKey-Small.gif
new file mode 100755
index 000000000..6fed0d5ce
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/NetKey-Small.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyInsert.gif b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyInsert.gif
new file mode 100755
index 000000000..4fb74b2b7
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyInsert.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyLogo.gif b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyLogo.gif
new file mode 100755
index 000000000..53af00410
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyLogo.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyPair.gif b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyPair.gif
new file mode 100755
index 000000000..b1ff91b5e
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyPair.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyProgress.gif b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyProgress.gif
new file mode 100755
index 000000000..aaadf358f
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyProgress.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyQuestionMark.gif b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyQuestionMark.gif
new file mode 100755
index 000000000..b12a77908
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/NetKeyQuestionMark.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/OKButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/OKButton.gif
new file mode 100755
index 000000000..64d69e440
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/OKButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/PadLock.gif b/pki/linux/tps-ui/shared/docroot/esc/images/PadLock.gif
new file mode 100755
index 000000000..5e4e044c8
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/PadLock.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/PurchaseButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/PurchaseButton.gif
new file mode 100755
index 000000000..beb0dacab
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/PurchaseButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/ReactivateButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/ReactivateButton.gif
new file mode 100755
index 000000000..86de2eb68
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/ReactivateButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/ReleaseButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/ReleaseButton.gif
new file mode 100755
index 000000000..7ab79be8c
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/ReleaseButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/SecureButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/SecureButton.gif
new file mode 100755
index 000000000..fc37f2a77
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/SecureButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/SuspendButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/SuspendButton.gif
new file mode 100755
index 000000000..24ac0337a
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/SuspendButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/TryAgainButton.gif b/pki/linux/tps-ui/shared/docroot/esc/images/TryAgainButton.gif
new file mode 100755
index 000000000..e71934677
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/TryAgainButton.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/bg.jpg b/pki/linux/tps-ui/shared/docroot/esc/images/bg.jpg
new file mode 100755
index 000000000..56a4af048
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/bg.jpg
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/images/logo.gif b/pki/linux/tps-ui/shared/docroot/esc/images/logo.gif
new file mode 100644
index 000000000..2d1ea5579
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/images/logo.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/so/EnrollSuccess.html b/pki/linux/tps-ui/shared/docroot/esc/so/EnrollSuccess.html
new file mode 100644
index 000000000..edfa30e6b
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/so/EnrollSuccess.html
@@ -0,0 +1,45 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<link rel=stylesheet href="/home/style.css" type="text/css">
+<title>Success!</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+
+<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
+<table width="100%" border="0" cellspacing="0" cellpadding="0" class="logobar">
+ <tr>
+ <td bgcolor="#000000">&nbsp;&nbsp;&nbsp;<img src="/home/logo.jpg" width="250" height="50"></td>
+ </tr>
+</table>
+
+<p class="bodyText" >
+Congratulations! You have successfully Enrolled your Security Officer Smartcard! Now that you have enrolled, you will be able to access the Security Officer Workstation.
+
+</p>
+<p class="bodyText">
+
+</p>
+
+</body>
+
+</html>
+
diff --git a/pki/linux/tps-ui/shared/docroot/esc/so/GenericAuth.html b/pki/linux/tps-ui/shared/docroot/esc/so/GenericAuth.html
new file mode 100755
index 000000000..5660a7c50
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/so/GenericAuth.html
@@ -0,0 +1,539 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<style>
+
+body {
+background: #ffffff url(../images/bg.jpg) repeat-x;
+ font-family: arial;
+ font-size: 7pt;
+
+}
+
+h1
+{
+ text-align: left;
+
+ font-weight: bold;
+
+ font-size: 13pt;
+
+
+}
+
+
+h2 {
+
+ text-align: left;
+ font-size: 10pt;
+
+ font-weight: lighter;
+}
+
+</style>
+<script language = "Javascript">
+
+var test_ui = "id=USER_ID&name=User ID&desc=User ID&type=string&option=option1,option2,option3&&id=USER_PWD&name=User Password&desc=User Password&type=password&option=&&id=USER_PIN&name=PIN&desc=One time PIN received via mail&type=password&option=";
+
+var theForm = null;
+var curKeyID = null;
+var curKeyType = 0;
+
+
+var gTitle = null;
+var gDescription = null;
+
+
+
+function ConfirmPassword(password_element)
+{
+
+ if(!password_element)
+ return 0;
+
+ password_id = password_element.id;
+
+ if(!password_id)
+ return 0;
+
+ confirm_id = "RE_" + password_element.id;
+
+ var size = theForm.length;
+
+ if(theForm)
+ {
+ for(i = 0; i < size ; i++)
+ {
+ var cur_element = theForm.elements[i];
+
+ if(cur_element.id == confirm_id)
+ {
+ if(cur_element.value != password_element.value)
+ {
+ alert("Value " + password_element.name + " must match " + cur_element.name);
+ return 0;
+
+ }
+ else
+ {
+ return 1;
+ }
+
+ }
+
+ }
+
+ }
+
+ return 1;
+}
+
+function Validate()
+{
+ if(theForm)
+ {
+ var size = theForm.length;
+
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ if(element.type == "text" )
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+ }
+
+ if(element.type == "password")
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+
+ if(!ConfirmPassword(element))
+ {
+ return 0;
+ }
+
+ }
+ }
+
+ }
+
+ return 1;
+}
+
+function FormSubmit()
+{
+ var result = Validate();
+
+ var thisParent = window.opener;
+
+ if(!parent)
+ {
+ alert("No parent window.");
+ window.close();
+ return;
+ }
+
+ if(!result)
+ {
+ return;
+ }
+
+ if(theForm)
+ {
+ var size = theForm.length;
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ var value = element.value;
+
+ if(element.type == "text" )
+ {
+ var id = element.id;
+ value = element.value;
+
+ if(thisParent)
+ {
+ //alert("about to set data value key " + curKeyID + " id " + id + " value " + value);
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,id,value);
+
+ }
+ }
+
+ if(element.type == "password")
+ {
+ var p_id = new String(element.id);
+
+ if(p_id.indexOf("RE_") == -1)
+ {
+ if(thisParent)
+ {
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,p_id,value);
+ }
+ }
+ }
+ }
+
+ }
+
+ window.close();
+}
+
+function GetUIObjectList(uiData)
+{
+ var str = new String(uiData);
+ var splits = str.split("&&");
+
+// alert("Get " + splits + " len " + splits.length);
+
+ var params = new Array();
+ var size = splits.length;
+
+ for(i = 0 ; i < size ; i++)
+ {
+ params[i] = splits[i].split("&");
+ }
+
+ size = params.length;
+ var name_value_objects = new Array();
+
+ for(i = 0 ; i < size; i++)
+ {
+ var name_values = new Array();
+
+ pISize = params[i].length;
+ for(j = 0 ; j < pISize ; j ++)
+ {
+ var pair = params[i][j].split("=");
+
+ //alert(" pair " + pair[0] + " pair1 " + pair[1]);
+
+ if(pair[0] == "option")
+ {
+ var options = pair[1].split(",");
+ }
+
+ name_values[pair[0]] = pair[1];
+ }
+
+ name_value_objects[i] = name_values;
+ }
+
+ return name_value_objects;
+
+}
+
+function AddBRToNode(theNode)
+{
+
+ if(!theNode)
+ return;
+
+ var br = document.createElement("br");
+
+ theNode.appendChild(br);
+
+}
+
+function AddTextToNode(theNode,theText)
+{
+
+ if(!theNode || !theText)
+ return;
+
+
+ var text = document.createTextNode(theText);
+
+ theNode.appendChild(text);
+
+
+
+
+}
+function AddTextToDocument(theText)
+{
+ if(!theText)
+ return;
+
+ var p = document.createElement("p");
+
+ if(p)
+ {
+ p.appendChild(document.createTextNode(theText));
+ }
+
+ document.body.appendChild(p);
+}
+
+function CreateForm()
+{
+ var form = document.createElement("form");
+ document.body.appendChild(form);
+ return form;
+}
+
+function CreateTable()
+{
+ var table = document.createElement("table");
+ document.body.appendChild(table);
+ tbody = document.createElement("tbody");
+ table.appendChild(tbody);
+
+ return table;
+}
+
+function AddRowToTable(table)
+{
+ if(!table)
+ return null;
+
+ var tr = document.createElement("tr");
+ (table.tBodies[0]).appendChild(tr);
+
+ return tr;
+}
+
+function AddColumnToRow(row)
+{
+ if(!row)
+ return null;
+
+ var td = document.createElement("td");
+ row.appendChild(td);
+
+ return td;
+}
+
+function AddTextToColumn(column,text)
+{
+ if(!column || !text)
+ return;
+
+ var text_node = document.createTextNode(text);
+ column.appendChild(text_node);
+
+ return text_node;
+}
+
+function AddInputField(type,id, name,value)
+{
+ var field = document.createElement("input");
+
+ if(!field)
+ return null;
+
+ field.type = type;
+ field.id =id;
+ field.name =name;
+ field.value =value;
+
+ return field;
+}
+
+function ConstructUI(aKeyType,aKeyID,uiData)
+{
+
+ //alert("Construct UI data " + uiData);
+ var name_value_objects = GetUIObjectList(uiData);
+ var len = name_value_objects.length;
+
+ gTitle = document.createElement("h1");
+
+ gDescription = document.createElement("h2");
+
+
+ document.body.appendChild(gTitle);
+
+
+ document.body.appendChild(gDescription);
+
+
+ form = CreateForm();
+ theForm = form;
+ curKeyID = aKeyID;
+ curKeyType = aKeyType;
+
+ table = CreateTable();
+
+ form.appendChild(table);
+
+ for(i = 0 ; i < len ; i ++)
+ {
+ curParameter = name_value_objects[i];
+
+ if(curParameter)
+ {
+
+ title = curParameter["title"];
+
+
+ if(title)
+ {
+ //alert("title " + title);
+
+ AddTextToNode(gTitle,title);
+
+
+ }
+
+ description = curParameter["description"];
+
+ if(description)
+ {
+ AddBRToNode(document.body);
+ AddBRToNode(document.body);
+
+ AddTextToNode(gDescription,description);
+
+ AddBRToNode(document.body);
+
+ }
+
+ id = curParameter["id"];
+ name = curParameter["name"];
+ type = curParameter["type"];
+ desc = curParameter["desc"];
+
+ //alert(" id " + id + " name " + name + " type " + type + " desc " + desc);
+
+ if(id)
+ {
+ if(table)
+ {
+ row = AddRowToTable(table);
+ }
+
+ if(row)
+ {
+ column = AddColumnToRow(row);
+ }
+
+ if(column)
+ {
+ AddTextToColumn(column,name);
+ }
+
+ if(type == "string" || type == "integer")
+ {
+ field = AddInputField("text",id,name,"");
+ }
+
+ re_field = null;
+
+ if(type == "password")
+ {
+ field = AddInputField("password",id,name,"");
+ }
+
+ if(type == "hidden")
+ {
+ field = AddInputField("hidden",id,name,"");
+ }
+
+ if(field)
+ {
+ field_col = AddColumnToRow(row);
+ if(field_col)
+ {
+ field_col.appendChild(field);
+ }
+ }
+
+ if(re_field)
+ {
+ re_text = AddColumnToRow(row);
+
+ if(re_text)
+ {
+ AddTextToColumn(re_text,"Confirm " + name);
+ re_field_col = AddColumnToRow(row);
+ if(re_field_col)
+ {
+ re_field_col.appendChild(re_field);
+ }
+
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ var last_row = AddRowToTable(table);
+
+ if(last_row)
+ {
+ var button_field = AddColumnToRow(last_row);
+
+ if(button_field)
+ {
+ var button = AddInputField("button","Submit","Submit","Submit");
+ button.onclick = FormSubmit;
+ button_field.appendChild(button);
+
+ }
+
+ }
+}
+
+function UiLoad()
+{
+
+
+ var thisParent = window.opener;
+
+
+ if(!thisParent)
+ {
+ alert("Auth dialog has no parent!");
+ return;
+ }
+
+ var keyID = this.name;
+
+ var ui = thisParent.getUIForKey(keyID);
+
+ var type = thisParent.getTypeForKey(keyID);
+
+ //alert("UiLoad " + ui);
+
+ if(ui)
+ {
+ ConstructUI(type,keyID,ui);
+ }
+}
+
+</script>
+</head>
+<body onload = "UiLoad()">
+</body>
+</html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/so/logo.jpg b/pki/linux/tps-ui/shared/docroot/esc/so/logo.jpg
new file mode 100644
index 000000000..7cb31affc
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/so/logo.jpg
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/so/style.css b/pki/linux/tps-ui/shared/docroot/esc/so/style.css
new file mode 100755
index 000000000..e9d7d9bf7
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/so/style.css
@@ -0,0 +1,214 @@
+/* --- BEGIN COPYRIGHT BLOCK ---
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Copyright (C) 2007 Red Hat, Inc.
+ * All rights reserved.
+ * --- END COPYRIGHT BLOCK ---
+ */
+
+body {
+background-color: grey;
+ font-family: arial;
+ font-size: 7p
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+h2 {
+ font-size: 12pt;
+}
+
+.logobar {
+
+ background-color:black;
+ font-family: "Arial";
+ font-size: 7p;
+
+}
+
+.headerText {
+ font-family: "Arial";
+ font-size: 14pt;
+ font-weight: bold;
+ color: white;
+}
+
+.titleText {
+ font-family: "Arial";
+ font-size: 10pt;
+}
+
+.bodyText {
+ font-family: "Arial";
+ font-size: 10pt;
+ color: white;
+}
+
+.formText {
+ font-family: "Arial";
+ font-size: 9pt;
+ color: black;
+
+}
+
+.linkText {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+#BindingTable {
+ background-color: #ffffff ;
+ font-size: 7pt;
+}
+
+#BindingTable th {
+ color: rgb(0, 0, 0);
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+#BindingTable tr {
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+tr [COOLKeyPresent="yes"]{
+ background-color: rgb(255, 0, 0);
+}
+
+.cylon {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+}
+
+.cylonEye {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+}
+
+#statusMsg {
+ font-weight: bold;
+}
+
+.ProgressMeter {
+ position: relative;
+ padding: 0px;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+ text-align: center;
+}
+
+.ProgressBar {
+ position: absolute;
+ z-index: 0;
+ top: 0px;
+ left: 0px;
+ border-right: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+ margin: 0px;
+}
+
+.ProgressBarStatus {
+ position: relative;
+ z-index: 10;
+ margin: 0px;
+ padding: 0px;
+
+}
+
+.KeyTableHeader {
+ color: rgb(0,0, 0);
+ background-color: #ffffff;
+ text-align: left;
+}
+
+#KeyTable td {
+ background-color: #ffffff;
+ padding-left: 3px;
+ padding-right: 3px;
+};
+
+.TableDescriptionPanel {
+ background-color: #ffffff);
+ margin-right: 5px;
+ margin-left: 5px;
+ margin-bottom: 0px;
+ margin-bottom: 5px;
+ padding: 5px;
+}
+
+.PurchasePanel {
+ width: 100%;
+ text-align: center;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+
+.NeedQuestionText {
+ font-size: 16pt;
+ font-weight: bold;
+}
+
+.COOLHeaderText {
+ font-family: "Arial";
+ font-size: 20pt;
+ font-weight: bold;
+}
+
+.ContentTable {
+ background-color: #ffffff;
+ margin: 0px;
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+
+table {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+.TableTitle {
+ font-size: 12pt;
+ font-weight: bold;
+}
+
+.PageHeader {
+ width: 100%;
+ border-bottom: solid black 1px;
+ vertical-align: center;
+ background-color: #ffffff;
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/so/util.js b/pki/linux/tps-ui/shared/docroot/esc/so/util.js
new file mode 100755
index 000000000..76e14014c
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/so/util.js
@@ -0,0 +1,1507 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA
+//
+// Copyright (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+//
+// initialize netkey globals
+var netkey;
+
+
+var keyUITable = new Array();
+var keyTypeTable = new Array();
+var curChildWindow = null;
+
+var gWindow = null;
+
+const ErrorText = "For additional assistance contact your Technical Support";
+
+
+function getUIForKey(aKeyID)
+{
+ return keyUITable[aKeyID];
+
+}
+
+function getTypeForKey(aKeyID)
+{
+ return keyTypeTable[aKeyID];
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData,strData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ MyAlert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+ gNotify = new jsNotify;
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+}
+
+var gScreenName = "";
+var gKeyEnrollmentType = "soKey";
+
+var gCurrentSelectedRow = null;
+
+
+var gCurKeyType = null;
+var gCurKeyID = null;
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+
+// List of Error Messages to be printed out
+
+var Status_Messages = new Array(
+
+ "Operation Completed Successfully.",
+ "Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Problem communicating with the smartcard.",
+ "Problem resetting smartcard's pin.",
+ "Internal Smartcard Server error.",
+ "Internal Smartcard Server error.",
+ "Smartcard enrollment error.",
+ "Can not communicate with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the Certificattion Authority.",
+ "Internal Smartcard Server error.",
+ "Error resetting the smartcard's password.",
+ "Internal Smartcard Server error.",
+ "Smartcard Server authentication failure.",
+ "Internal Smartcard Server error.",
+ "Your Smartcard is listed as disabled.",
+ "Problem communicating with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Cannot upgrade smartcard software.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Invalid smartcard type.",
+ "Invalid smartcard type.",
+ "Cannot publish smartcard information.",
+ "Cannot communicate with smartcard database.",
+ "Smartcard is disabled.",
+ "Cannot reset password value for the smartcard.",
+ "Connection to Smartcard Server lost.",
+ "Cannot create entry for smartcard in smartcard database.",
+ "Smartcard found to be in an inconsistent state.",
+ "Invalid reason for lost smartcard submitted.",
+ "Smartcard found to be unusable due to compromise.",
+ "No such inactive smartcard found.",
+ "Cannot process more than one active smartcard.",
+ "Internal Smartcard Server error.",
+ "Smartcard key recovery has been processed.",
+ "Smartcard key recovery failed.",
+ "Cannot process this smartcard, which has been reported lost.",
+ "Smartcard key archival error.",
+ "Problem connecting to the Smartcard TKS Server.",
+ "Failed to update smartcard database.",
+ "Internal certificate revocation error discovered.",
+ "User does not own this smartcard.",
+ "Smart Card Manager has been misconfigured.",
+ "Smart Card Manager can not talk to smart card reader.",
+ "Smart Card Manager can not establish a session with the smart card.",
+ "Smart Card Manager can not talk to Smart Card Server.",
+ "Smart Card Manager can not talk to smart card reader."
+ );
+
+function GetAuthDataFromPopUp(aKeyType,aKeyID,aUiData)
+{
+
+ keyUITable[aKeyID] = aUiData;
+ keyTypeTable[aKeyID] = aKeyType;
+
+ //alert("GetAuthDataFromPopUp data " + aUiData);
+ var child = window.open("/GenericAuth.html",aKeyID,"height=400,width=400");
+
+ //alert("Attempted to create child window " + child);
+
+ curChildWindow = child;
+
+}
+
+function COOLKeySetDataValue(aKeyType,aKeyID,name,value)
+{
+ //alert("In COOLKeySetDataValue aKeyType " + aKeyType + " aKeyID " + aKeyID + " name " + name + " value " + value);
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(aKeyType,aKeyID,name,value);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+
+}
+
+function COOLKeySetTokenPin(pin)
+{
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"TokenPin",pin);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+}
+
+function COOLKeySetUidPassword(uid,pwd)
+{
+
+ if(netkey)
+ {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"UserId",uid);
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"Password",pwd);
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+
+ }
+
+}
+
+
+function MyGetErrorMessage(status_code)
+{
+
+ var result = "Internal Server Error";
+
+ if(status_code < 0 && status_code >= Status_Messages.length)
+ {
+ return result;
+
+ }
+
+ return Status_Messages[status_code];
+
+}
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function ReportException(msg, e)
+{
+ MyAlert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetCOOLKeyStatus(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyStatus(keyType, keyID);
+ } catch (e) {
+ ReportException("netkey.GetCOOLKeyStatus() failed!", e);
+ return 0;
+ }
+}
+
+function GetCOOLKeyPolicy(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyPolicy(keyType, keyID);
+ } catch (e) {
+ // ReportException("netkey.GetCOOLKeyPolicy() failed!", e);
+ return "";
+ }
+}
+
+function GetCOOLKeyRequiresAuth(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyRequiresAuthentication(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyRequiresAuthentication() failed!", e);
+ return false;
+ }
+}
+
+function GetCOOLKeyIsAuthed(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsAuthenticated(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsAuthenticated() failed!", e);
+ return false;
+ }
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableCoolKeys() failed!", e);
+ return [];
+ }
+}
+
+function EnrollCOOLKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.EnrollCoolKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.EnrollCoolKey() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+function GetCOOLKeyIsEnrolled(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsEnrolled(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsEnrolled() failed!", e);
+ return false;
+ }
+}
+
+function CancelCOOLKeyOperation(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.CancelCoolKeyOperation(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.CancelCoolKeyOperation() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function MyAlert(message)
+{
+ if(message)
+ DoMyAlert(message,"Smart Card Manager");
+
+}
+function DoMyAlert(message,title)
+{
+
+ if(!message || !title)
+ return;
+
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+
+
+ prompts.alert(window,title,message);
+
+ } catch(e) {
+
+
+ alert("Problem with nsIPromptService " + e);
+ }
+
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ table.deleteRow(row.rowIndex);
+}
+
+function GetCell(row, index)
+{
+ var cell;
+
+ cell = row.cells[index];
+ return cell;
+}
+
+function GetNode(parent, index)
+{
+ var node;
+ node = parent.childNodes[index];
+ return node;
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ row = table.insertRow(table.rows.length);
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ cell = row.insertCell(row.cells.length);
+ return cell;
+}
+
+function RemoveAllChildNodes(parent)
+{
+ var numChildren = parent.childNodes.length;
+ var i;
+
+ i = numChildren;
+ while (numChildren)
+ {
+ parent.removeChild(GetNode(parent,0));
+ numChildren--;
+ }
+
+}
+
+
+function UpdateInfoForKeyID(keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return;
+
+ var cell = GetCell(row,1)
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+// cell = GetCell(row,2);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ // cell = GetCell(row,3);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(isAuthed));
+}
+
+function GetStatusForKeyID(keyType, keyID)
+{
+ var keyStatus = "BLANK";
+
+ var status;
+
+ try {
+ status = GetCOOLKeyStatus(keyType, keyID);
+ } catch(e) {
+ status = 0;
+ }
+
+ switch (status) {
+ case 0: // Unavailable
+ keyStatus = "UNAVAILABLE";
+ break;
+ case 1: // AppletNotFound
+ keyStatus = "NO APPLET";
+ break;
+ case 2: // Uninitialized
+ keyStatus = "UNINITIALIZED";
+ break;
+ case 3: // Unknown
+ keyStatus = "UNKNOWN";
+ break;
+ case 4: // Available
+ case 6: // UnblockInProgress
+ case 7: // PINResetInProgress
+ case 8: // RenewInProgress
+ keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ break;
+ case 5: // EnrollmentInProgress
+ keyStatus = "BUSY";
+ break;
+ break;
+ case 9: // FormatInProgress
+ keyStatus = "BUSY";
+ break;
+ }
+
+ return keyStatus;
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ gWindow = window;
+ if (!row)
+ {
+ var table = document.getElementById("BindingTable");
+ if (table)
+ {
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ row = CreateTableRow(table, keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ }
+
+ if (!row)
+ return null;
+ }
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ {
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(arr[i][0], arr[i][1]);
+ }
+}
+
+function InitializeBindingTable()
+{
+ UpdateBindingTableAvailability();
+ UpdateButtonStates();
+ if (UserOnDoneInitializeBindingTable) {
+ UserOnDoneInitializeBindingTable();
+ }
+}
+
+function KeyIsPresent(keyType, keyID)
+{
+ row = document.all.item(keyType, keyID);
+
+ if (!row)
+ return false;
+
+ return true;
+}
+
+function SetStatusMessage(str)
+{
+ var cell = document.getElementById("statusMsg");
+
+ if (!cell)
+ return;
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(str));
+}
+
+function UpdateButtonStates()
+{
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+
+ document.getElementById("enrollbtn").disabled = false;
+ }
+ else
+ {
+ document.getElementById("enrollbtn").disabled = true;
+ }
+
+ refresh();
+}
+
+function SetEnrollmentType(type)
+{
+ gKeyEnrollmentType = type;
+ UpdateButtonStates();
+}
+
+function FindRow(node)
+{
+ while (node && node.tagName != "TR")
+ {
+ node = node.parentNode;
+ }
+
+ return node;
+}
+
+function SelectRow(row)
+{
+ if (!row || gCurrentSelectedRow == row)
+ return;
+
+ if (gCurrentSelectedRow)
+ gCurrentSelectedRow.removeAttribute("style");
+
+ gCurrentSelectedRow = row;
+ gCurrentSelectedRow.style.backgroundColor="rgb(200,200,200)";
+ UpdateButtonStates();
+}
+
+function SelectRowByKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ SelectRow(row);
+}
+
+function DoSelectRow(event)
+{
+ var row;
+
+ row = FindRow(event.parentNode);
+ SelectRow(row);
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+
+
+function CreateTableRow(table, keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+ row.onclick = DoSelectRow;
+
+ // Create the key ID cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(KeyToUIString(keyType, keyID)));
+
+ //cell.setAttribute("onClick", "DoSelectRow(this);");
+
+ // Create the keyStatus cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(keyStatus));
+
+ // Create the requires auth cell.
+ // cell = InsertCell(row);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode("Enrollment Progress"));
+
+ // Create the status bar cell
+
+ cell = InsertCell(row);
+
+ var progressMeter = document.createElement("div");
+ progressMeter.setAttribute("id", KeyToProgressBarID(keyType, keyID));
+ progressMeter.className = "ProgressMeter";
+ progressMeter.style.width = "100px";
+ progressMeter.style.height = "1.5em";
+// progressMeter.style.visibility = "hidden";
+ progressMeter.setAttribute("value", 0);
+
+ var progressBar = document.createElement("div");
+ progressBar.className = "ProgressBar";
+ progressBar.style.width = "0px";
+ progressBar.style.height = "100%";
+// progressBar.style.visibility = "hidden";
+
+ var progressBarStatus = document.createElement("div");
+ progressBarStatus.className = "ProgressBarStatus";
+ progressBarStatus.appendChild(document.createTextNode(""));
+
+ progressMeter.appendChild(progressBar);
+ progressMeter.appendChild(progressBarStatus);
+ cell.appendChild(progressMeter);
+
+ //row.style.display ="none";
+
+ return row;
+}
+
+gAnimationMSecs = 1000/30;
+
+function SetCylonTimer(cylonID, cylonEyeID)
+{
+ setTimeout("AnimateCylonStatusBar(\"" + cylonID +
+ "\", \"" + cylonEyeID + "\");", gAnimationMSecs);
+}
+
+function AnimateCylonStatusBar(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID);
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ return;
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (!eye)
+ return;
+
+ var dir = eye.getAttribute("direction");
+ var wid = parseInt(eye.style.width);
+ var cywid = parseInt(cylon.style.width);
+ var left = parseInt(eye.style.left);
+
+ var dx = 10;
+
+ if (!dir || dir >= 0)
+ {
+ left += dx;
+
+ if (left + wid > cywid)
+ {
+ left = cywid - wid;
+ eye.setAttribute("direction", "-1");
+ }
+ }
+ else
+ {
+ left -= dx;
+
+ if (left < 0)
+ {
+ left = 0;
+ eye.setAttribute("direction", "1");
+ }
+ }
+
+ eye.style.left = left + "px";
+
+ SetCylonTimer(cylonID, cylonEyeID);
+}
+
+function StartCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ {
+ cylon.setAttribute("cylonactive", "true");
+
+ var eye = document.getElementById(cylonEyeID);
+ if (eye)
+ {
+ eye.style.left = "0px";
+ eye.style.visibility = "visible";
+ }
+
+ SetCylonTimer(cylonID, cylonEyeID);
+ }
+}
+
+function StopCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (cylon)
+ cylon.removeAttribute("cylonactive");
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (eye)
+ eye.style.visibility = "hidden";
+}
+
+function GetProgressMeterValue(progMeterID)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return -1;
+
+ return parseInt(progMeter.getAttribute("value"));
+}
+
+function SetProgressMeterValue(progMeterID, value)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter || value < 0)
+ return;
+
+ if (value > 100)
+ value = 100;
+
+ var progBar = progMeter.firstChild;
+
+ if (value == 0)
+ {
+ progBar.style.width = "0px";
+ progBar.style.visibility = "hidden";
+ progMeter.setAttribute("value", 0);
+ return;
+ }
+
+ progBar.style.visibility = "visible";
+
+ var newWidth = parseInt(progMeter.style.width) * value / 100 - 2;
+
+ progBar.style.width = newWidth + "px";
+ progMeter.setAttribute("value", value);
+}
+
+function SetProgressMeterStatus(progMeterID, statusMsg)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return;
+
+ var progBar = progMeter.firstChild;
+
+ // If it exists, the meter status should be
+ // div that is the next sibling of the progressMeter.
+
+ var meterStatus = progBar.nextSibling;
+
+ // Just replace the data in the text node, it's much faster,
+ // and reduces flashing!
+
+ meterStatus.firstChild.replaceData(0, meterStatus.firstChild.length, statusMsg);
+}
+
+function ClearProgressBar(progMeterID)
+{
+ SetProgressMeterValue(progMeterID, 0);
+ SetProgressMeterStatus(progMeterID, "");
+}
+
+function KeyToProgressBarID(keyType, keyID)
+{
+ return "PM" + keyType + "-" + keyID;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ESC native code.
+//
+// ESC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.EnrollCOOLKey(keyType, keyID, enrollmentType, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass "houseKey" as the enrollmentType, and null values for both
+// screenName and pin. For a NetKey, use "netKey" as the enrollmentType,
+// and pass a valid screenName and pin.
+//
+//
+////////////////////////////////////////////////////////////////
+
+function GetScreenNameValue()
+{
+ var sname = document.getElementById("snametf").value;
+
+ if (! sname)
+ {
+ MyAlert("You must provide a valid LDAP User ID!");
+ return null;
+ }
+
+ return sname;
+}
+
+function GetPINValue()
+{
+ var pinVal = document.getElementById("pintf").value;
+ var rpinVal = document.getElementById("reenterpintf").value;
+
+ if (! pinVal)
+ {
+ MyAlert("You must provide a valid Key Password!");
+ return null;
+ }
+
+ if ( pinVal != rpinVal)
+ {
+ MyAlert("The Key Password values you entered do not match!");
+ return null;
+ }
+
+ return pinVal;
+}
+
+function GetScreenNamePwd()
+{
+
+ var pwd = document.getElementById("snamepwd").value;
+
+ if(!pwd)
+ {
+ MyAlert("You must provide a valid LDAP User ID !");
+ return null;
+ }
+ return pwd;
+}
+
+function GetTokenCode()
+{
+
+ return null;
+}
+function DoEnrollCOOLKey()
+{
+
+ if (!gCurrentSelectedRow)
+ {
+ MyAlert("Please select a key.");
+ return;
+ }
+
+
+ if(!Validate())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "soKey")
+ {
+ screenname = GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = GetScreenNamePwd();
+
+ tokencode = GetTokenCode();
+
+ //SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+ }
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ var doShow = true;
+
+ ShowProgressBar(keyType,keyID,doShow );
+
+ if (!EnrollCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(aKeyType,aKeyID,doShow );
+ }
+}
+
+function DoResetSelectedCOOLKeyPIN()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate())
+ return;
+
+ //alert("In DoResetSelectedCOOLKeyPIN!");
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var screenname = null;
+ var pin = null;
+ var screennamepwd = null;
+
+ if (GetCOOLKeyIsEnrolled(keyType, keyID))
+ {
+
+ SetStatusMessage("Resetting PIN for \"" + keyID + "\"...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+ }
+}
+
+function DoFormatCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+
+ if(!Validate())
+ return;
+
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+function DoCancelOperation()
+{
+
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ SetStatusMessage("Cancel operation for \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ CancelCOOLKeyOperation(keyType, keyID);
+
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+}
+
+function DoChallengeSelectedKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Generating Challenge ...");
+
+ var challengeArray = ChallengeCOOLKey(keyType, keyID, document.forms[0].challengedata.value);
+
+ if (challengeArray.length != 4)
+ {
+ MyAlert("Challenge for key \"" + KeyToUIString(keyType, keyID) + "\" failed!");
+ SetStatusMessage("");
+ return;
+ }
+
+ MyAlert("ChallengeCOOLKey(\""+ KeyToUIString(keyType, keyID) + "\") returned:\n\n" +
+ "challenge[0]: " + challengeArray[0] + "\n" +
+ "challenge[1]: " + challengeArray[1] + "\n" +
+ "challenge[2]: " + challengeArray[2] + "\n" +
+ "challenge[3]: " + challengeArray[3] + "\n");
+
+ SetStatusMessage("");
+}
+
+function DoBlinkCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Blinking \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+}
+
+function OnCOOLKeyBlinkComplete(keyType,keyID)
+{
+ //StopCylonAnimation("cylon1", "eye1");
+ //SetStatusMessage(" ");
+}
+
+function DoHelp()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ var policy = GetCOOLKeyPolicy(keyType, keyID);
+ var type = PolicyToKeyType(policy);
+ MyAlert("Policy: " + policy + "\n" + "Type: " + type);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions called directly from ASC native code.
+//
+////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(keyType, keyID);
+}
+
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("BindingTable");
+
+ if (row && table)
+ {
+ RemoveRow(table,row);
+
+ if (row == gCurrentSelectedRow)
+ gCurrentSelectedRow = null;
+ }
+
+ UpdateButtonStates();
+}
+
+var gKnownPolicies = [
+
+ // OID Value, precedence, name value
+
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4", 4, "NETKEY" ], // Platinum - MyDoctor
+
+ // XXX: Remove the Old OIDs below, after the RA starts generating
+ // certificates with the OIDs listed above!
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.4", 4, "NETKEY" ] // Platinum - MyDoctor
+];
+
+function PolicyToKeyType(policy)
+{
+ return "ENROLLED";
+}
+
+function OldPolicyToKeyType(policy)
+{
+ var i, j;
+
+ var knownPoliciesIndex = -1;
+
+
+ var policies;
+
+
+ if (policy.indexOf(",")== -1)
+ {
+ policies = new Array(1);
+ policies[0] = policy;
+ }
+ else
+ {
+ policies = policy.split(",");
+ }
+
+ for (j = 0; j < policies.length; j++)
+ {
+ for (i = 0; i < gKnownPolicies.length; i++)
+ {
+ if (gKnownPolicies[i][0] == policies[j])
+ {
+ if (knownPoliciesIndex < gKnownPolicies[i][1])
+ knownPoliciesIndex = i;
+ }
+ }
+ }
+
+ if (knownPoliciesIndex == -1)
+ return "INITIALIZED";
+
+ return gKnownPolicies[knownPoliciesIndex][2];
+}
+
+function BoolToYesNoStr(b)
+{
+ if (b)
+ return "YES";
+ return "NO";
+}
+
+function OnCOOLKeyEnrollmentComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+ SetStatusMessage("");
+ MyAlert("Enrollment of smartcard complete!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+
+ window.setTimeout("loadSuccessPage()",4);
+}
+
+function OnCOOLKeyPINResetComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Password Reset was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyFormatComplete(keyType, keyID)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Format of \"" + KeyToUIString(keyType, keyID)+ "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStateError(keyType, keyID, keyState, errorCode)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+
+ }
+
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+
+ var typeStr = "Error(" + errorCode + ")";
+
+ var messageStr = " \n\n Error Response: " + MyGetErrorMessage(errorCode) ;
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (keyState == 1004)
+ typeStr = "Enrollment of key failed. " + typeStr + messageStr ;
+ else if (keyState == 1016)
+ typeStr = "Formatting of key failed. " + typeStr + messageStr;
+ else if (keyState == 1010)
+ typeStr = "PIN Reset for key failed. " + typeStr + messageStr;
+ else if (keyState == 1020)
+ typeStr = "Operation for key canceled.";
+
+ typeStr += " \n " + ErrorText;
+ MyAlert(typeStr);
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyStatusUpdate(progMeterID, statusUpdate)
+{
+ SetProgressMeterValue(progMeterID, statusUpdate);
+ SetProgressMeterStatus(progMeterID, statusUpdate + "%");
+}
+
+function Validate()
+{
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "soKey")
+ {
+ screenname = GetScreenNameValue();
+ if (! screenname)
+ return 0;
+
+ screennamepwd = GetScreenNamePwd();
+
+ if(! screennamepwd)
+ return 0;
+
+ pin = GetPINValue();
+
+ if (! pin)
+ return 0;
+
+ }
+
+ return 1;
+}
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data,strData)
+{
+ // alert("KeyID: " + keyID + "\n" +
+ // "KeyState: " + keyState + "\n" +
+ // "Data: " + data);
+ //alert("State Change ="+keyState);
+
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ // OnCOOLKeyEnrollmentStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ OnCOOLKeyEnrollmentComplete(keyType, keyID);
+ break;
+ case 1004: // EnrollmentError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1008: // PINResetStart
+ // OnCOOLKeyPINResetStart(keyType, keyID);
+ break;
+ case 1009: // PINResetComplete
+ OnCOOLKeyPINResetComplete(keyType, keyID);
+ break;
+ case 1010: // PINResetError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1014: // FormatStart
+ // OnCOOLKeyFormatStart(keyType, keyID);
+ break;
+ case 1015: // FormatComplete
+ OnCOOLKeyFormatComplete(keyType, keyID);
+ break;
+ case 1016: // FormatError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1017: // BlinkStatus Update?
+ //OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1018:
+ OnCOOLKeyBlinkComplete(keyType, keyID);
+ break;
+ case 1020: // OperationCancelled
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1021: // OperationStatusUpdate
+ OnCOOLKeyStatusUpdate(KeyToProgressBarID(keyType, keyID), data);
+ break;
+
+ case 1022: //Need Auth
+
+
+ gCurKeyID = keyID;
+ gCurKeyType = keyType;
+
+ GetAuthDataFromPopUp(keyType,keyID,strData);
+
+ break;
+
+ }
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+function loadSuccessPage()
+{
+ window.location="/so/EnrollSuccess.html";
+}
+
+function ShowProgressBar(aKeyType,aKeyID, doShow)
+{
+ if(!gCurrentSelectedRow)
+ return;
+
+ if(doShow)
+ gCurrentSelectedRow.style.display="table-row";
+ else
+ {
+ gCurrentSelectedRow.style.display="none";
+ }
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/sow/EnrollSuccess.html b/pki/linux/tps-ui/shared/docroot/esc/sow/EnrollSuccess.html
new file mode 100644
index 000000000..3b2096308
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/sow/EnrollSuccess.html
@@ -0,0 +1,52 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<link rel=stylesheet href="/sow/style.css" type="text/css">
+<title>Success!</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" href="/sow/css/style.css" media="screen" type="text/css">
+</head>
+
+<body>
+
+
+<div id="header">
+ <div id="logo">
+ <h3><img align=bottom src="/sow/images/badget.png">Security Officer Station</h3>
+ </div>
+</div>
+
+
+<div id="content">
+ <div id="maintext">
+ <div id="topmenu">
+ | <a href="/cgi-bin/sow/main.cgi">Main</a> |
+ </div>
+<blockquote><strong>Congratulations!</strong> This user has successfully enrolled the Smartcard! Now that this user has enrolled, he/she will be able to use the smartcard to log onto all available Smartcard-protected services.</blockquote>
+<br/>
+
+</div>
+</div>
+
+</body>
+
+</html>
+
diff --git a/pki/linux/tps-ui/shared/docroot/esc/sow/GenericAuth.html b/pki/linux/tps-ui/shared/docroot/esc/sow/GenericAuth.html
new file mode 100755
index 000000000..5660a7c50
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/sow/GenericAuth.html
@@ -0,0 +1,539 @@
+<!-- --- BEGIN COPYRIGHT BLOCK ---
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA
+
+ Copyright (C) 2007 Red Hat, Inc.
+ All rights reserved.
+ --- END COPYRIGHT BLOCK --- -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<style>
+
+body {
+background: #ffffff url(../images/bg.jpg) repeat-x;
+ font-family: arial;
+ font-size: 7pt;
+
+}
+
+h1
+{
+ text-align: left;
+
+ font-weight: bold;
+
+ font-size: 13pt;
+
+
+}
+
+
+h2 {
+
+ text-align: left;
+ font-size: 10pt;
+
+ font-weight: lighter;
+}
+
+</style>
+<script language = "Javascript">
+
+var test_ui = "id=USER_ID&name=User ID&desc=User ID&type=string&option=option1,option2,option3&&id=USER_PWD&name=User Password&desc=User Password&type=password&option=&&id=USER_PIN&name=PIN&desc=One time PIN received via mail&type=password&option=";
+
+var theForm = null;
+var curKeyID = null;
+var curKeyType = 0;
+
+
+var gTitle = null;
+var gDescription = null;
+
+
+
+function ConfirmPassword(password_element)
+{
+
+ if(!password_element)
+ return 0;
+
+ password_id = password_element.id;
+
+ if(!password_id)
+ return 0;
+
+ confirm_id = "RE_" + password_element.id;
+
+ var size = theForm.length;
+
+ if(theForm)
+ {
+ for(i = 0; i < size ; i++)
+ {
+ var cur_element = theForm.elements[i];
+
+ if(cur_element.id == confirm_id)
+ {
+ if(cur_element.value != password_element.value)
+ {
+ alert("Value " + password_element.name + " must match " + cur_element.name);
+ return 0;
+
+ }
+ else
+ {
+ return 1;
+ }
+
+ }
+
+ }
+
+ }
+
+ return 1;
+}
+
+function Validate()
+{
+ if(theForm)
+ {
+ var size = theForm.length;
+
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ if(element.type == "text" )
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+ }
+
+ if(element.type == "password")
+ {
+ if(element.value == "")
+ {
+ alert("Please enter value for " + element.name);
+ return 0;
+ }
+
+ if(!ConfirmPassword(element))
+ {
+ return 0;
+ }
+
+ }
+ }
+
+ }
+
+ return 1;
+}
+
+function FormSubmit()
+{
+ var result = Validate();
+
+ var thisParent = window.opener;
+
+ if(!parent)
+ {
+ alert("No parent window.");
+ window.close();
+ return;
+ }
+
+ if(!result)
+ {
+ return;
+ }
+
+ if(theForm)
+ {
+ var size = theForm.length;
+ for( i = 0; i < size ; i++)
+ {
+ var element = theForm.elements[i];
+
+ var value = element.value;
+
+ if(element.type == "text" )
+ {
+ var id = element.id;
+ value = element.value;
+
+ if(thisParent)
+ {
+ //alert("about to set data value key " + curKeyID + " id " + id + " value " + value);
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,id,value);
+
+ }
+ }
+
+ if(element.type == "password")
+ {
+ var p_id = new String(element.id);
+
+ if(p_id.indexOf("RE_") == -1)
+ {
+ if(thisParent)
+ {
+ thisParent.COOLKeySetDataValue(curKeyType,curKeyID,p_id,value);
+ }
+ }
+ }
+ }
+
+ }
+
+ window.close();
+}
+
+function GetUIObjectList(uiData)
+{
+ var str = new String(uiData);
+ var splits = str.split("&&");
+
+// alert("Get " + splits + " len " + splits.length);
+
+ var params = new Array();
+ var size = splits.length;
+
+ for(i = 0 ; i < size ; i++)
+ {
+ params[i] = splits[i].split("&");
+ }
+
+ size = params.length;
+ var name_value_objects = new Array();
+
+ for(i = 0 ; i < size; i++)
+ {
+ var name_values = new Array();
+
+ pISize = params[i].length;
+ for(j = 0 ; j < pISize ; j ++)
+ {
+ var pair = params[i][j].split("=");
+
+ //alert(" pair " + pair[0] + " pair1 " + pair[1]);
+
+ if(pair[0] == "option")
+ {
+ var options = pair[1].split(",");
+ }
+
+ name_values[pair[0]] = pair[1];
+ }
+
+ name_value_objects[i] = name_values;
+ }
+
+ return name_value_objects;
+
+}
+
+function AddBRToNode(theNode)
+{
+
+ if(!theNode)
+ return;
+
+ var br = document.createElement("br");
+
+ theNode.appendChild(br);
+
+}
+
+function AddTextToNode(theNode,theText)
+{
+
+ if(!theNode || !theText)
+ return;
+
+
+ var text = document.createTextNode(theText);
+
+ theNode.appendChild(text);
+
+
+
+
+}
+function AddTextToDocument(theText)
+{
+ if(!theText)
+ return;
+
+ var p = document.createElement("p");
+
+ if(p)
+ {
+ p.appendChild(document.createTextNode(theText));
+ }
+
+ document.body.appendChild(p);
+}
+
+function CreateForm()
+{
+ var form = document.createElement("form");
+ document.body.appendChild(form);
+ return form;
+}
+
+function CreateTable()
+{
+ var table = document.createElement("table");
+ document.body.appendChild(table);
+ tbody = document.createElement("tbody");
+ table.appendChild(tbody);
+
+ return table;
+}
+
+function AddRowToTable(table)
+{
+ if(!table)
+ return null;
+
+ var tr = document.createElement("tr");
+ (table.tBodies[0]).appendChild(tr);
+
+ return tr;
+}
+
+function AddColumnToRow(row)
+{
+ if(!row)
+ return null;
+
+ var td = document.createElement("td");
+ row.appendChild(td);
+
+ return td;
+}
+
+function AddTextToColumn(column,text)
+{
+ if(!column || !text)
+ return;
+
+ var text_node = document.createTextNode(text);
+ column.appendChild(text_node);
+
+ return text_node;
+}
+
+function AddInputField(type,id, name,value)
+{
+ var field = document.createElement("input");
+
+ if(!field)
+ return null;
+
+ field.type = type;
+ field.id =id;
+ field.name =name;
+ field.value =value;
+
+ return field;
+}
+
+function ConstructUI(aKeyType,aKeyID,uiData)
+{
+
+ //alert("Construct UI data " + uiData);
+ var name_value_objects = GetUIObjectList(uiData);
+ var len = name_value_objects.length;
+
+ gTitle = document.createElement("h1");
+
+ gDescription = document.createElement("h2");
+
+
+ document.body.appendChild(gTitle);
+
+
+ document.body.appendChild(gDescription);
+
+
+ form = CreateForm();
+ theForm = form;
+ curKeyID = aKeyID;
+ curKeyType = aKeyType;
+
+ table = CreateTable();
+
+ form.appendChild(table);
+
+ for(i = 0 ; i < len ; i ++)
+ {
+ curParameter = name_value_objects[i];
+
+ if(curParameter)
+ {
+
+ title = curParameter["title"];
+
+
+ if(title)
+ {
+ //alert("title " + title);
+
+ AddTextToNode(gTitle,title);
+
+
+ }
+
+ description = curParameter["description"];
+
+ if(description)
+ {
+ AddBRToNode(document.body);
+ AddBRToNode(document.body);
+
+ AddTextToNode(gDescription,description);
+
+ AddBRToNode(document.body);
+
+ }
+
+ id = curParameter["id"];
+ name = curParameter["name"];
+ type = curParameter["type"];
+ desc = curParameter["desc"];
+
+ //alert(" id " + id + " name " + name + " type " + type + " desc " + desc);
+
+ if(id)
+ {
+ if(table)
+ {
+ row = AddRowToTable(table);
+ }
+
+ if(row)
+ {
+ column = AddColumnToRow(row);
+ }
+
+ if(column)
+ {
+ AddTextToColumn(column,name);
+ }
+
+ if(type == "string" || type == "integer")
+ {
+ field = AddInputField("text",id,name,"");
+ }
+
+ re_field = null;
+
+ if(type == "password")
+ {
+ field = AddInputField("password",id,name,"");
+ }
+
+ if(type == "hidden")
+ {
+ field = AddInputField("hidden",id,name,"");
+ }
+
+ if(field)
+ {
+ field_col = AddColumnToRow(row);
+ if(field_col)
+ {
+ field_col.appendChild(field);
+ }
+ }
+
+ if(re_field)
+ {
+ re_text = AddColumnToRow(row);
+
+ if(re_text)
+ {
+ AddTextToColumn(re_text,"Confirm " + name);
+ re_field_col = AddColumnToRow(row);
+ if(re_field_col)
+ {
+ re_field_col.appendChild(re_field);
+ }
+
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ var last_row = AddRowToTable(table);
+
+ if(last_row)
+ {
+ var button_field = AddColumnToRow(last_row);
+
+ if(button_field)
+ {
+ var button = AddInputField("button","Submit","Submit","Submit");
+ button.onclick = FormSubmit;
+ button_field.appendChild(button);
+
+ }
+
+ }
+}
+
+function UiLoad()
+{
+
+
+ var thisParent = window.opener;
+
+
+ if(!thisParent)
+ {
+ alert("Auth dialog has no parent!");
+ return;
+ }
+
+ var keyID = this.name;
+
+ var ui = thisParent.getUIForKey(keyID);
+
+ var type = thisParent.getTypeForKey(keyID);
+
+ //alert("UiLoad " + ui);
+
+ if(ui)
+ {
+ ConstructUI(type,keyID,ui);
+ }
+}
+
+</script>
+</head>
+<body onload = "UiLoad()">
+</body>
+</html>
diff --git a/pki/linux/tps-ui/shared/docroot/esc/sow/images/logo.gif b/pki/linux/tps-ui/shared/docroot/esc/sow/images/logo.gif
new file mode 100644
index 000000000..2d1ea5579
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/sow/images/logo.gif
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/sow/logo.jpg b/pki/linux/tps-ui/shared/docroot/esc/sow/logo.jpg
new file mode 100644
index 000000000..7cb31affc
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/sow/logo.jpg
Binary files differ
diff --git a/pki/linux/tps-ui/shared/docroot/esc/sow/style.css b/pki/linux/tps-ui/shared/docroot/esc/sow/style.css
new file mode 100755
index 000000000..e9d7d9bf7
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/sow/style.css
@@ -0,0 +1,214 @@
+/* --- BEGIN COPYRIGHT BLOCK ---
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Copyright (C) 2007 Red Hat, Inc.
+ * All rights reserved.
+ * --- END COPYRIGHT BLOCK ---
+ */
+
+body {
+background-color: grey;
+ font-family: arial;
+ font-size: 7p
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+h2 {
+ font-size: 12pt;
+}
+
+.logobar {
+
+ background-color:black;
+ font-family: "Arial";
+ font-size: 7p;
+
+}
+
+.headerText {
+ font-family: "Arial";
+ font-size: 14pt;
+ font-weight: bold;
+ color: white;
+}
+
+.titleText {
+ font-family: "Arial";
+ font-size: 10pt;
+}
+
+.bodyText {
+ font-family: "Arial";
+ font-size: 10pt;
+ color: white;
+}
+
+.formText {
+ font-family: "Arial";
+ font-size: 9pt;
+ color: black;
+
+}
+
+.linkText {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+#BindingTable {
+ background-color: #ffffff ;
+ font-size: 7pt;
+}
+
+#BindingTable th {
+ color: rgb(0, 0, 0);
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+#BindingTable tr {
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+tr [COOLKeyPresent="yes"]{
+ background-color: rgb(255, 0, 0);
+}
+
+.cylon {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+}
+
+.cylonEye {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+}
+
+#statusMsg {
+ font-weight: bold;
+}
+
+.ProgressMeter {
+ position: relative;
+ padding: 0px;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+ text-align: center;
+}
+
+.ProgressBar {
+ position: absolute;
+ z-index: 0;
+ top: 0px;
+ left: 0px;
+ border-right: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+ margin: 0px;
+}
+
+.ProgressBarStatus {
+ position: relative;
+ z-index: 10;
+ margin: 0px;
+ padding: 0px;
+
+}
+
+.KeyTableHeader {
+ color: rgb(0,0, 0);
+ background-color: #ffffff;
+ text-align: left;
+}
+
+#KeyTable td {
+ background-color: #ffffff;
+ padding-left: 3px;
+ padding-right: 3px;
+};
+
+.TableDescriptionPanel {
+ background-color: #ffffff);
+ margin-right: 5px;
+ margin-left: 5px;
+ margin-bottom: 0px;
+ margin-bottom: 5px;
+ padding: 5px;
+}
+
+.PurchasePanel {
+ width: 100%;
+ text-align: center;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+
+.NeedQuestionText {
+ font-size: 16pt;
+ font-weight: bold;
+}
+
+.COOLHeaderText {
+ font-family: "Arial";
+ font-size: 20pt;
+ font-weight: bold;
+}
+
+.ContentTable {
+ background-color: #ffffff;
+ margin: 0px;
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+
+table {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+.TableTitle {
+ font-size: 12pt;
+ font-weight: bold;
+}
+
+.PageHeader {
+ width: 100%;
+ border-bottom: solid black 1px;
+ vertical-align: center;
+ background-color: #ffffff;
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/sow/util.js b/pki/linux/tps-ui/shared/docroot/esc/sow/util.js
new file mode 100755
index 000000000..2af341937
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/sow/util.js
@@ -0,0 +1,1698 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301 USA
+//
+// Copyright (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+//
+// initialize netkey globals
+var netkey;
+
+
+var keyUITable = new Array();
+var keyTypeTable = new Array();
+var curChildWindow = null;
+
+var gWindow = null;
+
+const ErrorText = "For additional assistance contact your Technical Support";
+
+
+function getUIForKey(aKeyID)
+{
+ return keyUITable[aKeyID];
+
+}
+
+function getTypeForKey(aKeyID)
+{
+ return keyTypeTable[aKeyID];
+}
+
+
+//
+// Notify callback for GECKO
+//
+function jsNotify() {}
+
+jsNotify.prototype = {
+
+ rhNotifyKeyStateChange: function(aKeyType,aKeyID,aKeyState,aData,strData)
+ {
+ OnCOOLKeyStateChange(aKeyType, aKeyID, aKeyState, aData,strData);
+ },
+
+ QueryInterface: function(iid)
+ {
+ <!-- alert("iid: " + iid); -->
+ if(!iid.equals(Components.interfaces.rhIKeyNotify) &&
+ !iid.equals(Components.interfaces.nsISupports))
+ {
+ MyAlert("Can't find jsNotify interface");
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+};
+
+//
+// Attach to the object.
+//
+ // GECKO ONLY initialization
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey = Components.classes["@redhat.com/rhCoolKey"].getService();
+ netkey = netkey.QueryInterface(Components.interfaces.rhICoolKey);
+ gNotify = new jsNotify;
+ netkey.rhCoolKeySetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+
+//
+// unregister our notify event
+//
+function cleanup()
+{
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.rhCoolKeyUnSetNotifyCallback(gNotify);
+ } catch(e) {
+ MyAlert("Can't get UniversalXPConnect: " + e);
+ }
+}
+
+var gScreenName = "";
+var gKeyEnrollmentType = "userKey";
+
+var gCurrentSelectedRow = null;
+
+
+var gCurKeyType = null;
+var gCurKeyID = null;
+
+////////////////////////////////////////////////////////////////
+//
+// Utility functions specific to this page.
+//
+////////////////////////////////////////////////////////////////
+
+
+// List of Error Messages to be printed out
+
+var Status_Messages = new Array(
+
+ "Operation Completed Successfully.",
+ "Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Problem communicating with the smartcard.",
+ "Problem resetting smartcard's pin.",
+ "Internal Smartcard Server error.",
+ "Internal Smartcard Server error.",
+ "Smartcard enrollment error.",
+ "Can not communicate with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the Certificattion Authority.",
+ "Internal Smartcard Server error.",
+ "Error resetting the smartcard's password.",
+ "Internal Smartcard Server error.",
+ "Smartcard Server authentication failure.",
+ "Internal Smartcard Server error.",
+ "Your Smartcard is listed as disabled.",
+ "Problem communicating with the smartcard.",
+ "Internal Smartcard Server error.",
+ "Cannot upgrade smartcard software.",
+ "Internal Smartcard Server error.",
+ "Problem communicating with the smartcard.",
+ "Invalid smartcard type.",
+ "Invalid smartcard type.",
+ "Cannot publish smartcard information.",
+ "Cannot communicate with smartcard database.",
+ "Smartcard is disabled.",
+ "Cannot reset password value for the smartcard.",
+ "Connection to Smartcard Server lost.",
+ "Cannot create entry for smartcard in smartcard database.",
+ "Smartcard found to be in an inconsistent state.",
+ "Invalid reason for lost smartcard submitted.",
+ "Smartcard found to be unusable due to compromise.",
+ "No such inactive smartcard found.",
+ "Cannot process more than one active smartcard.",
+ "Internal Smartcard Server error.",
+ "Smartcard key recovery has been processed.",
+ "Smartcard key recovery failed.",
+ "Cannot process this smartcard, which has been reported lost.",
+ "Smartcard key archival error.",
+ "Problem connecting to the Smartcard TKS Server.",
+ "Failed to update smartcard database.",
+ "Internal certificate revocation error discovered.",
+ "User does not own this smartcard.",
+ "Smart Card Manager has been misconfigured.",
+ "Smart Card Manager can not talk to smart card reader.",
+ "Smart Card Manager can not establish a session with the smart card.",
+ "Smart Card Manager can not talk to Smart Card Server.",
+ "Smart Card Manager can not talk to smart card reader."
+ );
+
+function GetAuthDataFromPopUp(aKeyType,aKeyID,aUiData)
+{
+
+ keyUITable[aKeyID] = aUiData;
+ keyTypeTable[aKeyID] = aKeyType;
+
+ //alert("GetAuthDataFromPopUp data " + aUiData);
+ var child = window.open("/GenericAuth.html",aKeyID,"height=400,width=400");
+
+ //alert("Attempted to create child window " + child);
+
+ curChildWindow = child;
+
+}
+
+function COOLKeySetDataValue(aKeyType,aKeyID,name,value)
+{
+ //alert("In COOLKeySetDataValue aKeyType " + aKeyType + " aKeyID " + aKeyID + " name " + name + " value " + value);
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(aKeyType,aKeyID,name,value);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+
+}
+
+function COOLKeySetTokenPin(pin)
+{
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"TokenPin",pin);
+
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+ }
+}
+
+function COOLKeySetUidPassword(uid,pwd)
+{
+
+ if(netkey)
+ {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"UserId",uid);
+
+ netkey.SetCoolKeyDataValue(gCurKeyType,gCurKeyID,"Password",pwd);
+
+ } catch(e) {
+ MyAlert("Error Setting data values: " + e);
+ }
+
+ }
+
+}
+
+
+function MyGetErrorMessage(status_code)
+{
+
+ var result = "Internal Server Error";
+
+ if(status_code < 0 && status_code >= Status_Messages.length)
+ {
+ return result;
+
+ }
+
+ return Status_Messages[status_code];
+
+}
+
+function KeyToRowID(keyType, keyID)
+{
+ return keyType + "--" + keyID;
+}
+
+function RowIDToKeyInfo(rowID)
+{
+ return rowID.split("--");
+}
+
+function GetRowForKey(keyType, keyID)
+{
+ return document.getElementById(KeyToRowID(keyType, keyID));
+}
+
+function ReportException(msg, e)
+{
+ MyAlert(msg + " " + e.description + "(" + e.number + ")");
+}
+
+function GetCOOLKeyStatus(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyStatus(keyType, keyID);
+ } catch (e) {
+ ReportException("netkey.GetCOOLKeyStatus() failed!", e);
+ return 0;
+ }
+}
+
+function GetCOOLKeyPolicy(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyPolicy(keyType, keyID);
+ } catch (e) {
+ // ReportException("netkey.GetCOOLKeyPolicy() failed!", e);
+ return "";
+ }
+}
+
+function GetCOOLKeyRequiresAuth(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyRequiresAuthentication(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyRequiresAuthentication() failed!", e);
+ return false;
+ }
+}
+
+function GetCOOLKeyIsAuthed(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsAuthenticated(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsAuthenticated() failed!", e);
+ return false;
+ }
+}
+
+function GetAvailableCOOLKeys()
+{
+ try {
+ var keyArr;
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var inArray = netkey.GetAvailableCoolKeys( {} );
+ keyArr = new Array(inArray.length);
+ var i;
+
+ for (i=0; i < keyArr.length; i++) {
+ keyArr[i] = new Array( "1", inArray[i]);
+ }
+ return keyArr;
+ } catch(e) {
+ ReportException("netkey.GetAvailableCoolKeys() failed!", e);
+ return [];
+ }
+}
+
+function EnrollCOOLKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.EnrollCoolKey(keyType, keyID, enrollmentType, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException("netkey.EnrollCoolKey() failed!", e);
+ return false;
+ }
+
+ return true;
+}
+
+function GetCOOLKeyIsEnrolled(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ return netkey.GetCoolKeyIsEnrolled(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.GetCoolKeyIsEnrolled() failed!", e);
+ return false;
+ }
+}
+
+function CancelCOOLKeyOperation(keyType, keyID)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.CancelCoolKeyOperation(keyType, keyID);
+ } catch(e) {
+ ReportException("netkey.CancelCoolKeyOperation() failed!", e);
+ return false;
+ }
+ return true;
+}
+
+function MyAlert(message)
+{
+ if(message)
+ DoMyAlert(message,"Smart Card Manager");
+
+}
+function DoMyAlert(message,title)
+{
+
+ if(!message || !title)
+ return;
+
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+
+
+ prompts.alert(window,title,message);
+
+ } catch(e) {
+
+
+ alert("Problem with nsIPromptService " + e);
+ }
+
+}
+
+//
+// MSHTML/GECKO compatibility functions.
+//
+function RemoveRow(table, row)
+{
+ table.deleteRow(row.rowIndex);
+}
+
+function GetCell(row, index)
+{
+ var cell;
+
+ cell = row.cells[index];
+ return cell;
+}
+
+function GetNode(parent, index)
+{
+ var node;
+ node = parent.childNodes[index];
+ return node;
+}
+
+function InsertRow(table)
+{
+ var row;
+
+ row = table.insertRow(table.rows.length);
+ return row;
+}
+
+function InsertCell(row)
+{
+ var cell;
+
+ cell = row.insertCell(row.cells.length);
+ return cell;
+}
+
+function RemoveAllChildNodes(parent)
+{
+ var numChildren = parent.childNodes.length;
+ var i;
+
+ i = numChildren;
+ while (numChildren)
+ {
+ parent.removeChild(GetNode(parent,0));
+ numChildren--;
+ }
+
+}
+
+
+function UpdateInfoForKeyID(keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ if (!row)
+ return;
+
+ var cell = GetCell(row,1)
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(keyStatus));
+
+// cell = GetCell(row,2);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ // cell = GetCell(row,3);
+ // RemoveAllChildNodes(cell);
+ // cell.appendChild(document.createTextNode(isAuthed));
+}
+
+function GetStatusForKeyID(keyType, keyID)
+{
+ var keyStatus = "BLANK";
+
+ var status;
+
+ try {
+ status = GetCOOLKeyStatus(keyType, keyID);
+ } catch(e) {
+ status = 0;
+ }
+
+ switch (status) {
+ case 0: // Unavailable
+ keyStatus = "UNAVAILABLE";
+ break;
+ case 1: // AppletNotFound
+ keyStatus = "NO APPLET";
+ break;
+ case 2: // Uninitialized
+ keyStatus = "UNINITIALIZED";
+ break;
+ case 3: // Unknown
+ keyStatus = "UNKNOWN";
+ break;
+ case 4: // Available
+ case 6: // UnblockInProgress
+ case 7: // PINResetInProgress
+ case 8: // RenewInProgress
+ keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ break;
+ case 5: // EnrollmentInProgress
+ keyStatus = "BUSY";
+ break;
+ break;
+ case 9: // FormatInProgress
+ keyStatus = "BUSY";
+ break;
+ }
+
+ return keyStatus;
+}
+
+function InsertCOOLKeyIntoBindingTable(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+
+ gWindow = window;
+ if (!row)
+ {
+ var table = document.getElementById("BindingTable");
+ if (table)
+ {
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ row = CreateTableRow(table, keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ }
+
+ if (!row)
+ return null;
+ }
+
+ return row;
+}
+
+function ConvertVariantArrayToJScriptArray(varr)
+{
+ // C++ native methods, like netkey.GetAvailableCOOLKeys(), can only
+ // return variant SafeArrays, so to access the data inside, you must
+ // first convert it to a VBArray, and then call toArray() to convert
+ // it to a JScript array. Lame, but that's what it takes to
+ // use an array returned from an ActiveX component.
+
+ return new VBArray(varr).toArray();
+}
+
+function UpdateBindingTableAvailability()
+{
+ var arr = GetAvailableCOOLKeys();
+
+ if (!arr || arr.length < 1)
+ return;
+
+ var i;
+
+ for (i=0; i < arr.length; i++)
+ {
+ InsertCOOLKeyIntoBindingTable(arr[i][0], arr[i][1]);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(arr[i][0], arr[i][1]);
+ }
+}
+
+function InitializeBindingTable()
+{
+ UpdateBindingTableAvailability();
+ UpdateButtonStates();
+ if (UserOnDoneInitializeBindingTable) {
+ UserOnDoneInitializeBindingTable();
+ }
+}
+
+function KeyIsPresent(keyType, keyID)
+{
+ row = document.all.item(keyType, keyID);
+
+ if (!row)
+ return false;
+
+ return true;
+}
+
+function SetStatusMessage(str)
+{
+ var cell = document.getElementById("statusMsg");
+
+ if (!cell)
+ return;
+ RemoveAllChildNodes(cell);
+ cell.appendChild(document.createTextNode(str));
+}
+
+function UpdateButtonStates()
+{
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+
+ document.getElementById("enrollbtn").disabled = false;
+ }
+ else
+ {
+ document.getElementById("enrollbtn").disabled = true;
+ }
+
+ refresh();
+}
+
+function GetCurrentKeyID()
+{
+ if (gCurrentSelectedRow)
+ {
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+ return keyID;
+ } else {
+ return "No Key Found!";
+ }
+}
+
+function SetEnrollmentType(type)
+{
+ gKeyEnrollmentType = type;
+ UpdateButtonStates();
+}
+
+function FindRow(node)
+{
+ while (node && node.tagName != "TR")
+ {
+ node = node.parentNode;
+ }
+
+ return node;
+}
+
+function SelectRow(row)
+{
+ if (!row || gCurrentSelectedRow == row)
+ return;
+
+ if (gCurrentSelectedRow)
+ gCurrentSelectedRow.removeAttribute("style");
+
+ gCurrentSelectedRow = row;
+ gCurrentSelectedRow.style.backgroundColor="rgb(200,200,200)";
+ UpdateButtonStates();
+}
+
+function SelectRowByKeyID(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ SelectRow(row);
+}
+
+function DoSelectRow(event)
+{
+ var row;
+
+ row = FindRow(event.parentNode);
+ SelectRow(row);
+}
+
+function KeyToUIString(keyType, keyID)
+{
+ // If it's an COOLKey, format the keyID string.
+
+ if (keyType == 1 && keyID.length == 20)
+ {
+ var re = /([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})/i;
+ keyID = keyID.replace(re, "$1-$2-$3-$4-$5").toLowerCase();
+ }
+
+ return keyID;
+}
+
+
+
+function CreateTableRow(table, keyType, keyID, keyStatus, reqAuth, isAuthed)
+{
+ var row = InsertRow(table);
+ if (!row)
+ return null;
+
+ row.setAttribute("id", KeyToRowID(keyType, keyID));
+
+ row.onclick = DoSelectRow;
+
+ // Create the key ID cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(KeyToUIString(keyType, keyID)));
+
+ //cell.setAttribute("onClick", "DoSelectRow(this);");
+
+ // Create the keyStatus cell.
+ //cell = InsertCell(row);
+ //cell.appendChild(document.createTextNode(keyStatus));
+
+ // Create the requires auth cell.
+ // cell = InsertCell(row);
+ // cell.appendChild(document.createTextNode(reqAuth));
+
+ cell = InsertCell(row);
+ cell.appendChild(document.createTextNode("Enrollment Progress"));
+
+ // Create the status bar cell
+
+ cell = InsertCell(row);
+
+ var progressMeter = document.createElement("div");
+ progressMeter.setAttribute("id", KeyToProgressBarID(keyType, keyID));
+ progressMeter.className = "ProgressMeter";
+ progressMeter.style.width = "100px";
+ progressMeter.style.height = "1.5em";
+// progressMeter.style.visibility = "hidden";
+ progressMeter.setAttribute("value", 0);
+
+ var progressBar = document.createElement("div");
+ progressBar.className = "ProgressBar";
+ progressBar.style.width = "0px";
+ progressBar.style.height = "100%";
+// progressBar.style.visibility = "hidden";
+
+ var progressBarStatus = document.createElement("div");
+ progressBarStatus.className = "ProgressBarStatus";
+ progressBarStatus.appendChild(document.createTextNode(""));
+
+ progressMeter.appendChild(progressBar);
+ progressMeter.appendChild(progressBarStatus);
+ cell.appendChild(progressMeter);
+
+ //row.style.display ="none";
+
+ return row;
+}
+
+gAnimationMSecs = 1000/30;
+
+function SetCylonTimer(cylonID, cylonEyeID)
+{
+ setTimeout("AnimateCylonStatusBar(\"" + cylonID +
+ "\", \"" + cylonEyeID + "\");", gAnimationMSecs);
+}
+
+function AnimateCylonStatusBar(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID);
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ return;
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (!eye)
+ return;
+
+ var dir = eye.getAttribute("direction");
+ var wid = parseInt(eye.style.width);
+ var cywid = parseInt(cylon.style.width);
+ var left = parseInt(eye.style.left);
+
+ var dx = 10;
+
+ if (!dir || dir >= 0)
+ {
+ left += dx;
+
+ if (left + wid > cywid)
+ {
+ left = cywid - wid;
+ eye.setAttribute("direction", "-1");
+ }
+ }
+ else
+ {
+ left -= dx;
+
+ if (left < 0)
+ {
+ left = 0;
+ eye.setAttribute("direction", "1");
+ }
+ }
+
+ eye.style.left = left + "px";
+
+ SetCylonTimer(cylonID, cylonEyeID);
+}
+
+function StartCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (!cylon)
+ return;
+
+ var active = cylon.getAttribute("cylonactive");
+
+ if (!active)
+ {
+ cylon.setAttribute("cylonactive", "true");
+
+ var eye = document.getElementById(cylonEyeID);
+ if (eye)
+ {
+ eye.style.left = "0px";
+ eye.style.visibility = "visible";
+ }
+
+ SetCylonTimer(cylonID, cylonEyeID);
+ }
+}
+
+function StopCylonAnimation(cylonID, cylonEyeID)
+{
+ var cylon = document.getElementById(cylonID)
+
+ if (cylon)
+ cylon.removeAttribute("cylonactive");
+
+ var eye = document.getElementById(cylonEyeID);
+
+ if (eye)
+ eye.style.visibility = "hidden";
+}
+
+function GetProgressMeterValue(progMeterID)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return -1;
+
+ return parseInt(progMeter.getAttribute("value"));
+}
+
+function SetProgressMeterValue(progMeterID, value)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter || value < 0)
+ return;
+
+ if (value > 100)
+ value = 100;
+
+ var progBar = progMeter.firstChild;
+
+ if (value == 0)
+ {
+ progBar.style.width = "0px";
+ progBar.style.visibility = "hidden";
+ progMeter.setAttribute("value", 0);
+ return;
+ }
+
+ progBar.style.visibility = "visible";
+
+ var newWidth = parseInt(progMeter.style.width) * value / 100 - 2;
+
+ progBar.style.width = newWidth + "px";
+ progMeter.setAttribute("value", value);
+}
+
+function SetProgressMeterStatus(progMeterID, statusMsg)
+{
+ var progMeter = document.getElementById(progMeterID);
+
+ if (!progMeter)
+ return;
+
+ var progBar = progMeter.firstChild;
+
+ // If it exists, the meter status should be
+ // div that is the next sibling of the progressMeter.
+
+ var meterStatus = progBar.nextSibling;
+
+ // Just replace the data in the text node, it's much faster,
+ // and reduces flashing!
+
+ meterStatus.firstChild.replaceData(0, meterStatus.firstChild.length, statusMsg);
+}
+
+function ClearProgressBar(progMeterID)
+{
+ SetProgressMeterValue(progMeterID, 0);
+ SetProgressMeterStatus(progMeterID, "");
+}
+
+function KeyToProgressBarID(keyType, keyID)
+{
+ return "PM" + keyType + "-" + keyID;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions that contact the server or talk directly to
+// ESC native code.
+//
+// ESC Native Functions:
+//
+// netkey.GetAvailableCOOLKeys()
+//
+// - Returns an ActiveX Variant SafeArray containing the ID for each key
+// that is currentlly plugged into the computer. Before accessing any
+// data in this array you must convert it to a JScript Array with a
+// call to ConvertVariantArrayToJScriptArray().
+//
+// netkey.GetCOOLKeyIsEnrolled(keyType, keyID)
+//
+// - Returns true if a key has been initialized, false if it hasn't.
+// Initialized means the card has been formatted with certificates
+// for either an COOL HouseKey or NetKey.
+//
+// netkey.EnrollCOOLKey(keyType, keyID, enrollmentType, screenName, pin)
+//
+// - Initiates an async connection to the RA to initialize a specific
+// key. If you want the key to be initialized as a HouseKey, you should
+// pass "houseKey" as the enrollmentType, and null values for both
+// screenName and pin. For a NetKey, use "netKey" as the enrollmentType,
+// and pass a valid screenName and pin.
+//
+//
+////////////////////////////////////////////////////////////////
+
+function GetScreenNameValue()
+{
+ var sname = document.getElementById("snametf").value;
+
+ if (! sname)
+ {
+ MyAlert("You must provide a valid LDAP User ID!");
+ if (UserOnCOOLKeyStateError) {
+ UserOnCOOLKeyStateError(); // call user-level
+ }
+ return null;
+ }
+
+ return sname;
+}
+
+function GetPINValue()
+{
+ var pinVal = document.getElementById("pintf").value;
+ var rpinVal = document.getElementById("reenterpintf").value;
+
+ if (! pinVal)
+ {
+ MyAlert("You must provide a valid Key Password!");
+ if (UserOnCOOLKeyStateError) {
+ UserOnCOOLKeyStateError(); // call user-level
+ }
+ return null;
+ }
+
+ if ( pinVal != rpinVal)
+ {
+ MyAlert("The Key Password values you entered do not match!");
+ if (UserOnCOOLKeyStateError) {
+ UserOnCOOLKeyStateError(); // call user-level
+ }
+ return null;
+ }
+
+ return pinVal;
+}
+
+function GetScreenNamePwd()
+{
+
+ var pwd = document.getElementById("snamepwd").value;
+
+ if(!pwd)
+ {
+ MyAlert("You must provide a valid LDAP User ID !");
+ if (UserOnCOOLKeyStateError) {
+ UserOnCOOLKeyStateError(); // call user-level
+ }
+ return null;
+ }
+ return pwd;
+}
+
+function GetTokenCode()
+{
+
+ return null;
+}
+function DoEnrollTempCOOLKey()
+{
+
+ if (!gCurrentSelectedRow)
+ {
+ MyAlert("Please select a key.");
+ return;
+ }
+
+ if(!Validate())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ screenname = GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = GetScreenNamePwd();
+
+ tokencode = GetTokenCode();
+
+ //SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ var doShow = true;
+
+ ShowProgressBar(keyType,keyID,doShow );
+
+ if (!EnrollCOOLKey(keyType, keyID, 'userKeyTemporary', screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(aKeyType,aKeyID,doShow );
+ }
+}
+function DoEnrollCOOLKey()
+{
+
+ if (!gCurrentSelectedRow)
+ {
+ MyAlert("Please select a key.");
+ return;
+ }
+
+ if(!Validate())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = GetScreenNameValue();
+
+ pin = GetPINValue();
+
+
+ screennamepwd = GetScreenNamePwd();
+
+ tokencode = GetTokenCode();
+
+ //SetStatusMessage("Enrolling UserKey \"" + KeyToUIString(keyType, keyID) + "\"...");
+ }
+
+ StartCylonAnimation("cylon1", "eye1");
+
+ var doShow = true;
+
+ ShowProgressBar(keyType,keyID,doShow );
+
+ if (!EnrollCOOLKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(aKeyType,aKeyID,doShow );
+ }
+}
+
+function DoResetSelectedCOOLKeyPIN()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate())
+ return;
+
+ //alert("In DoResetSelectedCOOLKeyPIN!");
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var screenname = null;
+ var pin = null;
+ var screennamepwd = null;
+
+ if (GetCOOLKeyIsEnrolled(keyType, keyID))
+ {
+
+ SetStatusMessage("Resetting PIN for \"" + keyID + "\"...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!ResetCOOLKeyPIN(keyType, keyID, screenname, pin,screennamepwd))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+ }
+}
+
+function DoSetURLCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate1())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = 'soUserKey';
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+
+function DoFormatSoCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate1())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = 'soCleanSOToken';
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+
+function DoFormatCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ if(!Validate1())
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ var type = 'soCleanUserToken';
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ SetStatusMessage("Formatting \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ if (!FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode))
+ {
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+ }
+}
+
+function FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netkey.FormatCoolKey(keyType, keyID, type, screenname, pin,screennamepwd,tokencode);
+ } catch(e) {
+ ReportException(getBundleString("errorFormatCoolKey"), e);
+ return false;
+ }
+ return true;
+}
+
+function DoCancelOperation()
+{
+
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ SetStatusMessage("Cancel operation for \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ CancelCOOLKeyOperation(keyType, keyID);
+
+ SetStatusMessage("");
+ StopCylonAnimation("cylon1", "eye1");
+}
+
+function DoChallengeSelectedKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Generating Challenge ...");
+
+ var challengeArray = ChallengeCOOLKey(keyType, keyID, document.forms[0].challengedata.value);
+
+ if (challengeArray.length != 4)
+ {
+ MyAlert("Challenge for key \"" + KeyToUIString(keyType, keyID) + "\" failed!");
+ SetStatusMessage("");
+ return;
+ }
+
+ MyAlert("ChallengeCOOLKey(\""+ KeyToUIString(keyType, keyID) + "\") returned:\n\n" +
+ "challenge[0]: " + challengeArray[0] + "\n" +
+ "challenge[1]: " + challengeArray[1] + "\n" +
+ "challenge[2]: " + challengeArray[2] + "\n" +
+ "challenge[3]: " + challengeArray[3] + "\n");
+
+ SetStatusMessage("");
+}
+
+function DoBlinkCOOLKey()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ SetStatusMessage("Blinking \"" + KeyToUIString(keyType, keyID) + "\" ...");
+ StartCylonAnimation("cylon1", "eye1");
+
+ BlinkCOOLKey(keyType, keyID, 400, 5000);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+}
+
+function OnCOOLKeyBlinkComplete(keyType,keyID)
+{
+ //StopCylonAnimation("cylon1", "eye1");
+ //SetStatusMessage(" ");
+}
+
+function DoHelp()
+{
+ if (!gCurrentSelectedRow)
+ return;
+
+ var keyInfo = RowIDToKeyInfo(gCurrentSelectedRow.getAttribute("id"));
+ var keyType = keyInfo[0];
+ var keyID = keyInfo[1];
+
+ if (!keyID)
+ return;
+
+ var policy = GetCOOLKeyPolicy(keyType, keyID);
+ var type = PolicyToKeyType(policy);
+ MyAlert("Policy: " + policy + "\n" + "Type: " + type);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Functions called directly from ASC native code.
+//
+////////////////////////////////////////////////////////////////
+
+function OnCOOLKeyInserted(keyType, keyID)
+{
+ var row = InsertCOOLKeyIntoBindingTable(keyType, keyID);
+
+ if (!gCurrentSelectedRow)
+ SelectRowByKeyID(keyType, keyID);
+ if (UserOnCOOLKeyInserted) {
+ UserOnCOOLKeyInserted(keyType, keyID);
+ }
+}
+
+
+function OnCOOLKeyRemoved(keyType, keyID)
+{
+ var row = GetRowForKey(keyType, keyID);
+ var table = document.getElementById("BindingTable");
+
+ if (row && table)
+ {
+ RemoveRow(table,row);
+
+ if (row == gCurrentSelectedRow)
+ gCurrentSelectedRow = null;
+ }
+
+ UpdateButtonStates();
+ if (UserOnCOOLKeyRemoved) {
+ UserOnCOOLKeyRemoved(keyType, keyID);
+ }
+}
+
+var gKnownPolicies = [
+
+ // OID Value, precedence, name value
+
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.1.0.1.4", 4, "NETKEY" ], // Platinum - MyDoctor
+
+ // XXX: Remove the Old OIDs below, after the RA starts generating
+ // certificates with the OIDs listed above!
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.1", 1, "HOUSEKEY" ], // Bronze - HouseKey
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.2", 2, "NETKEY" ], // Silver - Member
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.3", 3, "NETKEY" ], // Gold - Associate
+ [ "OID.1.3.6.1.4.1.1066.1.1000.2.4", 4, "NETKEY" ] // Platinum - MyDoctor
+];
+
+function PolicyToKeyType(policy)
+{
+ return "ENROLLED";
+}
+
+function OldPolicyToKeyType(policy)
+{
+ var i, j;
+
+ var knownPoliciesIndex = -1;
+
+
+ var policies;
+
+
+ if (policy.indexOf(",")== -1)
+ {
+ policies = new Array(1);
+ policies[0] = policy;
+ }
+ else
+ {
+ policies = policy.split(",");
+ }
+
+ for (j = 0; j < policies.length; j++)
+ {
+ for (i = 0; i < gKnownPolicies.length; i++)
+ {
+ if (gKnownPolicies[i][0] == policies[j])
+ {
+ if (knownPoliciesIndex < gKnownPolicies[i][1])
+ knownPoliciesIndex = i;
+ }
+ }
+ }
+
+ if (knownPoliciesIndex == -1)
+ return "INITIALIZED";
+
+ return gKnownPolicies[knownPoliciesIndex][2];
+}
+
+function BoolToYesNoStr(b)
+{
+ if (b)
+ return "YES";
+ return "NO";
+}
+
+function OnCOOLKeyEnrollmentComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+ SetStatusMessage("");
+ MyAlert("Enrollment of smartcard complete!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+
+ window.setTimeout("loadSuccessPage()",4);
+}
+
+function OnCOOLKeyPINResetComplete(keyType, keyID)
+{
+ var keyStatus = PolicyToKeyType(GetCOOLKeyPolicy(keyType, keyID));
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+ UpdateButtonStates();
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Password Reset was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+}
+
+function OnCOOLKeyFormatComplete(keyType, keyID)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+ MyAlert("Format of \"" + KeyToUIString(keyType, keyID)+ "\" was successful!");
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+ if (UserOnCOOLKeyFormatComplete) {
+ UserOnCOOLKeyFormatComplete(); // call user-level
+ }
+}
+
+function OnCOOLKeyStateError(keyType, keyID, keyState, errorCode)
+{
+ var keyStatus = GetStatusForKeyID(keyType, keyID);
+ var keyReqAuth = BoolToYesNoStr(GetCOOLKeyRequiresAuth(keyType, keyID));
+ var keyIsAuthed = BoolToYesNoStr(GetCOOLKeyIsAuthed(keyType, keyID));
+
+ if(curChildWindow)
+ {
+ curChildWindow.close();
+ curChildWindow = null;
+
+ }
+
+ var doShow = false;
+ ShowProgressBar(keyType,keyID, doShow);
+
+ //UpdateInfoForKeyID(keyType, keyID, keyStatus, keyReqAuth, keyIsAuthed);
+
+ StopCylonAnimation("cylon1", "eye1");
+ SetStatusMessage("");
+
+ var typeStr = "Error(" + errorCode + ")";
+
+ var messageStr = " \n\n Error Response: " + MyGetErrorMessage(errorCode) ;
+
+ var keyIDStr = KeyToUIString(keyType, keyID);
+
+ if (keyState == 1004)
+ typeStr = "Enrollment of key failed. " + typeStr + messageStr ;
+ else if (keyState == 1016)
+ typeStr = "Formatting of key failed. " + typeStr + messageStr;
+ else if (keyState == 1010)
+ typeStr = "PIN Reset for key failed. " + typeStr + messageStr;
+ else if (keyState == 1020)
+ typeStr = "Operation for key canceled.";
+
+ typeStr += " \n " + ErrorText;
+ MyAlert(typeStr);
+ ClearProgressBar(KeyToProgressBarID(keyType, keyID));
+ if (UserOnCOOLKeyStateError) {
+ UserOnCOOLKeyStateError(); // call user-level
+ }
+}
+
+function OnCOOLKeyStatusUpdate(progMeterID, statusUpdate)
+{
+ SetProgressMeterValue(progMeterID, statusUpdate);
+ SetProgressMeterStatus(progMeterID, statusUpdate + "%");
+}
+
+function Validate1()
+{
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ screenname = '';
+ screennamepwd = 'netscape';
+ pin = 'netscape'
+
+ return 1;
+}
+function Validate()
+{
+
+ var type = gKeyEnrollmentType;
+ var screenname = null;
+ var pin = null;
+
+ var screennamepwd = null;
+ var tokencode = null;
+
+ if (type == "userKey")
+ {
+ screenname = GetScreenNameValue();
+ if (! screenname)
+ return 0;
+
+ screennamepwd = GetScreenNamePwd();
+
+ if(! screennamepwd)
+ return 0;
+
+ pin = GetPINValue();
+
+ if (! pin)
+ return 0;
+
+ }
+
+ return 1;
+}
+
+function OnCOOLKeyStateChange(keyType, keyID, keyState, data,strData)
+{
+ // alert("KeyID: " + keyID + "\n" +
+ // "KeyState: " + keyState + "\n" +
+ // "Data: " + data);
+ //alert("State Change ="+keyState);
+
+ switch(keyState)
+ {
+ case 1000: // KeyInserted
+ OnCOOLKeyInserted(keyType, keyID);
+ break;
+ case 1001: // KeyRemoved
+ OnCOOLKeyRemoved(keyType, keyID);
+ break;
+ case 1002: // EnrollmentStart
+ // OnCOOLKeyEnrollmentStart(keyType, keyID);
+ break;
+ case 1003: // EnrollmentComplete
+ OnCOOLKeyEnrollmentComplete(keyType, keyID);
+ break;
+ case 1004: // EnrollmentError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1008: // PINResetStart
+ // OnCOOLKeyPINResetStart(keyType, keyID);
+ break;
+ case 1009: // PINResetComplete
+ OnCOOLKeyPINResetComplete(keyType, keyID);
+ break;
+ case 1010: // PINResetError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1014: // FormatStart
+ // OnCOOLKeyFormatStart(keyType, keyID);
+ break;
+ case 1015: // FormatComplete
+ OnCOOLKeyFormatComplete(keyType, keyID);
+ break;
+ case 1016: // FormatError
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1017: // BlinkStatus Update?
+ //OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1018:
+ OnCOOLKeyBlinkComplete(keyType, keyID);
+ break;
+ case 1020: // OperationCancelled
+ OnCOOLKeyStateError(keyType, keyID, keyState, data);
+ break;
+ case 1021: // OperationStatusUpdate
+ OnCOOLKeyStatusUpdate(KeyToProgressBarID(keyType, keyID), data);
+ break;
+
+ case 1022: //Need Auth
+
+
+ gCurKeyID = keyID;
+ gCurKeyType = keyType;
+
+ GetAuthDataFromPopUp(keyType,keyID,strData);
+
+ break;
+
+ }
+}
+
+function refresh()
+{
+ window.resizeBy(0,1);
+ window.resizeBy(0,-1);
+
+}
+
+function loadSuccessPage()
+{
+ window.location="/sow/EnrollSuccess.html";
+}
+
+function ShowProgressBar(aKeyType,aKeyID, doShow)
+{
+ if(!gCurrentSelectedRow)
+ return;
+
+ if(doShow)
+ gCurrentSelectedRow.style.display="table-row";
+ else
+ {
+ gCurrentSelectedRow.style.display="none";
+ }
+}
+function DoCoolKeySetConfigValue(configValue,newValue)
+{
+ if(!configValue || !newValue)
+ return null;
+
+ var result = null;
+
+ if(netkey)
+ {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ result = netkey.SetCoolKeyConfigValue(configValue,newValue);
+
+ } catch(e) {
+ MyAlert(getBundleString("errorConfigValue") + " " + e);
+ }
+
+ }
+
+ return result;
+}
diff --git a/pki/linux/tps-ui/shared/docroot/esc/style.css b/pki/linux/tps-ui/shared/docroot/esc/style.css
new file mode 100755
index 000000000..f85d18ee2
--- /dev/null
+++ b/pki/linux/tps-ui/shared/docroot/esc/style.css
@@ -0,0 +1,197 @@
+/* --- BEGIN COPYRIGHT BLOCK ---
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Copyright (C) 2007 Red Hat, Inc.
+ * All rights reserved.
+ * --- END COPYRIGHT BLOCK ---
+ */
+
+body {
+background: #ffffff url(../images/bg.jpg) repeat-x;
+ font-family: arial;
+ font-size: 7p
+
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+h2 {
+ font-size: 12pt;
+}
+
+.headerText {
+ font-family: "Arial";
+ font-size: 12pt;
+ font-weight: bold;
+}
+
+.titleText {
+ font-family: "Arial";
+ font-size: 10pt;
+}
+
+.bodyText {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+.linkText {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+#BindingTable {
+ background-color: #ffffff ;
+ font-size: 7pt;
+}
+
+#BindingTable th {
+ color: rgb(0, 0, 0);
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+#BindingTable tr {
+ background-color: #fffffe;
+ font-size: 7pt;
+}
+
+tr [COOLKeyPresent="yes"]{
+ background-color: rgb(255, 0, 0);
+}
+
+.cylon {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+}
+
+.cylonEye {
+ font-size: 4pt;
+ position: relative;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+}
+
+#statusMsg {
+ font-weight: bold;
+}
+
+.ProgressMeter {
+ position: relative;
+ padding: 0px;
+ border: 1px solid rgb(60, 60, 60);
+ background-color: #ffffff;
+ text-align: center;
+}
+
+.ProgressBar {
+ position: absolute;
+ z-index: 0;
+ top: 0px;
+ left: 0px;
+ border-right: 1px solid rgb(60, 60, 60);
+ background-color: rgb(0, 128, 192);
+ margin: 0px;
+}
+
+.ProgressBarStatus {
+ position: relative;
+ z-index: 10;
+ margin: 0px;
+ padding: 0px;
+
+}
+
+.KeyTableHeader {
+ color: rgb(0,0, 0);
+ background-color: #ffffff;
+ text-align: left;
+}
+
+#KeyTable td {
+ background-color: #ffffff;
+ padding-left: 3px;
+ padding-right: 3px;
+};
+
+.TableDescriptionPanel {
+ background-color: #ffffff);
+ margin-right: 5px;
+ margin-left: 5px;
+ margin-bottom: 0px;
+ margin-bottom: 5px;
+ padding: 5px;
+}
+
+.PurchasePanel {
+ width: 100%;
+ text-align: center;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+
+.NeedQuestionText {
+ font-size: 16pt;
+ font-weight: bold;
+}
+
+.COOLHeaderText {
+ font-family: "Arial";
+ font-size: 20pt;
+ font-weight: bold;
+}
+
+.ContentTable {
+ background-color: #ffffff;
+ margin: 0px;
+}
+
+form {
+ margin: 0px;
+ padding: 0px;
+};
+
+* {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+
+table {
+ font-family: "Arial";
+ font-size: 8pt;
+}
+
+.TableTitle {
+ font-size: 12pt;
+ font-weight: bold;
+}
+
+.PageHeader {
+ width: 100%;
+ border-bottom: solid black 1px;
+ vertical-align: center;
+ background-color: #ffffff;
+}