JSONFileKeyStoreClient

public class JSONFileKeyStoreClient
extends Object implements IKeyStoreClient

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


A sample implementation where a local JSON file acts a key store. The JSON text file should have key to value in string format.

Summary

Fields

protected JSONObject mJsonKeyStore

Public constructors

JSONFileKeyStoreClient()
JSONFileKeyStoreClient(File jsonFile)

Public methods

boolean containsKey(String key)

A method to check if the key store contains a given key.

String fetchKey(String key)

A method to fetch a given key inside the key store.

boolean isAvailable()

A method to check whether or not we have a valid key store to talk to.

void setKeyStore(JSONObject keyStore)

Helper method used to set key store.

Fields

mJsonKeyStore

JSONObject mJsonKeyStore

Public constructors

JSONFileKeyStoreClient

JSONFileKeyStoreClient ()

JSONFileKeyStoreClient

JSONFileKeyStoreClient (File jsonFile)

Parameters
jsonFile File

Throws
KeyStoreException

Public methods

containsKey

boolean containsKey (String key)

A method to check if the key store contains a given key.

Parameters
key String: to check existence for.

Returns
boolean true if the given key exists.

fetchKey

String fetchKey (String key)

A method to fetch a given key inside the key store.

Parameters
key String: to fetch inside the key store.

Returns
String the String value of the key. It will return null if key is not found.

isAvailable

boolean isAvailable ()

A method to check whether or not we have a valid key store to talk to.

Returns
boolean true if we have a valid key store, false otherwise.

setKeyStore

void setKeyStore (JSONObject keyStore)

Helper method used to set key store. Used for testing.

Parameters
keyStore JSONObject: JSONObject to use as key store.