Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- runtime dependencies -->
<api.version>0.1.3</api.version>
<api.version>1.0.0-beta2</api.version>
<secret-service.version>1.5.0</secret-service.version>
<kdewallet.version>1.1.1</kdewallet.version>
<guava.version>30.0-jre</guava.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public boolean isSupported() {
return wallet.map(ConnectedWallet::isSupported).orElse(false);
}

@Override
public boolean isLocked() {
return wallet.map(ConnectedWallet::isLocked).orElse(false);
}

@Override
public void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
Preconditions.checkState(wallet.isPresent(), "Keychain not supported.");
Expand Down Expand Up @@ -84,6 +89,8 @@ public boolean isSupported() {
return wallet.isEnabled();
}

public boolean isLocked() { return !wallet.isOpen(Static.DEFAULT_WALLET); }

public void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
try {
if (walletIsOpen() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public boolean isSupported() {
return SimpleCollection.isAvailable();
}

@Override
public boolean isLocked() {
try (@SuppressWarnings("unused") SimpleCollection keyring = new SimpleCollection()) {
// seems like we're able to access the keyring.
return keyring.isLocked();
} catch (IOException | ExceptionInInitializerError | RuntimeException e) {
return true;
}
}

@Override
public void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
try (SimpleCollection keyring = new SimpleCollection()) {
Expand Down