NS_IMETHODIMP nsPK11Token::CheckPassword(const char16_t *password, bool *_retval) { nsNSSShutDownPreventionLock locker; if (isAlreadyShutDown()) return NS_ERROR_NOT_AVAILABLE; SECStatus srv; int32_t prerr; NS_ConvertUTF16toUTF8 aUtf8Password(password); srv = PK11_CheckUserPassword(mSlot, const_cast<char *>(aUtf8Password.get())); if (srv != SECSuccess) { *_retval = false; prerr = PR_GetError(); if (prerr != SEC_ERROR_BAD_PASSWORD) { /* something really bad happened - throw an exception */ return NS_ERROR_FAILURE; } } else { *_retval = true; } return NS_OK; }
/* boolean checkPassword (in wstring password); */ NS_IMETHODIMP nsPK11Token::CheckPassword(const PRUnichar *password, PRBool *_retval) { nsNSSShutDownPreventionLock locker; if (isAlreadyShutDown()) return NS_ERROR_NOT_AVAILABLE; SECStatus srv; PRInt32 prerr; NS_ConvertUCS2toUTF8 aUtf8Password(password); srv = PK11_CheckUserPassword(mSlot, NS_CONST_CAST(char *, aUtf8Password.get())); if (srv != SECSuccess) { *_retval = PR_FALSE; prerr = PR_GetError(); if (prerr != SEC_ERROR_BAD_PASSWORD) { /* something really bad happened - throw an exception */ return NS_ERROR_FAILURE; } } else { *_retval = PR_TRUE; } return NS_OK; }