JSONFileKeyStoreClient

public class JSONFileKeyStoreClient
extends Object implements IKeyStoreClient

java.lang.Object
   ↳ com.android.tradefed.util.keystore.JSONFileKeyStoreClient


一个示例实现,其中本地 JSON 文件充当密钥库。JSON 文本文件应包含采用字符串格式的键值对。

摘要

字段

protected JSONObject mJsonKeyStore

公共构造函数

JSONFileKeyStoreClient()
JSONFileKeyStoreClient(File jsonFile)

公共方法

boolean containsKey(String key)

一种用于检查密钥库是否包含给定密钥的方法。

String fetchKey(String key)

一种用于提取密钥库中指定密钥的方法。

boolean isAvailable()

一种用于检查我们是否具有有效的密钥库以进行通信的方法。

void setKeyStore(JSONObject keyStore)

用于设置密钥库的辅助方法。

受保护的方法

void setKey(String key, String value)

key 映射到 value

字段

mJsonKeyStore

protected JSONObject mJsonKeyStore

公共构造函数

JSONFileKeyStoreClient

public JSONFileKeyStoreClient ()

JSONFileKeyStoreClient

public JSONFileKeyStoreClient (File jsonFile)

参数
jsonFile File

抛出
KeyStoreException

公共方法

containsKey

public boolean containsKey (String key)

一种用于检查密钥库是否包含指定密钥的方法。

参数
key String:要检查是否存在。

返回
boolean 如果给定的键存在,则为 true。

fetchKey

public String fetchKey (String key)

一种用于提取密钥库中指定密钥的方法。

参数
key String:用于在密钥库中提取。

返回
String 键的 String 值。如果未找到键,则返回 null。

isAvailable

public boolean isAvailable ()

一种用于检查我们是否具有有效的密钥库以进行通信的方法。

返回
boolean 如果我们有有效的密钥库,则为 true,否则为 false。

setKeyStore

public void setKeyStore (JSONObject keyStore)

用于设置密钥库的辅助方法。用于测试。

参数
keyStore JSONObject:用作密钥库的 JSONObject

受保护的方法

setKey

protected void setKey (String key, 
                String value)

key 映射到 value。等同于 mJsonKeyStore.put(key, value)

参数
key String

value String

抛出
JSONException