зеркало из https://github.com/mozilla/pjs.git
Land SDR changes from SDR_BRANCH.
Enable calls to new interface functions in wallet.
This commit is contained in:
Родитель
3f33bcf35d
Коммит
b025ecdd7d
|
@ -1,57 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* thayes@netscape.com
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/* Buffer type - for storing 8-bit octet values */
|
||||
[ptr] native buffer(unsigned char);
|
||||
|
||||
[scriptable, uuid(0EC80360-075C-11d4-9FD4-00C04F1B83D8)]
|
||||
interface nsISecretDecoderRing: nsISupports {
|
||||
|
||||
/* Encrypt a buffer - callable only from C++ */
|
||||
[noscript] long encrypt(in buffer data, in long dataLen, out buffer result);
|
||||
|
||||
/* Decrypt a buffer - callable only from C++ */
|
||||
[noscript] long decrypt(in buffer data, in long dataLen, out buffer result);
|
||||
|
||||
/* Encrypt nul-terminated string to BASE64 output */
|
||||
string encryptString(in string text);
|
||||
|
||||
/* Decrypt BASE64 input to nul-terminated string output */
|
||||
/* There is no check for embedded nul values in the decrypted output */
|
||||
string decryptString(in string crypt);
|
||||
};
|
||||
|
||||
/*
|
||||
* Configuration interface for the Secret Decoder Ring
|
||||
* - this interface allows setting the window that will be
|
||||
* used as parent for dialog windows (such as password prompts)
|
||||
*/
|
||||
[scriptable, uuid(01D8C0F0-0CCC-11d4-9FDD-000064657374)]
|
||||
interface nsISecretDecoderRingConfig: nsISupports {
|
||||
void setWindow(in nsISupports w);
|
||||
};
|
||||
|
||||
|
|
@ -54,7 +54,8 @@ static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
|||
static char * PromptUserCallback(void *arg, char *prompt, int isPasswd);
|
||||
static char * FilePathPromptCallback(void *arg, char *prompt, char *fileRegEx, CMUint32 shouldFileExist);
|
||||
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);
|
||||
|
||||
|
||||
|
@ -265,7 +266,7 @@ PRStatus DisplayPSMUIDialog(PCMT_CONTROL control, const char *pickledStatus, con
|
|||
return PR_FAILURE;
|
||||
|
||||
/* 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:
|
||||
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;
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "nsIAllocator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "plbase64.h"
|
||||
|
||||
#include "nsISecretDecoderRing.h"
|
||||
|
||||
#include "cmtcmn.h"
|
||||
|
@ -195,10 +197,53 @@ loser:
|
|||
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::
|
||||
encode(const unsigned char *data, PRInt32 dataLen, char **_retval)
|
||||
{
|
||||
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;
|
||||
|
||||
// Allocate space for encoded string (with NUL)
|
||||
|
@ -215,11 +260,31 @@ loser:
|
|||
if (r) nsAllocator::Free(r);
|
||||
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult nsSecretDecoderRing::
|
||||
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;
|
||||
unsigned char *r = 0;
|
||||
PRInt32 rLen;
|
||||
|
@ -239,6 +304,7 @@ loser:
|
|||
if (r) nsAllocator::Free(r);
|
||||
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char * nsSecretDecoderRing::kPSMComponentProgID = PSM_COMPONENT_PROGID;
|
||||
|
|
|
@ -1092,7 +1092,7 @@ PUBLIC void
|
|||
WLLT_ExpirePassword() {
|
||||
nsresult rv = wallet_CryptSetup();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// rv = gSecretDecoderRing->Logout();
|
||||
rv = gSecretDecoderRing->Logout();
|
||||
}
|
||||
PRUnichar * message;
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -1108,7 +1108,7 @@ PUBLIC
|
|||
void WLLT_ChangePassword() {
|
||||
nsresult rv = wallet_CryptSetup();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// rv = gSecretDecoderRing->ChangePassword();
|
||||
rv = gSecretDecoderRing->ChangePassword();
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
PRUnichar * message = Wallet_Localize("PasswordNotChanged");
|
||||
|
|
Загрузка…
Ссылка в новой задаче