Skip to content

Commit 4adbc31

Browse files
committed
Enforce that enum names must be singular, not plural.
1 parent b794f84 commit 4adbc31

File tree

212 files changed

+1188
-1225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+1188
-1225
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"type": "feature",
4+
"description": "Renamed all non-service enums to be singular, not plural."
5+
}

auth/src/main/java/software/amazon/awssdk/auth/AwsExecutionAttributes.java renamed to auth/src/main/java/software/amazon/awssdk/auth/AwsExecutionAttribute.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import software.amazon.awssdk.auth.credentials.AwsCredentials;
2121
import software.amazon.awssdk.core.interceptor.ExecutionAttribute;
2222
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
23-
import software.amazon.awssdk.core.interceptor.SdkExecutionAttributes;
23+
import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute;
2424
import software.amazon.awssdk.core.signer.Signer;
2525
import software.amazon.awssdk.regions.Region;
2626

@@ -30,7 +30,7 @@
3030
*/
3131
@ReviewBeforeRelease("We should also consider making some of the SDK/AWS-owned set of attributes part of the immutable context"
3232
+ "if we don't want the interceptors to modify them.")
33-
public final class AwsExecutionAttributes extends SdkExecutionAttributes {
33+
public final class AwsExecutionAttribute extends SdkExecutionAttribute {
3434
/**
3535
* The key under which the request credentials are set.
3636
*/
@@ -63,6 +63,6 @@ public final class AwsExecutionAttributes extends SdkExecutionAttributes {
6363
*/
6464
public static final ExecutionAttribute<Instant> PRESIGNER_EXPIRATION = new ExecutionAttribute<>("PresignerExpiration");
6565

66-
private AwsExecutionAttributes() {
66+
private AwsExecutionAttribute() {
6767
}
6868
}

auth/src/main/java/software/amazon/awssdk/auth/credentials/internal/ProfileCredentialsUtils.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import software.amazon.awssdk.auth.credentials.ChildProfileCredentialsProviderFactory;
3030
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
3131
import software.amazon.awssdk.profiles.Profile;
32-
import software.amazon.awssdk.profiles.ProfileProperties;
32+
import software.amazon.awssdk.profiles.ProfileProperty;
3333
import software.amazon.awssdk.utils.SdkAutoCloseable;
3434
import software.amazon.awssdk.utils.Validate;
3535

@@ -85,15 +85,15 @@ public Optional<AwsCredentialsProvider> credentialsProvider() {
8585
* @param children The child profiles that source credentials from this profile.
8686
*/
8787
private Optional<AwsCredentialsProvider> credentialsProvider(Set<String> children) {
88-
if (properties.containsKey(ProfileProperties.ROLE_ARN)) {
88+
if (properties.containsKey(ProfileProperty.ROLE_ARN)) {
8989
return Optional.ofNullable(roleBasedProfileCredentialsProvider(children));
9090
}
9191

92-
if (properties.containsKey(ProfileProperties.AWS_SESSION_TOKEN)) {
92+
if (properties.containsKey(ProfileProperty.AWS_SESSION_TOKEN)) {
9393
return Optional.of(sessionProfileCredentialsProvider());
9494
}
9595

96-
if (properties.containsKey(ProfileProperties.AWS_ACCESS_KEY_ID)) {
96+
if (properties.containsKey(ProfileProperty.AWS_ACCESS_KEY_ID)) {
9797
return Optional.of(basicProfileCredentialsProvider());
9898
}
9999

@@ -104,23 +104,23 @@ private Optional<AwsCredentialsProvider> credentialsProvider(Set<String> childre
104104
* Load a basic set of credentials that have been configured in this profile.
105105
*/
106106
private AwsCredentialsProvider basicProfileCredentialsProvider() {
107-
requireProperties(ProfileProperties.AWS_ACCESS_KEY_ID,
108-
ProfileProperties.AWS_SECRET_ACCESS_KEY);
109-
AwsCredentials credentials = AwsCredentials.create(properties.get(ProfileProperties.AWS_ACCESS_KEY_ID),
110-
properties.get(ProfileProperties.AWS_SECRET_ACCESS_KEY));
107+
requireProperties(ProfileProperty.AWS_ACCESS_KEY_ID,
108+
ProfileProperty.AWS_SECRET_ACCESS_KEY);
109+
AwsCredentials credentials = AwsCredentials.create(properties.get(ProfileProperty.AWS_ACCESS_KEY_ID),
110+
properties.get(ProfileProperty.AWS_SECRET_ACCESS_KEY));
111111
return StaticCredentialsProvider.create(credentials);
112112
}
113113

114114
/**
115115
* Load a set of session credentials that have been configured in this profile.
116116
*/
117117
private AwsCredentialsProvider sessionProfileCredentialsProvider() {
118-
requireProperties(ProfileProperties.AWS_ACCESS_KEY_ID,
119-
ProfileProperties.AWS_SECRET_ACCESS_KEY,
120-
ProfileProperties.AWS_SESSION_TOKEN);
121-
AwsCredentials credentials = AwsSessionCredentials.create(properties.get(ProfileProperties.AWS_ACCESS_KEY_ID),
122-
properties.get(ProfileProperties.AWS_SECRET_ACCESS_KEY),
123-
properties.get(ProfileProperties.AWS_SESSION_TOKEN));
118+
requireProperties(ProfileProperty.AWS_ACCESS_KEY_ID,
119+
ProfileProperty.AWS_SECRET_ACCESS_KEY,
120+
ProfileProperty.AWS_SESSION_TOKEN);
121+
AwsCredentials credentials = AwsSessionCredentials.create(properties.get(ProfileProperty.AWS_ACCESS_KEY_ID),
122+
properties.get(ProfileProperty.AWS_SECRET_ACCESS_KEY),
123+
properties.get(ProfileProperty.AWS_SESSION_TOKEN));
124124
return StaticCredentialsProvider.create(credentials);
125125
}
126126

@@ -131,7 +131,7 @@ private AwsCredentialsProvider sessionProfileCredentialsProvider() {
131131
* @param children The child profiles that source credentials from this profile.
132132
*/
133133
private AwsCredentialsProvider roleBasedProfileCredentialsProvider(Set<String> children) {
134-
requireProperties(ProfileProperties.SOURCE_PROFILE);
134+
requireProperties(ProfileProperty.SOURCE_PROFILE);
135135

136136
Validate.validState(!children.contains(name),
137137
"Invalid profile file: Circular relationship detected with profiles %s.", children);
@@ -140,7 +140,7 @@ private AwsCredentialsProvider roleBasedProfileCredentialsProvider(Set<String> c
140140

141141
children.add(name);
142142
AwsCredentialsProvider sourceCredentialsProvider =
143-
credentialsSourceResolver.apply(properties.get(ProfileProperties.SOURCE_PROFILE))
143+
credentialsSourceResolver.apply(properties.get(ProfileProperty.SOURCE_PROFILE))
144144
.flatMap(p -> new ProfileCredentialsUtils(p, credentialsSourceResolver)
145145
.credentialsProvider(children))
146146
.orElseThrow(this::noSourceCredentialsException);
@@ -159,7 +159,7 @@ private void requireProperties(String... requiredProperties) {
159159

160160
private IllegalStateException noSourceCredentialsException() {
161161
String error = String.format("The source profile of '%s' was configured to be '%s', but that source profile has no "
162-
+ "credentials configured.", name, properties.get(ProfileProperties.SOURCE_PROFILE));
162+
+ "credentials configured.", name, properties.get(ProfileProperty.SOURCE_PROFILE));
163163
return new IllegalStateException(error);
164164
}
165165

auth/src/main/java/software/amazon/awssdk/auth/signer/AbstractAws4Signer.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.slf4j.Logger;
3131
import org.slf4j.LoggerFactory;
3232
import software.amazon.awssdk.annotations.SdkProtectedApi;
33-
import software.amazon.awssdk.auth.AwsExecutionAttributes;
33+
import software.amazon.awssdk.auth.AwsExecutionAttribute;
3434
import software.amazon.awssdk.auth.credentials.AwsCredentials;
3535
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
3636
import software.amazon.awssdk.auth.signer.internal.AbstractAwsSigner;
@@ -79,9 +79,9 @@ protected SdkHttpFullRequest.Builder doSign(SdkHttpFullRequest request,
7979
addDateHeader(mutableRequest, requestParams.getFormattedSigningDateTime());
8080

8181
String contentSha256 = calculateContentHash(mutableRequest, signingParams);
82-
mutableRequest.firstMatchingHeader(SignerConstants.X_AMZ_CONTENT_SHA256)
82+
mutableRequest.firstMatchingHeader(SignerConstant.X_AMZ_CONTENT_SHA256)
8383
.filter(h -> h.equals("required"))
84-
.ifPresent(h -> mutableRequest.header(SignerConstants.X_AMZ_CONTENT_SHA256, contentSha256));
84+
.ifPresent(h -> mutableRequest.header(SignerConstant.X_AMZ_CONTENT_SHA256, contentSha256));
8585

8686
final String canonicalRequest = createCanonicalRequest(mutableRequest, contentSha256, signingParams.doubleUrlEncode());
8787

@@ -91,7 +91,7 @@ protected SdkHttpFullRequest.Builder doSign(SdkHttpFullRequest request,
9191

9292
final byte[] signature = computeSignature(stringToSign, signingKey);
9393

94-
mutableRequest.header(SignerConstants.AUTHORIZATION,
94+
mutableRequest.header(SignerConstant.AUTHORIZATION,
9595
buildAuthorizationHeader(signature, sanitizedCredentials, requestParams, mutableRequest));
9696

9797
processRequestPayload(mutableRequest, signature, signingKey, requestParams, signingParams);
@@ -113,7 +113,7 @@ protected SdkHttpFullRequest.Builder doPresign(SdkHttpFullRequest request,
113113
// For SigV4 pre-signing URL, we need to add "X-Amz-Security-Token"
114114
// as a query string parameter, before constructing the canonical
115115
// request.
116-
mutableRequest.rawQueryParameter(SignerConstants.X_AMZ_SECURITY_TOKEN,
116+
mutableRequest.rawQueryParameter(SignerConstant.X_AMZ_SECURITY_TOKEN,
117117
((AwsSessionCredentials) sanitizedCredentials).sessionToken());
118118
}
119119

@@ -132,15 +132,15 @@ protected SdkHttpFullRequest.Builder doPresign(SdkHttpFullRequest request,
132132

133133
final byte[] signature = computeSignature(stringToSign, signingKey);
134134

135-
mutableRequest.rawQueryParameter(SignerConstants.X_AMZ_SIGNATURE, BinaryUtils.toHex(signature));
135+
mutableRequest.rawQueryParameter(SignerConstant.X_AMZ_SIGNATURE, BinaryUtils.toHex(signature));
136136

137137
return mutableRequest;
138138
}
139139

140140
@Override
141141
protected void addSessionCredentials(SdkHttpFullRequest.Builder mutableRequest,
142142
AwsSessionCredentials credentials) {
143-
mutableRequest.header(SignerConstants.X_AMZ_SECURITY_TOKEN, credentials.sessionToken());
143+
mutableRequest.header(SignerConstant.X_AMZ_SECURITY_TOKEN, credentials.sessionToken());
144144
}
145145

146146
/**
@@ -180,16 +180,16 @@ private String createCanonicalRequest(SdkHttpFullRequest.Builder request,
180180
String contentSha256,
181181
boolean doubleUrlEncode) {
182182
final String canonicalRequest = request.method().toString() +
183-
SignerConstants.LINE_SEPARATOR +
183+
SignerConstant.LINE_SEPARATOR +
184184
// This would optionally double url-encode the resource path
185185
getCanonicalizedResourcePath(request.encodedPath(), doubleUrlEncode) +
186-
SignerConstants.LINE_SEPARATOR +
186+
SignerConstant.LINE_SEPARATOR +
187187
getCanonicalizedQueryString(request.rawQueryParameters()) +
188-
SignerConstants.LINE_SEPARATOR +
188+
SignerConstant.LINE_SEPARATOR +
189189
getCanonicalizedHeaderString(request.headers()) +
190-
SignerConstants.LINE_SEPARATOR +
190+
SignerConstant.LINE_SEPARATOR +
191191
getSignedHeadersString(request.headers()) +
192-
SignerConstants.LINE_SEPARATOR +
192+
SignerConstant.LINE_SEPARATOR +
193193
contentSha256;
194194

195195
if (LOG.isDebugEnabled()) {
@@ -208,11 +208,11 @@ private String createStringToSign(String canonicalRequest,
208208
Aws4SignerRequestParams requestParams) {
209209

210210
final String stringToSign = requestParams.getSigningAlgorithm() +
211-
SignerConstants.LINE_SEPARATOR +
211+
SignerConstant.LINE_SEPARATOR +
212212
requestParams.getFormattedSigningDateTime() +
213-
SignerConstants.LINE_SEPARATOR +
213+
SignerConstant.LINE_SEPARATOR +
214214
requestParams.getScope() +
215-
SignerConstants.LINE_SEPARATOR +
215+
SignerConstant.LINE_SEPARATOR +
216216
BinaryUtils.toHex(hash(canonicalRequest));
217217

218218
if (LOG.isDebugEnabled()) {
@@ -287,7 +287,7 @@ private String buildAuthorizationHeader(byte[] signature,
287287
getSignedHeadersString(mutableRequest.headers());
288288
String signatureHeader = "Signature=" + BinaryUtils.toHex(signature);
289289

290-
return SignerConstants.AWS4_SIGNING_ALGORITHM + " " + credential + ", " + signerHeaders + ", " + signatureHeader;
290+
return SignerConstant.AWS4_SIGNING_ALGORITHM + " " + credential + ", " + signerHeaders + ", " + signatureHeader;
291291
}
292292

293293
/**
@@ -301,13 +301,13 @@ private void addPreSignInformationToRequest(SdkHttpFullRequest.Builder mutableRe
301301

302302
String signingCredentials = sanitizedCredentials.accessKeyId() + "/" + signerParams.getScope();
303303

304-
mutableRequest.rawQueryParameter(SignerConstants.X_AMZ_ALGORITHM, SignerConstants.AWS4_SIGNING_ALGORITHM);
305-
mutableRequest.rawQueryParameter(SignerConstants.X_AMZ_DATE, timeStamp);
306-
mutableRequest.rawQueryParameter(SignerConstants.X_AMZ_SIGNED_HEADER,
304+
mutableRequest.rawQueryParameter(SignerConstant.X_AMZ_ALGORITHM, SignerConstant.AWS4_SIGNING_ALGORITHM);
305+
mutableRequest.rawQueryParameter(SignerConstant.X_AMZ_DATE, timeStamp);
306+
mutableRequest.rawQueryParameter(SignerConstant.X_AMZ_SIGNED_HEADER,
307307
getSignedHeadersString(mutableRequest.headers()));
308-
mutableRequest.rawQueryParameter(SignerConstants.X_AMZ_EXPIRES,
308+
mutableRequest.rawQueryParameter(SignerConstant.X_AMZ_EXPIRES,
309309
Long.toString(expirationInSeconds));
310-
mutableRequest.rawQueryParameter(SignerConstants.X_AMZ_CREDENTIAL, signingCredentials);
310+
mutableRequest.rawQueryParameter(SignerConstant.X_AMZ_CREDENTIAL, signingCredentials);
311311
}
312312

313313

@@ -367,11 +367,11 @@ private void addHostHeader(SdkHttpFullRequest.Builder mutableRequest) {
367367
hostHeaderBuilder.append(":").append(mutableRequest.port());
368368
}
369369

370-
mutableRequest.header(SignerConstants.HOST, hostHeaderBuilder.toString());
370+
mutableRequest.header(SignerConstant.HOST, hostHeaderBuilder.toString());
371371
}
372372

373373
private void addDateHeader(SdkHttpFullRequest.Builder mutableRequest, String dateTime) {
374-
mutableRequest.header(SignerConstants.X_AMZ_DATE, dateTime);
374+
mutableRequest.header(SignerConstant.X_AMZ_DATE, dateTime);
375375
}
376376

377377
/**
@@ -382,9 +382,9 @@ private long generateExpirationTime(Instant expirationTime) {
382382

383383
long expirationInSeconds = expirationTime != null
384384
? expirationTime.getEpochSecond()
385-
: SignerConstants.PRESIGN_URL_MAX_EXPIRATION_SECONDS;
385+
: SignerConstant.PRESIGN_URL_MAX_EXPIRATION_SECONDS;
386386

387-
if (expirationInSeconds > SignerConstants.PRESIGN_URL_MAX_EXPIRATION_SECONDS) {
387+
if (expirationInSeconds > SignerConstant.PRESIGN_URL_MAX_EXPIRATION_SECONDS) {
388388
throw new SdkClientException(
389389
"Requests that are pre-signed by SigV4 algorithm are valid for at most 7 days. "
390390
+ "The expiration date set on the current request ["
@@ -404,26 +404,26 @@ private byte[] newSigningKey(AwsCredentials credentials,
404404
byte[] kRegion = sign(regionName, kDate, SigningAlgorithm.HmacSHA256);
405405
byte[] kService = sign(serviceName, kRegion,
406406
SigningAlgorithm.HmacSHA256);
407-
return sign(SignerConstants.AWS4_TERMINATOR, kService, SigningAlgorithm.HmacSHA256);
407+
return sign(SignerConstant.AWS4_TERMINATOR, kService, SigningAlgorithm.HmacSHA256);
408408
}
409409

410410
protected <B extends Aws4PresignerParams.Builder> B extractPresignerParams(B builder,
411411
ExecutionAttributes executionAttributes) {
412412
builder = extractSignerParams(builder, executionAttributes);
413-
builder.expirationTime(executionAttributes.getAttribute(AwsExecutionAttributes.PRESIGNER_EXPIRATION));
413+
builder.expirationTime(executionAttributes.getAttribute(AwsExecutionAttribute.PRESIGNER_EXPIRATION));
414414

415415
return builder;
416416
}
417417

418418
protected <B extends Aws4SignerParams.Builder> B extractSignerParams(B paramsBuilder,
419419
ExecutionAttributes executionAttributes) {
420-
paramsBuilder.awsCredentials(executionAttributes.getAttribute(AwsExecutionAttributes.AWS_CREDENTIALS))
421-
.signingName(executionAttributes.getAttribute(AwsExecutionAttributes.SERVICE_SIGNING_NAME))
422-
.signingRegion(executionAttributes.getAttribute(AwsExecutionAttributes.SIGNING_REGION))
423-
.timeOffset(executionAttributes.getAttribute(AwsExecutionAttributes.TIME_OFFSET));
420+
paramsBuilder.awsCredentials(executionAttributes.getAttribute(AwsExecutionAttribute.AWS_CREDENTIALS))
421+
.signingName(executionAttributes.getAttribute(AwsExecutionAttribute.SERVICE_SIGNING_NAME))
422+
.signingRegion(executionAttributes.getAttribute(AwsExecutionAttribute.SIGNING_REGION))
423+
.timeOffset(executionAttributes.getAttribute(AwsExecutionAttribute.TIME_OFFSET));
424424

425-
if (executionAttributes.getAttribute(AwsExecutionAttributes.SIGNER_DOUBLE_URL_ENCODE) != null) {
426-
paramsBuilder.doubleUrlEncode(executionAttributes.getAttribute(AwsExecutionAttributes.SIGNER_DOUBLE_URL_ENCODE));
425+
if (executionAttributes.getAttribute(AwsExecutionAttribute.SIGNER_DOUBLE_URL_ENCODE) != null) {
426+
paramsBuilder.doubleUrlEncode(executionAttributes.getAttribute(AwsExecutionAttribute.SIGNER_DOUBLE_URL_ENCODE));
427427
}
428428

429429
return paramsBuilder;

auth/src/main/java/software/amazon/awssdk/auth/signer/QueryStringSigner.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.time.Instant;
2020
import java.util.Date;
2121
import java.util.TimeZone;
22-
import software.amazon.awssdk.auth.AwsExecutionAttributes;
22+
import software.amazon.awssdk.auth.AwsExecutionAttribute;
2323
import software.amazon.awssdk.auth.credentials.AwsCredentials;
2424
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
2525
import software.amazon.awssdk.auth.signer.internal.AbstractAwsSigner;
@@ -61,8 +61,8 @@ public static QueryStringSigner create() {
6161
*/
6262
@Override
6363
public SdkHttpFullRequest sign(SdkHttpFullRequest request, ExecutionAttributes executionAttributes) {
64-
final AwsCredentials awsCredentials = executionAttributes.getAttribute(AwsExecutionAttributes.AWS_CREDENTIALS);
65-
final Integer offset = executionAttributes.getAttribute(AwsExecutionAttributes.TIME_OFFSET);
64+
final AwsCredentials awsCredentials = executionAttributes.getAttribute(AwsExecutionAttribute.AWS_CREDENTIALS);
65+
final Integer offset = executionAttributes.getAttribute(AwsExecutionAttribute.TIME_OFFSET);
6666

6767
// anonymous credentials, don't sign
6868
if (CredentialUtils.isAnonymous(awsCredentials)) {

auth/src/main/java/software/amazon/awssdk/auth/signer/SignerConstants.java renamed to auth/src/main/java/software/amazon/awssdk/auth/signer/SignerConstant.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import software.amazon.awssdk.annotations.SdkProtectedApi;
1919

2020
@SdkProtectedApi
21-
public final class SignerConstants {
21+
public final class SignerConstant {
2222

2323
public static final String AWS4_TERMINATOR = "aws4_request";
2424

@@ -49,6 +49,6 @@ public final class SignerConstants {
4949

5050
static final String LINE_SEPARATOR = "\n";
5151

52-
private SignerConstants() {
52+
private SignerConstant() {
5353
}
5454
}

0 commit comments

Comments
 (0)