mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 02:31:27 +00:00
cleanup
This commit is contained in:
@@ -64,16 +64,12 @@ public class Passphrase implements Destroyable, CharSequence {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// TODO: do we really need to a secure hashcode? toString leaks the pw anyway
|
||||
var md = MessageDigestSupplier.SHA256.get();
|
||||
ByteBuffer buf = ByteBuffer.allocate(Character.BYTES * length);
|
||||
// basically Arrays.hashCode, but only for a certain subarray
|
||||
int result = 1;
|
||||
for (int i = 0; i < length; i++) {
|
||||
char c = charAt(i);
|
||||
buf.putChar(i * Character.BYTES, c);
|
||||
result = 31 * result + charAt(i);
|
||||
}
|
||||
buf.flip();
|
||||
md.update(buf);
|
||||
return Arrays.hashCode(md.digest());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,10 @@ public class FxmlLoaderFactory {
|
||||
this.resourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
public static <T extends FxController> FxmlLoaderFactory forController(T controller, Function<Parent, Scene> sceneFactory, ResourceBundle resourceBundle) {
|
||||
return new FxmlLoaderFactory(Map.of(controller.getClass(), () -> controller), sceneFactory, resourceBundle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A new FXMLLoader instance
|
||||
*/
|
||||
|
||||
@@ -27,16 +27,7 @@ interface ChooseMasterkeyFileModule {
|
||||
@Provides
|
||||
@ChooseMasterkeyFileScoped
|
||||
static Scene provideChooseMasterkeyScene(ChooseMasterkeyFileController controller, DefaultSceneFactory sceneFactory, ResourceBundle resourceBundle) {
|
||||
// TODO: simplify FxmlLoaderFactory
|
||||
try {
|
||||
var url = FxmlLoaderFactory.class.getResource(FxmlFile.UNLOCK_SELECT_MASTERKEYFILE.getRessourcePathString());
|
||||
var loader = new FXMLLoader(url, resourceBundle, null, clazz -> controller);
|
||||
Parent root = loader.load();
|
||||
return sceneFactory.apply(root);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException("Failed to load ChooseMasterkeyScene", e);
|
||||
}
|
||||
return FxmlLoaderFactory.forController(controller, sceneFactory, resourceBundle).createScene(FxmlFile.UNLOCK_SELECT_MASTERKEYFILE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,16 +26,7 @@ interface PassphraseEntryModule {
|
||||
@Provides
|
||||
@PassphraseEntryScoped
|
||||
static Scene provideUnlockScene(PassphraseEntryController controller, DefaultSceneFactory sceneFactory, ResourceBundle resourceBundle) {
|
||||
// TODO: simplify FxmlLoaderFactory
|
||||
try {
|
||||
var url = FxmlLoaderFactory.class.getResource(FxmlFile.UNLOCK_ENTER_PASSWORD.getRessourcePathString());
|
||||
var loader = new FXMLLoader(url, resourceBundle, null, clazz -> controller);
|
||||
Parent root = loader.load();
|
||||
return sceneFactory.apply(root);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException("Failed to load UnlockScene", e);
|
||||
}
|
||||
return FxmlLoaderFactory.forController(controller, sceneFactory, resourceBundle).createScene(FxmlFile.UNLOCK_ENTER_PASSWORD);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.cryptomator.ui.keyloading.masterkeyfile;
|
||||
|
||||
import org.cryptomator.common.Passphrase;
|
||||
|
||||
// TODO needs to be public due to Dagger -.-
|
||||
// TODO: change to package-private, as soon as this works for Dagger -.-
|
||||
public record PassphraseEntryResult(Passphrase passphrase, boolean savePassphrase) {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package org.cryptomator.ui.lock;
|
||||
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.fxml.FXML;
|
||||
@@ -15,8 +13,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
@LockScoped
|
||||
public class LockForcedController implements FxController {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LockForcedController.class);
|
||||
|
||||
private final Stage window;
|
||||
private final Vault vault;
|
||||
private final AtomicReference<CompletableFuture<Boolean>> forceRetryDecision;
|
||||
|
||||
Reference in New Issue
Block a user