11package org .cryptomator .linux .keychain ;
22
3+ import org .cryptomator .integrations .common .OperatingSystem ;
4+ import org .cryptomator .integrations .common .Priority ;
35import org .cryptomator .integrations .keychain .KeychainAccessException ;
46import org .cryptomator .integrations .keychain .KeychainAccessProvider ;
57import org .freedesktop .secret .simple .SimpleCollection ;
68
79import java .io .IOException ;
8- import java .security .AccessControlException ;
910import java .util .List ;
1011import java .util .Map ;
1112
13+ @ Priority (900 )
14+ @ OperatingSystem (OperatingSystem .Value .LINUX )
1215public class SecretServiceKeychainAccess implements KeychainAccessProvider {
1316
1417 private final String LABEL_FOR_SECRET_IN_KEYRING = "Cryptomator" ;
@@ -33,15 +36,15 @@ public boolean isLocked() {
3336 }
3437
3538 @ Override
36- public void storePassphrase (String key , CharSequence passphrase ) throws KeychainAccessException {
39+ public void storePassphrase (String key , String displayName , CharSequence passphrase ) throws KeychainAccessException {
3740 try (SimpleCollection keyring = new SimpleCollection ()) {
3841 List <String > list = keyring .getItems (createAttributes (key ));
3942 if (list == null || list .isEmpty ()) {
4043 keyring .createItem (LABEL_FOR_SECRET_IN_KEYRING , passphrase , createAttributes (key ));
4144 } else {
42- changePassphrase (key , passphrase );
45+ changePassphrase (key , displayName , passphrase );
4346 }
44- } catch (IOException | AccessControlException e ) {
47+ } catch (IOException | SecurityException e ) {
4548 throw new KeychainAccessException ("Storing password failed." , e );
4649 }
4750 }
@@ -55,7 +58,7 @@ public char[] loadPassphrase(String key) throws KeychainAccessException {
5558 } else {
5659 return null ;
5760 }
58- } catch (IOException | AccessControlException e ) {
61+ } catch (IOException | SecurityException e ) {
5962 throw new KeychainAccessException ("Loading password failed." , e );
6063 }
6164 }
@@ -67,19 +70,19 @@ public void deletePassphrase(String key) throws KeychainAccessException {
6770 if (list != null && !list .isEmpty ()) {
6871 keyring .deleteItem (list .get (0 ));
6972 }
70- } catch (IOException | AccessControlException e ) {
73+ } catch (IOException | SecurityException e ) {
7174 throw new KeychainAccessException ("Deleting password failed." , e );
7275 }
7376 }
7477
7578 @ Override
76- public void changePassphrase (String key , CharSequence passphrase ) throws KeychainAccessException {
79+ public void changePassphrase (String key , String displayName , CharSequence passphrase ) throws KeychainAccessException {
7780 try (SimpleCollection keyring = new SimpleCollection ()) {
7881 List <String > list = keyring .getItems (createAttributes (key ));
7982 if (list != null && !list .isEmpty ()) {
8083 keyring .updateItem (list .get (0 ), LABEL_FOR_SECRET_IN_KEYRING , passphrase , createAttributes (key ));
8184 }
82- } catch (IOException | AccessControlException e ) {
85+ } catch (IOException | SecurityException e ) {
8386 throw new KeychainAccessException ("Changing password failed." , e );
8487 }
8588 }
0 commit comments