Class AuthConfigFactory


  • public class AuthConfigFactory
    extends Object
    Factory for creating docker specific authentication configuration
    Since:
    29.07.14
    Author:
    roland
    • Constructor Summary

      Constructors 
      Constructor Description
      AuthConfigFactory​(org.codehaus.plexus.PlexusContainer container)
      Constructor which should be used during startup phase of a plugin
    • Constructor Detail

      • AuthConfigFactory

        public AuthConfigFactory​(org.codehaus.plexus.PlexusContainer container)
        Constructor which should be used during startup phase of a plugin
        Parameters:
        container - the container used for do decryption of passwords
    • Method Detail

      • setLog

        public void setLog​(Logger log)
      • createAuthConfig

        public AuthConfig createAuthConfig​(boolean isPush,
                                           boolean skipExtendedAuth,
                                           Map authConfig,
                                           org.apache.maven.settings.Settings settings,
                                           String user,
                                           String registry)
                                    throws org.apache.maven.plugin.MojoExecutionException
        Create an authentication config object which can be used for communication with a Docker registry The authentication information is looked up at various places (in this order):
        • From system properties
        • From the provided map which can contain key-value pairs
        • From the openshift settings in ~/.config/kube
        • From the Maven settings stored typically in ~/.m2/settings.xml
        • From the Docker settings stored in ~/.docker/config.json
        The following properties (prefix with 'docker.') and config key are evaluated:
        • username: User to authenticate
        • password: Password to authenticate. Can be encrypted
        • email: Optional EMail address which is send to the registry, too
        If the repository is in an aws ecr registry and skipExtendedAuth is not true, if found credentials are not from docker settings, they will be interpreted as iam credentials and exchanged for ecr credentials.
        Parameters:
        isPush - if true this AuthConfig is created for a push, if false it's for a pull
        skipExtendedAuth - if true, do not execute extended authentication methods
        authConfig - String-String Map holding configuration info from the plugin's configuration. Can be null in which case the settings are consulted.
        settings - the global Maven settings object
        user - user to check for
        registry - registry to use, might be null in which case a default registry is checked,
        Returns:
        the authentication configuration or null if none could be found
        Throws:
        org.apache.maven.plugin.MojoFailureException
        org.apache.maven.plugin.MojoExecutionException
      • hasAuthForRegistryInDockerConfig

        public static boolean hasAuthForRegistryInDockerConfig​(Logger logger,
                                                               String registry,
                                                               AuthConfigList authConfigList)
                                                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException