KeyStoreManager.GrantKeyAccess(String, Int32) Method

Definition

Grants access to the key owned by the calling app stored under the specified alias to another app on the device with the provided uid.

[Android.Runtime.Register("grantKeyAccess", "(Ljava/lang/String;I)J", "", ApiSince=36)]
public long GrantKeyAccess(string alias, int uid);
[<Android.Runtime.Register("grantKeyAccess", "(Ljava/lang/String;I)J", "", ApiSince=36)>]
member this.GrantKeyAccess : string * int -> int64

Parameters

alias
String

the alias of the key to be granted to another app

uid
Int32

the uid of the app to which the key should be granted

Returns

the ID of the granted key; this can be shared with the specified app, and that app can use #getGrantedKeyFromId(long) to access the key

Attributes

Remarks

Grants access to the key owned by the calling app stored under the specified alias to another app on the device with the provided uid.

This method supports granting access to instances of both javax.crypto.SecretKey and java.security.PrivateKey. The resulting ID will persist across reboots and can be used by the grantee app for the life of the key or until access is revoked with #revokeKeyAccess(String, int).

If the provided alias does not correspond to a key in the Android KeyStore, then an UnrecoverableKeyException is thrown.

Java documentation for android.security.keystore.KeyStoreManager.grantKeyAccess(java.lang.String, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to