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