bool doGetCertificate(PluginInstance *obj, NPVariant *result) { LOG_LOCATION; FAIL_IF_NOT_ALLOWED_SITE; char selectedCertID[33]; int dlg_result = 0; #ifdef _WIN32 HWND ownerWindowHandle = (HWND)getNativeWindowHandle(obj); EstEID_log("owner window handle passed to DialogBoxParam() = %08X", ownerWindowHandle); dlg_result = (int)DialogBoxParam(pluginInstance, MAKEINTRESOURCE(IDD_CERTIFICATESELECTIONDLG), ownerWindowHandle, CertSelectionDialogProc, (LPARAM)selectedCertID); #else dlg_result = promptForCertificate(getNativeWindowHandle(obj), selectedCertID); #endif EstEID_log("Certificate selection dialog result = %i", dlg_result); EstEID_log("Selected certificate ID = %s", selectedCertID); if(dlg_result == IDCANCEL) { sprintf(EstEID_error, "User canceled"); EstEID_errorCode = ESTEID_USER_CANCEL; EstEID_log("EstEID_error = %s", EstEID_error); browserFunctions->setexception(&obj->header, EstEID_error); return false; } CertInstance *certInstance = (CertInstance *)browserFunctions->createobject(obj->npp, certClass()); certInstance->npp = obj->npp; certInstance->certInfo = EstEID_mapClone(EstEID_getNonRepudiationCertById(selectedCertID)); // certInstance->certInfo = EstEID_mapClone(EstEID_getNonRepudiationCert()); EstEID_log("certObject=%p", certInstance); OBJECT_TO_NPVARIANT((NPObject *)certInstance, *result); EstEID_log("result=%p", result); return true; }
bool doGetCertificate(PluginInstance *obj, NPVariant *result) { LOG_LOCATION; FAIL_IF_NOT_ALLOWED_SITE; char selectedCertID[33]; int dlg_result = 0; dlg_result = promptForCertificate(getNativeWindowHandle(obj), selectedCertID); EstEID_log("Certificate selection dialog result = %i", dlg_result); EstEID_log("Selected certificate ID = %s", selectedCertID); if(dlg_result == IDCANCEL) { sprintf(EstEID_error, "User canceled"); EstEID_errorCode = ESTEID_USER_CANCEL; EstEID_log("EstEID_error = %s", EstEID_error); browserFunctions->setexception(&obj->header, EstEID_error); return false; } CertInstance *certInstance = (CertInstance *)browserFunctions->createobject(obj->npp, certClass()); certInstance->npp = obj->npp; certInstance->certInfo = EstEID_mapClone(EstEID_getNonRepudiationCertById(selectedCertID)); // certInstance->certInfo = EstEID_mapClone(EstEID_getNonRepudiationCert()); EstEID_log("certObject=%p", certInstance); OBJECT_TO_NPVARIANT((NPObject *)certInstance, *result); EstEID_log("result=%p", result); return true; }
bool doSign(PluginInstance *obj, NPVariant *args, unsigned argCount, NPVariant *result) { EstEID_log("obj=%p, name=sign argCount=%u", obj, argCount); FAIL_IF_NOT_ALLOWED_SITE; if (argCount < 2) { browserFunctions->setexception(&obj->header, "Missing arguments"); return false; } if(argCount > 2 && NPVARIANT_IS_OBJECT(args[2])){ strncpy(pluginLanguage, getLanguageFromOptions(obj, args[2]), 2); } EstEID_setLocale(pluginLanguage); void* wnd = getNativeWindowHandle(obj); EstEID_PINPromptData pinPromptData = {promptForPIN, showAlert, wnd}; NPUTF8* certId = createStringFromNPVariant(&args[0]); NPUTF8* hash = createStringFromNPVariant(&args[1]); char *signature = NULL; #ifdef _WIN32 DialogData dialogData; dialogData.pin2[0] = '\0'; dialogData.minPin2Length = 5; dialogData.certId = certId; dialogData.hash = hash; dialogData.signature[0] = '\0'; CK_SLOT_ID slotId; if(EstEID_getSlotId(certId, &slotId)){ if(EstEID_isPinPad(slotId)) { signature = EstEID_sign(certId, hash, pinPromptData); } else { DialogBoxParam(pluginInstance, MAKEINTRESOURCEW(IDD_PIN_DIALOG), (HWND)wnd, Pin2DialogProc, (LPARAM)&dialogData); LOG_LOCATION; signature = (char*)malloc(SIGNATURE_BUFFER_SIZE); // check? strcpy(signature, dialogData.signature); } } else { return false; } #else signature = EstEID_sign(certId, hash, pinPromptData); #endif LOG_LOCATION if (signature) { copyStringToNPVariant(signature, result); free(signature); return true; } else { EstEID_log("EstEID_error=%s", EstEID_error); browserFunctions->setexception(&obj->header, EstEID_error); return false; } }
void init( char* arg0 ) { // OpenGL initialization glClearColor( 0.0f, 0.0f, 0.0f, 0.5f); glEnable( GL_COLOR_MATERIAL ); glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE ); glEnable( GL_TEXTURE_2D ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glEnable( GL_CULL_FACE ); // calculate texture size required (next power of two above browser window size for ( mAppTextureWidth = 1; mAppTextureWidth < mBrowserWindowWidth; mAppTextureWidth <<= 1 ) { }; for ( mAppTextureHeight = 1; mAppTextureHeight < mBrowserWindowHeight; mAppTextureHeight <<= 1 ) { }; // create the texture used to display the browser data glGenTextures( 1, &mAppTexture ); glBindTexture( GL_TEXTURE_2D, mAppTexture ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, mAppTextureWidth, mAppTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, 0 ); // create a single browser window and set things up. std::string applicationDir = std::string( arg0 ).substr( 0, std::string( arg0 ).find_last_of("\\/") ); std::string componentDir = applicationDir; std::string profileDir = applicationDir + "\\" + "testGL_profile"; LLMozLib::getInstance()->init( applicationDir, componentDir, profileDir, getNativeWindowHandle() ); mBrowserWindowId = LLMozLib::getInstance()->createBrowserWindow( mBrowserWindowWidth, mBrowserWindowHeight ); // tell LLMozLib about the size of the browser window LLMozLib::getInstance()->setSize( mBrowserWindowId, mBrowserWindowWidth, mBrowserWindowHeight ); // observer events that LLMozLib emits LLMozLib::getInstance()->addObserver( mBrowserWindowId, this ); // append details to agent string LLMozLib::getInstance()->setBrowserAgentId( mAppWindowName ); // don't flip bitmap LLMozLib::getInstance()->flipWindow( mBrowserWindowId, false ); // go to the "home page" LLMozLib::getInstance()->navigateTo( mBrowserWindowId, mHomeUrl ); };
bool doSign(PluginInstance *obj, NPVariant *args, unsigned argCount, NPVariant *result) { EstEID_log("obj=%p, name=sign argCount=%u", obj, argCount); FAIL_IF_NOT_ALLOWED_SITE; if (argCount < 2) { browserFunctions->setexception(&obj->header, "Missing arguments"); return false; } if(argCount > 2 && NPVARIANT_IS_OBJECT(args[2])){ strncpy(pluginLanguage, getLanguageFromOptions(obj, args[2]), 2); } EstEID_setLocale(pluginLanguage); if(argCount > 3 && NPVARIANT_IS_OBJECT(args[3])){ strcpy(promptMessage, createStringFromNPVariant(args[3])); } void* wnd = getNativeWindowHandle(obj); EstEID_PINPromptData pinPromptData = {promptForPIN, showAlert, wnd, promptMessage, NULL}; NPUTF8* certId = createStringFromNPVariant(&args[0]); NPUTF8* hash = createStringFromNPVariant(&args[1]); char *signature = NULL; signature = EstEID_sign(certId, hash, pinPromptData); LOG_LOCATION if (signature) { copyStringToNPVariant(signature, result); free(signature); return true; } else { EstEID_log("EstEID_error=%s", EstEID_error); browserFunctions->setexception(&obj->header, EstEID_error); return false; } }
void init( const std::string argv0, const std::string argv1 ) { // OpenGL initialization glClearColor( 0.0f, 0.0f, 0.0f, 0.5f); glEnable( GL_COLOR_MATERIAL ); glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE ); glEnable( GL_TEXTURE_2D ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glEnable( GL_CULL_FACE ); // calculate texture size required (next power of two above browser window size for ( mAppTextureWidth = 1; mAppTextureWidth < mBrowserWindowWidth; mAppTextureWidth <<= 1 ) { }; for ( mAppTextureHeight = 1; mAppTextureHeight < mBrowserWindowHeight; mAppTextureHeight <<= 1 ) { }; // create the texture used to display the browser data glGenTextures( 1, &mAppTexture ); glBindTexture( GL_TEXTURE_2D, mAppTexture ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, mAppTextureWidth, mAppTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, 0 ); // create a single browser window and set things up. mProfileDir = mCwd + PATH_SEPARATOR + "testGL_profile"; std::cout << "Profiles dir location is " << mProfileDir << std::endl; mCookiePath = mProfileDir + PATH_SEPARATOR + "cookies.txt"; std::cout << "Cookies.txt file location is " << mCookiePath << std::endl; LLQtWebKit::getInstance()->init( mApplicationDir, mApplicationDir, mProfileDir, getNativeWindowHandle() ); // set host language test (in reality, string will be language code passed into client) // IMPORTANT: must be called before createBrowserWindow(...) LLQtWebKit::getInstance()->setHostLanguage( "EN-AB-CD-EF" ); // enable Javascript LLQtWebKit::getInstance()->enableJavascript( true ); // enable Plugins LLQtWebKit::getInstance()->enablePlugins( true ); // make a browser window mBrowserWindowId = LLQtWebKit::getInstance()->createBrowserWindow( mBrowserWindowWidth, mBrowserWindowHeight ); // tell LLQtWebKit about the size of the browser window LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mBrowserWindowWidth, mBrowserWindowHeight ); // observer events that LLQtWebKit emits LLQtWebKit::getInstance()->addObserver( mBrowserWindowId, this ); // append details to agent string LLQtWebKit::getInstance()->setBrowserAgentId( mAppWindowName ); // don't flip bitmap LLQtWebKit::getInstance()->flipWindow( mBrowserWindowId, false ); // Attempt to read cookies from the cookie file and send them to llqtwebkit. { std::ifstream cookie_file(mCookiePath.c_str(), std::ios_base::in); std::string cookies; while(cookie_file.good() && !cookie_file.eof()) { std::string tmp; std::getline(cookie_file, tmp); cookies += tmp; cookies += "\n"; } if(!cookies.empty()) { LLQtWebKit::getInstance()->setCookies(cookies); } } // Tell llqtwebkit to look for a CA file in the application directory. // If it can't find or parse the file, this should have no effect. std::string ca_pem_file_loc = mCwd + PATH_SEPARATOR + "CA.pem"; LLQtWebKit::getInstance()->addCAFile( ca_pem_file_loc.c_str() ); std::cout << "Expected CA.pem file location is " << ca_pem_file_loc << std::endl; // go to the "home page" or URL passed in via command line if ( ! argv1.empty() ) LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, argv1 ); else LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, mHomeUrl ); };