All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.gesellix.docker.client.authentication.FileStore.groovy Maven / Gradle / Ivy

package de.gesellix.docker.client.authentication

import static de.gesellix.docker.client.authentication.AuthConfig.EMPTY_AUTH_CONFIG

class FileStore implements CredsStore {

  private Map config

  private transient Map allAuthConfigs

  FileStore(Map config) {
    this.config = config['auths'] ? config.auths as Map : config
  }

  @Override
  AuthConfig getAuthConfig(String registry) {
    return getAuthConfigs()[registry] ?: EMPTY_AUTH_CONFIG
  }

  @Override
  Map getAuthConfigs() {
    if (!allAuthConfigs) {
      allAuthConfigs = config.findAll { it.value?.auth }.collectEntries { String registry, Map value ->
        def (username, password) = new String(value.auth.decodeBase64()).split(":")
        return [(registry): new AuthConfig(
            serveraddress: registry,
            username: username,
            password: password,
            email: value.email)]
      }
    }
    return allAuthConfigs
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy