summaryrefslogtreecommitdiffstats
path: root/android_webview/java
diff options
context:
space:
mode:
authorsgurun <sgurun@chromium.org>2016-01-22 12:06:05 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-22 20:07:02 +0000
commit690d4d96a4ceb89129b3106c226fed6ea1399fe6 (patch)
treea75adbeca647ac8cfcb58026d4140c0657154045 /android_webview/java
parent4309ed87806a1df7175554016ea949fbe01acd89 (diff)
downloadchromium_src-690d4d96a4ceb89129b3106c226fed6ea1399fe6.zip
chromium_src-690d4d96a4ceb89129b3106c226fed6ea1399fe6.tar.gz
chromium_src-690d4d96a4ceb89129b3106c226fed6ea1399fe6.tar.bz2
Add TokenBinding plumbing.
BUG=558776 This is the first CL to create the plumbing. It does not have support for conversion from ECPrivateKey to KeyPair yet. Review URL: https://codereview.chromium.org/1550403002 Cr-Commit-Position: refs/heads/master@{#371016}
Diffstat (limited to 'android_webview/java')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java b/android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java
new file mode 100644
index 0000000..3f2f695
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwTokenBindingManager.java
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview;
+
+import android.net.Uri;
+import android.webkit.ValueCallback;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+
+import java.security.KeyPair;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * AwTokenBindingManager manages the token binding protocol.
+ *
+ * see https://tools.ietf.org/html/draft-ietf-tokbind-protocol-03
+ *
+ * The token binding protocol can be enabled for browser context
+ * separately. However all webviews share the same browser context and do not
+ * expose the browser context to the embedder app. As such, there is no way to
+ * enable token binding manager for individual webviews.
+ */
+@JNINamespace("android_webview")
+public final class AwTokenBindingManager {
+ public void enableTokenBinding() {
+ nativeEnableTokenBinding();
+ }
+
+ public void getKey(Uri origin, AlgorithmParameterSpec[] spec, ValueCallback<KeyPair> callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("callback can't be null");
+ }
+ nativeGetTokenBindingKey(origin.getHost(), callback);
+ }
+
+ public void deleteKey(Uri origin, ValueCallback<Boolean> callback) {
+ if (origin == null) {
+ throw new IllegalArgumentException("origin can't be null");
+ }
+ // null callback is allowed
+ nativeDeleteTokenBindingKey(origin.getHost(), callback);
+ }
+
+ public void deleteAllKeys(ValueCallback<Boolean> callback) {
+ // null callback is allowed
+ nativeDeleteAllTokenBindingKeys(callback);
+ }
+
+ @CalledByNative
+ private static void onKeyReady(ValueCallback<KeyPair> callback) {
+ callback.onReceiveValue(null);
+ }
+
+ @CalledByNative
+ private static void onDeletionComplete(ValueCallback<Boolean> callback) {
+ // At present, the native deletion complete callback always succeeds.
+ callback.onReceiveValue(true);
+ }
+
+ private native void nativeEnableTokenBinding();
+ private native void nativeGetTokenBindingKey(String host, ValueCallback<KeyPair> callback);
+ private native void nativeDeleteTokenBindingKey(String host, ValueCallback<Boolean> callback);
+ private native void nativeDeleteAllTokenBindingKeys(ValueCallback<Boolean> callback);
+}