summaryrefslogtreecommitdiffstats
path: root/base/tps/apache/cgi-bin/sow/enroll_temp.html
blob: 342eddb1bc9bac635cab85c22c6664fab0fe6b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!-- --- BEGIN COPYRIGHT BLOCK ---
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; version 2 of the License.

     This program 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 General Public License for more details.

     You should have received a copy of the GNU General Public License along
     with this program; if not, write to the Free Software Foundation, Inc.,
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

     Copyright (C) 2009 Red Hat, Inc.
     All rights reserved.
     --- END COPYRIGHT BLOCK --- -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel=stylesheet href="/pki/esc/sow/style.css" type="text/css">

<title>Enrollment</title>
<script type="text/javascript" src="/esc/sow/js/prototype.js"></script>
<script type="text/javascript" src="/esc/sow/js/scriptaculous.js?load=effects"></script>
<script type="text/JavaScript" src="/esc/sow/util.js"></script>
<link rel="stylesheet" href="/pki/esc/sow/css/style.css" media="screen" type="text/css">
<script type="text/javascript">
<!--
function UserOnCOOLKeyStateError()
{
  toggleAjaxProgress('ajax-pb', 'off');
  toggleButton('enrollbtn', 'on');
  toggleButton('cancel', 'on');
}

function UserSelectRowByKeyID(keyType, keyID)
{
  DoCoolKeySetConfigValue("Operation-" + keyID,
           "https://$host:$secure_port/nk_service");
  DoCoolKeySetConfigValue("TokenType-" + keyID, "userKey");
  SelectRowByKeyID(keyType, keyID);
}

function updateKeyText(text)
{
  var f = document.getElementById('keytext');
  new Effect.Shake(f);
  var text = document.createTextNode(text);
  var len= f.childNodes.length;  
  for (i=0;i<len;i++){
       f.removeChild(f.childNodes[0]);
  }
  f.appendChild(text);
}

var officerToken = null;
function UserOnDoneInitializeBindingTable()
{
  // display existing blank smart
  var arr = GetAvailableCOOLKeys();
  if (!arr || arr.length < 1)
    return;
  var i;
  for (i=0; i < arr.length; i++)
  {
    var keyType = arr[i][0];
    var keyID = arr[i][1];
    var keyStatus = GetStatusForKeyID(keyType, keyID);
    if (keyStatus == "BLANK") {
      updateKeyText('A ' + keyStatus + ' smartcard "' + keyID + '" is detected!');
      UserSelectRowByKeyID(keyType, keyID);
    } else if (keyStatus == "UNINITIALIZED") {
      updateKeyText('An ' + keyStatus + ' smartcard "' + keyID + '" is detected!');
      UserSelectRowByKeyID(keyType, keyID);
    }

    if(keyStatus == "ENROLLED" ) {
        var uid =  GetCoolKeyIssuedTo(keyType,keyID);
        if(uid)
        {
            isAgent = window.IsAgentOrUser(uid,"agent");
        }
        if(isAgent == true)
        {
            officerToken = keyID;
        }
    }

  }
}

function UserOnCOOLKeyInserted(keyType, keyID)
{
  var arr = GetAvailableCOOLKeys();
  var curKeyType = null;
  var curKeyID = null;
  var curKeyStatus = null;
  var i = 0;
  var enrollbtn = document.getElementById('enrollbtn');
  while(1) {
      if (arr && arr.length <= 1  )
      {
          toggleButton('enrollbtn','off');
          return;
      }
      if (arr && arr.length > 1 )
      {
          toggleButton('enrollbtn','on');
      }
      curKeyType = arr[i][0];
      curKeyID = arr[i][1];

      var curKeyStatus = GetStatusForKeyID(curKeyType, curKeyID);
      if(!(curKeyID == officerToken && curKeyStatus == "ENROLLED")) {
          break;
      }
      i++;
  }

  if (curKeyStatus == "ENROLLED" || curKeyStatus == "UNINITIALIZED") {
      updateKeyText('An ' + curKeyStatus + ' smartcard "' + curKeyID + '" is detected!');
  } else {
      updateKeyText('A ' + curKeyStatus + ' smartcard "' + curKeyID + '" is detected!');
  }

  var uid = null;
  var isAgent = null;
  UserSelectRowByKeyID(curKeyType, curKeyID);

  if(curKeyStatus == "ENROLLED")
  {
    uid =  GetCoolKeyIssuedTo(curKeyType,curKeyID);
    if(uid)
    {
        isAgent = window.IsAgentOrUser(uid,"agent");
    }     
    if(isAgent == true)
    {
        MyAlert("You can't Enroll a temporary card that belongs to another Security Officer!");
        updateKeyText('A ' + curKeyStatus + ' smartcard "' + curKeyID + '" SECURITY OFFICER is detected!');
        toggleButton('enrollbtn','off');
    }
  }
}

function UserOnCOOLKeyRemoved(keyType, keyID)
{
  updateKeyText('Please insert a blank smartcard now!');
}

function UserOnCOOLKeyStatusUpdate(data)
{
  var progress = document.getElementById("progress");
  if(progress)
      progress.innerHTML = data + "%";
}


function toggleAjaxProgress(id, i)
{
  var e = document.getElementById(id);
  if (i == 'off') {
    e.style.display = 'none';
  } else {
    e.style.display = 'block';
  }
}

function toggleButton(id, i)
{
  var e = document.getElementById(id);
  if (i == 'off') {
    e.disabled = true;
  } else {
    e.disabled = false;
  }
}
// -->
</script>
</head>

<body onload="InitializeBindingTable();" onunload=cleanup()>

<progressmeter id="progress-id" hidden="true" align = "center"/>

<div id="pb" style="display:none;">
  <table id="BindingTable" width="200px" align="center">
    <tr id="HeaderRow">
    </tr>
  </table>
</div>
<div id="header">
  <div id="logo">
      <h3>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><p>The security officer has identified the user as <strong>$cn</strong>. The User ID is <strong>$uid</strong>.</p>
</blockquote>
<h3><span id="keytext">Please insert new smartcard now!</span></h3>
      <blockquote><p>The user must provide a password to protect the smart card.</p> </blockquote>
        <h3>New Token Password:</h3>
        <input type="password" id="pintf" name="pintf" value=""><br/>
        <h3>Re-Enter Token Password:</h3>
        <input type="password" id="reenterpintf" name="reenterpintf" value=""><br/>
        <input type="hidden" id="snametf"  value="$uid">
        <h3>User Password:</h3>
        <input type="password" id="snamepwd" value=""><br/>
    <table width="100%">
      <tr>
<td>
<div id="ajax-pb" style="display:none;">
  <img src="/pki/esc/sow/images/indicator.gif">
  <h2 id="progress" name="progress" value="0%" ></h2>
</div>
</td>
        <td align="right">
          <input type="button" id="enrollbtn" name="enrollbtn" value="Start Enrollment" onClick="toggleButton('enrollbtn','off');toggleButton('cancel', 'off');toggleAjaxProgress('ajax-pb','on');DoEnrollTempCOOLKey();">
          <input type="submit" id="cancel" name="cancel" value="Cancel" onClick="javascript:location.href='/cgi-bin/sow/search.cgi';">
        </td>
      </tr>
    </table>
  </div>
</div>
</body></html>