Skip to content

Commit e186400

Browse files
committed
Widen integrations-api to check whether keychain is locked
1 parent bd1beaa commit e186400

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>org.cryptomator</groupId>
77
<artifactId>integrations-linux</artifactId>
8-
<version>0.1.1</version>
8+
<version>0.2.0-SNAPSHOT</version>
99

1010
<name>integrations-linux</name>
1111
<description>Provides optional Linux services used by Cryptomator</description>
@@ -38,8 +38,8 @@
3838
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3939

4040
<!-- runtime dependencies -->
41-
<api.version>0.1.3</api.version>
42-
<secret-service.version>1.2.1</secret-service.version>
41+
<api.version>1.0.0-beta2</api.version>
42+
<secret-service.version>1.5.0</secret-service.version>
4343
<kdewallet.version>1.1.1</kdewallet.version>
4444
<guava.version>30.0-jre</guava.version>
4545
<slf4j.version>1.7.30</slf4j.version>

src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public boolean isSupported() {
4747
return wallet.map(ConnectedWallet::isSupported).orElse(false);
4848
}
4949

50+
@Override
51+
public boolean isLocked() {
52+
return wallet.map(ConnectedWallet::isLocked).orElse(false);
53+
}
54+
5055
@Override
5156
public void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
5257
Preconditions.checkState(wallet.isPresent(), "Keychain not supported.");
@@ -84,6 +89,8 @@ public boolean isSupported() {
8489
return wallet.isEnabled();
8590
}
8691

92+
public boolean isLocked() { return !wallet.isOpen(Static.DEFAULT_WALLET); }
93+
8794
public void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
8895
try {
8996
if (walletIsOpen() &&

src/main/java/org/cryptomator/linux/keychain/SecretServiceKeychainAccess.java

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ public boolean isSupported() {
2323
}
2424
}
2525

26+
@Override
27+
public boolean isLocked() {
28+
try (@SuppressWarnings("unused") SimpleCollection keyring = new SimpleCollection()) {
29+
// seems like we're able to access the keyring.
30+
return keyring.isLocked();
31+
} catch (IOException | ExceptionInInitializerError | RuntimeException e) {
32+
return true;
33+
}
34+
}
35+
2636
@Override
2737
public void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
2838
try (SimpleCollection keyring = new SimpleCollection()) {

0 commit comments

Comments
 (0)