< prev index next >

src/share/classes/sun/security/pkcs11/SunPKCS11.java

Print this page
rev 1461 : 6987827: security/util/Resources.java needs improvement
Reviewed-by: valeriep


1114             // ignore - fall thru and attempt login
1115         }
1116 
1117         // get the pin if necessary
1118 
1119         char[] pin = null;
1120         if ((token.tokenInfo.flags & CKF_PROTECTED_AUTHENTICATION_PATH) == 0) {
1121 
1122             // get password
1123 
1124             CallbackHandler myHandler = getCallbackHandler(handler);
1125             if (myHandler == null) {
1126                 // XXX PolicyTool is dependent on this message text
1127                 throw new LoginException
1128                         ("no password provided, and no callback handler " +
1129                         "available for retrieving password");
1130             }
1131 
1132             java.text.MessageFormat form = new java.text.MessageFormat
1133                         (ResourcesMgr.getString
1134                         ("PKCS11 Token [providerName] Password: "));
1135             Object[] source = { getName() };
1136 
1137             PasswordCallback pcall = new PasswordCallback(form.format(source),
1138                                                         false);
1139             Callback[] callbacks = { pcall };
1140             try {
1141                 myHandler.handle(callbacks);
1142             } catch (Exception e) {
1143                 LoginException le = new LoginException
1144                         ("Unable to perform password callback");
1145                 le.initCause(e);
1146                 throw le;
1147             }
1148 
1149             pin = pcall.getPassword();
1150             pcall.clearPassword();
1151             if (pin == null) {
1152                 if (debug != null) {
1153                     debug.println("caller passed NULL pin");
1154                 }




1114             // ignore - fall thru and attempt login
1115         }
1116 
1117         // get the pin if necessary
1118 
1119         char[] pin = null;
1120         if ((token.tokenInfo.flags & CKF_PROTECTED_AUTHENTICATION_PATH) == 0) {
1121 
1122             // get password
1123 
1124             CallbackHandler myHandler = getCallbackHandler(handler);
1125             if (myHandler == null) {
1126                 // XXX PolicyTool is dependent on this message text
1127                 throw new LoginException
1128                         ("no password provided, and no callback handler " +
1129                         "available for retrieving password");
1130             }
1131 
1132             java.text.MessageFormat form = new java.text.MessageFormat
1133                         (ResourcesMgr.getString
1134                         ("PKCS11.Token.providerName.Password."));
1135             Object[] source = { getName() };
1136 
1137             PasswordCallback pcall = new PasswordCallback(form.format(source),
1138                                                         false);
1139             Callback[] callbacks = { pcall };
1140             try {
1141                 myHandler.handle(callbacks);
1142             } catch (Exception e) {
1143                 LoginException le = new LoginException
1144                         ("Unable to perform password callback");
1145                 le.initCause(e);
1146                 throw le;
1147             }
1148 
1149             pin = pcall.getPassword();
1150             pcall.clearPassword();
1151             if (pin == null) {
1152                 if (debug != null) {
1153                     debug.println("caller passed NULL pin");
1154                 }


< prev index next >