mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
refactor PushUtils
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
01b0452d6f
commit
31f2f40bcf
@ -85,21 +85,17 @@ public class PushUtils {
|
|||||||
@Inject
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
private File keysFile;
|
private final File publicKeyFile;
|
||||||
private File publicKeyFile;
|
private final File privateKeyFile;
|
||||||
private File privateKeyFile;
|
|
||||||
|
|
||||||
private String proxyServer;
|
private final String proxyServer;
|
||||||
|
|
||||||
public PushUtils() {
|
public PushUtils() {
|
||||||
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
||||||
|
|
||||||
keysFile = NextcloudTalkApplication.Companion.getSharedApplication().getDir("PushKeyStore", Context.MODE_PRIVATE);
|
String keyPath = NextcloudTalkApplication.Companion.getSharedApplication().getDir("PushKeystore", Context.MODE_PRIVATE).getAbsolutePath();
|
||||||
|
publicKeyFile = new File(keyPath, "push_key.pub");
|
||||||
publicKeyFile = new File(NextcloudTalkApplication.Companion.getSharedApplication().getDir("PushKeystore",
|
privateKeyFile = new File(keyPath, "push_key.priv");
|
||||||
Context.MODE_PRIVATE), "push_key.pub");
|
|
||||||
privateKeyFile = new File(NextcloudTalkApplication.Companion.getSharedApplication().getDir("PushKeystore",
|
|
||||||
Context.MODE_PRIVATE), "push_key.priv");
|
|
||||||
proxyServer = NextcloudTalkApplication.Companion.getSharedApplication().getResources().
|
proxyServer = NextcloudTalkApplication.Companion.getSharedApplication().getResources().
|
||||||
getString(R.string.nc_push_server_url);
|
getString(R.string.nc_push_server_url);
|
||||||
}
|
}
|
||||||
@ -190,9 +186,6 @@ public class PushUtils {
|
|||||||
|
|
||||||
public int generateRsa2048KeyPair() {
|
public int generateRsa2048KeyPair() {
|
||||||
if (!publicKeyFile.exists() && !privateKeyFile.exists()) {
|
if (!publicKeyFile.exists() && !privateKeyFile.exists()) {
|
||||||
if (!keysFile.exists()) {
|
|
||||||
keysFile.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyPairGenerator keyGen = null;
|
KeyPairGenerator keyGen = null;
|
||||||
try {
|
try {
|
||||||
@ -226,7 +219,6 @@ public class PushUtils {
|
|||||||
String token = appPreferences.getPushToken();
|
String token = appPreferences.getPushToken();
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(token)) {
|
if (!TextUtils.isEmpty(token)) {
|
||||||
String credentials;
|
|
||||||
String pushTokenHash = generateSHA512Hash(token).toLowerCase();
|
String pushTokenHash = generateSHA512Hash(token).toLowerCase();
|
||||||
PublicKey devicePublicKey = (PublicKey) readKeyFromFile(true);
|
PublicKey devicePublicKey = (PublicKey) readKeyFromFile(true);
|
||||||
if (devicePublicKey != null) {
|
if (devicePublicKey != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user