Skip to content

Commit

Permalink
use static and session name
Browse files Browse the repository at this point in the history
  • Loading branch information
FANNG1 committed Oct 29, 2024
1 parent 4088c32 commit 809b7f6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ public class S3SecretKeyCredential implements Credential {
/** S3 secret key credential type. */
public static final String S3_SECRET_KEY_CREDENTIAL_TYPE = "s3-secret-key";
/** The static access key ID used to access S3 data. */
public static final String GRAVITINO_S3_STATIC_ACCESS_KEY_ID = "s3-static-access-key-id";
public static final String GRAVITINO_S3_STATIC_ACCESS_KEY_ID = "s3-access-key-id";
/** The static secret access key used to access S3 data. */
public static final String GRAVITINO_S3_STATIC_SECRET_ACCESS_KEY = "s3-static-secret-access-key";
public static final String GRAVITINO_S3_STATIC_SECRET_ACCESS_KEY = "s3-secret-access-key";

private final String staticAccessKeyId;
private final String staticSecretAccessKey;
private final String accessKeyId;
private final String secretAccessKey;

/**
* Constructs an instance of {@link S3SecretKeyCredential} with the static S3 access key ID and
* secret access key.
*
* @param staticAccessKeyId The S3 static access key ID.
* @param staticSecretAccessKey The S3 static secret access key.
* @param accessKeyId The S3 static access key ID.
* @param secretAccessKey The S3 static secret access key.
*/
public S3SecretKeyCredential(String staticAccessKeyId, String staticSecretAccessKey) {
Preconditions.checkNotNull(staticAccessKeyId, "S3 access key Id should not null");
Preconditions.checkNotNull(staticSecretAccessKey, "S3 secret access key should not null");
public S3SecretKeyCredential(String accessKeyId, String secretAccessKey) {
Preconditions.checkNotNull(accessKeyId, "S3 access key Id should not null");
Preconditions.checkNotNull(secretAccessKey, "S3 secret access key should not null");

this.staticAccessKeyId = staticAccessKeyId;
this.staticSecretAccessKey = staticSecretAccessKey;
this.accessKeyId = accessKeyId;
this.secretAccessKey = secretAccessKey;
}

@Override
Expand All @@ -64,8 +64,8 @@ public long expireTimeInMs() {
@Override
public Map<String, String> credentialInfo() {
return (new ImmutableMap.Builder<String, String>())
.put(GRAVITINO_S3_STATIC_ACCESS_KEY_ID, staticAccessKeyId)
.put(GRAVITINO_S3_STATIC_SECRET_ACCESS_KEY, staticSecretAccessKey)
.put(GRAVITINO_S3_STATIC_ACCESS_KEY_ID, accessKeyId)
.put(GRAVITINO_S3_STATIC_SECRET_ACCESS_KEY, secretAccessKey)
.build();
}

Expand All @@ -74,16 +74,16 @@ public Map<String, String> credentialInfo() {
*
* @return The S3 access key ID.
*/
public String staticAccessKeyId() {
return staticAccessKeyId;
public String accessKeyId() {
return accessKeyId;
}

/**
* Get S3 static secret access key.
*
* @return The S3 secret access key.
*/
public String staticSecretAccessKey() {
return staticSecretAccessKey;
public String secretAccessKey() {
return secretAccessKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,36 @@ public class S3TokenCredential implements Credential {
/** S3 token credential type. */
public static final String S3_TOKEN_CREDENTIAL_TYPE = "s3-token";
/** S3 session access key ID used to access S3 data. */
public static final String GRAVITINO_S3_SESSION_ACCESS_KEY_ID = "s3-session-access-key-id";
public static final String GRAVITINO_S3_SESSION_ACCESS_KEY_ID = "s3-access-key-id";
/** S3 session secret access key used to access S3 data. */
public static final String GRAVITINO_S3_SESSION_SECRET_ACCESS_KEY =
"s3-session-secret-access-key";
public static final String GRAVITINO_S3_SESSION_SECRET_ACCESS_KEY = "s3-secret-access-key";
/** S3 session token. */
public static final String GRAVITINO_S3_TOKEN = "s3-session-token";

private final String sessionAccessKeyId;
private final String sessionSecretAccessKey;
private final String accessKeyId;
private final String secretAccessKey;
private final String sessionToken;
private final long expireTimeInMS;

/**
* Constructs an instance of {@link S3SecretKeyCredential} with session secret key and token.
*
* @param sessionAccessKeyId The S3 session access key ID.
* @param sessionSecretAccessKey The S3 session secret access key.
* @param accessKeyId The S3 session access key ID.
* @param secretAccessKey The S3 session secret access key.
* @param sessionToken The S3 session token.
* @param expireTimeInMS The S3 session token expire time in ms.
*/
public S3TokenCredential(
String sessionAccessKeyId,
String sessionSecretAccessKey,
String sessionToken,
long expireTimeInMS) {
String accessKeyId, String secretAccessKey, String sessionToken, long expireTimeInMS) {
Preconditions.checkArgument(
StringUtils.isNotBlank(sessionAccessKeyId), "S3 access key Id should not be empty");
StringUtils.isNotBlank(accessKeyId), "S3 access key Id should not be empty");
Preconditions.checkArgument(
StringUtils.isNotBlank(sessionSecretAccessKey), "S3 secret access key should not be empty");
StringUtils.isNotBlank(secretAccessKey), "S3 secret access key should not be empty");
Preconditions.checkArgument(
StringUtils.isNotBlank(sessionToken), "S3 session token should not be empty");

this.sessionAccessKeyId = sessionAccessKeyId;
this.sessionSecretAccessKey = sessionSecretAccessKey;
this.accessKeyId = accessKeyId;
this.secretAccessKey = secretAccessKey;
this.sessionToken = sessionToken;
this.expireTimeInMS = expireTimeInMS;
}
Expand All @@ -81,8 +77,8 @@ public long expireTimeInMs() {
@Override
public Map<String, String> credentialInfo() {
return (new ImmutableMap.Builder<String, String>())
.put(GRAVITINO_S3_SESSION_ACCESS_KEY_ID, sessionAccessKeyId)
.put(GRAVITINO_S3_SESSION_SECRET_ACCESS_KEY, sessionSecretAccessKey)
.put(GRAVITINO_S3_SESSION_ACCESS_KEY_ID, accessKeyId)
.put(GRAVITINO_S3_SESSION_SECRET_ACCESS_KEY, secretAccessKey)
.put(GRAVITINO_S3_TOKEN, sessionToken)
.build();
}
Expand All @@ -92,17 +88,17 @@ public Map<String, String> credentialInfo() {
*
* @return The S3 access key ID.
*/
public String sessionAccessKeyId() {
return sessionAccessKeyId;
public String accessKeyId() {
return accessKeyId;
}

/**
* Get S3 session secret access key.
*
* @return The S3 secret access key.
*/
public String sessionSecretAccessKey() {
return sessionSecretAccessKey;
public String secretAccessKey() {
return secretAccessKey;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ public class CredentialPropertyUtils {
ICEBERG_S3_ACCESS_KEY_ID,
S3SecretKeyCredential.GRAVITINO_S3_STATIC_SECRET_ACCESS_KEY,
ICEBERG_S3_SECRET_ACCESS_KEY,
S3TokenCredential.GRAVITINO_S3_SESSION_ACCESS_KEY_ID,
ICEBERG_S3_ACCESS_KEY_ID,
S3TokenCredential.GRAVITINO_S3_SESSION_SECRET_ACCESS_KEY,
ICEBERG_S3_SECRET_ACCESS_KEY,
S3TokenCredential.GRAVITINO_S3_TOKEN,
ICEBERG_S3_TOKEN);

Expand Down

0 comments on commit 809b7f6

Please sign in to comment.