android: Change how CA certificate reloads are initiated
This commit is contained in:
+8
-8
@@ -33,6 +33,7 @@ public class TrustedCertificateManager
|
|||||||
private static final String TAG = TrustedCertificateManager.class.getSimpleName();
|
private static final String TAG = TrustedCertificateManager.class.getSimpleName();
|
||||||
private final ReentrantReadWriteLock mLock = new ReentrantReadWriteLock();
|
private final ReentrantReadWriteLock mLock = new ReentrantReadWriteLock();
|
||||||
private Hashtable<String, X509Certificate> mCACerts = new Hashtable<String, X509Certificate>();
|
private Hashtable<String, X509Certificate> mCACerts = new Hashtable<String, X509Certificate>();
|
||||||
|
private volatile boolean mReload;
|
||||||
private boolean mLoaded;
|
private boolean mLoaded;
|
||||||
private final ArrayList<KeyStore> mKeyStores = new ArrayList<KeyStore>();
|
private final ArrayList<KeyStore> mKeyStores = new ArrayList<KeyStore>();
|
||||||
|
|
||||||
@@ -94,16 +95,14 @@ public class TrustedCertificateManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forces a load/reload of the cached CA certificates.
|
* Invalidates the current load state so that the next call to load()
|
||||||
* As this takes a while it should be called asynchronously.
|
* will force a reload of the cached CA certificates.
|
||||||
* @return reference to itself
|
* @return reference to itself
|
||||||
*/
|
*/
|
||||||
public TrustedCertificateManager reload()
|
public TrustedCertificateManager reset()
|
||||||
{
|
{
|
||||||
Log.d(TAG, "Force reload of cached CA certificates");
|
Log.d(TAG, "Force reload of cached CA certificates on next load");
|
||||||
this.mLock.writeLock().lock();
|
this.mReload = true;
|
||||||
loadCertificates();
|
|
||||||
this.mLock.writeLock().unlock();
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,8 +116,9 @@ public class TrustedCertificateManager
|
|||||||
{
|
{
|
||||||
Log.d(TAG, "Ensure cached CA certificates are loaded");
|
Log.d(TAG, "Ensure cached CA certificates are loaded");
|
||||||
this.mLock.writeLock().lock();
|
this.mLock.writeLock().lock();
|
||||||
if (!this.mLoaded)
|
if (!this.mLoaded || this.mReload)
|
||||||
{
|
{
|
||||||
|
this.mReload = false;
|
||||||
loadCertificates();
|
loadCertificates();
|
||||||
}
|
}
|
||||||
this.mLock.writeLock().unlock();
|
this.mLock.writeLock().unlock();
|
||||||
|
|||||||
+1
-1
@@ -179,7 +179,7 @@ public class TrustedCertificatesActivity extends Activity implements TrustedCert
|
|||||||
@Override
|
@Override
|
||||||
protected TrustedCertificateManager doInBackground(Void... params)
|
protected TrustedCertificateManager doInBackground(Void... params)
|
||||||
{
|
{
|
||||||
return TrustedCertificateManager.getInstance().reload();
|
return TrustedCertificateManager.getInstance().reset().load();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(TrustedCertificateManager result)
|
protected void onPostExecute(TrustedCertificateManager result)
|
||||||
|
|||||||
Reference in New Issue
Block a user