diff options
author | Robin Lee <rgl@google.com> | 2015-05-05 15:57:17 +0100 |
---|---|---|
committer | Robin Lee <rgl@google.com> | 2015-05-14 07:15:18 +0100 |
commit | 39087b1cec6a54e96ab9eafe8317952720790533 (patch) | |
tree | 2cf6abb18a200d9d55423ab3280f91e4396e2f8c /keystore/java | |
parent | a47fb5ad5d3863bc6de418c7269d2463f39f432b (diff) | |
download | frameworks_base-39087b1cec6a54e96ab9eafe8317952720790533.zip frameworks_base-39087b1cec6a54e96ab9eafe8317952720790533.tar.gz frameworks_base-39087b1cec6a54e96ab9eafe8317952720790533.tar.bz2 |
Replace String host:port/url args with Uri arg
Uri provides a stronger guarantee of well-formedness and lets apps do
nice extra things like specifying scheme etc. without twisting any
expectations.
Bug: 20820034
Change-Id: Ia6bbedb74765444920b667d643fb7e1eb6a7292b
Diffstat (limited to 'keystore/java')
-rw-r--r-- | keystore/java/android/security/KeyChain.java | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java index 19b62a6..817b7c9 100644 --- a/keystore/java/android/security/KeyChain.java +++ b/keystore/java/android/security/KeyChain.java @@ -23,6 +23,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; +import android.net.Uri; import android.os.IBinder; import android.os.Looper; import android.os.Process; @@ -119,19 +120,7 @@ public final class KeyChain { * Extra for use with {@link #ACTION_CHOOSER} * @hide Also used by KeyChainActivity implementation */ - public static final String EXTRA_HOST = "host"; - - /** - * Extra for use with {@link #ACTION_CHOOSER} - * @hide Also used by KeyChainActivity implementation - */ - public static final String EXTRA_PORT = "port"; - - /** - * Extra for use with {@link #ACTION_CHOOSER} - * @hide Also used by KeyChainActivity implementation - */ - public static final String EXTRA_URL = "url"; + public static final String EXTRA_URI = "uri"; /** * Extra for use with {@link #ACTION_CHOOSER} @@ -270,7 +259,13 @@ public final class KeyChain { @NonNull KeyChainAliasCallback response, @KeyProperties.KeyAlgorithmEnum String[] keyTypes, Principal[] issuers, @Nullable String host, int port, @Nullable String alias) { - choosePrivateKeyAlias(activity, response, keyTypes, issuers, host, port, null, alias); + Uri uri = null; + if (host != null) { + uri = new Uri.Builder() + .authority(host + (port != -1 ? ":" + port : "")) + .build(); + } + choosePrivateKeyAlias(activity, response, keyTypes, issuers, uri, alias); } /** @@ -303,11 +298,7 @@ public final class KeyChain { * "EC" or "RSA", or a null array. * @param issuers The acceptable certificate issuers for the * certificate matching the private key, or null. - * @param host The host name of the server requesting the - * certificate, or null if unavailable. - * @param port The port number of the server requesting the - * certificate, or -1 if unavailable. - * @param url The full url the server is requesting the certificate + * @param uri The full URI the server is requesting the certificate * for, or null if unavailable. * @param alias The alias to preselect if available, or null if * unavailable. @@ -315,7 +306,7 @@ public final class KeyChain { public static void choosePrivateKeyAlias(@NonNull Activity activity, @NonNull KeyChainAliasCallback response, @KeyProperties.KeyAlgorithmEnum String[] keyTypes, Principal[] issuers, - @Nullable String host, int port, @Nullable String url, @Nullable String alias) { + @Nullable Uri uri, @Nullable String alias) { /* * TODO currently keyTypes, issuers are unused. They are meant * to follow the semantics and purpose of X509KeyManager @@ -341,9 +332,7 @@ public final class KeyChain { Intent intent = new Intent(ACTION_CHOOSER); intent.setPackage(KEYCHAIN_PACKAGE); intent.putExtra(EXTRA_RESPONSE, new AliasResponse(response)); - intent.putExtra(EXTRA_HOST, host); - intent.putExtra(EXTRA_PORT, port); - intent.putExtra(EXTRA_URL, url); + intent.putExtra(EXTRA_URI, uri); intent.putExtra(EXTRA_ALIAS, alias); // the PendingIntent is used to get calling package name intent.putExtra(EXTRA_SENDER, PendingIntent.getActivity(activity, 0, new Intent(), 0)); |