|
20 | 20 | import java.security.InvalidKeyException; |
21 | 21 | import java.security.NoSuchAlgorithmException; |
22 | 22 | import java.util.ArrayList; |
| 23 | +import java.util.HashMap; |
23 | 24 | import java.util.List; |
24 | 25 | import java.util.Map; |
25 | 26 |
|
26 | | -@Priority(900) |
| 27 | +@Priority(1100) |
27 | 28 | @OperatingSystem(OperatingSystem.Value.LINUX) |
28 | 29 | @DisplayName("Secret Service") |
29 | 30 | public class SecretServiceKeychainAccess implements KeychainAccessProvider { |
@@ -176,15 +177,21 @@ private void migrateKDEWalletEntries() { |
176 | 177 | session.getService().ensureUnlocked(i); |
177 | 178 | var item = new Item(i); |
178 | 179 | var secret = item.getSecret(session.getSession()); |
| 180 | + Map<String, String> newAttribs = new HashMap<>(attribs.value()); |
| 181 | + newAttribs.put("server", "Cryptomator - already migrated"); |
| 182 | + var label = item.getLabel().value(); |
| 183 | + var itemProps = Item.createProperties(label, newAttribs); |
| 184 | + var replace = collection.createItem(itemProps, secret, true); |
| 185 | + assert replace.isSuccess() : "Replacing migrated item failed"; |
| 186 | + item.delete(); |
179 | 187 | try { |
180 | 188 | storePassphrase(attribs.value().get("user"), "Cryptomator", new String(session.decrypt(secret))); |
| 189 | + LOG.info("Successfully migrated password for vault {}", attribs.value().get("user")); |
181 | 190 | } catch (KeychainAccessException | NoSuchPaddingException | NoSuchAlgorithmException | |
182 | 191 | InvalidAlgorithmParameterException | InvalidKeyException | BadPaddingException | |
183 | 192 | IllegalBlockSizeException e) { |
184 | 193 | LOG.error("Migrating entry {} for vault {} failed", i.getPath(), attribs.value().get("user")); |
185 | 194 | } |
186 | | - item.delete(); |
187 | | - LOG.info("Successfully migrated password for vault {}", attribs.value().get("user")); |
188 | 195 | } |
189 | 196 | } |
190 | 197 | } |
|
0 commit comments