Record Class S3Credentials

java.lang.Object
java.lang.Record
dev.hardwood.s3.S3Credentials
Record Components:
accessKeyId - the AWS access key ID
secretAccessKey - the AWS secret access key
sessionToken - the session token, or null for long-term credentials

public record S3Credentials(String accessKeyId, String secretAccessKey, String sessionToken) extends Record

Long-term or temporary AWS credentials.

This is a plain record with no AWS SDK dependency. Use of(String, String) for long-term credentials (access key + secret key) or the canonical constructor to include a session token for temporary credentials (STS AssumeRole, EC2/ECS instance profile, IRSA, etc.).

  • Constructor Details

    • S3Credentials

      public S3Credentials(String accessKeyId, String secretAccessKey, String sessionToken)
      Creates an instance of a S3Credentials record class.
      Parameters:
      accessKeyId - the value for the accessKeyId record component
      secretAccessKey - the value for the secretAccessKey record component
      sessionToken - the value for the sessionToken record component
  • Method Details

    • of

      public static S3Credentials of(String accessKeyId, String secretAccessKey)
      Creates long-term credentials (no session token).
      Parameters:
      accessKeyId - the AWS access key ID
      secretAccessKey - the AWS secret access key
      Returns:
      credentials without a session token
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • accessKeyId

      public String accessKeyId()
      Returns the value of the accessKeyId record component.
      Returns:
      the value of the accessKeyId record component
    • secretAccessKey

      public String secretAccessKey()
      Returns the value of the secretAccessKey record component.
      Returns:
      the value of the secretAccessKey record component
    • sessionToken

      public String sessionToken()
      Returns the value of the sessionToken record component.
      Returns:
      the value of the sessionToken record component