@@ -89,8 +89,11 @@ public class HubSession extends HttpSession<HubApiClient> {
8989
9090 private UserDto me ;
9191 private ConfigDto config ;
92- private UserKeys userKeys ;
93- private AttributedList <Path > vaults ;
92+
93+ private final ExpiringObjectHolder <UserKeys > userKeys
94+ = new ExpiringObjectHolder <>(preferences .getLong ("katta.userkeys.ttl" ));
95+
96+ private HubVaultListService vaults ;
9497
9598 public HubSession (final Host host , final X509TrustManager trust , final X509KeyManager key ) {
9699 super (host , trust , key );
@@ -166,7 +169,7 @@ public void login(final LoginCallback prompt, final CancelCallback cancel) throw
166169 // Ensure device key is available
167170 final DeviceSetupCallback setup = prompt .getFeature (DeviceSetupCallback .class );
168171 log .debug ("Configured with setup prompt {}" , setup );
169- userKeys = this .pair (setup );
172+ userKeys . set ( this .pair (setup ) );
170173 final List <StorageProfileDto > storageProfileDtos = new StorageProfileResourceApi (client ).apiStorageprofileGet (false );
171174 for (StorageProfileDto storageProfileDto : storageProfileDtos ) {
172175 final StorageProfileDtoWrapper storageProfile = StorageProfileDtoWrapper .coerce (storageProfileDto );
@@ -184,8 +187,7 @@ public void login(final LoginCallback prompt, final CancelCallback cancel) throw
184187 throw new InteroperabilityException (String .format ("Unsupported storage configuration %s" , storageProfile .getProtocol ().name ()));
185188 }
186189 }
187- // Ensure vaults are registered
188- vaults = new HubVaultListService (this , prompt ).list (Home .root (), new DisabledListProgressListener ());
190+ vaults = new HubVaultListService (this , prompt );
189191 }
190192 catch (ApiException e ) {
191193 throw new HubExceptionMappingService ().map (e );
@@ -230,18 +232,18 @@ public UserDto getMe() {
230232 *
231233 * @return Destroyed keys after login
232234 */
233- public UserKeys getUserKeys () {
234- return userKeys ;
235+ public UserKeys getUserKeys (final DeviceSetupCallback setup ) throws BackgroundException {
236+ if (userKeys .get () == null ) {
237+ userKeys .set (this .pair (setup ));
238+ }
239+ return userKeys .get ();
235240 }
236241
237242 @ Override
238243 @ SuppressWarnings ("unchecked" )
239244 public <T > T _getFeature (final Class <T > type ) {
240245 if (type == ListService .class ) {
241- return (T ) (ListService ) (Path directory , ListProgressListener listener ) -> {
242- listener .chunk (directory , vaults );
243- return vaults ;
244- };
246+ return (T ) vaults ;
245247 }
246248 if (type == Scheduler .class ) {
247249 return (T ) access ;
0 commit comments