Skip to content

Commit fbd3fc7

Browse files
committed
feedback review
1 parent 7f43e71 commit fbd3fc7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

core/src/main/java/cloud/stackit/sdk/core/KeyFlowAuthenticator.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@
2424
import java.util.concurrent.TimeUnit;
2525
import okhttp3.*;
2626

27+
2728
/** KeyFlowAuthenticator handles the Key Flow Authentication based on the Service Account Key. */
2829
public class KeyFlowAuthenticator {
2930
private final String REFRESH_TOKEN = "refresh_token";
3031
private final String ASSERTION = "assertion";
3132
private final String DEFAULT_TOKEN_ENDPOINT = "https://service-account.api.stackit.cloud/token";
3233
private final long DEFAULT_TOKEN_LEEWAY = 60;
34+
private final int CONNECT_TIMEOUT = 10;
35+
private final int WRITE_TIMEOUT = 10;
36+
private final int READ_TIMEOUT = 10;
3337

3438
private final OkHttpClient httpClient;
3539
private final ServiceAccountKey saKey;
@@ -94,9 +98,9 @@ public KeyFlowAuthenticator(
9498
this.gson = new Gson();
9599
this.httpClient =
96100
new OkHttpClient.Builder()
97-
.connectTimeout(10, TimeUnit.SECONDS)
98-
.writeTimeout(10, TimeUnit.SECONDS)
99-
.readTimeout(30, TimeUnit.SECONDS)
101+
.connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
102+
.writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS)
103+
.readTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
100104
.build();
101105

102106
if (environmentVariables == null) {

core/src/main/java/cloud/stackit/sdk/core/auth/SetupAuth.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,17 @@ protected void loadPrivateKey(CoreConfiguration cfg, ServiceAccountKey saKey)
212212
private String getPrivateKey(CoreConfiguration cfg)
213213
throws CredentialsInFileNotFoundException, IOException {
214214
// Explicit code config
215-
// Set private key
215+
// Get private key
216216
if (Utils.isStringSet(cfg.getPrivateKey())) {
217217
return cfg.getPrivateKey();
218218
}
219-
// Set private key path
219+
// Get private key path
220220
if (Utils.isStringSet(cfg.getPrivateKeyPath())) {
221221
String privateKeyPath = cfg.getPrivateKeyPath();
222222
return new String(
223223
Files.readAllBytes(Paths.get(privateKeyPath)), StandardCharsets.UTF_8);
224224
}
225-
// Set credentials file
225+
// Get credentials file
226226
if (Utils.isStringSet(cfg.getCredentialsFilePath())) {
227227
return readValueFromCredentialsFile(
228228
cfg.getCredentialsFilePath(),
@@ -231,15 +231,18 @@ private String getPrivateKey(CoreConfiguration cfg)
231231
}
232232

233233
// ENVs config
234+
// Get private key
234235
if (Utils.isStringSet(env.getStackitPrivateKey())) {
235236
return env.getStackitPrivateKey().trim();
236237
}
238+
// Get private key path
237239
if (Utils.isStringSet(env.getStackitPrivateKeyPath())) {
238240
return new String(
239241
Files.readAllBytes(Paths.get(env.getStackitPrivateKeyPath())),
240242
StandardCharsets.UTF_8);
241243
}
242244

245+
// Get credentialsFilePath
243246
String credentialsFilePath =
244247
Utils.isStringSet(env.getStackitCredentialsPath())
245248
? env.getStackitCredentialsPath()

0 commit comments

Comments
 (0)