ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
JSONFileKeyStoreClient
public
class
JSONFileKeyStoreClient
extends Object
implements
IKeyStoreClient
java.lang.Object
|
↳ |
com.android.tradefed.util.keystore.JSONFileKeyStoreClient
|
ตัวอย่างการใช้งานที่ไฟล์ JSON ในเครื่องทำหน้าที่เป็นคีย์สโตร์ ไฟล์ข้อความ JSON ควรมีคีย์เป็นค่าในรูปแบบสตริง
สรุป
เมธอดสาธารณะ |
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 |
เมธอดสาธารณะ
containsKey
public boolean containsKey (String key)
วิธีการตรวจสอบว่าแหล่งเก็บคีย์มีคีย์ที่ระบุหรือไม่
พารามิเตอร์ |
key |
String : เพื่อตรวจสอบการมีอยู่ |
คิกรีเทิร์น |
boolean |
จริงหากมีคีย์ที่ระบุ |
fetchKey
public String fetchKey (String key)
วิธีการดึงข้อมูลคีย์ที่ระบุภายในที่เก็บคีย์
พารามิเตอร์ |
key |
String : เพื่อดึงข้อมูลภายในที่เก็บคีย์ |
คิกรีเทิร์น |
String |
ค่า String ของคีย์ โดยจะแสดงผล Null หากไม่พบคีย์ |
isAvailable
public boolean isAvailable ()
วิธีตรวจสอบว่าเรามีคีย์สโตร์ที่ถูกต้องที่จะพูดคุยด้วยหรือไม่
คิกรีเทิร์น |
boolean |
จะเป็นจริงหากเรามีที่เก็บคีย์ที่ถูกต้อง หรือเป็นเท็จหากไม่ |
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 |
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 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` | |"]]