Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release
, bukan aosp-main
, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
JSONFileKeyStoreClient
public
class
JSONFileKeyStoreClient
extends Object
implements
IKeyStoreClient
java.lang.Object
|
↳ |
com.android.tradefed.util.keystore.JSONFileKeyStoreClient
|
Contoh implementasi saat file JSON lokal bertindak sebagai penyimpanan kunci. File teks JSON harus memiliki kunci ke nilai dalam format string.
Ringkasan
Metode publik |
boolean
|
containsKey(String key)
Metode untuk memeriksa apakah keystore berisi kunci tertentu.
|
String
|
fetchKey(String key)
Metode untuk mengambil kunci tertentu di dalam key store.
|
boolean
|
isAvailable()
Metode untuk memeriksa apakah kita memiliki key store yang valid untuk diajak berkomunikasi atau tidak.
|
void
|
setKeyStore(JSONObject keyStore)
Metode bantuan yang digunakan untuk menetapkan penyimpanan kunci.
|
Metode yang dilindungi |
void
|
setKey(String key, String value)
Memetakan key ke value .
|
Kolom
mJsonKeyStore
protected JSONObject mJsonKeyStore
Konstruktor publik
JSONFileKeyStoreClient
public JSONFileKeyStoreClient ()
JSONFileKeyStoreClient
public JSONFileKeyStoreClient (File jsonFile)
Metode publik
containsKey
public boolean containsKey (String key)
Metode untuk memeriksa apakah keystore berisi kunci tertentu.
Parameter |
key |
String : untuk memeriksa keberadaan. |
Hasil |
boolean |
benar (true) jika kunci yang diberikan ada. |
fetchKey
public String fetchKey (String key)
Metode untuk mengambil kunci tertentu di dalam key store.
Parameter |
key |
String : untuk mengambil di dalam key store. |
Hasil |
String |
nilai String kunci. Fungsi ini akan menampilkan null jika kunci tidak ditemukan. |
isAvailable
public boolean isAvailable ()
Metode untuk memeriksa apakah kita memiliki key store yang valid untuk diajak berkomunikasi atau tidak.
Hasil |
boolean |
true jika kita memiliki key store yang valid, false jika tidak. |
setKeyStore
public void setKeyStore (JSONObject keyStore)
Metode bantuan yang digunakan untuk menetapkan penyimpanan kunci. Digunakan untuk pengujian.
Parameter |
keyStore |
JSONObject : JSONObject yang akan digunakan sebagai key store. |
Metode yang dilindungi
setKey
protected void setKey (String key,
String value)
Memetakan key
ke value
. Setara dengan mJsonKeyStore.put(key, value)
.
Parameter |
key |
String |
value |
String |
Menampilkan |
JSONException |
|
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],null,["# JSONFileKeyStoreClient\n======================\n\n\n`\npublic\n\n\nclass\nJSONFileKeyStoreClient\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\nimplements\n\n`[IKeyStoreClient](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/IKeyStoreClient.html)`\n\n\n`\n\n|---|-----------------------------------------------------------|\n| java.lang.Object ||\n| ↳ | com.android.tradefed.util.keystore.JSONFileKeyStoreClient |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA sample implementation where a local JSON file acts a key store. The JSON\ntext file should have key to value in string format.\n\nSummary\n-------\n\n| ### Fields ||\n|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| ` protected JSONObject` | [mJsonKeyStore](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#mJsonKeyStore) |\n\n| ### Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[JSONFileKeyStoreClient](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#JSONFileKeyStoreClient())`() ` |\n| ` `[JSONFileKeyStoreClient](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#JSONFileKeyStoreClient(File))`(File jsonFile) ` |\n\n| ### Public methods ||\n|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` boolean` | ` `[containsKey](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#containsKey(java.lang.String))`(String key) ` A method to check if the key store contains a given key. |\n| ` String` | ` `[fetchKey](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#fetchKey(java.lang.String))`(String key) ` A method to fetch a given key inside the key store. |\n| ` boolean` | ` `[isAvailable](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#isAvailable())`() ` A method to check whether or not we have a valid key store to talk to. |\n| ` void` | ` `[setKeyStore](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#setKeyStore(org.json.JSONObject))`(JSONObject keyStore) ` Helper method used to set key store. |\n\n| ### Protected methods ||\n|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[setKey](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/JSONFileKeyStoreClient.html#setKey(java.lang.String,%20java.lang.String))`(String key, String value) ` Maps `key` to `value`. |\n\nFields\n------\n\n### mJsonKeyStore\n\n```\nprotected JSONObject mJsonKeyStore\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nPublic constructors\n-------------------\n\n### JSONFileKeyStoreClient\n\n```\npublic JSONFileKeyStoreClient ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### JSONFileKeyStoreClient\n\n```\npublic JSONFileKeyStoreClient (File jsonFile)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|---------------|\n| `jsonFile` | `File` \u003cbr /\u003e |\n\n| Throws ||\n|------------------------------------------------------------------------------------------------------------------------|---|\n| [KeyStoreException](../../../../../../../reference/tradefed/com/android/tradefed/util/keystore/KeyStoreException.html) | |\n\nPublic methods\n--------------\n\n### containsKey\n\n```\npublic boolean containsKey (String key)\n```\n\nA method to check if the key store contains a given key.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------|------------------------------------------|\n| `key` | `String`: to check existence for. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------|\n| `boolean` | true if the given key exists. \u003cbr /\u003e |\n\n### fetchKey\n\n```\npublic String fetchKey (String key)\n```\n\nA method to fetch a given key inside the key store.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------|-------------------------------------------------|\n| `key` | `String`: to fetch inside the key store. \u003cbr /\u003e |\n\n| Returns ||\n|----------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| `String` | the [String](../../../../../../../reference/tradefed/java/lang/String.html) value of the key. It will return null if key is not found. \u003cbr /\u003e |\n\n### isAvailable\n\n```\npublic boolean isAvailable ()\n```\n\nA method to check whether or not we have a valid key store to talk to.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|------------------------------------------------------------|\n| `boolean` | true if we have a valid key store, false otherwise. \u003cbr /\u003e |\n\n### setKeyStore\n\n```\npublic void setKeyStore (JSONObject keyStore)\n```\n\nHelper method used to set key store. Used for testing.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|--------------------------------------------------------------------------------------------------------------------------|\n| `keyStore` | `JSONObject`: [JSONObject](../../../../../../../reference/tradefed/org/json/JSONObject.html) to use as key store. \u003cbr /\u003e |\n\nProtected methods\n-----------------\n\n### setKey\n\n```\nprotected void setKey (String key, \n String value)\n```\n\nMaps `key` to `value`. Equivalent to `mJsonKeyStore.put(key, value)`.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|-----------------|\n| `key` | `String` \u003cbr /\u003e |\n| `value` | `String` \u003cbr /\u003e |\n\n| Throws ||\n|-----------------|---|\n| `JSONException` | |"]]