Skip to content

Commit ac70731

Browse files
committed
Fix #13.
1 parent cb60f2b commit ac70731

File tree

11 files changed

+47
-47
lines changed

11 files changed

+47
-47
lines changed

hub/src/main/java/ch/iterate/hub/core/FirstLoginDeviceSetupCallbackFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public FirstLoginDeviceSetupCallback create() {
2525
final Constructor<? extends FirstLoginDeviceSetupCallback> constructor
2626
= ConstructorUtils.getMatchingAccessibleConstructor(clazz);
2727
if(null == constructor) {
28-
log.warn(String.format("No default controller in %s", constructor.getClass()));
28+
log.warn("No default controller in {}", constructor.getClass());
2929
// Call default constructor for disabled implementations
3030
return clazz.getDeclaredConstructor().newInstance();
3131
}
3232
return constructor.newInstance();
3333
}
3434
catch(InstantiationException | InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
35-
log.error(String.format("Failure loading callback class %s. %s", clazz, e.getMessage()));
35+
log.error("Failure loading callback class {}. {}", clazz, e.getMessage());
3636
return FirstLoginDeviceSetupCallback.disabled;
3737
}
3838
}

hub/src/main/java/ch/iterate/hub/crypto/JWE.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static String pbes2Encrypt(final JWEPayload payload, final String kid, fi
101101
*/
102102
public static String pbes2Encrypt(final JWEPayload payload, final String kid, final String password, final String apu, final String apv) throws JsonProcessingException, JOSEException {
103103
final JWEEncrypter jweEncrypter = new PasswordBasedEncrypter(password, PBES2_SALT_LENGTH, PBES2_ITERATION_COUNT);
104-
JWEHeader header = new JWEHeader.Builder(PBES2_DESIGNATION_ALG, PBES2_DESIGNATION_ENC)
104+
final JWEHeader header = new JWEHeader.Builder(PBES2_DESIGNATION_ALG, PBES2_DESIGNATION_ENC)
105105
.keyID(kid)
106106
.agreementPartyUInfo(Base64URL.encode(apu))
107107
.agreementPartyVInfo(Base64URL.encode(apv))

hub/src/main/java/ch/iterate/hub/crypto/wot/WoT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static Map<TrustedUserDto, Integer> verifyTrusts(final List<TrustedUserDt
176176
}
177177
catch(SecurityFailure e) {
178178
if(log.isWarnEnabled()) {
179-
log.warn(String.format("Verification for %s failed - not granting access.", trust), e);
179+
log.warn("Verification for {} failed - not granting access.", trust, e);
180180
}
181181
}
182182
}

hub/src/main/java/ch/iterate/hub/model/StorageProfileDtoWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private StorageProfileDtoWrapper(final StorageProfileDto proxy) {
2222
this.proxy = proxy;
2323
}
2424

25-
public static StorageProfileDtoWrapper coerce(StorageProfileDto o) {
25+
public static StorageProfileDtoWrapper coerce(final StorageProfileDto o) {
2626
return new StorageProfileDtoWrapper(o);
2727
}
2828

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public HubCryptoVault(final Path home, final String masterkey, final String conf
6565
public synchronized Path create(final Session<?> session, final String region, final VaultCredentials credentials, final int version, final String metadata, final String rootDirHash) throws BackgroundException {
6666
final Path home = new Path(session.getHost().getDefaultPath(), EnumSet.of(AbstractPath.Type.directory));
6767
if(log.isDebugEnabled()) {
68-
log.debug(String.format("Uploading vault template %s in %s ", home, session.getHost()));
68+
log.debug("Uploading vault template {} in {} ", home, session.getHost());
6969
}
7070

7171
// N.B. there seems to be no API to check write permissions without actually writing.
@@ -85,7 +85,7 @@ public synchronized Path create(final Session<?> session, final String region, f
8585
final Path firstLevel = secondLevel.getParent();
8686
final Path dataDir = firstLevel.getParent();
8787
if(log.isDebugEnabled()) {
88-
log.debug(String.format("Create vault root directory at %s", secondLevel));
88+
log.debug("Create vault root directory at {}", secondLevel);
8989
}
9090
final TransferStatus status = (new TransferStatus()).withRegion(region);
9191

@@ -112,4 +112,4 @@ public Path getMasterkey() {
112112
// No master key in vault
113113
return null;
114114
}
115-
}
115+
}

hub/src/main/java/ch/iterate/hub/protocols/s3/STSChainedAssumeRoleRequestInterceptor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public void refresh() {
8686
}
8787
});
8888
if(log.isDebugEnabled()) {
89-
log.debug(String.format("Chained assume role for %s", bookmark));
89+
log.debug("Chained assume role for {}", bookmark);
9090
}
91-
log.debug(String.format("Assume role with temporary credentials %s", tokens));
91+
log.debug("Assume role with temporary credentials {}", tokens);
9292
final PreferencesReader preferences = new HostPreferences(bookmark);
9393
if(preferences.getInteger(S3AutoLoadVaultProtocol.S3_ASSUMEROLE_DURATIONSECONDS) != -1) {
9494
request.setDurationSeconds(preferences.getInteger(S3AutoLoadVaultProtocol.S3_ASSUMEROLE_DURATIONSECONDS));
@@ -103,7 +103,7 @@ public void refresh() {
103103
sub = JWT.decode(identityToken).getSubject();
104104
}
105105
catch(JWTDecodeException e) {
106-
log.warn(String.format("Failure %s decoding JWT %s", e, identityToken));
106+
log.warn("Failure {} decoding JWT {}", e, identityToken);
107107
throw new LoginFailureException("Invalid JWT or JSON format in authentication token", e);
108108
}
109109
if(StringUtils.isNotBlank(preferences.getProperty(S3AutoLoadVaultProtocol.S3_ASSUMEROLE_ROLESESSIONNAME))) {
@@ -114,7 +114,7 @@ public void refresh() {
114114
request.setRoleSessionName(sub);
115115
}
116116
else {
117-
log.warn(String.format("Missing subject in decoding JWT %s", identityToken));
117+
log.warn("Missing subject in decoding JWT {}", identityToken);
118118
request.setRoleSessionName(new AsciiRandomStringService().random());
119119
}
120120
}
@@ -125,11 +125,11 @@ public void refresh() {
125125
}
126126
try {
127127
if(log.isDebugEnabled()) {
128-
log.debug(String.format("Use request %s", request));
128+
log.debug("Use request {}", request);
129129
}
130130
final AssumeRoleResult result = service.assumeRole(request);
131131
if(log.isDebugEnabled()) {
132-
log.debug(String.format("Received assume role result %s for host %s", result, bookmark));
132+
log.debug("Received assume role result {} for host {}", result, bookmark);
133133
}
134134
return new TemporaryAccessTokens(result.getCredentials().getAccessKeyId(),
135135
result.getCredentials().getSecretAccessKey(),

hub/src/main/java/ch/iterate/hub/protocols/s3/TokenExchangeRequestInterceptor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class TokenExchangeRequestInterceptor extends OAuth2RequestInterceptor {
4848
private final Host bookmark;
4949
private final HttpClient client;
5050

51-
public TokenExchangeRequestInterceptor(final HttpClient client, final Host bookmark, LoginCallback prompt) throws LoginCanceledException {
51+
public TokenExchangeRequestInterceptor(final HttpClient client, final Host bookmark, final LoginCallback prompt) throws LoginCanceledException {
5252
super(client, bookmark, prompt);
5353
this.bookmark = bookmark;
5454
this.client = client;
@@ -60,7 +60,7 @@ public OAuthTokens authorize() throws BackgroundException {
6060
}
6161

6262
@Override
63-
public OAuthTokens refresh(OAuthTokens previous) throws BackgroundException {
63+
public OAuthTokens refresh(final OAuthTokens previous) throws BackgroundException {
6464
return this.exchange(super.refresh(previous));
6565
}
6666

@@ -74,7 +74,7 @@ public OAuthTokens refresh(OAuthTokens previous) throws BackgroundException {
7474
* @see S3AutoLoadVaultProtocol#OAUTH_TOKENEXCHANGE_ADDITIONAL_SCOPES
7575
*/
7676
public OAuthTokens exchange(final OAuthTokens previous) throws BackgroundException {
77-
log.info(String.format("Exchange tokens %s for %s", previous, bookmark));
77+
log.info("Exchange tokens {} for {}", previous, bookmark);
7878
final TokenRequest request = new TokenRequest(
7979
new ApacheHttpTransport(client),
8080
new GsonFactory(),
@@ -93,7 +93,7 @@ public OAuthTokens exchange(final OAuthTokens previous) throws BackgroundExcepti
9393
}
9494
request.setScopes(scopes);
9595
if(log.isDebugEnabled()) {
96-
log.debug(String.format("Token exchange request %s for %s", request, bookmark));
96+
log.debug("Token exchange request {} for {}", request, bookmark);
9797
}
9898
try {
9999
final TokenResponse tokenExchangeResponse = request.execute();
@@ -102,7 +102,7 @@ public OAuthTokens exchange(final OAuthTokens previous) throws BackgroundExcepti
102102
tokenExchangeResponse.getRefreshToken(),
103103
System.currentTimeMillis() + tokenExchangeResponse.getExpiresInSeconds() * 1000);
104104
if(log.isDebugEnabled()) {
105-
log.debug(String.format("Received exchanged token %s for %s", tokens, bookmark));
105+
log.debug("Received exchanged token {} for {}", tokens, bookmark);
106106
}
107107
return tokens;
108108
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void createVault(final StorageProfileDtoWrapper storageProfileWrapper, fi
8686
.maxWotDepth(vaultModel.maxWotLevel())
8787
);
8888
if(log.isDebugEnabled()) {
89-
log.debug(String.format("Created metadata JWE %s", metadataJWE));
89+
log.debug("Created metadata JWE {}", metadataJWE);
9090
}
9191
final String uvfMetadataFile = metadataJWE.encrypt(
9292
String.format("%s/api", new HostUrlProvider(false, true).get(hubSession.getHost())),
@@ -110,7 +110,7 @@ public void createVault(final StorageProfileDtoWrapper storageProfileWrapper, fi
110110
.rootDirHash(metadataJWE.computeRootDirIdHash(metadataJWE.computeRootDirId()))
111111
.region(metadataJWE.storage().getRegion());
112112
if(log.isDebugEnabled()) {
113-
log.debug(String.format("Created storage dto %s", storageDto));
113+
log.debug("Created storage dto {}", storageDto);
114114
}
115115
final Host bookmark = HubStorageVaultSyncSchedulerService.toBookmark(hubSession.getHost(), vaultDto.getId(), metadataJWE.storage());
116116
if(storageProfileWrapper.getStsEndpoint() == null) {
@@ -135,7 +135,7 @@ public void createVault(final StorageProfileDtoWrapper storageProfileWrapper, fi
135135
storageProfileWrapper.getBucketAcceleration()
136136
);
137137
if(log.isDebugEnabled()) {
138-
log.debug(String.format("Create STS bucket %s for vault %s", storageDto, vaultDto));
138+
log.debug("Create STS bucket {} for vault {}", storageDto, vaultDto);
139139
}
140140
new StorageResourceApi(hubSession.getClient()).apiStorageVaultIdPut(vaultDto.getId(),
141141
storageDto.awsAccessKey(stsTokens.getAccessKeyId())
@@ -144,13 +144,13 @@ public void createVault(final StorageProfileDtoWrapper storageProfileWrapper, fi
144144
}
145145
// create vault in hub
146146
if(log.isDebugEnabled()) {
147-
log.debug(String.format("Create vault %s", vaultDto));
147+
log.debug("Create vault {}", vaultDto);
148148
}
149149
new VaultResourceApi(hubSession.getClient()).apiVaultsVaultIdPut(vaultDto.getId(), vaultDto);
150150

151151
// upload JWE
152152
if(log.isDebugEnabled()) {
153-
log.debug(String.format("Upload JWE %s for vault %s", uvfMetadataFile, vaultDto));
153+
log.debug("Upload JWE {} for vault {}", uvfMetadataFile, vaultDto);
154154
}
155155
final UserDto userDto = new UsersResourceApi(hubSession.getClient()).apiUsersMeGet(false);
156156
new VaultResourceApi(hubSession.getClient()).apiVaultsVaultIdAccessTokensPost(vaultDto.getId(), Collections.singletonMap(userDto.getId(), jwks.toOwnerAccessToken().encryptForUser(userKeys.ecdhKeyPair().getPublic())));
@@ -165,7 +165,7 @@ public void createVault(final StorageProfileDtoWrapper storageProfileWrapper, fi
165165

166166
private static TemporaryAccessTokens getSTSTokensFromAccessTokenWithCreateBucketInlinePoliy(final String token, final String roleArn, final String roleSessionName, final String stsEndpoint, final String bucketName, final Boolean bucketAcceleration) throws IOException {
167167
if(log.isDebugEnabled()) {
168-
log.debug(String.format("Get STS tokens from %s to pass to backend %s with role %s and session name %s", token, stsEndpoint, roleArn, roleSessionName));
168+
log.debug("Get STS tokens from {} to pass to backend {} with role {} and session name {}", token, stsEndpoint, roleArn, roleSessionName);
169169
}
170170

171171
final AssumeRoleWithWebIdentityRequest request = new AssumeRoleWithWebIdentityRequest();
@@ -192,11 +192,11 @@ private static TemporaryAccessTokens getSTSTokensFromAccessTokenWithCreateBucket
192192

193193

194194
if(log.isDebugEnabled()) {
195-
log.debug(String.format("Use request %s", request));
195+
log.debug("Use request {}", request);
196196
}
197197
final AssumeRoleWithWebIdentityResult result = service.assumeRoleWithWebIdentity(request);
198198
if(log.isDebugEnabled()) {
199-
log.debug(String.format("Received assume role identity result %s", result));
199+
log.debug("Received assume role identity result {}", result);
200200
}
201201
return new TemporaryAccessTokens(result.getCredentials().getAccessKeyId(),
202202
result.getCredentials().getSecretAccessKey(),

hub/src/test/java/ch/iterate/hub/core/AbstractHubSynchronizeTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public abstract class AbstractHubSynchronizeTest extends AbstractHubTest {
7070
@ParameterizedTest
7171
@MethodIgnorableSource(value = "arguments")
7272
public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Exception {
73-
log.info(String.format("M01 %s", hubTestConfig));
73+
log.info("M01 {}", hubTestConfig);
7474

7575
final HubSession hubSession = setupConnection(hubTestConfig.setup);
7676
try {
@@ -132,9 +132,9 @@ public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Except
132132
// trigger blocking sync
133133
new HubStorageProfileSyncSchedulerService(hubSession).operate(new DisabledLoginCallback());
134134

135-
log.info(String.format("%s Protocols found:", ProtocolFactory.get().find().size()));
135+
log.info("{} Protocols found:", ProtocolFactory.get().find().size());
136136
for(final Protocol protocol : ProtocolFactory.get().find()) {
137-
log.info(String.format("- %s", protocol));
137+
log.info("- {}", protocol);
138138
}
139139

140140
// aws static
@@ -147,7 +147,7 @@ public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Except
147147
assertNotNull(ProtocolFactory.get().forName("732D43FA-3716-46C4-B931-66EA5405EF1C".toLowerCase()));
148148
}
149149
catch(ApiException e) {
150-
log.error(String.format("%s %s", e.getCode(), e.getMessage()), e);
150+
log.error("{} {}", e.getCode(), e.getMessage(), e);
151151
throw e;
152152
}
153153
finally {
@@ -161,7 +161,7 @@ public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Except
161161
@ParameterizedTest
162162
@MethodIgnorableSource(value = "arguments")
163163
public void test02AddStorageProfile(final HubTestConfig hubTestConfig) throws Exception {
164-
log.info(String.format("M02 %s", hubTestConfig));
164+
log.info("M02 {}", hubTestConfig);
165165

166166
final HubSession hubSession = setupConnection(hubTestConfig.setup);
167167
try {
@@ -175,7 +175,7 @@ public void test02AddStorageProfile(final HubTestConfig hubTestConfig) throws Ex
175175
new HubStorageProfileSyncSchedulerService(hubSession).operate(new DisabledLoginCallback());
176176
final int numProtocols = ProtocolFactory.get().find().size();
177177

178-
log.info(String.format("Add storage profile for UUID %s", uuid));
178+
log.info("Add storage profile for UUID {}", uuid);
179179
Assertions.assertNull(ProtocolFactory.get().forName(uuid.toString().toLowerCase()));
180180

181181
final StorageProfileDto storageProfile = storageProfiles.get(0);
@@ -211,27 +211,27 @@ else if(storageProfile.getActualInstance() instanceof StorageProfileS3Dto) {
211211
@ParameterizedTest
212212
@MethodIgnorableSource(value = "arguments")
213213
public void test03AddVault(final HubTestConfig config) throws Exception {
214-
log.info(String.format("M03 %s", config));
214+
log.info("M03 {}", config);
215215

216216
final HubSession hubSession = setupConnection(config.setup);
217217
try {
218218
final ApiClient adminApiClient = getAdminApiClient(config.setup);
219219
final List<StorageProfileDto> storageProfiles = new StorageProfileResourceApi(adminApiClient).apiStorageprofileGet(false);
220-
log.info(String.format("Coercing storage profiles %s", storageProfiles));
220+
log.info("Coercing storage profiles {}", storageProfiles);
221221
final StorageProfileDtoWrapper storageProfileWrapper = storageProfiles.stream()
222222
.map(StorageProfileDtoWrapper::coerce)
223223
.filter(p -> p.getId().toString().equals(config.vault.storageProfileId.toLowerCase())).findFirst().get();
224224
assertNotNull(new HubStorageProfileListService(hubSession).list(Home.ROOT, new DisabledListProgressListener()).find(p -> StringUtils.equals(p.attributes().getFileId(),
225225
config.vault.storageProfileId.toLowerCase())));
226226

227-
log.info(String.format("Creating vault in %s", hubSession));
227+
log.info("Creating vault in {}", hubSession);
228228
final UUID vaultId = UUID.randomUUID();
229229
new CreateVaultService(hubSession).createVault(storageProfileWrapper, new CreateVaultService.CreateVaultModel(
230230
vaultId, "vault", null,
231231
config.vault.storageProfileId, config.vault.username, config.vault.password, config.vault.bucketName, config.vault.region, true, 3));
232-
log.info(String.format("Getting vault bookmark for vault %s", vaultId));
232+
log.info("Getting vault bookmark for vault {}", vaultId);
233233
final Host vaultBookmark = new HubStorageVaultSyncSchedulerService(hubSession).toBookmark(vaultId, FirstLoginDeviceSetupCallback.disabled);
234-
log.info(String.format("Using vault bookmark %s", vaultBookmark));
234+
log.info("Using vault bookmark {}", vaultBookmark);
235235

236236
final DefaultVaultRegistry vaultRegistry = new DefaultVaultRegistry(new DisabledPasswordCallback());
237237
final Session<?> session = new S3AutoLoadVaultSession(vaultBookmark, new DisabledX509TrustManager(), new DefaultX509KeyManager())

0 commit comments

Comments
 (0)