Skip to content

Commit 98a8b65

Browse files
committed
Extract builder method.
1 parent 34abf06 commit 98a8b65

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import cloud.katta.client.ApiException;
2020
import cloud.katta.client.api.StorageProfileResourceApi;
2121
import cloud.katta.client.model.StorageProfileDto;
22+
import cloud.katta.crypto.uvf.UvfMetadataPayload;
23+
import cloud.katta.crypto.uvf.VaultMetadataJWEAutomaticAccessGrantDto;
24+
import cloud.katta.crypto.uvf.VaultMetadataJWEBackendDto;
2225
import cloud.katta.model.StorageProfileDtoWrapper;
2326

2427
public class HubStorageLocationService implements Location {
@@ -111,5 +114,17 @@ public static StorageLocation fromIdentifier(final String identifier) {
111114
}
112115
return new StorageLocation(StringUtils.isBlank(parts[0]) ? null : parts[0], StringUtils.isBlank(parts[1]) ? null : parts[1], null);
113116
}
117+
118+
public UvfMetadataPayload toUvfMetadataPayload(final Path bucket) {
119+
return UvfMetadataPayload.create()
120+
.withStorage(new VaultMetadataJWEBackendDto()
121+
.provider(this.getProfile())
122+
.defaultPath(bucket.getAbsolute())
123+
.region(this.getRegion())
124+
.nickname(null != bucket.attributes().getDisplayname() ? bucket.attributes().getDisplayname() : "Vault"))
125+
.withAutomaticAccessGrant(new VaultMetadataJWEAutomaticAccessGrantDto()
126+
.enabled(true)
127+
.maxWotDepth(null));
128+
}
114129
}
115130
}

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import cloud.katta.crypto.UserKeys;
5454
import cloud.katta.crypto.uvf.UvfMetadataPayload;
5555
import cloud.katta.crypto.uvf.UvfMetadataPayloadPasswordCallback;
56-
import cloud.katta.crypto.uvf.VaultMetadataJWEAutomaticAccessGrantDto;
5756
import cloud.katta.crypto.uvf.VaultMetadataJWEBackendDto;
5857
import cloud.katta.protocols.hub.exceptions.HubExceptionMappingService;
5958
import cloud.katta.protocols.s3.S3AssumeRoleProtocol;
@@ -89,16 +88,7 @@ public HubUVFVault(final Protocol profile, final Path bucket, final HubStorageLo
8988
* @param bucket Bucket
9089
*/
9190
public HubUVFVault(final Protocol profile, final UUID vaultId, final Path bucket, final HubStorageLocationService.StorageLocation location, final LoginCallback prompt) throws ConnectionCanceledException {
92-
this(profile, vaultId, bucket,
93-
UvfMetadataPayload.create()
94-
.withStorage(new VaultMetadataJWEBackendDto()
95-
.provider(location.getProfile())
96-
.defaultPath(bucket.getAbsolute())
97-
.region(location.getRegion())
98-
.nickname(null != bucket.attributes().getDisplayname() ? bucket.attributes().getDisplayname() : "Vault"))
99-
.withAutomaticAccessGrant(new VaultMetadataJWEAutomaticAccessGrantDto()
100-
.enabled(true)
101-
.maxWotDepth(null)), prompt);
91+
this(profile, vaultId, bucket, location.toUvfMetadataPayload(bucket), prompt);
10292
}
10393

10494
/**

0 commit comments

Comments
 (0)