Skip to content

Commit 09c61e2

Browse files
committed
Additional Chnages:
- Address PR feedback Remaning sourceFeatureID to sourceChain
1 parent 278791f commit 09c61e2

20 files changed

+202
-186
lines changed

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/ChildProfileCredentialsProviderFactory.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* classpath.
2727
*/
2828
@SdkProtectedApi
29+
@FunctionalInterface
2930
public interface ChildProfileCredentialsProviderFactory {
3031
/**
3132
* Create a credentials provider for the provided profile, using the provided source credentials provider to authenticate
@@ -39,13 +40,7 @@ public interface ChildProfileCredentialsProviderFactory {
3940
* provider.
4041
* @return The credentials provider with permissions derived from the source credentials provider and profile.
4142
*/
42-
default AwsCredentialsProvider create(AwsCredentialsProvider sourceCredentialsProvider, Profile profile) {
43-
ChildProfileCredentialsRequest request = ChildProfileCredentialsRequest.builder()
44-
.sourceCredentialsProvider(sourceCredentialsProvider)
45-
.profile(profile)
46-
.build();
47-
return create(request);
48-
}
43+
AwsCredentialsProvider create(AwsCredentialsProvider sourceCredentialsProvider, Profile profile);
4944

5045
/**
5146
* Create a credentials provider for the provided profile, using the provided source credentials provider to authenticate
@@ -57,18 +52,18 @@ default AwsCredentialsProvider create(AwsCredentialsProvider sourceCredentialsPr
5752
* @return The credentials provider with permissions derived from the request parameters.
5853
*/
5954
default AwsCredentialsProvider create(ChildProfileCredentialsRequest request) {
60-
throw new UnsupportedOperationException();
55+
return create(request.sourceCredentialsProvider(), request.profile());
6156
}
6257

6358
final class ChildProfileCredentialsRequest {
6459
private final AwsCredentialsProvider sourceCredentialsProvider;
6560
private final Profile profile;
66-
private final String sourceFeatureId;
61+
private final String sourceChain;
6762

6863
private ChildProfileCredentialsRequest(Builder builder) {
6964
this.sourceCredentialsProvider = builder.sourceCredentialsProvider;
7065
this.profile = builder.profile;
71-
this.sourceFeatureId = builder.sourceFeatureId;
66+
this.sourceChain = builder.sourceChain;
7267
}
7368

7469
public static Builder builder() {
@@ -83,14 +78,14 @@ public Profile profile() {
8378
return profile;
8479
}
8580

86-
public String sourceFeatureId() {
87-
return sourceFeatureId;
81+
public String sourceChain() {
82+
return sourceChain;
8883
}
8984

9085
public static final class Builder {
9186
private AwsCredentialsProvider sourceCredentialsProvider;
9287
private Profile profile;
93-
private String sourceFeatureId;
88+
private String sourceChain;
9489

9590
public Builder sourceCredentialsProvider(AwsCredentialsProvider sourceCredentialsProvider) {
9691
this.sourceCredentialsProvider = sourceCredentialsProvider;
@@ -102,8 +97,8 @@ public Builder profile(Profile profile) {
10297
return this;
10398
}
10499

105-
public Builder sourceFeatureId(String sourceFeatureId) {
106-
this.sourceFeatureId = sourceFeatureId;
100+
public Builder sourceChain(String sourceChain) {
101+
this.sourceChain = sourceChain;
107102
return this;
108103
}
109104

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/ContainerCredentialsProvider.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public final class ContainerCredentialsProvider
9292
private final Boolean asyncCredentialUpdateEnabled;
9393

9494
private final String asyncThreadName;
95-
private final String sourceFeatureId;
95+
private final String sourceChain;
9696
private final String providerName;
9797

9898
/**
@@ -102,10 +102,10 @@ private ContainerCredentialsProvider(BuilderImpl builder) {
102102
this.endpoint = builder.endpoint;
103103
this.asyncCredentialUpdateEnabled = builder.asyncCredentialUpdateEnabled;
104104
this.asyncThreadName = builder.asyncThreadName;
105-
this.sourceFeatureId = builder.sourceFeatureId;
106-
this.providerName = StringUtils.isEmpty(builder.sourceFeatureId)
105+
this.sourceChain = builder.sourceChain;
106+
this.providerName = StringUtils.isEmpty(builder.sourceChain)
107107
? PROVIDER_NAME
108-
: builder.sourceFeatureId + "," + PROVIDER_NAME;
108+
: builder.sourceChain + "," + PROVIDER_NAME;
109109
this.httpCredentialsLoader = HttpCredentialsLoader.create(this.providerName);
110110

111111
if (Boolean.TRUE.equals(builder.asyncCredentialUpdateEnabled)) {
@@ -326,7 +326,7 @@ private static final class BuilderImpl implements Builder {
326326
private String endpoint;
327327
private Boolean asyncCredentialUpdateEnabled;
328328
private String asyncThreadName;
329-
private String sourceFeatureId;
329+
private String sourceChain;
330330

331331
private BuilderImpl() {
332332
asyncThreadName("container-credentials-provider");
@@ -336,7 +336,7 @@ private BuilderImpl(ContainerCredentialsProvider credentialsProvider) {
336336
this.endpoint = credentialsProvider.endpoint;
337337
this.asyncCredentialUpdateEnabled = credentialsProvider.asyncCredentialUpdateEnabled;
338338
this.asyncThreadName = credentialsProvider.asyncThreadName;
339-
this.sourceFeatureId = credentialsProvider.sourceFeatureId;
339+
this.sourceChain = credentialsProvider.sourceChain;
340340
}
341341

342342
@Override
@@ -369,14 +369,19 @@ public void setAsyncThreadName(String asyncThreadName) {
369369
asyncThreadName(asyncThreadName);
370370
}
371371

372+
/**
373+
* An optional string denoting previous credentials providers that are chained with this one.
374+
* <p><b>Note:</b> This method is primarily intended for use by AWS SDK internal components
375+
* and should not be used directly by external users.</p>
376+
*/
372377
@Override
373-
public Builder sourceFeatureId(String sourceFeatureId) {
374-
this.sourceFeatureId = sourceFeatureId;
378+
public Builder sourceChain(String sourceChain) {
379+
this.sourceChain = sourceChain;
375380
return this;
376381
}
377382

378-
public void setSourceFeatureId(String sourceFeatureId) {
379-
sourceFeatureId(sourceFeatureId);
383+
public void setSourceChain(String sourceChain) {
384+
sourceChain(sourceChain);
380385
}
381386

382387
@Override

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/HttpCredentialsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface Builder<TypeToBuildT extends HttpCredentialsProvider, BuilderT extends
5353
* <p><b>Note:</b> This method is primarily intended for use by AWS SDK internal components
5454
* and should not be used directly by external users.</p>
5555
*/
56-
default BuilderT sourceFeatureId(String sourceFeatureId) {
56+
default BuilderT sourceChain(String sourceChain) {
5757
throw new UnsupportedOperationException();
5858
}
5959

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/InstanceProfileCredentialsProvider.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public final class InstanceProfileCredentialsProvider
9393

9494
private final Duration staleTime;
9595

96-
private final String sourceFeatureId;
96+
private final String sourceChain;
9797
private final String providerName;
9898

9999
/**
@@ -108,10 +108,10 @@ private InstanceProfileCredentialsProvider(BuilderImpl builder) {
108108
.orElseGet(() -> ProfileFileSupplier.fixedProfileFile(ProfileFile.defaultProfileFile()));
109109
this.profileName = Optional.ofNullable(builder.profileName)
110110
.orElseGet(ProfileFileSystemSetting.AWS_PROFILE::getStringValueOrThrow);
111-
this.sourceFeatureId = builder.sourceFeatureId;
112-
this.providerName = StringUtils.isEmpty(builder.sourceFeatureId)
111+
this.sourceChain = builder.sourceChain;
112+
this.providerName = StringUtils.isEmpty(builder.sourceChain)
113113
? PROVIDER_NAME
114-
: builder.sourceFeatureId + "," + PROVIDER_NAME;
114+
: builder.sourceChain + "," + PROVIDER_NAME;
115115

116116
this.httpCredentialsLoader = HttpCredentialsLoader.create(this.providerName);
117117
this.configProvider =
@@ -382,7 +382,7 @@ static final class BuilderImpl implements Builder {
382382
private Supplier<ProfileFile> profileFile;
383383
private String profileName;
384384
private Duration staleTime;
385-
private String sourceFeatureId;
385+
private String sourceChain;
386386

387387
private BuilderImpl() {
388388
asyncThreadName("instance-profile-credentials-provider");
@@ -396,7 +396,7 @@ private BuilderImpl(InstanceProfileCredentialsProvider provider) {
396396
this.profileFile = provider.profileFile;
397397
this.profileName = provider.profileName;
398398
this.staleTime = provider.staleTime;
399-
this.sourceFeatureId = provider.sourceFeatureId;
399+
this.sourceChain = provider.sourceChain;
400400
}
401401

402402
Builder clock(Clock clock) {
@@ -475,14 +475,19 @@ public void setStaleTime(Duration duration) {
475475
staleTime(duration);
476476
}
477477

478+
/**
479+
* An optional string denoting previous credentials providers that are chained with this one.
480+
* <p><b>Note:</b> This method is primarily intended for use by AWS SDK internal components
481+
* and should not be used directly by external users.</p>
482+
*/
478483
@Override
479-
public Builder sourceFeatureId(String sourceFeatureId) {
480-
this.sourceFeatureId = sourceFeatureId;
484+
public Builder sourceChain(String sourceChain) {
485+
this.sourceChain = sourceChain;
481486
return this;
482487
}
483488

484-
public void setSourceFeatureId(String sourceFeatureId) {
485-
sourceFeatureId(sourceFeatureId);
489+
public void setSourceChain(String sourceChain) {
490+
sourceChain(sourceChain);
486491
}
487492

488493
@Override

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/ProcessCredentialsProvider.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public final class ProcessCredentialsProvider
8585

8686
private final Boolean asyncCredentialUpdateEnabled;
8787

88-
private final String sourceFeatureId;
88+
private final String sourceChain;
8989
private final String providerName;
9090

9191
/**
@@ -99,10 +99,10 @@ private ProcessCredentialsProvider(Builder builder) {
9999
this.commandAsListOfStringsFromBuilder = builder.commandAsListOfStrings;
100100
this.asyncCredentialUpdateEnabled = builder.asyncCredentialUpdateEnabled;
101101
this.staticAccountId = builder.staticAccountId;
102-
this.sourceFeatureId = builder.sourceFeatureId;
103-
this.providerName = StringUtils.isEmpty(builder.sourceFeatureId)
102+
this.sourceChain = builder.sourceChain;
103+
this.providerName = StringUtils.isEmpty(builder.sourceChain)
104104
? PROVIDER_NAME
105-
: builder.sourceFeatureId + "," + PROVIDER_NAME;
105+
: builder.sourceChain + "," + PROVIDER_NAME;
106106

107107
CachedSupplier.Builder<AwsCredentials> cacheBuilder = CachedSupplier.builder(this::refreshCredentials)
108108
.cachedValueName(toString());
@@ -280,7 +280,7 @@ public static class Builder implements CopyableBuilder<Builder, ProcessCredentia
280280
private Duration credentialRefreshThreshold = Duration.ofSeconds(15);
281281
private long processOutputLimit = 64000;
282282
private String staticAccountId;
283-
private String sourceFeatureId;
283+
private String sourceChain;
284284

285285
/**
286286
* @see #builder()
@@ -295,7 +295,7 @@ private Builder(ProcessCredentialsProvider provider) {
295295
this.credentialRefreshThreshold = provider.credentialRefreshThreshold;
296296
this.processOutputLimit = provider.processOutputLimit;
297297
this.staticAccountId = provider.staticAccountId;
298-
this.sourceFeatureId = provider.sourceFeatureId;
298+
this.sourceChain = provider.sourceChain;
299299
}
300300

301301
/**
@@ -370,10 +370,12 @@ public Builder staticAccountId(String staticAccountId) {
370370
}
371371

372372
/**
373-
* Configure the source of this credentials provider. This is used for business metrics tracking.
373+
* An optional string denoting previous credentials providers that are chained with this one.
374+
* <p><b>Note:</b> This method is primarily intended for use by AWS SDK internal components
375+
* and should not be used directly by external users.</p>
374376
*/
375-
public Builder sourceFeatureId(String sourceFeatureId) {
376-
this.sourceFeatureId = sourceFeatureId;
377+
public Builder sourceChain(String sourceChain) {
378+
this.sourceChain = sourceChain;
377379
return this;
378380
}
379381

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/ProfileProviderCredentialsContext.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public final class ProfileProviderCredentialsContext {
3030

3131
private final Profile profile;
3232
private final ProfileFile profileFile;
33-
private final String sourceFeatureId;
33+
private final String sourceChain;
3434

3535
private ProfileProviderCredentialsContext(Builder builder) {
3636
this.profile = builder.profile;
3737
this.profileFile = builder.profileFile;
38-
this.sourceFeatureId = builder.sourceFeatureId;
38+
this.sourceChain = builder.sourceChain;
3939
}
4040

4141
public static Builder builder() {
@@ -62,8 +62,8 @@ public ProfileFile profileFile() {
6262
* An optional string list of {@link software.amazon.awssdk.core.useragent.BusinessMetricFeatureId} denoting previous
6363
* credentials providers that are chained with this one.
6464
*/
65-
public String sourceFeatureId() {
66-
return sourceFeatureId;
65+
public String sourceChain() {
66+
return sourceChain;
6767
}
6868

6969
@Override
@@ -89,7 +89,7 @@ public int hashCode() {
8989
public static final class Builder {
9090
private Profile profile;
9191
private ProfileFile profileFile;
92-
private String sourceFeatureId;
92+
private String sourceChain;
9393

9494
private Builder() {
9595
}
@@ -117,15 +117,15 @@ public Builder profileFile(ProfileFile profileFile) {
117117

118118
/**
119119
* Builder interface to set source.
120-
* @param sourceFeatureId An optional string list of {@link BusinessMetricFeatureId} denoting previous credentials
120+
* @param sourceChain An optional string list of {@link BusinessMetricFeatureId} denoting previous credentials
121121
* providers that are chained with this one. This method is primarily
122122
* intended for use by AWS SDK internal components
123123
* and should not be used directly by external users.
124124
*
125125
* @return Returns a reference to this object so that method calls can be chained together.
126126
*/
127-
public Builder sourceFeatureId(String sourceFeatureId) {
128-
this.sourceFeatureId = sourceFeatureId;
127+
public Builder sourceChain(String sourceChain) {
128+
this.sourceChain = sourceChain;
129129
return this;
130130
}
131131

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/WebIdentityTokenFileCredentialsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private WebIdentityTokenFileCredentialsProvider(BuilderImpl builder) {
109109
.prefetchTime(prefetchTime)
110110
.staleTime(staleTime)
111111
.roleSessionDuration(roleSessionDuration)
112-
.sourceFeatureId(BusinessMetricFeatureId
112+
.sourceChain(BusinessMetricFeatureId
113113
.CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN.value())
114114
.build();
115115

0 commit comments

Comments
 (0)