|
13 | 13 | import ch.cyberduck.core.HostPasswordStore; |
14 | 14 | import ch.cyberduck.core.LocaleFactory; |
15 | 15 | import ch.cyberduck.core.LoginCallback; |
16 | | -import ch.cyberduck.core.LoginOptions; |
17 | 16 | import ch.cyberduck.core.PasswordStoreFactory; |
18 | 17 | import ch.cyberduck.core.Path; |
19 | 18 | import ch.cyberduck.core.exception.BackgroundException; |
|
27 | 26 | import ch.cyberduck.core.ssl.X509KeyManager; |
28 | 27 | import ch.cyberduck.core.ssl.X509TrustManager; |
29 | 28 | import ch.cyberduck.core.threading.CancelCallback; |
30 | | -import ch.cyberduck.core.vault.VaultCredentials; |
31 | 29 | import ch.cyberduck.core.vault.VaultFactory; |
32 | 30 |
|
33 | 31 | import org.apache.logging.log4j.LogManager; |
34 | 32 | import org.apache.logging.log4j.Logger; |
35 | 33 |
|
36 | | -import java.util.Base64; |
37 | 34 | import java.util.UUID; |
38 | 35 |
|
39 | 36 | import ch.iterate.hub.client.ApiException; |
|
44 | 41 | import ch.iterate.hub.workflows.VaultServiceImpl; |
45 | 42 | import ch.iterate.hub.workflows.exceptions.AccessException; |
46 | 43 | import ch.iterate.hub.workflows.exceptions.SecurityFailure; |
47 | | -import com.google.common.primitives.Bytes; |
48 | | -import com.nimbusds.jose.util.Base64URL; |
| 44 | +import com.fasterxml.jackson.core.JsonProcessingException; |
49 | 45 |
|
50 | 46 | public class S3AutoLoadVaultSession extends S3AssumeRoleSession { |
51 | 47 | private static final Logger log = LogManager.getLogger(S3AutoLoadVaultSession.class); |
@@ -83,23 +79,13 @@ public void login(final LoginCallback prompt, final CancelCallback cancel) throw |
83 | 79 | super.login(prompt, cancel); |
84 | 80 | final Path home = new DelegatingHomeFeature(new DefaultPathHomeFeature(host)).find(); |
85 | 81 | log.debug("Attempting to locate vault in {}", home); |
86 | | - final Vault vault = VaultFactory.get(home); |
87 | | - // TODO https://github.com/shift7-ch/cipherduck-hub/issues/19 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! MUST NEVER BE RELEASED LIKE THIS |
88 | | - // TODO https://github.com/shift7-ch/cipherduck-hub/issues/19 use rawFileKey,rawNameKey as vault key for now (going into cryptolib's Masterkey) |
89 | 82 | final UvfMetadataPayload vaultMetadata = new VaultServiceImpl(backend).getVaultMetadataJWE( |
90 | 83 | UUID.fromString(host.getUuid()), new UserKeysServiceImpl(backend).getUserKeys(backend.getHost(), FirstLoginDeviceSetupCallbackFactory.get())); |
91 | | - final byte[] rawFileKey = Base64URL.from(vaultMetadata.seeds().get(vaultMetadata.latestSeed())).decode(); |
92 | | - final byte[] rawNameKey = Base64URL.from(vaultMetadata.seeds().get(vaultMetadata.latestSeed())).decode(); |
93 | | - final byte[] vaultKey = Bytes.concat(rawFileKey, rawNameKey); |
94 | | - registry.add(vault.load(this, new DisabledPasswordCallback() { |
95 | | - @Override |
96 | | - public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) { |
97 | | - return new VaultCredentials(Base64.getEncoder().encodeToString(vaultKey)); |
98 | | - } |
99 | | - })); |
| 84 | + final Vault vault = VaultFactory.get(home, vaultMetadata.toJSON(), null, null); |
| 85 | + vault.load(this, new DisabledPasswordCallback()); |
100 | 86 | backend.close(); |
101 | 87 | } |
102 | | - catch(ApiException | SecurityFailure | AccessException e) { |
| 88 | + catch(ApiException | SecurityFailure | AccessException | JsonProcessingException e) { |
103 | 89 | throw new LoginFailureException(LocaleFactory.localizedString("Login failed", "Credentials"), e); |
104 | 90 | } |
105 | 91 | } |
|
0 commit comments