Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
         
       
     
  
  
  
  
  
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
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
| 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.
        
    
 | 
  
| Protected methods | 
|---|
  
  
  
    | 
        
        
        
        
        
        void | 
      setKey(String key, String value)
      Maps keytovalue. | 
  
Fields
    mJsonKeyStore
    
      
  
      
  
    
protected JSONObject mJsonKeyStore
    
    
    
  
    
 
Public constructors
    JSONFileKeyStoreClient
    
public JSONFileKeyStoreClient ()
    
    
    
  
 
    JSONFileKeyStoreClient
    
public JSONFileKeyStoreClient (File jsonFile)
    
    
    
  
    
      
  
 
Public methods
    containsKey
    
public 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
    
public 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 Stringvalue of the key. It will return null if key
         is not found. | 
    
 
    isAvailable
    
public 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
    
public void setKeyStore (JSONObject keyStore)
    
    
    
  Helper method used to set key store. Used for testing.
    
    | Parameters | 
|---|
      
        | keyStore | JSONObject:JSONObjectto use as key store. | 
    
 
Protected methods
    setKey
    
protected void setKey (String key, 
                String value)
    
    
    
  Maps key to value. Equivalent to mJsonKeyStore.put(key, value).
    
    | Parameters | 
|---|
      
        | key | String | 
      
        | value | String | 
    
      
  
 
 
 
  
  
 
  
    
    
      
    
    
  
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2023-07-19 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-07-19 UTC."],[],[]]