1010import ch .cyberduck .core .exception .BackgroundException ;
1111import ch .cyberduck .core .exception .ConnectionCanceledException ;
1212import ch .cyberduck .core .exception .InteroperabilityException ;
13+ import ch .cyberduck .core .exception .UnsupportedException ;
1314import ch .cyberduck .core .features .AttributesFinder ;
1415import ch .cyberduck .core .features .Directory ;
1516import ch .cyberduck .core .features .Write ;
@@ -63,17 +64,18 @@ public class HubUVFVault extends UVFVault {
6364 private final Session <?> storage ;
6465
6566 private final Path home ;
67+ private final LoginCallback prompt ;
6668
67- public HubUVFVault (final HubSession hub , final Path bucket , final HubStorageLocationService .StorageLocation location ) throws ConnectionCanceledException {
68- this (hub , UUID .fromString (new UUIDRandomStringService ().random ()), bucket , location );
69+ public HubUVFVault (final HubSession hub , final Path bucket , final HubStorageLocationService .StorageLocation location , final LoginCallback prompt ) throws ConnectionCanceledException {
70+ this (hub , UUID .fromString (new UUIDRandomStringService ().random ()), bucket , location , prompt );
6971 }
7072
7173 /**
7274 * Constructor for factory creating new vault
7375 *
7476 * @param bucket Bucket
7577 */
76- public HubUVFVault (final HubSession hub , final UUID vaultId , final Path bucket , final HubStorageLocationService .StorageLocation location ) throws ConnectionCanceledException {
78+ public HubUVFVault (final HubSession hub , final UUID vaultId , final Path bucket , final HubStorageLocationService .StorageLocation location , final LoginCallback prompt ) throws ConnectionCanceledException {
7779 this (hub , vaultId , bucket ,
7880 UvfMetadataPayload .create ()
7981 .withStorage (new VaultMetadataJWEBackendDto ()
@@ -83,25 +85,25 @@ public HubUVFVault(final HubSession hub, final UUID vaultId, final Path bucket,
8385 .nickname (null != bucket .attributes ().getDisplayname () ? bucket .attributes ().getDisplayname () : "Vault" ))
8486 .withAutomaticAccessGrant (new VaultMetadataJWEAutomaticAccessGrantDto ()
8587 .enabled (true )
86- .maxWotDepth (null )));
88+ .maxWotDepth (null )), prompt );
8789 }
8890
8991 /**
9092 * Open from existing metadata
9193 *
9294 * @param vaultId Vault ID Used to lookup profile
9395 */
94- public HubUVFVault (final HubSession hub , final UUID vaultId , final UvfMetadataPayload vaultMetadata ) throws ConnectionCanceledException {
96+ public HubUVFVault (final HubSession hub , final UUID vaultId , final UvfMetadataPayload vaultMetadata , final LoginCallback prompt ) throws ConnectionCanceledException {
9597 this (hub , vaultId , new Path (vaultMetadata .storage ().getDefaultPath (), EnumSet .of (Path .Type .directory , Path .Type .volume ),
96- new PathAttributes ().setDisplayname (vaultMetadata .storage ().getNickname ())), vaultMetadata );
98+ new PathAttributes ().setDisplayname (vaultMetadata .storage ().getNickname ())), vaultMetadata , prompt );
9799 }
98100
99- public HubUVFVault (final HubSession hub , final UUID vaultId , final Path bucket , final UvfMetadataPayload vaultMetadata ) throws ConnectionCanceledException {
101+ public HubUVFVault (final HubSession hub , final UUID vaultId , final Path bucket , final UvfMetadataPayload vaultMetadata , final LoginCallback prompt ) throws ConnectionCanceledException {
100102 super (bucket );
101103 this .vaultId = vaultId ;
102104 this .vaultMetadata = vaultMetadata ;
103105 this .home = bucket ;
104-
106+ this . prompt = prompt ;
105107 final VaultMetadataJWEBackendDto vaultStorageMetadata = vaultMetadata .storage ();
106108 final Protocol profile = ProtocolFactory .get ().forName (vaultStorageMetadata .getProvider ());
107109 log .debug ("Loaded profile {} for UVF metadata {}" , profile , vaultMetadata );
@@ -130,13 +132,13 @@ public Session<?> getStorage() {
130132 }
131133
132134 @ Override
133- public <T > T getFeature (final Session <?> hub , final Class <T > type , final T delegate ) {
135+ public <T > T getFeature (final Session <?> hub , final Class <T > type , final T delegate ) throws UnsupportedException {
134136 log .debug ("Delegate to {} for feature {}" , storage , type );
135137 // Ignore feature implementation but delegate to storage backend
136138 final T feature = storage ._getFeature (type );
137139 if (null == feature ) {
138140 log .warn ("No feature {} available for {}" , type , storage );
139- return null ;
141+ throw new UnsupportedException () ;
140142 }
141143 return super .getFeature (storage , type , feature );
142144 }
@@ -193,7 +195,7 @@ public Path create(final Session<?> session, final String region, final VaultCre
193195 new ProxyPreferencesReader (storage .getHost ()).getProperty (S3AssumeRoleProtocol .S3_ASSUMEROLE_ROLEARN_CREATE_BUCKET ));
194196 // No role chaining when creating vault
195197 configuration .setProperty (S3AssumeRoleProtocol .S3_ASSUMEROLE_ROLEARN_TAG , null );
196- storage .open (ProxyFactory .get (), new DisabledHostKeyCallback (), new DisabledLoginCallback () , new DisabledCancelCallback ());
198+ storage .open (ProxyFactory .get (), new DisabledHostKeyCallback (), prompt , new DisabledCancelCallback ());
197199 final Path vault ;
198200 if (false ) {
199201 log .debug ("Upload vault template to {}" , storage );
@@ -243,7 +245,7 @@ public HubUVFVault load(final Session<?> session, final PasswordCallback prompt)
243245 try {
244246 log .debug ("Connect to {}" , storage );
245247 try {
246- storage .open (ProxyFactory .get (), new DisabledHostKeyCallback (), new DisabledLoginCallback () , new DisabledCancelCallback ());
248+ storage .open (ProxyFactory .get (), new DisabledHostKeyCallback (), this . prompt , new DisabledCancelCallback ());
247249 }
248250 catch (BackgroundException e ) {
249251 log .warn ("Skip loading vault with failure {} connecting to storage" , e .toString ());
0 commit comments