Skip to content

Commit

Permalink
fixed problem with initializeKeyPaths in client
Browse files Browse the repository at this point in the history
  • Loading branch information
pankinkun committed Oct 24, 2024
1 parent 75cf7ed commit 3408f52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
import net.discdd.android.fragments.PermissionsFragment;
import net.discdd.client.bundlerouting.ClientWindow;
import net.discdd.client.bundlesecurity.BundleSecurity;
import net.discdd.pathutils.ClientPaths;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -104,6 +106,13 @@ protected void onCreate(Bundle savedInstanceState) {
fragmentsWithTitles.get(position).title()));
tabMediator.attach();

try {
ClientPaths clientPaths = new ClientPaths(
Paths.get(getApplicationContext().getApplicationInfo().dataDir));
} catch (IOException e) {
throw new RuntimeException(e);
}

//Application context
var resources = getApplicationContext().getResources();
try (InputStream inServerIdentity = resources.openRawResource(
Expand All @@ -112,8 +121,7 @@ protected void onCreate(Bundle savedInstanceState) {
net.discdd.android_core.R.raw.server_signed_pre); InputStream inServerRatchet =
resources.openRawResource(
net.discdd.android_core.R.raw.server_ratchet)) {
BundleSecurity.initializeKeyPaths(inServerIdentity, inServerSignedPre, inServerRatchet,
Paths.get(getApplicationContext().getApplicationInfo().dataDir));
BundleSecurity.initializeKeyPaths(inServerIdentity, inServerSignedPre, inServerRatchet);
} catch (IOException e) {
logger.log(SEVERE, "[SEC]: Failed to initialize Server Keys", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public BundleSecurity(ClientPaths clientPaths) throws IOException, InvalidKeyExc
// TODO: this function makes me sad! it should not be static. We should probably inject BundleSecurity
// into Bundle transport so that everything can be set up properly
public static void initializeKeyPaths(InputStream inServerIdentity, InputStream inServerSignedPre,
InputStream inServerRatchet, Path rootFolder) throws IOException {
InputStream inServerRatchet) throws IOException {
Files.copy(inServerIdentity, clientPaths.outServerIdentity, StandardCopyOption.REPLACE_EXISTING);
inServerIdentity.close();

Expand Down

0 comments on commit 3408f52

Please sign in to comment.