Class RegistryAuthLocator


  • public class RegistryAuthLocator
    extends Object
    Utility class to get credentials information from extension of type DockerRegistryCredentials or from $DOCKER_CONFIG/.docker/config.json file.

    Supports auth token, credentials store and credentials helpers. Only Linux OS is supported at the moment. Returns default auth object if called on Windows.

    The class is ported from the testcontainers-java project (PR 729).

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String getRegistry​(String image)
      Extract registry name from the image name
      com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs()
      Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an empty AuthConfigurations object is returned
      com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs​(DockerRegistryCredentials registryCredentials)
      Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed registryCredentials is returned
      com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs​(com.github.dockerjava.api.model.AuthConfig additionalAuthConfig)
      Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed additionalAuthConfig is returned
      com.github.dockerjava.api.model.AuthConfig lookupAuthConfig​(String image, DockerRegistryCredentials registryCredentials)
      Gets authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, gets the information from the registryCredentials object
    • Method Detail

      • lookupAuthConfig

        public com.github.dockerjava.api.model.AuthConfig lookupAuthConfig​(String image,
                                                                           DockerRegistryCredentials registryCredentials)
        Gets authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, gets the information from the registryCredentials object
        Parameters:
        registryCredentials - extension of type registryCredentials
        image - the name of docker image the action to be authorized for
        Returns:
        AuthConfig object with a credentials info or default object if no credentials found
      • lookupAllAuthConfigs

        public com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs()
        Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an empty AuthConfigurations object is returned
        Returns:
        AuthConfigurations object containing all authorization information, or an empty object if not available
      • lookupAllAuthConfigs

        public com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs​(DockerRegistryCredentials registryCredentials)
        Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed registryCredentials is returned
        Parameters:
        registryCredentials - extension of type registryCredentials
        Returns:
        AuthConfigurations object containing all authorization information (if available), and the registryCredentials
      • lookupAllAuthConfigs

        public com.github.dockerjava.api.model.AuthConfigurations lookupAllAuthConfigs​(com.github.dockerjava.api.model.AuthConfig additionalAuthConfig)
        Gets all authorization information using $DOCKER_CONFIG/.docker/config.json file If missing, an AuthConfigurations object containing only the passed additionalAuthConfig is returned
        Parameters:
        additionalAuthConfig - An additional AuthConfig object to add to the discovered authorization information.
        Returns:
        AuthConfigurations object containing all authorization information (if available), and the additionalAuthConfig
      • getRegistry

        public String getRegistry​(String image)
        Extract registry name from the image name
        Parameters:
        image - the name of the docker image
        Returns:
        docker registry name