Skip to content

Commit eb39be9

Browse files
Merge branch 'develop' into release/1.0.0
2 parents bcc34aa + 3371cf5 commit eb39be9

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3939

4040
<!-- runtime dependencies -->
41-
<api.version>1.0.0-beta2</api.version>
42-
<secret-service.version>1.5.0</secret-service.version>
43-
<kdewallet.version>1.1.1</kdewallet.version>
41+
<api.version>1.0.0-rc1</api.version>
42+
<secret-service.version>1.6.2</secret-service.version>
43+
<kdewallet.version>1.2.1</kdewallet.version>
4444
<guava.version>30.0-jre</guava.version>
4545
<slf4j.version>1.7.30</slf4j.version>
4646
<junit.version>5.7.0</junit.version>

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

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.cryptomator.integrations.keychain.KeychainAccessException;
55
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
66
import org.freedesktop.dbus.connections.impl.DBusConnection;
7+
import org.freedesktop.dbus.exceptions.DBusConnectionException;
78
import org.freedesktop.dbus.exceptions.DBusException;
89
import org.kde.KWallet;
910
import org.kde.Static;
@@ -22,24 +23,12 @@ public class KDEWalletKeychainAccess implements KeychainAccessProvider {
2223
private final Optional<ConnectedWallet> wallet;
2324

2425
public KDEWalletKeychainAccess() {
25-
ConnectedWallet wallet = null;
26-
try {
27-
DBusConnection conn = null;
28-
try {
29-
conn = DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION);
30-
} catch (RuntimeException e) {
31-
if (e.getMessage() == "Cannot Resolve Session Bus Address") {
32-
LOG.warn("SESSION DBus not found.");
33-
}
34-
}
35-
if (conn == null) {
36-
conn = DBusConnection.getConnection(DBusConnection.DBusBusType.SYSTEM);
37-
}
38-
wallet = new ConnectedWallet(conn);
39-
} catch (DBusException e) {
40-
LOG.warn("Connecting to D-Bus failed.", e);
41-
}
42-
this.wallet = Optional.ofNullable(wallet);
26+
this.wallet = ConnectedWallet.connect();
27+
}
28+
29+
@Override
30+
public String displayName() {
31+
return "KDE Wallet";
4332
}
4433

4534
@Override
@@ -85,6 +74,28 @@ public ConnectedWallet(DBusConnection connection) {
8574
this.wallet = new KDEWallet(connection);
8675
}
8776

77+
static Optional<ConnectedWallet> connect() {
78+
try {
79+
return Optional.of(new ConnectedWallet(getConnection()));
80+
} catch (DBusException e) {
81+
LOG.warn("Connecting to D-Bus failed.", e);
82+
return Optional.empty();
83+
}
84+
}
85+
86+
private static DBusConnection getConnection() throws DBusException {
87+
try {
88+
return DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION);
89+
} catch (DBusConnectionException ce) {
90+
LOG.warn("SESSION DBus not found, falling back to SYSTEM DBus");
91+
try {
92+
return DBusConnection.getConnection(DBusConnection.DBusBusType.SYSTEM);
93+
} catch (DBusException e) {
94+
throw e;
95+
}
96+
}
97+
}
98+
8899
public boolean isSupported() {
89100
return wallet.isEnabled();
90101
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66

77
import java.io.IOException;
88
import java.security.AccessControlException;
9-
import java.util.HashMap;
109
import java.util.List;
1110
import java.util.Map;
1211

1312
public class SecretServiceKeychainAccess implements KeychainAccessProvider {
1413

1514
private final String LABEL_FOR_SECRET_IN_KEYRING = "Cryptomator";
1615

16+
@Override
17+
public String displayName() {
18+
return "Gnome Keyring";
19+
}
20+
1721
@Override
1822
public boolean isSupported() {
1923
return SimpleCollection.isAvailable();
@@ -24,7 +28,7 @@ public boolean isLocked() {
2428
try (@SuppressWarnings("unused") SimpleCollection keyring = new SimpleCollection()) {
2529
// seems like we're able to access the keyring.
2630
return keyring.isLocked();
27-
} catch (IOException | ExceptionInInitializerError | RuntimeException e) {
31+
} catch (IOException e) {
2832
return true;
2933
}
3034
}

0 commit comments

Comments
 (0)