diff options
| author | Grace Kloba <klobag@google.com> | 2009-06-12 11:52:18 -0700 |
|---|---|---|
| committer | Grace Kloba <klobag@google.com> | 2009-06-12 15:04:54 -0700 |
| commit | 0f07938f7e51e7a7eb4239b8a30e64b68dac8c66 (patch) | |
| tree | ca3e5b64126145bda66085250fc250a3ba347e58 /WebKit | |
| parent | 40e08ce5f3984e7f4c70ea623114b1aca1cc9c42 (diff) | |
| download | external_webkit-0f07938f7e51e7a7eb4239b8a30e64b68dac8c66.zip external_webkit-0f07938f7e51e7a7eb4239b8a30e64b68dac8c66.tar.gz external_webkit-0f07938f7e51e7a7eb4239b8a30e64b68dac8c66.tar.bz2 | |
Add <keygen> support for VPN team.
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/android/jni/JavaBridge.cpp | 49 | ||||
| -rw-r--r-- | WebKit/android/jni/JavaSharedClient.cpp | 13 | ||||
| -rw-r--r-- | WebKit/android/jni/JavaSharedClient.h | 4 |
3 files changed, 65 insertions, 1 deletions
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index 5c9df97..d0f7f0e 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -31,6 +31,7 @@ #include "Cache.h" #include "CookieClient.h" #include "JavaSharedClient.h" +#include "KeyGeneratorClient.h" #include "KURL.h" #include "NetworkStateNotifier.h" #include "Timer.h" @@ -55,7 +56,7 @@ static jfieldID gJavaBridge_ObjectID; // ---------------------------------------------------------------------------- -class JavaBridge : public TimerClient, public CookieClient +class JavaBridge : public TimerClient, public CookieClient, public KeyGeneratorClient { public: JavaBridge(JNIEnv* env, jobject obj); @@ -71,6 +72,10 @@ public: virtual WebCore::String cookies(WebCore::KURL const& url); virtual bool cookiesEnabled(); + virtual WTF::Vector<String> getSupportedKeyStrengthList(); + virtual WebCore::String getSignedPublicKeyAndChallengeString(unsigned index, + const WebCore::String& challenge, const WebCore::KURL& url); + //////////////////////////////////////////// virtual void setSharedTimerCallback(void (*f)()); @@ -96,6 +101,8 @@ private: jmethodID mCookies; jmethodID mCookiesEnabled; jmethodID mSignalFuncPtrQueue; + jmethodID mGetKeyStrengthList; + jmethodID mGetSignedPublicKey; }; static void (*sSharedTimerFiredCallback)(); @@ -112,15 +119,20 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj) mCookies = env->GetMethodID(clazz, "cookies", "(Ljava/lang/String;)Ljava/lang/String;"); mCookiesEnabled = env->GetMethodID(clazz, "cookiesEnabled", "()Z"); mSignalFuncPtrQueue = env->GetMethodID(clazz, "signalServiceFuncPtrQueue", "()V"); + mGetKeyStrengthList = env->GetMethodID(clazz, "getKeyStrengthList", "()[Ljava/lang/String;"); + mGetSignedPublicKey = env->GetMethodID(clazz, "getSignedPublicKey", "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); LOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer"); LOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer"); LOG_ASSERT(mSetCookies, "Could not find method setCookies"); LOG_ASSERT(mCookies, "Could not find method cookies"); LOG_ASSERT(mCookiesEnabled, "Could not find method cookiesEnabled"); + LOG_ASSERT(mGetKeyStrengthList, "Could not find method getKeyStrengthList"); + LOG_ASSERT(mGetSignedPublicKey, "Could not find method getSignedPublicKey"); JavaSharedClient::SetTimerClient(this); JavaSharedClient::SetCookieClient(this); + JavaSharedClient::SetKeyGeneratorClient(this); gJavaBridge = this; } @@ -134,6 +146,7 @@ JavaBridge::~JavaBridge() JavaSharedClient::SetTimerClient(NULL); JavaSharedClient::SetCookieClient(NULL); + JavaSharedClient::SetKeyGeneratorClient(NULL); } void @@ -213,6 +226,40 @@ void JavaBridge::signalServiceFuncPtrQueue() env->CallVoidMethod(obj.get(), mSignalFuncPtrQueue); } +WTF::Vector<WebCore::String>JavaBridge::getSupportedKeyStrengthList() { + WTF::Vector<WebCore::String> list; + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = getRealObject(env, mJavaObject); + jobjectArray array = (jobjectArray) env->CallObjectMethod(obj.get(), + mGetKeyStrengthList); + int count = env->GetArrayLength(array); + for (int i = 0; i < count; ++i) { + jstring keyStrength = (jstring) env->GetObjectArrayElement(array, i); + list.append(to_string(env, keyStrength)); + env->DeleteLocalRef(keyStrength); + } + env->DeleteLocalRef(array); + checkException(env); + return list; +} + +WebCore::String JavaBridge::getSignedPublicKeyAndChallengeString(unsigned index, + const WebCore::String& challenge, const WebCore::KURL& url) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jstring jChallenge = env->NewString(challenge.characters(), + challenge.length()); + const WebCore::String& urlStr = url.string(); + jstring jUrl = env->NewString(urlStr.characters(), urlStr.length()); + AutoJObject obj = getRealObject(env, mJavaObject); + jstring key = (jstring) env->CallObjectMethod(obj.get(), + mGetSignedPublicKey, index, jChallenge, jUrl); + WebCore::String ret = to_string(env, key); + env->DeleteLocalRef(jChallenge); + env->DeleteLocalRef(jUrl); + env->DeleteLocalRef(key); + return ret; +} + // ---------------------------------------------------------------------------- // visible to Shared diff --git a/WebKit/android/jni/JavaSharedClient.cpp b/WebKit/android/jni/JavaSharedClient.cpp index f115f62..bf52ecd 100644 --- a/WebKit/android/jni/JavaSharedClient.cpp +++ b/WebKit/android/jni/JavaSharedClient.cpp @@ -45,6 +45,12 @@ namespace android { return gCookieClient; } + KeyGeneratorClient* JavaSharedClient::GetKeyGeneratorClient() + { + //LOG_ASSERT(gKeyGeneratorClient != NULL, "gKeyGeneratorClient not initialized!!!"); + return gKeyGeneratorClient; + } + void JavaSharedClient::SetTimerClient(TimerClient* client) { //LOG_ASSERT(gTimerClient == NULL || client == NULL, "gTimerClient already set, aborting..."); @@ -57,8 +63,15 @@ namespace android { gCookieClient = client; } + void JavaSharedClient::SetKeyGeneratorClient(KeyGeneratorClient* client) + { + //LOG_ASSERT(gKeyGeneratorClient == NULL || client == NULL, "gKeyGeneratorClient already set, aborting..."); + gKeyGeneratorClient = client; + } + TimerClient* JavaSharedClient::gTimerClient = NULL; CookieClient* JavaSharedClient::gCookieClient = NULL; + KeyGeneratorClient* JavaSharedClient::gKeyGeneratorClient = NULL; /////////////////////////////////////////////////////////////////////////// diff --git a/WebKit/android/jni/JavaSharedClient.h b/WebKit/android/jni/JavaSharedClient.h index 05788e1..862b508 100644 --- a/WebKit/android/jni/JavaSharedClient.h +++ b/WebKit/android/jni/JavaSharedClient.h @@ -30,15 +30,18 @@ namespace android { class TimerClient; class CookieClient; + class KeyGeneratorClient; class JavaSharedClient { public: static TimerClient* GetTimerClient(); static CookieClient* GetCookieClient(); + static KeyGeneratorClient* GetKeyGeneratorClient(); static void SetTimerClient(TimerClient* client); static void SetCookieClient(CookieClient* client); + static void SetKeyGeneratorClient(KeyGeneratorClient* client); // can be called from any thread, to be executed in webkit thread static void EnqueueFunctionPtr(void (*proc)(void*), void* payload); @@ -48,6 +51,7 @@ namespace android { private: static TimerClient* gTimerClient; static CookieClient* gCookieClient; + static KeyGeneratorClient* gKeyGeneratorClient; }; } #endif |
