Skip to content

Commit bdb09a3

Browse files
committed
Rename.
1 parent 1afdb7e commit bdb09a3

File tree

10 files changed

+40
-41
lines changed

10 files changed

+40
-41
lines changed

hub/src/main/java/ch/iterate/hub/core/FirstLoginDeviceSetupCallback.java renamed to hub/src/main/java/ch/iterate/hub/core/DeviceSetupCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import ch.iterate.hub.model.AccountKeyAndDeviceName;
1313
import ch.iterate.hub.workflows.exceptions.AccessException;
1414

15-
public interface FirstLoginDeviceSetupCallback {
15+
public interface DeviceSetupCallback {
1616

1717
/**
1818
* Prompt user for device name
@@ -48,7 +48,7 @@ default UserKeys generateUserKeys() {
4848
return UserKeys.create();
4949
}
5050

51-
FirstLoginDeviceSetupCallback disabled = new FirstLoginDeviceSetupCallback() {
51+
DeviceSetupCallback disabled = new DeviceSetupCallback() {
5252
@Override
5353
public String displayAccountKeyAndAskDeviceName(final Host bookmark, final AccountKeyAndDeviceName accountKeyAndDeviceName) throws AccessException {
5454
throw new AccessException("Disabled");
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
import java.lang.reflect.Constructor;
1414
import java.lang.reflect.InvocationTargetException;
1515

16-
public class FirstLoginDeviceSetupCallbackFactory extends Factory<FirstLoginDeviceSetupCallback> {
17-
private static final Logger log = LogManager.getLogger(FirstLoginDeviceSetupCallbackFactory.class);
16+
public final class DeviceSetupCallbackFactory extends Factory<DeviceSetupCallback> {
17+
private static final Logger log = LogManager.getLogger(DeviceSetupCallbackFactory.class);
1818

19-
private FirstLoginDeviceSetupCallbackFactory() {
20-
super("factory.firstlogindevicesetupcallback.class");
19+
private DeviceSetupCallbackFactory() {
20+
super("factory.devicesetupcallback.class");
2121
}
2222

23-
public FirstLoginDeviceSetupCallback create() {
23+
public DeviceSetupCallback create() {
2424
try {
25-
final Constructor<? extends FirstLoginDeviceSetupCallback> constructor
25+
final Constructor<? extends DeviceSetupCallback> constructor
2626
= ConstructorUtils.getMatchingAccessibleConstructor(clazz);
2727
if(null == constructor) {
2828
log.warn("No default controller in {}", constructor.getClass());
@@ -33,18 +33,18 @@ public FirstLoginDeviceSetupCallback create() {
3333
}
3434
catch(InstantiationException | InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
3535
log.error("Failure loading callback class {}. {}", clazz, e.getMessage());
36-
return FirstLoginDeviceSetupCallback.disabled;
36+
return DeviceSetupCallback.disabled;
3737
}
3838
}
3939

40-
private static FirstLoginDeviceSetupCallbackFactory singleton;
40+
private static DeviceSetupCallbackFactory singleton;
4141

4242
/**
4343
* @return Firs tLogin Device Setup Callback instance for the current platform.
4444
*/
45-
public static synchronized FirstLoginDeviceSetupCallback get() {
45+
public static synchronized DeviceSetupCallback get() {
4646
if(null == singleton) {
47-
singleton = new FirstLoginDeviceSetupCallbackFactory();
47+
singleton = new DeviceSetupCallbackFactory();
4848
}
4949
return singleton.create();
5050
}

hub/src/main/java/ch/iterate/hub/protocols/hub/HubSession.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import ch.cyberduck.core.oauth.OAuth2RequestInterceptor;
2828
import ch.cyberduck.core.preferences.HostPreferences;
2929
import ch.cyberduck.core.proxy.ProxyFinder;
30-
import ch.cyberduck.core.shared.DelegatingSchedulerFeature;
3130
import ch.cyberduck.core.ssl.X509KeyManager;
3231
import ch.cyberduck.core.ssl.X509TrustManager;
3332
import ch.cyberduck.core.threading.CancelCallback;
@@ -45,8 +44,8 @@
4544
import ch.iterate.hub.client.api.UsersResourceApi;
4645
import ch.iterate.hub.client.model.ConfigDto;
4746
import ch.iterate.hub.client.model.UserDto;
48-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
49-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallbackFactory;
47+
import ch.iterate.hub.core.DeviceSetupCallback;
48+
import ch.iterate.hub.core.DeviceSetupCallbackFactory;
5049
import ch.iterate.hub.protocols.hub.exceptions.HubExceptionMappingService;
5150
import ch.iterate.hub.protocols.hub.serializer.HubConfigDtoDeserializer;
5251
import ch.iterate.hub.workflows.DeviceKeysServiceImpl;
@@ -136,7 +135,7 @@ protected HubApiClient connect(final ProxyFinder proxy, final HostKeyCallback ke
136135

137136
@Override
138137
public void login(final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
139-
final FirstLoginDeviceSetupCallback setup = FirstLoginDeviceSetupCallbackFactory.get();
138+
final DeviceSetupCallback setup = DeviceSetupCallbackFactory.get();
140139
final Credentials credentials = authorizationService.validate();
141140
try {
142141
// Set username from OAuth ID Token for saving in keychain

hub/src/main/java/ch/iterate/hub/workflows/CachingUserKeysService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import ch.iterate.hub.client.ApiException;
1010
import ch.iterate.hub.client.model.UserDto;
11-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
11+
import ch.iterate.hub.core.DeviceSetupCallback;
1212
import ch.iterate.hub.crypto.DeviceKeys;
1313
import ch.iterate.hub.crypto.UserKeys;
1414
import ch.iterate.hub.workflows.exceptions.AccessException;
@@ -38,7 +38,7 @@ public UserKeys getUserKeys(final Host hub, final UserDto me, final DeviceKeys d
3838
}
3939

4040
@Override
41-
public UserKeys getOrCreateUserKeys(final Host hub, final UserDto me, final DeviceKeys deviceKeyPair, final FirstLoginDeviceSetupCallback prompt) throws ApiException, AccessException, SecurityFailure {
41+
public UserKeys getOrCreateUserKeys(final Host hub, final UserDto me, final DeviceKeys deviceKeyPair, final DeviceSetupCallback prompt) throws ApiException, AccessException, SecurityFailure {
4242
if(userKeys == null) {
4343
userKeys = proxy.getOrCreateUserKeys(hub, me, deviceKeyPair, prompt);
4444
}

hub/src/main/java/ch/iterate/hub/workflows/DeviceKeysService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import ch.cyberduck.core.Host;
88

9-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
9+
import ch.iterate.hub.core.DeviceSetupCallback;
1010
import ch.iterate.hub.crypto.DeviceKeys;
1111
import ch.iterate.hub.workflows.exceptions.AccessException;
1212

@@ -20,7 +20,7 @@ public interface DeviceKeysService {
2020
* @throws AccessException Failure accessing storage or not found
2121
* @throws SecurityException Failure decoding device keys retrieved from storage
2222
*/
23-
DeviceKeys getOrCreateDeviceKeys(Host hub, FirstLoginDeviceSetupCallback setup) throws AccessException;
23+
DeviceKeys getOrCreateDeviceKeys(Host hub, DeviceSetupCallback setup) throws AccessException;
2424

2525
/**
2626
* Retrieve saved device keys

hub/src/main/java/ch/iterate/hub/workflows/DeviceKeysServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import static ch.iterate.hub.crypto.KeyHelper.decodeKeyPair;
2020

21-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
21+
import ch.iterate.hub.core.DeviceSetupCallback;
2222
import ch.iterate.hub.crypto.DeviceKeys;
2323
import ch.iterate.hub.workflows.exceptions.AccessException;
2424

@@ -45,7 +45,7 @@ private static String toAccountName(final Host hub) {
4545
}
4646

4747
@Override
48-
public DeviceKeys getOrCreateDeviceKeys(final Host hub, final FirstLoginDeviceSetupCallback setup) throws AccessException {
48+
public DeviceKeys getOrCreateDeviceKeys(final Host hub, final DeviceSetupCallback setup) throws AccessException {
4949
final DeviceKeys deviceKeys = this.getDeviceKeys(hub);
5050
if(DeviceKeys.validate(deviceKeys)) {
5151
return deviceKeys;

hub/src/main/java/ch/iterate/hub/workflows/UserKeysService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import ch.iterate.hub.client.ApiException;
1010
import ch.iterate.hub.client.model.UserDto;
11-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
11+
import ch.iterate.hub.core.DeviceSetupCallback;
1212
import ch.iterate.hub.crypto.DeviceKeys;
1313
import ch.iterate.hub.crypto.UserKeys;
1414
import ch.iterate.hub.workflows.exceptions.AccessException;
@@ -32,5 +32,5 @@ public interface UserKeysService {
3232
* @throws SecurityFailure Failure decoding keys
3333
* @throws AccessException Failure accessing or saving device keys
3434
*/
35-
UserKeys getOrCreateUserKeys(Host hub, UserDto me, DeviceKeys deviceKeyPair, FirstLoginDeviceSetupCallback prompt) throws ApiException, AccessException, SecurityFailure;
35+
UserKeys getOrCreateUserKeys(Host hub, UserDto me, DeviceKeys deviceKeyPair, DeviceSetupCallback prompt) throws ApiException, AccessException, SecurityFailure;
3636
}

hub/src/main/java/ch/iterate/hub/workflows/UserKeysServiceImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
import java.text.ParseException;
1515
import java.util.Base64;
1616

17+
import static ch.iterate.hub.crypto.KeyHelper.getDeviceIdFromDeviceKeyPair;
18+
import static ch.iterate.hub.workflows.DeviceKeysServiceImpl.COMPUTER_NAME;
19+
1720
import ch.iterate.hub.client.ApiException;
1821
import ch.iterate.hub.client.api.DeviceResourceApi;
1922
import ch.iterate.hub.client.api.UsersResourceApi;
2023
import ch.iterate.hub.client.model.DeviceDto;
2124
import ch.iterate.hub.client.model.Type1;
2225
import ch.iterate.hub.client.model.UserDto;
23-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
26+
import ch.iterate.hub.core.DeviceSetupCallback;
2427
import ch.iterate.hub.crypto.DeviceKeys;
2528
import ch.iterate.hub.crypto.UserKeys;
2629
import ch.iterate.hub.model.AccountKeyAndDeviceName;
@@ -31,9 +34,6 @@
3134
import com.fasterxml.jackson.core.JsonProcessingException;
3235
import com.nimbusds.jose.JOSEException;
3336

34-
import static ch.iterate.hub.crypto.KeyHelper.getDeviceIdFromDeviceKeyPair;
35-
import static ch.iterate.hub.workflows.DeviceKeysServiceImpl.COMPUTER_NAME;
36-
3737
public class UserKeysServiceImpl implements UserKeysService {
3838
private static final Logger log = LogManager.getLogger(UserKeysServiceImpl.class.getName());
3939

@@ -67,7 +67,7 @@ public UserKeys getUserKeys(final Host hub, final UserDto me, final DeviceKeys d
6767
}
6868

6969
@Override
70-
public UserKeys getOrCreateUserKeys(final Host hub, final UserDto me, final DeviceKeys deviceKeyPair, final FirstLoginDeviceSetupCallback prompt) throws ApiException, AccessException, SecurityFailure {
70+
public UserKeys getOrCreateUserKeys(final Host hub, final UserDto me, final DeviceKeys deviceKeyPair, final DeviceSetupCallback prompt) throws ApiException, AccessException, SecurityFailure {
7171
if(UserKeys.validate(me)) {
7272
try {
7373
return this.getUserKeys(hub, me, deviceKeyPair);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
import ch.cyberduck.core.Host;
88

9-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
9+
import ch.iterate.hub.core.DeviceSetupCallback;
1010
import ch.iterate.hub.model.AccountKeyAndDeviceName;
1111
import ch.iterate.hub.workflows.exceptions.AccessException;
1212

13-
public class MockableFirstLoginDeviceSetupCallback implements FirstLoginDeviceSetupCallback {
14-
public static void setProxy(final FirstLoginDeviceSetupCallback proxy) {
15-
MockableFirstLoginDeviceSetupCallback.proxy = proxy;
13+
public class MockableDeviceSetupCallback implements DeviceSetupCallback {
14+
public static void setProxy(final DeviceSetupCallback proxy) {
15+
MockableDeviceSetupCallback.proxy = proxy;
1616
}
1717

18-
private static FirstLoginDeviceSetupCallback proxy = null;
18+
private static DeviceSetupCallback proxy = null;
1919

2020
@Override
2121
public String displayAccountKeyAndAskDeviceName(final Host bookmark, final AccountKeyAndDeviceName accountKeyAndDeviceName) throws AccessException {

hub/src/test/java/ch/iterate/hub/testsetup/AbstractHubTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
import java.time.format.FormatStyle;
4040
import java.util.function.Function;
4141

42-
import ch.iterate.hub.core.FirstLoginDeviceSetupCallback;
43-
import ch.iterate.hub.core.util.MockableFirstLoginDeviceSetupCallback;
42+
import static org.junit.jupiter.api.Assertions.assertNotNull;
43+
44+
import ch.iterate.hub.core.DeviceSetupCallback;
45+
import ch.iterate.hub.core.util.MockableDeviceSetupCallback;
4446
import ch.iterate.hub.model.AccountKeyAndDeviceName;
4547
import ch.iterate.hub.protocols.hub.HubCryptoVault;
4648
import ch.iterate.hub.protocols.hub.HubProtocol;
4749
import ch.iterate.hub.protocols.hub.HubSession;
4850
import ch.iterate.hub.protocols.s3.S3AutoLoadVaultProtocol;
4951

50-
import static org.junit.jupiter.api.Assertions.assertNotNull;
51-
5252
@HubIntegrationTest
5353
public abstract class AbstractHubTest extends VaultTest {
5454

@@ -149,7 +149,7 @@ protected void configureLogging(final String level) {
149149
preferences.setProperty("factory.vault.class", HubCryptoVault.class.getName());
150150
preferences.setProperty("factory.supportdirectoryfinder.class", ch.cyberduck.core.preferences.TemporarySupportDirectoryFinder.class.getName());
151151
preferences.setProperty("factory.passwordstore.class", UnsecureHostPasswordStore.class.getName());
152-
preferences.setProperty("factory.firstlogindevicesetupcallback.class", MockableFirstLoginDeviceSetupCallback.class.getName());
152+
preferences.setProperty("factory.devicesetupcallback.class", MockableDeviceSetupCallback.class.getName());
153153

154154
preferences.setProperty("oauth.handler.scheme", "katta");
155155
preferences.setProperty("hub.protocol.scheduler.period", 30);
@@ -177,7 +177,7 @@ protected static HubSession setupConnection(final HubTestConfig.Setup setup) thr
177177
assertNotNull(ProtocolFactory.get().forName("s3"));
178178
assertNotNull(ProtocolFactory.get().forName("katta-s3"));
179179

180-
final FirstLoginDeviceSetupCallback proxy = new FirstLoginDeviceSetupCallback() {
180+
final DeviceSetupCallback proxy = new DeviceSetupCallback() {
181181
@Override
182182
public String displayAccountKeyAndAskDeviceName(final Host bookmark, final AccountKeyAndDeviceName accountKeyAndDeviceName) {
183183
return "firstLoginMockSetup";
@@ -194,7 +194,7 @@ public String generateAccountKey() {
194194
return staticSetupCode();
195195
}
196196
};
197-
MockableFirstLoginDeviceSetupCallback.setProxy(proxy);
197+
MockableDeviceSetupCallback.setProxy(proxy);
198198

199199
final Host hub = new HostParser(factory).get(setup.hubURL).withCredentials(new Credentials(setup.userConfig.username, setup.userConfig.password));
200200
final HubSession session = (HubSession) SessionFactory.create(hub, new DefaultX509TrustManager(), new DefaultX509KeyManager());

0 commit comments

Comments
 (0)