Skip to content

Commit 2614555

Browse files
committed
Inline configuration.
1 parent cee1a6a commit 2614555

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class HubUVFVault extends UVFVault {
7878
private final Session<?> storage;
7979

8080
private final Path home;
81-
private final LoginCallback prompt;
81+
private final LoginCallback login;
8282

8383
public HubUVFVault(final HubSession hub, final Path bucket, final HubStorageLocationService.StorageLocation location, final LoginCallback prompt) throws ConnectionCanceledException {
8484
this(hub, UUID.fromString(new UUIDRandomStringService().random()), bucket, location, prompt);
@@ -117,14 +117,13 @@ public HubUVFVault(final HubSession session, final UUID vaultId, final Path buck
117117
this.vaultId = vaultId;
118118
this.vaultMetadata = vaultMetadata;
119119
this.home = bucket;
120-
this.prompt = prompt;
120+
this.login = prompt;
121121
final VaultMetadataJWEBackendDto vaultStorageMetadata = vaultMetadata.storage();
122122
final Protocol profile = ProtocolFactory.get().forName(vaultStorageMetadata.getProvider());
123123
log.debug("Loaded profile {} for UVF metadata {}", profile, vaultMetadata);
124124
final Host storageProvider = new Host(profile, session.getFeature(CredentialsConfigurator.class).reload().configure(session.getHost())
125-
.withUsername(vaultStorageMetadata.getUsername()).withPassword(vaultStorageMetadata.getPassword()));
125+
.withUsername(vaultStorageMetadata.getUsername()).withPassword(vaultStorageMetadata.getPassword())).withRegion(vaultStorageMetadata.getRegion());
126126
storageProvider.setProperty(OAUTH_TOKENEXCHANGE_VAULT, vaultId.toString());
127-
storageProvider.setRegion(vaultStorageMetadata.getRegion());
128127
log.debug("Configured {} for vault {}", storageProvider, this);
129128
this.storage = SessionFactory.create(storageProvider, session.getFeature(X509TrustManager.class), session.getFeature(X509KeyManager.class));
130129
}
@@ -188,7 +187,7 @@ public Path create(final Session<?> session, final String region, final VaultCre
188187
// Upload JWE
189188
log.debug("Grant access to vault {}", vaultDto);
190189
final UserDto userDto = hub.getMe();
191-
final DeviceSetupCallback setup = prompt.getFeature(DeviceSetupCallback.class);
190+
final DeviceSetupCallback setup = login.getFeature(DeviceSetupCallback.class);
192191
final UserKeys userKeys = hub.getUserKeys(setup);
193192
vaultResourceApi.apiVaultsVaultIdAccessTokensPost(vaultDto.getId(),
194193
Collections.singletonMap(userDto.getId(), jwks.toOwnerAccessToken().encryptForUser(userKeys.ecdhKeyPair().getPublic())));
@@ -202,7 +201,7 @@ public Path create(final Session<?> session, final String region, final VaultCre
202201
new ProxyPreferencesReader(storage.getHost()).getProperty(S3AssumeRoleProtocol.S3_ASSUMEROLE_ROLEARN_CREATE_BUCKET));
203202
// No role chaining when creating vault
204203
configuration.setProperty(S3AssumeRoleProtocol.S3_ASSUMEROLE_ROLEARN_TAG, null);
205-
storage.open(ProxyFactory.get(), new DisabledHostKeyCallback(), prompt, new DisabledCancelCallback());
204+
storage.open(ProxyFactory.get(), new DisabledHostKeyCallback(), login, new DisabledCancelCallback());
206205
final Path vault;
207206
if(false) {
208207
log.debug("Upload vault template to {}", storage);
@@ -252,15 +251,14 @@ public HubUVFVault load(final Session<?> session, final PasswordCallback prompt)
252251
try {
253252
log.debug("Connect to {}", storage);
254253
try {
255-
storage.open(ProxyFactory.get(), new DisabledHostKeyCallback(), this.prompt, new DisabledCancelCallback());
254+
storage.open(ProxyFactory.get(), new DisabledHostKeyCallback(), login, new DisabledCancelCallback());
256255
}
257256
catch(BackgroundException e) {
258257
log.warn("Skip loading vault with failure {} connecting to storage", e.toString());
259258
throw new VaultUnlockCancelException(this, e);
260259
}
261-
final PathAttributes attr = storage.getFeature(AttributesFinder.class).find(home);
262-
attr.setDisplayname(vaultMetadata.storage().getNickname());
263-
home.setAttributes(attr);
260+
home.setAttributes(storage.getFeature(AttributesFinder.class).find(home)
261+
.setDisplayname(vaultMetadata.storage().getNickname()));
264262
log.debug("Initialize vault {} with metadata {}", this, vaultMetadata);
265263
// Initialize cryptors
266264
super.load(storage, new UvfMetadataPayloadPasswordCallback(vaultMetadata.toJSON()));

0 commit comments

Comments
 (0)