FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.security.KeystoreHelper Class Reference

Data Structures

class  KeystoreException
 

Public Member Functions

byte[] getOrCreateDbKey () throws KeystoreException
 

Static Public Member Functions

static KeystoreHelper getInstance (Context context)
 

Detailed Description

Definition at line 31 of file KeystoreHelper.java.

Member Function Documentation

◆ getInstance()

static KeystoreHelper com.freerdp.freerdpcore.security.KeystoreHelper.getInstance ( Context  context)
inlinestatic

Definition at line 51 of file KeystoreHelper.java.

52 {
53 if (instance == null)
54 {
55 synchronized (KeystoreHelper.class)
56 {
57 if (instance == null)
58 {
59 instance = new KeystoreHelper(context);
60 }
61 }
62 }
63 return instance;
64 }

◆ getOrCreateDbKey()

byte[] com.freerdp.freerdpcore.security.KeystoreHelper.getOrCreateDbKey ( ) throws KeystoreException
inline

Definition at line 66 of file KeystoreHelper.java.

67 {
68 SharedPreferences prefs =
69 applicationContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
70 String encoded = prefs.getString(PREF_ENCRYPTED_DB_KEY, null);
71
72 if (encoded != null)
73 {
74 return decryptDbKey(encoded);
75 }
76
77 byte[] rawKey = new byte[DB_KEY_LENGTH];
78 new SecureRandom().nextBytes(rawKey);
79 String encrypted = encryptDbKey(rawKey);
80 prefs.edit().putString(PREF_ENCRYPTED_DB_KEY, encrypted).apply();
81 return rawKey;
82 }

The documentation for this class was generated from the following file: