|
1 | 1 | package org.cryptomator.linux.keychain; |
2 | 2 |
|
3 | | -import com.google.common.base.Preconditions; |
4 | 3 | import org.cryptomator.integrations.common.OperatingSystem; |
5 | 4 | import org.cryptomator.integrations.common.Priority; |
6 | 5 | import org.cryptomator.integrations.keychain.KeychainAccessException; |
7 | 6 | import org.cryptomator.integrations.keychain.KeychainAccessProvider; |
| 7 | +import org.cryptomator.linux.util.CheckUtil; |
8 | 8 | import org.freedesktop.dbus.connections.impl.DBusConnection; |
9 | 9 | import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder; |
10 | 10 | import org.freedesktop.dbus.exceptions.DBusConnectionException; |
@@ -49,25 +49,25 @@ public boolean isLocked() { |
49 | 49 |
|
50 | 50 | @Override |
51 | 51 | public void storePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException { |
52 | | - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); |
| 52 | + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); |
53 | 53 | wallet.get().storePassphrase(key, passphrase); |
54 | 54 | } |
55 | 55 |
|
56 | 56 | @Override |
57 | 57 | public char[] loadPassphrase(String key) throws KeychainAccessException { |
58 | | - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); |
| 58 | + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); |
59 | 59 | return wallet.get().loadPassphrase(key); |
60 | 60 | } |
61 | 61 |
|
62 | 62 | @Override |
63 | 63 | public void deletePassphrase(String key) throws KeychainAccessException { |
64 | | - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); |
| 64 | + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); |
65 | 65 | wallet.get().deletePassphrase(key); |
66 | 66 | } |
67 | 67 |
|
68 | 68 | @Override |
69 | 69 | public void changePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException { |
70 | | - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); |
| 70 | + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); |
71 | 71 | wallet.get().changePassphrase(key, passphrase); |
72 | 72 | } |
73 | 73 |
|
@@ -95,11 +95,7 @@ private static DBusConnection getNewConnection() throws DBusException { |
95 | 95 | } catch (DBusConnectionException | DBusExecutionException de) { |
96 | 96 | LOG.warn("Connecting to SESSION bus failed.", de); |
97 | 97 | LOG.warn("Falling back to SYSTEM DBus"); |
98 | | - try { |
99 | | - return DBusConnectionBuilder.forSystemBus().build(); |
100 | | - } catch (DBusException e) { |
101 | | - throw e; |
102 | | - } |
| 98 | + return DBusConnectionBuilder.forSystemBus().build(); |
103 | 99 | } |
104 | 100 | } |
105 | 101 |
|
@@ -144,7 +140,7 @@ public char[] loadPassphrase(String key) throws KeychainAccessException { |
144 | 140 | } else { |
145 | 141 | LOG.debug("loadPassphrase: wallet is closed."); |
146 | 142 | } |
147 | | - return (password.equals("")) ? null : password.toCharArray(); |
| 143 | + return (password.isEmpty()) ? null : password.toCharArray(); |
148 | 144 | } catch (RuntimeException e) { |
149 | 145 | throw new KeychainAccessException("Loading the passphrase failed.", e); |
150 | 146 | } |
|
0 commit comments