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

Unified Diff: base_policy/policy-utils.js

Issue 6338003: Explicitly logging out the token to avoid leaving it in a non-stable state. (Closed) Base URL: http://git.chromium.org/git/entd.git@master
Patch Set: Returning early on logout failure. Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | crypto_pkcs11.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base_policy/policy-utils.js
diff --git a/base_policy/policy-utils.js b/base_policy/policy-utils.js
index e3283236761b3bd9edc8e3057867667779802b5b..03d99640a9f980a18c1cd373831220f791867408 100644
--- a/base_policy/policy-utils.js
+++ b/base_policy/policy-utils.js
@@ -494,7 +494,7 @@ function setTokenPins(token, userType, oldPin, newPin) {
this.stop(token, 'error', 'Failed to login to token');
} catch (ex) {
this.stop(token, 'error', 'Exception initializing PIN: ' + ex);
- session.close();
+ session.logoutAndClose();
return false;
}
@@ -505,7 +505,7 @@ function setTokenPins(token, userType, oldPin, newPin) {
this.info('PIN Reset complete.');
} catch (ex) {
this.stop(token, 'error', 'Exception changing PIN: ' + ex);
- session.close();
+ session.logoutAndClose();
return false;
}
@@ -515,7 +515,7 @@ function setTokenPins(token, userType, oldPin, newPin) {
this.stop(token, pinType);
}
- session.close();
+ session.logoutAndClose();
return true;
}
@@ -813,6 +813,8 @@ function loginToken(token, sessionType, pin) {
var session = null;
+ this.info('Opening session and logging into token.');
+
try {
token.closeAllSessions();
session = token.openSession(Token.CKF_RW_SESSION);
@@ -824,12 +826,12 @@ function loginToken(token, sessionType, pin) {
try {
if (!session.login(sessionType, pin)) {
this.error('Unable to log in user into token.');
- session.close();
+ session.logoutAndClose();
return null;
}
} catch (ex) {
this.error('Failed to login user into token: ' + ex);
- session.close();
+ session.logoutAndClose();
return null;
}
@@ -952,11 +954,11 @@ function isInstalled() {
var cert = policy.findCertificateById(session, this.id);
var key = policy.findPrivateKeyById(session, this.id);
- session.close();
+ session.logoutAndClose();
return (cert != null && key != null);
} catch(ex) {
- session.close();
+ session.logoutAndClose();
this.error('Error checking certificate is installed: ', ex);
}
@@ -1002,13 +1004,13 @@ function initiateCSR() {
// Generate a key pair.
this.policy.generateKeyPair(session, this.id, this.label);
} catch(e) {
- session.close();
+ session.logoutAndClose();
return this.stop('error', 'Failed to create key on PKCS#11 device: ' + e);
}
this.stop('key', 'Key generation complete');
- session.close();
+ session.logoutAndClose();
this.start('csr', 'Initiating Certificate Signing Request');
@@ -1157,7 +1159,7 @@ function onIssuanceComplete(request, response) {
this.stop('cert');
- session.close();
+ session.logoutAndClose();
};
Policy.prototype.setBrowserPolicy =
« no previous file with comments | « no previous file | crypto_pkcs11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698