Land SDR changes from SDR_BRANCH.

Enable calls to new interface functions in wallet.
This commit is contained in:
thayes%netscape.com 2000-05-11 18:59:25 +00:00
parent a198e7ea07
commit caef913351
4 changed files with 78 additions and 5 deletions

View File

@ -42,6 +42,12 @@ interface nsISecretDecoderRing: nsISupports {
/* Decrypt BASE64 input to nul-terminated string output */ /* Decrypt BASE64 input to nul-terminated string output */
/* There is no check for embedded nul values in the decrypted output */ /* There is no check for embedded nul values in the decrypted output */
string decryptString(in string crypt); string decryptString(in string crypt);
/* Prompt the user to change the password on the SDR key */
void changePassword();
/* Logout of the security device that protects the SDR key */
void logout();
}; };
/* /*

View File

@ -54,7 +54,8 @@ static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static char * PromptUserCallback(void *arg, char *prompt, int isPasswd); static char * PromptUserCallback(void *arg, char *prompt, int isPasswd);
static char * FilePathPromptCallback(void *arg, char *prompt, char *fileRegEx, CMUint32 shouldFileExist); static char * FilePathPromptCallback(void *arg, char *prompt, char *fileRegEx, CMUint32 shouldFileExist);
static void ApplicationFreeCallback(char *userInput); static void ApplicationFreeCallback(char *userInput);
static void * CartmanUIHandler(uint32 resourceID, void* clientContext, uint32 width, uint32 height, char* urlStr, void *data); static void * CartmanUIHandler(uint32 resourceID, void* clientContext, uint32 width, uint32 height, PRBool isModel,
char* urlStr, void *data);
extern "C" void CARTMAN_UIEventLoop(void *data); extern "C" void CARTMAN_UIEventLoop(void *data);
@ -265,7 +266,7 @@ PRStatus DisplayPSMUIDialog(PCMT_CONTROL control, const char *pickledStatus, con
return PR_FAILURE; return PR_FAILURE;
/* Fire the URL up in a window of its own. */ /* Fire the URL up in a window of its own. */
pwin = CartmanUIHandler(advRID, nsnull, width, height, (char*)urlItem.data, NULL); pwin = CartmanUIHandler(advRID, nsnull, width, height, PR_FALSE, (char*)urlItem.data, NULL);
//allocated by cmt, we can free with free: //allocated by cmt, we can free with free:
free(urlItem.data); free(urlItem.data);
@ -275,7 +276,7 @@ PRStatus DisplayPSMUIDialog(PCMT_CONTROL control, const char *pickledStatus, con
void* CartmanUIHandler(uint32 resourceID, void* clientContext, uint32 width, uint32 height, char* urlStr, void *data) void* CartmanUIHandler(uint32 resourceID, void* clientContext, uint32 width, uint32 height, PRBool isModal, char* urlStr, void *data)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;

View File

@ -26,6 +26,8 @@
#include "nsIAllocator.h" #include "nsIAllocator.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "plbase64.h"
#include "nsISecretDecoderRing.h" #include "nsISecretDecoderRing.h"
#include "cmtcmn.h" #include "cmtcmn.h"
@ -195,10 +197,53 @@ loser:
return rv; return rv;
} }
/* void changePassword(); */
NS_IMETHODIMP nsSecretDecoderRing::
ChangePassword()
{
return NS_OK;
}
/* void logout(); */
NS_IMETHODIMP nsSecretDecoderRing::
Logout()
{
nsresult rv = NS_OK;
CMTStatus status;
CMT_CONTROL *control;
/* Check object initialization */
NS_ASSERTION(mPSM != nsnull, "SDR object not initialized");
if (mPSM == nsnull) { rv = NS_ERROR_NOT_INITIALIZED; goto loser; }
/* Get the control connection */
rv = mPSM->GetControlConnection(&control);
if (rv != NS_OK) { rv = NS_ERROR_NOT_AVAILABLE; goto loser; }
/* Call PSM to decrypt the value */
status = CMT_LogoutAllTokens(control);
if (status != CMTSuccess) { rv = NS_ERROR_FAILURE; goto loser; } /* Promote? */
loser:
return rv;
}
// Support routines
nsresult nsSecretDecoderRing:: nsresult nsSecretDecoderRing::
encode(const unsigned char *data, PRInt32 dataLen, char **_retval) encode(const unsigned char *data, PRInt32 dataLen, char **_retval)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
*_retval = PL_Base64Encode((const char *)data, dataLen, NULL);
if (!*_retval) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; }
loser:
return rv;
#if 0
nsresult rv = NS_OK;
char *r = 0; char *r = 0;
// Allocate space for encoded string (with NUL) // Allocate space for encoded string (with NUL)
@ -215,11 +260,31 @@ loser:
if (r) nsAllocator::Free(r); if (r) nsAllocator::Free(r);
return rv; return rv;
#endif
} }
nsresult nsSecretDecoderRing:: nsresult nsSecretDecoderRing::
decode(const char *data, unsigned char **result, PRInt32 * _retval) decode(const char *data, unsigned char **result, PRInt32 * _retval)
{ {
nsresult rv = NS_OK;
PRUint32 len = PL_strlen(data);
int adjust = 0;
/* Compute length adjustment */
if (data[len-1] == '=') {
adjust++;
if (data[len-2] == '=') adjust++;
}
*result = (unsigned char *)PL_Base64Decode(data, len, NULL);
if (!*result) { rv = NS_ERROR_ILLEGAL_VALUE; goto loser; }
*_retval = (len*3)/4 - adjust;
loser:
return rv;
#if 0
nsresult rv = NS_OK; nsresult rv = NS_OK;
unsigned char *r = 0; unsigned char *r = 0;
PRInt32 rLen; PRInt32 rLen;
@ -239,6 +304,7 @@ loser:
if (r) nsAllocator::Free(r); if (r) nsAllocator::Free(r);
return rv; return rv;
#endif
} }
const char * nsSecretDecoderRing::kPSMComponentProgID = PSM_COMPONENT_PROGID; const char * nsSecretDecoderRing::kPSMComponentProgID = PSM_COMPONENT_PROGID;

View File

@ -1092,7 +1092,7 @@ PUBLIC void
WLLT_ExpirePassword() { WLLT_ExpirePassword() {
nsresult rv = wallet_CryptSetup(); nsresult rv = wallet_CryptSetup();
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// rv = gSecretDecoderRing->Logout(); rv = gSecretDecoderRing->Logout();
} }
PRUnichar * message; PRUnichar * message;
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@ -1108,7 +1108,7 @@ PUBLIC
void WLLT_ChangePassword() { void WLLT_ChangePassword() {
nsresult rv = wallet_CryptSetup(); nsresult rv = wallet_CryptSetup();
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// rv = gSecretDecoderRing->ChangePassword(); rv = gSecretDecoderRing->ChangePassword();
} }
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
PRUnichar * message = Wallet_Localize("PasswordNotChanged"); PRUnichar * message = Wallet_Localize("PasswordNotChanged");