Class CodeArtifactCredentials

java.lang.Object
ai.clarity.codeartifact.CodeArtifactCredentials

public final class CodeArtifactCredentials extends Object
Static AWS credentials of a service account, used to request the CodeArtifact authorization token without relying on a local AWS profile.

A session token can be supplied for temporary credentials, and must be omitted for the long lived access keys of an IAM user.

  • Method Details

    • of

      public static CodeArtifactCredentials of(String accessKeyId, String secretAccessKey)
      Builds the long-lived credentials of an IAM user.
      Parameters:
      accessKeyId - the access key id, required
      secretAccessKey - the secret access key, required
      Returns:
      the credentials
      Throws:
      IllegalArgumentException - when either value is missing or blank
    • of

      public static CodeArtifactCredentials of(String accessKeyId, String secretAccessKey, String sessionToken)
      Builds the credentials of an IAM user, or the temporary ones of an assumed role when a session token is given.
      Parameters:
      accessKeyId - the access key id, required
      secretAccessKey - the secret access key, required
      sessionToken - the session token of temporary credentials, or null for long-lived ones
      Returns:
      the credentials
      Throws:
      IllegalArgumentException - when the access key id or the secret access key is missing or blank
    • of

      public static CodeArtifactCredentials of(Map<?,?> values)
      Builds the credentials from a map, which is the shape the Groovy DSL passes them in, as in codeartifact(url, [accessKeyId: '...', secretAccessKey: '...']).
      Parameters:
      values - the credentials keyed by accessKeyId, secretAccessKey and, optionally, sessionToken
      Returns:
      the credentials
      Throws:
      IllegalArgumentException - when the map carries an unsupported key, or the access key id or the secret access key is missing or blank
    • getAccessKeyId

      public String getAccessKeyId()
      Returns the access key id in clear. Use getMaskedAccessKeyId() for anything that reaches a log.
      Returns:
      the access key id
    • getMaskedAccessKeyId

      public String getMaskedAccessKeyId()
      The access key id with its middle section hidden, safe to write to the build log.
      Returns:
      the access key id with all but its first and last four characters replaced by asterisks, or fully masked when it is eight characters or shorter
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Redacted on purpose: these credentials end up in build logs and in Gradle error messages.
      Overrides:
      toString in class Object