Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add context object to pass to supplier functions #1363

Merged
merged 12 commits into from
Feb 2, 2024
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.google.auth.oauth2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a copyright header?


import com.google.auth.oauth2.ExternalAccountCredentials.SubjectTokenTypes;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;

/** Context object to pass relevant variables from external account credentials to suppliers. */
/**
* Context object to pass relevant variables from external account credentials to suppliers. This
* will be passed on any call made to {@link IdentityPoolSubjectTokenSupplier} or {@link
* AwsSecurityCredentialsSupplier}.
*/
public class ExternalAccountSupplierContext implements Serializable {

private static final long serialVersionUID = -7852130853542313494L;
Expand All @@ -12,13 +17,13 @@ public class ExternalAccountSupplierContext implements Serializable {
private final String subjectTokenType;

/** Internal constructor. See {@link ExternalAccountSupplierContext.Builder}. */
ExternalAccountSupplierContext(Builder builder) {
private ExternalAccountSupplierContext(Builder builder) {
this.audience = builder.audience;
this.subjectTokenType = builder.subjectTokenType;
}

/**
* Gets the credentials expected audience.
* Returns the credentials' expected audience.
*
* @return the audience.
*/
Expand All @@ -27,7 +32,7 @@ public String getAudience() {
}

/**
* Gets the credentials expected subject token type.
* Returns the credentials' expected subject token type.
*
aeitzman marked this conversation as resolved.
Show resolved Hide resolved
* @return the subject token type.
*/
Expand All @@ -45,8 +50,6 @@ public static class Builder {
protected String audience;
protected String subjectTokenType;

public Builder() {}

/**
* Sets the Audience.
*
Expand All @@ -71,6 +74,18 @@ public Builder setSubjectTokenType(String subjectTokenType) {
return this;
}

/**
* Sets the subject token type.
aeitzman marked this conversation as resolved.
Show resolved Hide resolved
*
* @param subjectTokenType the subjectTokenType to set.
* @return this {@code Builder} object
*/
@CanIgnoreReturnValue
public Builder setSubjectTokenType(SubjectTokenTypes subjectTokenType) {
this.subjectTokenType = subjectTokenType.value;
return this;
}

public ExternalAccountSupplierContext build() {
return new ExternalAccountSupplierContext(this);
}
Expand Down
Loading