PKIFSimplePasswordCallback.cpp

Go to the documentation of this file.
00001 
00009 #include "PKIFSimplePasswordCallback.h"
00010 
00011 #include "wx/textdlg.h"
00012 
00013 #include "PRStringUtils.h"
00014 
00022 CPKIFSimplePasswordCallback::CPKIFSimplePasswordCallback()
00023 :m_parentWin(0)
00024 {
00025 }
00026 
00034 CPKIFSimplePasswordCallback::~CPKIFSimplePasswordCallback()
00035 {
00036 }
00037 
00049 char * CPKIFSimplePasswordCallback::operator ()(const char *tokenName, bool retrying)
00050 {
00051     wxString prompt;
00052     if(tokenName) {
00053         prompt.Printf(wxT("Please enter the password for %s"),WXCASTCHARS(tokenName));
00054     } else {
00055         prompt = wxT("Please enter the token password.");
00056     }
00057     wxString pass = ::wxGetPasswordFromUser(prompt,wxT("Token password entry"),wxT(""),m_parentWin);
00058     if(pass.IsEmpty()) return 0;
00059 
00060     size_t passBufLen = pass.length() * sizeof(char) + 1;
00061     // PKIF will zero and free this buffer, so it needs to allocate it.
00062     char * pkifPass = (char *)PKIFNew(passBufLen);
00063     memset(pkifPass,0x00,passBufLen);
00064     memcpy(pkifPass,pass.c_str(),pass.length() * sizeof(char));
00065 
00066     return pkifPass;
00067 
00068 }
00076 void CPKIFSimplePasswordCallback::SetParent(wxWindow * parent)
00077 {
00078     m_parentWin = parent;
00079 }

Generated on Mon Nov 15 11:15:55 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6