Skip to content

Commit cee1a6a

Browse files
committed
Inline configuration.
1 parent b23ef58 commit cee1a6a

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

hub/src/main/java/cloud/katta/protocols/hub/HubUVFVault.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@
44

55
package cloud.katta.protocols.hub;
66

7-
import ch.cyberduck.core.*;
7+
import ch.cyberduck.core.CredentialsConfigurator;
8+
import ch.cyberduck.core.DisabledCancelCallback;
9+
import ch.cyberduck.core.DisabledHostKeyCallback;
10+
import ch.cyberduck.core.Host;
11+
import ch.cyberduck.core.HostUrlProvider;
12+
import ch.cyberduck.core.LoginCallback;
13+
import ch.cyberduck.core.PasswordCallback;
14+
import ch.cyberduck.core.Path;
15+
import ch.cyberduck.core.PathAttributes;
16+
import ch.cyberduck.core.Protocol;
17+
import ch.cyberduck.core.ProtocolFactory;
18+
import ch.cyberduck.core.Session;
19+
import ch.cyberduck.core.SessionFactory;
20+
import ch.cyberduck.core.UUIDRandomStringService;
821
import ch.cyberduck.core.cryptomator.ContentWriter;
922
import ch.cyberduck.core.cryptomator.UVFVault;
1023
import ch.cyberduck.core.exception.BackgroundException;
@@ -99,7 +112,7 @@ public HubUVFVault(final HubSession hub, final UUID vaultId, final UvfMetadataPa
99112
new PathAttributes().setDisplayname(vaultMetadata.storage().getNickname())), vaultMetadata, prompt);
100113
}
101114

102-
public HubUVFVault(final HubSession hub, final UUID vaultId, final Path bucket, final UvfMetadataPayload vaultMetadata, final LoginCallback prompt) throws ConnectionCanceledException {
115+
public HubUVFVault(final HubSession session, final UUID vaultId, final Path bucket, final UvfMetadataPayload vaultMetadata, final LoginCallback prompt) throws ConnectionCanceledException {
103116
super(bucket);
104117
this.vaultId = vaultId;
105118
this.vaultMetadata = vaultMetadata;
@@ -108,20 +121,12 @@ public HubUVFVault(final HubSession hub, final UUID vaultId, final Path bucket,
108121
final VaultMetadataJWEBackendDto vaultStorageMetadata = vaultMetadata.storage();
109122
final Protocol profile = ProtocolFactory.get().forName(vaultStorageMetadata.getProvider());
110123
log.debug("Loaded profile {} for UVF metadata {}", profile, vaultMetadata);
111-
final Credentials credentials =
112-
hub.getFeature(CredentialsConfigurator.class).reload().configure(hub.getHost());
113-
log.debug("Copy credentials {}", credentials);
114-
if(vaultStorageMetadata.getUsername() != null) {
115-
credentials.setUsername(vaultStorageMetadata.getUsername());
116-
}
117-
if(vaultStorageMetadata.getPassword() != null) {
118-
credentials.setPassword(vaultStorageMetadata.getPassword());
119-
}
120-
final Host storageProvider = new Host(profile, credentials);
124+
final Host storageProvider = new Host(profile, session.getFeature(CredentialsConfigurator.class).reload().configure(session.getHost())
125+
.withUsername(vaultStorageMetadata.getUsername()).withPassword(vaultStorageMetadata.getPassword()));
121126
storageProvider.setProperty(OAUTH_TOKENEXCHANGE_VAULT, vaultId.toString());
122127
storageProvider.setRegion(vaultStorageMetadata.getRegion());
123128
log.debug("Configured {} for vault {}", storageProvider, this);
124-
this.storage = SessionFactory.create(storageProvider, hub.getFeature(X509TrustManager.class), hub.getFeature(X509KeyManager.class));
129+
this.storage = SessionFactory.create(storageProvider, session.getFeature(X509TrustManager.class), session.getFeature(X509KeyManager.class));
125130
}
126131

127132
/**

0 commit comments

Comments
 (0)