SafeByteArray AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element)); SafeByteArray value; boost::optional<SafeByteArray> message = authResponse->getValue(); if (message) { if ((*message).empty()) { value = createSafeByteArray("="); } else { value = Base64::encode(*message); } } return concat(createSafeByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"), value, createSafeByteArray("</response>")); }
void CPppMsChap2::SuccessL(RMBufPacket& aPacket) /** @copydoc CPppChap::SuccessL(RMBufPacket&) @see CPppChap::SuccessL(RMBufPacket&) @internalComponent */ { __ASSERT_ALWAYS(aPacket.Length() >= KPppChapCodeFieldSize + KPppChapIdFieldSize + KPppChapLengthFieldSize + KPppMsChap2AuthenticatorResponseSize, User::Leave(KErrUnderflow)); // check the id if (!CheckIdentifier(aPacket)) User::Leave(KErrGeneral); // no more retries TimerCancel(); // Read the length of the MS-CHAP-V2 Failure packet and compute // the length of the CHAP Message field and go past the CHAP Code // field, the CHAP Identifier field and the CHAP Length field, in // order to read the CHAP Message field. TPtrC8 authResponse(aPacket.First()->Ptr() + KPppChapCodeFieldSize + KPppChapIdFieldSize + KPppChapLengthFieldSize, KPppMsChap2AuthenticatorResponseSize); // TPtrC8 message(ptr + KPppChapCodeFieldSize + KPppChapIdFieldSize + KPppChapLengthFieldSize + KPppMsChap2AuthenticatorResponseSize + 3, BigEndian::Get16(ptr + KPppChapCodeFieldSize + KPppChapIdFieldSize) - KPppChapCodeFieldSize - KPppChapIdFieldSize - KPppChapLengthFieldSize - KPppMsChap2AuthenticatorResponseSize - 3); if (authResponse!=iAuthenticatorResponse) DoFail(KErrIfAuthenticationFailure); else DoSucceed(); }
void MediaPluginCEF::receiveMessage(const char* message_string) { // std::cerr << "MediaPluginCEF::receiveMessage: received message: \"" << message_string << "\"" << std::endl; LLPluginMessage message_in; if (message_in.parse(message_string) >= 0) { std::string message_class = message_in.getClass(); std::string message_name = message_in.getName(); if (message_class == LLPLUGIN_MESSAGE_CLASS_BASE) { if (message_name == "init") { LLPluginMessage message("base", "init_response"); LLSD versions = LLSD::emptyMap(); versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER] = LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER_VERSION; message.setValueLLSD("versions", versions); std::string plugin_version = "CEF plugin 1.1.3"; message.setValue("plugin_version", plugin_version); sendMessage(message); } else if (message_name == "idle") { mLLCEFLib->update(); mVolumeCatcher.pump(); // this seems bad but unless the state changes (it won't until we figure out // how to get CEF to tell us if copy/cut/paste is available) then this function // will return immediately checkEditState(); } else if (message_name == "cleanup") { mLLCEFLib->requestExit(); } else if (message_name == "shm_added") { SharedSegmentInfo info; info.mAddress = message_in.getValuePointer("address"); info.mSize = (size_t)message_in.getValueS32("size"); std::string name = message_in.getValue("name"); mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); } else if (message_name == "shm_remove") { std::string name = message_in.getValue("name"); SharedSegmentMap::iterator iter = mSharedSegments.find(name); if (iter != mSharedSegments.end()) { if (mPixels == iter->second.mAddress) { mPixels = NULL; mTextureSegmentName.clear(); } mSharedSegments.erase(iter); } else { } LLPluginMessage message("base", "shm_remove_response"); message.setValue("name", name); sendMessage(message); } else { } } else if (message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA) { if (message_name == "init") { // event callbacks from LLCefLib mLLCEFLib->setOnPageChangedCallback(std::bind(&MediaPluginCEF::onPageChangedCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); mLLCEFLib->setOnCustomSchemeURLCallback(std::bind(&MediaPluginCEF::onCustomSchemeURLCallback, this, std::placeholders::_1)); mLLCEFLib->setOnConsoleMessageCallback(std::bind(&MediaPluginCEF::onConsoleMessageCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); mLLCEFLib->setOnStatusMessageCallback(std::bind(&MediaPluginCEF::onStatusMessageCallback, this, std::placeholders::_1)); mLLCEFLib->setOnTitleChangeCallback(std::bind(&MediaPluginCEF::onTitleChangeCallback, this, std::placeholders::_1)); mLLCEFLib->setOnLoadStartCallback(std::bind(&MediaPluginCEF::onLoadStartCallback, this)); mLLCEFLib->setOnLoadEndCallback(std::bind(&MediaPluginCEF::onLoadEndCallback, this, std::placeholders::_1)); mLLCEFLib->setOnAddressChangeCallback(std::bind(&MediaPluginCEF::onAddressChangeCallback, this, std::placeholders::_1)); mLLCEFLib->setOnNavigateURLCallback(std::bind(&MediaPluginCEF::onNavigateURLCallback, this, std::placeholders::_1, std::placeholders::_2)); mLLCEFLib->setOnHTTPAuthCallback(std::bind(&MediaPluginCEF::onHTTPAuthCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); mLLCEFLib->setOnFileDownloadCallback(std::bind(&MediaPluginCEF::onFileDownloadCallback, this, std::placeholders::_1)); mLLCEFLib->setOnCursorChangedCallback(std::bind(&MediaPluginCEF::onCursorChangedCallback, this, std::placeholders::_1, std::placeholders::_2)); mLLCEFLib->setOnRequestExitCallback(std::bind(&MediaPluginCEF::onRequestExitCallback, this)); LLCEFLib::LLCEFLibSettings settings; settings.initial_width = 1024; settings.initial_height = 1024; settings.plugins_enabled = mPluginsEnabled; settings.media_stream_enabled = false; // MAINT-6060 - WebRTC media removed until we can add granualrity/query UI settings.javascript_enabled = mJavascriptEnabled; settings.cookies_enabled = mCookiesEnabled; settings.cookie_store_path = mCookiePath; settings.cache_enabled = true; settings.cache_path = mCachePath; settings.locale = generate_cef_locale(mHostLanguage); settings.accept_language_list = mHostLanguage; settings.user_agent_substring = mLLCEFLib->makeCompatibleUserAgentString(mUserAgentSubtring); settings.debug_output = mEnableMediaPluginDebugging; settings.log_file = mLogFile; bool result = mLLCEFLib->init(settings); if (!result) { // if this fails, the media system in viewer will put up a message } // Plugin gets to decide the texture parameters to use. mDepth = 4; LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params"); message.setValueS32("default_width", 1024); message.setValueS32("default_height", 1024); message.setValueS32("depth", mDepth); message.setValueU32("internalformat", GL_RGB); message.setValueU32("format", GL_BGRA); message.setValueU32("type", GL_UNSIGNED_BYTE); message.setValueBoolean("coords_opengl", true); sendMessage(message); } else if (message_name == "set_user_data_path") { std::string user_data_path_cache = message_in.getValue("cache_path"); std::string user_data_path_cookies = message_in.getValue("cookies_path"); std::string user_data_path_logs = message_in.getValue("logs_path"); mCachePath = user_data_path_cache + "cef_cache"; mCookiePath = user_data_path_cookies + "cef_cookies"; mLogFile = user_data_path_logs + "cef.log"; } else if (message_name == "size_change") { std::string name = message_in.getValue("name"); S32 width = message_in.getValueS32("width"); S32 height = message_in.getValueS32("height"); S32 texture_width = message_in.getValueS32("texture_width"); S32 texture_height = message_in.getValueS32("texture_height"); if (!name.empty()) { // Find the shared memory region with this name SharedSegmentMap::iterator iter = mSharedSegments.find(name); if (iter != mSharedSegments.end()) { mPixels = (unsigned char*)iter->second.mAddress; mWidth = width; mHeight = height; mTextureWidth = texture_width; mTextureHeight = texture_height; }; }; mLLCEFLib->setSize(mWidth, mHeight); LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response"); message.setValue("name", name); message.setValueS32("width", width); message.setValueS32("height", height); message.setValueS32("texture_width", texture_width); message.setValueS32("texture_height", texture_height); sendMessage(message); } else if (message_name == "set_language_code") { mHostLanguage = message_in.getValue("language"); } else if (message_name == "load_uri") { std::string uri = message_in.getValue("uri"); mLLCEFLib->navigate(uri); } else if (message_name == "set_cookie") { std::string uri = message_in.getValue("uri"); std::string name = message_in.getValue("name"); std::string value = message_in.getValue("value"); std::string domain = message_in.getValue("domain"); std::string path = message_in.getValue("path"); bool httponly = message_in.getValueBoolean("httponly"); bool secure = message_in.getValueBoolean("secure"); mLLCEFLib->setCookie(uri, name, value, domain, path, httponly, secure); } else if (message_name == "mouse_event") { std::string event = message_in.getValue("event"); S32 x = message_in.getValueS32("x"); S32 y = message_in.getValueS32("y"); // only even send left mouse button events to LLCEFLib // (partially prompted by crash in OS X CEF when sending right button events) // we catch the right click in viewer and display our own context menu anyway S32 button = message_in.getValueS32("button"); LLCEFLib::EMouseButton btn = LLCEFLib::MB_MOUSE_BUTTON_LEFT; if (event == "down" && button == 0) { mLLCEFLib->mouseButton(btn, LLCEFLib::ME_MOUSE_DOWN, x, y); mLLCEFLib->setFocus(true); std::stringstream str; str << "Mouse down at = " << x << ", " << y; postDebugMessage(str.str()); } else if (event == "up" && button == 0) { mLLCEFLib->mouseButton(btn, LLCEFLib::ME_MOUSE_UP, x, y); std::stringstream str; str << "Mouse up at = " << x << ", " << y; postDebugMessage(str.str()); } else if (event == "double_click") { mLLCEFLib->mouseButton(btn, LLCEFLib::ME_MOUSE_DOUBLE_CLICK, x, y); } else { mLLCEFLib->mouseMove(x, y); } } else if (message_name == "scroll_event") { S32 x = message_in.getValueS32("x"); S32 y = message_in.getValueS32("y"); const int scaling_factor = 40; y *= -scaling_factor; mLLCEFLib->mouseWheel(x, y); } else if (message_name == "text_event") { std::string text = message_in.getValue("text"); std::string modifiers = message_in.getValue("modifiers"); LLSD native_key_data = message_in.getValueLLSD("native_key_data"); unicodeInput(text, decodeModifiers(modifiers), native_key_data); } else if (message_name == "key_event") { #if LL_DARWIN std::string event = message_in.getValue("event"); S32 key = message_in.getValueS32("key"); LLSD native_key_data = message_in.getValueLLSD("native_key_data"); #if 0 if (event == "down") { //mLLCEFLib->keyPress(key, true); mLLCEFLib->keyboardEvent(LLCEFLib::KE_KEY_DOWN, (uint32_t)key, 0, LLCEFLib::KM_MODIFIER_NONE, 0, 0, 0); } else if (event == "up") { //mLLCEFLib->keyPress(key, false); mLLCEFLib->keyboardEvent(LLCEFLib::KE_KEY_UP, (uint32_t)key, 0, LLCEFLib::KM_MODIFIER_NONE, 0, 0, 0); } #else // Treat unknown events as key-up for safety. LLCEFLib::EKeyEvent key_event = LLCEFLib::KE_KEY_UP; if (event == "down") { key_event = LLCEFLib::KE_KEY_DOWN; } else if (event == "repeat") { key_event = LLCEFLib::KE_KEY_REPEAT; } keyEvent(key_event, key, LLCEFLib::KM_MODIFIER_NONE, native_key_data); #endif #else std::string event = message_in.getValue("event"); S32 key = message_in.getValueS32("key"); std::string modifiers = message_in.getValue("modifiers"); LLSD native_key_data = message_in.getValueLLSD("native_key_data"); // Treat unknown events as key-up for safety. LLCEFLib::EKeyEvent key_event = LLCEFLib::KE_KEY_UP; if (event == "down") { key_event = LLCEFLib::KE_KEY_DOWN; } else if (event == "repeat") { key_event = LLCEFLib::KE_KEY_REPEAT; } keyEvent(key_event, key, decodeModifiers(modifiers), native_key_data); #endif } else if (message_name == "enable_media_plugin_debugging") { mEnableMediaPluginDebugging = message_in.getValueBoolean("enable"); } if (message_name == "auth_response") { authResponse(message_in); } if (message_name == "edit_cut") { mLLCEFLib->editCut(); } if (message_name == "edit_copy") { mLLCEFLib->editCopy(); } if (message_name == "edit_paste") { mLLCEFLib->editPaste(); } } else if (message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER) { if (message_name == "set_page_zoom_factor") { F32 factor = (F32)message_in.getValueReal("factor"); mLLCEFLib->setPageZoom(factor); } if (message_name == "browse_stop") { mLLCEFLib->stop(); } else if (message_name == "browse_reload") { bool ignore_cache = true; mLLCEFLib->reload(ignore_cache); } else if (message_name == "browse_forward") { mLLCEFLib->goForward(); } else if (message_name == "browse_back") { mLLCEFLib->goBack(); } else if (message_name == "cookies_enabled") { mCookiesEnabled = message_in.getValueBoolean("enable"); } else if (message_name == "set_user_agent") { mUserAgentSubtring = message_in.getValue("user_agent"); } else if (message_name == "show_web_inspector") { mLLCEFLib->showDevTools(true); } else if (message_name == "plugins_enabled") { mPluginsEnabled = message_in.getValueBoolean("enable"); } else if (message_name == "javascript_enabled") { mJavascriptEnabled = message_in.getValueBoolean("enable"); } } else if (message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME) { if (message_name == "set_volume") { F32 volume = (F32)message_in.getValueReal("volume"); setVolume(volume); } } else { }; } }