Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: reference_extension/client.js

Issue 6821025: entd: move opencryptoki initialization out of entd (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/entd.git@master
Patch Set: switch to using a flag to expect cryptohome to init pkcs11 Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « main.cc ('k') | reference_extension/options.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Namespace object for the client side code. 6 * Namespace object for the client side code.
7 */ 7 */
8 var client = new Object(); 8 var client = new Object();
9 9
10 /** 10 /**
11 * Port to contact the policy's callback server. 11 * Port to contact the policy's callback server.
12 */ 12 */
13 client.policyCallbackPort = 5199; 13 client.policyCallbackPort = 5199;
14 14
15 client.cryptohome_init_pkcs11 = false;
16
15 /** 17 /**
16 * Initialize the client. 18 * Initialize the client.
17 */ 19 */
18 client.onLoad = 20 client.onLoad =
19 function onLoad() { 21 function onLoad() {
20 client.modalShade = document.getElementById('modal-shade'); 22 client.modalShade = document.getElementById('modal-shade');
21 client.loadManifest(); 23 client.loadManifest();
22 }; 24 };
23 25
24 client.onManifestLoaded = 26 client.onManifestLoaded =
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 'PKCS#11 services have not started, you may need to clear your ' + 132 'PKCS#11 services have not started, you may need to clear your ' +
131 'TPM to recover.', 'Error', 133 'TPM to recover.', 'Error',
132 { details: 'current state: ' + pkcs11.state + '\n' + 134 { details: 'current state: ' + pkcs11.state + '\n' +
133 pkcs11.log }); 135 pkcs11.log });
134 } 136 }
135 } else { 137 } else {
136 $("#pkcs11-status"). 138 $("#pkcs11-status").
137 text('Ready'). 139 text('Ready').
138 attr('status', 'green'); 140 attr('status', 'green');
139 141
142 // Use presence of isTokenReady to determine if
143 // cryptohome_init_pkcs11 is true.
144 // TODO(crosbug.com/14277): Remove this conditional and code
145 // to recognize if TPM has been initialized (only check token).
146 client.cryptohome_init_pkcs11 = 'isTokenReady' in pkcs11;
147
140 if (retval.data.isLibcrosLoaded && !retval.data.tpm.isEnabled) { 148 if (retval.data.isLibcrosLoaded && !retval.data.tpm.isEnabled) {
141 if (!tpmError) { 149 if (!tpmError) {
142 client.showError("Your TPM is not enabled. Please enable " + 150 client.showError("Your TPM is not enabled. Please enable " +
143 "it in the BIOS."); 151 "it in the BIOS.");
144 $('#entd-message'). 152 $('#entd-message').
145 text('Please reboot and enable your TPM.'). 153 text('Please reboot and enable your TPM.').
146 attr('status', 'red'); 154 attr('status', 'red');
147 tpmError = true; 155 tpmError = true;
148 } 156 }
149 } else if (retval.data.isLibcrosLoaded && !retval.data.tpm.isReady) { 157 } else if (retval.data.isLibcrosLoaded && !retval.data.tpm.isReady) {
(...skipping 10 matching lines...) Expand all
160 client.showError('Your TPM is not properly configured. Please ' + 168 client.showError('Your TPM is not properly configured. Please ' +
161 'clear your TPM and try again.', 'Error', 169 'clear your TPM and try again.', 'Error',
162 options); 170 options);
163 } 171 }
164 172
165 $('#entd-message'). 173 $('#entd-message').
166 text('Waiting for TPM.'). 174 text('Waiting for TPM.').
167 attr('status', 'red'); 175 attr('status', 'red');
168 tpmError = true; 176 tpmError = true;
169 } 177 }
178 } else if (retval.data.isLibcrosLoaded &&
179 client.cryptohome_init_pkcs11 &&
180 !pkcs11.isTokenReady) {
181 if (!tpmError) {
182 client.showAlert('Please wait while your TPM Token is being ' +
183 'created. This dialog should go away on its ' +
184 'own when the process completes.', 'Alert',
185 options);
186 $('#entd-message').
187 text('Waiting for TPM Token.').
188 attr('status', 'red');
189 tpmError = true;
190 }
170 } else { 191 } else {
171 ready = true; 192 ready = true;
172 } 193 }
173 } 194 }
174 } else { 195 } else {
175 $("#entd-status"). 196 $("#entd-status").
176 text('Waiting...'). 197 text('Waiting...').
177 attr('status', 'red'); 198 attr('status', 'red');
178 199
179 $("#pkcs11-status"). 200 $("#pkcs11-status").
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 client.invokePolicyCallback( 366 client.invokePolicyCallback(
346 'initiateCSR', { certificateId: cert.id, variables: variables }, 367 'initiateCSR', { certificateId: cert.id, variables: variables },
347 onerror); 368 onerror);
348 } 369 }
349 370
350 /** 371 /**
351 * Initiate a token initialization. 372 * Initiate a token initialization.
352 * 373 *
353 * This causes the token initialization progress dialog to be shown, and manages 374 * This causes the token initialization progress dialog to be shown, and manages
354 * the asynchronous initialization of a token. 375 * the asynchronous initialization of a token.
376 * TODO(crosbug.com/14277): Remove token initialization UI.
355 */ 377 */
356 client.initToken = 378 client.initToken =
357 function initToken(token, force) { 379 function initToken(token, force) {
358 var slotId = token.slotId; 380 var slotId = token.slotId;
359 381
360 // Called for any kind of error from the enterprise daemon. 382 // Called for any kind of error from the enterprise daemon.
361 function onerror(retval) { 383 function onerror(retval) {
362 if (retval instanceof client.CallbackError) 384 if (retval instanceof client.CallbackError)
363 client.showError('There was an error initializing your token. ' + 385 client.showError('There was an error initializing your token. ' +
364 'If the problem persists, clear your TPM and try ' + 386 'If the problem persists, clear your TPM and try ' +
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 */ 937 */
916 client.renderToken = 938 client.renderToken =
917 function renderToken(token) { 939 function renderToken(token) {
918 var li = document.createElement('li'); 940 var li = document.createElement('li');
919 li.className = 'token'; 941 li.className = 'token';
920 li.setAttribute('id', 'token-' + token.slotId); 942 li.setAttribute('id', 'token-' + token.slotId);
921 943
922 $(li).html( 944 $(li).html(
923 '<table width="100%">' + 945 '<table width="100%">' +
924 '<tr><td><span class="desc"></span> (<span class="label"></span>)</td>' + 946 '<tr><td><span class="desc"></span> (<span class="label"></span>)</td>' +
925 '<td rowspan="2" width="1%"><button>Initialize</button></td></tr>' + 947 '<td rowspan="2" width="1%"><button class="init-button">Initialize' +
926 '<tr><td class="status"></td></tr></table>'); 948 '</button></td></tr><tr><td class="status"></td></tr></table>');
927 949
928 $(li).find('button').click(function () { 950 $(li).find('button').click(function () {
929 client.onTokenClick_(client.tokens[token.slotId]); 951 client.onTokenClick_(client.tokens[token.slotId]);
930 }); 952 });
931 953
932 $(li).find('.status').click(function () { 954 $(li).find('.status').click(function () {
933 client.showTokenDetails(client.tokens[token.slotId]); 955 client.showTokenDetails(client.tokens[token.slotId]);
934 }); 956 });
935 957
936 client.refreshToken(li, token); 958 client.refreshToken(li, token);
(...skipping 21 matching lines...) Expand all
958 status = 'PINs not initialized.'; 980 status = 'PINs not initialized.';
959 } else { 981 } else {
960 color = 'red'; 982 color = 'red';
961 status = 'Token error'; 983 status = 'Token error';
962 } 984 }
963 985
964 $('.desc', li).text(token.manufacturerID + ', ' + token.model); 986 $('.desc', li).text(token.manufacturerID + ', ' + token.model);
965 $('.label', li).text(token.label || 'Unlabeled'); 987 $('.label', li).text(token.label || 'Unlabeled');
966 $('.status', li).attr('status', color); 988 $('.status', li).attr('status', color);
967 $('.status', li).text(status); 989 $('.status', li).text(status);
968 $('button', li).text(color == 'red' ? 'Initialize' : 'Reinitialize'); 990 if (client.cryptohome_init_pkcs11) {
991 // If automatic initialization is enabled, do not give the user
992 // the option to initialize.
993 $('.init-button', li).css('display', 'none');
994 } else {
995 $('button', li).text(color == 'red' ? 'Initialize' : 'Reinitialize');
996 }
969 } 997 }
970 998
971 /** 999 /**
972 * Create the UI for a list of certificates. 1000 * Create the UI for a list of certificates.
973 * 1001 *
974 * This will destroy any existing cert UI before proceeding. 1002 * This will destroy any existing cert UI before proceeding.
975 * 1003 *
976 * @param {Array} certs The list of known certificates. 1004 * @param {Array} certs The list of known certificates.
977 */ 1005 */
978 client.resetCertificates = 1006 client.resetCertificates =
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 * @param {string} name The name of the callback that returned this data. 1205 * @param {string} name The name of the callback that returned this data.
1178 * @param {Object} arg The argument object originally passed to the callback. 1206 * @param {Object} arg The argument object originally passed to the callback.
1179 * @param {Object} data The data returned by the callback. 1207 * @param {Object} data The data returned by the callback.
1180 */ 1208 */
1181 client.CallbackError = 1209 client.CallbackError =
1182 function CallbackError(name, arg, data) { 1210 function CallbackError(name, arg, data) {
1183 this.init_(name, arg, data); 1211 this.init_(name, arg, data);
1184 }; 1212 };
1185 1213
1186 client.CallbackError.prototype.init_ = client.CallbackSuccess.prototype.init_; 1214 client.CallbackError.prototype.init_ = client.CallbackSuccess.prototype.init_;
OLDNEW
« no previous file with comments | « main.cc ('k') | reference_extension/options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698