Class CodeArtifactToken

java.lang.Object
ai.clarity.codeartifact.CodeArtifactToken
All Implemented Interfaces:
org.gradle.api.services.BuildService<org.gradle.api.services.BuildServiceParameters.None>

public class CodeArtifactToken extends Object implements org.gradle.api.services.BuildService<org.gradle.api.services.BuildServiceParameters.None>
Build service that fetches CodeArtifact authorization tokens and shares them across the whole build.

A token is requested once per authentication and repository url, and reused from an in-memory cache afterwards. Profile entries and service-credential entries never share a cache slot, and the credentials half of the key is a digest, so no secret is held in clear.

Gradle instantiates it through sharedServices.registerIfAbsent; there is no reason to construct one directly.

  • Constructor Details

    • CodeArtifactToken

      public CodeArtifactToken()
      Creates the service. Called by Gradle, which owns the single instance registered for the build.
  • Method Details

    • getToken

      public String getToken(URI uri, String profile) throws MalformedURLException
      Returns the authorization token for uri, authenticating with an AWS profile.
      Parameters:
      uri - the CodeArtifact repository url
      profile - the AWS profile to authenticate with, or null to let the AWS SDK resolve the credentials
      Returns:
      the authorization token, from the cache when this authentication and url were already resolved
      Throws:
      MalformedURLException - when uri is not a valid CodeArtifact repository url
    • getToken

      public String getToken(String uri, String profile) throws MalformedURLException
      Returns the authorization token for uri, authenticating with an AWS profile.
      Parameters:
      uri - the CodeArtifact repository url
      profile - the AWS profile to authenticate with, or null to let the AWS SDK resolve the credentials
      Returns:
      the authorization token, from the cache when this authentication and url were already resolved
      Throws:
      MalformedURLException - when uri is not a valid CodeArtifact repository url
    • getToken

      public String getToken(URI uri, CodeArtifactCredentials credentials) throws MalformedURLException
      Returns the authorization token for uri, authenticating with the static credentials of a service account.
      Parameters:
      uri - the CodeArtifact repository url
      credentials - the service account credentials to authenticate with
      Returns:
      the authorization token, from the cache when this authentication and url were already resolved
      Throws:
      MalformedURLException - when uri is not a valid CodeArtifact repository url
    • getToken

      public String getToken(String uri, CodeArtifactCredentials credentials) throws MalformedURLException
      Returns the authorization token for uri, authenticating with the static credentials of a service account.
      Parameters:
      uri - the CodeArtifact repository url
      credentials - the service account credentials to authenticate with
      Returns:
      the authorization token, from the cache when this authentication and url were already resolved
      Throws:
      MalformedURLException - when uri is not a valid CodeArtifact repository url
    • getParameters

      public org.gradle.api.services.BuildServiceParameters.None getParameters()

      The service takes no parameters.

      Specified by:
      getParameters in interface org.gradle.api.services.BuildService<org.gradle.api.services.BuildServiceParameters.None>