Okay, toss BouncyCastleProvider so we can release a beta.
This commit is contained in:
parent
857f39b480
commit
bb0ea876fa
3 changed files with 9 additions and 55 deletions
|
@ -18,20 +18,13 @@ package com.keylesspalace.tusky;
|
|||
import android.app.Application;
|
||||
import android.arch.persistence.room.Room;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jakewharton.picasso.OkHttp3Downloader;
|
||||
import com.keylesspalace.tusky.db.AppDatabase;
|
||||
import com.keylesspalace.tusky.util.OkHttpUtils;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
import java.security.Provider;
|
||||
import java.security.Security;
|
||||
|
||||
public class TuskyApplication extends Application {
|
||||
private static final String TAG = "TuskyApplication"; // logging tag
|
||||
private static AppDatabase db;
|
||||
|
||||
public static AppDatabase getDB() {
|
||||
|
@ -59,40 +52,6 @@ public class TuskyApplication extends Application {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
/* Install the new provider or, if there's a pre-existing older version, replace the
|
||||
* existing version of it. */
|
||||
final String providerName = "BC";
|
||||
Provider existingProvider = Security.getProvider(providerName);
|
||||
if (existingProvider == null) {
|
||||
try {
|
||||
int priority = Security.addProvider(new BouncyCastleProvider());
|
||||
Log.i(TAG, String.format("BouncyCastleProvider was added with priority %d.",
|
||||
priority));
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, "Permission to add the security provider was denied.");
|
||||
}
|
||||
} else {
|
||||
Provider replacement = new BouncyCastleProvider();
|
||||
if (existingProvider.getVersion() < replacement.getVersion()) {
|
||||
Provider[] providers = Security.getProviders();
|
||||
int priority = 1;
|
||||
for (int i = 0; i < providers.length; i++) {
|
||||
if (providers[i].getName().equals(providerName)) {
|
||||
priority = i + 1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Security.removeProvider(providerName);
|
||||
Security.insertProviderAt(replacement, priority);
|
||||
Log.i(TAG, String.format(
|
||||
"BouncyCastleProvider version %f was updated to version %f.",
|
||||
existingProvider.getVersion(), replacement.getVersion()));
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, "Permission to update a security provider was denied.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "tuskyDB")
|
||||
.allowMainThreadQueries()
|
||||
.build();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue