com.github.dockerjava.core.command.AbstrAuthCfgDockerCmd Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docker-java Show documentation
Show all versions of docker-java Show documentation
Java API Client for Docker
package com.github.dockerjava.core.command;
import static com.google.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import org.apache.commons.codec.binary.Base64;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.api.command.DockerCmd;
import com.github.dockerjava.api.command.DockerCmdExec;
import com.github.dockerjava.api.model.AuthConfig;
public abstract class AbstrAuthCfgDockerCmd, RES_T> extends
AbstrDockerCmd {
public AbstrAuthCfgDockerCmd(DockerCmdExec execution, AuthConfig authConfig) {
super(execution);
withOptionalAuthConfig(authConfig);
}
public AbstrAuthCfgDockerCmd(DockerCmdExec execution) {
super(execution);
}
private AuthConfig authConfig;
public AuthConfig getAuthConfig() {
return authConfig;
}
public T withAuthConfig(AuthConfig authConfig) {
checkNotNull(authConfig, "authConfig was not specified");
return withOptionalAuthConfig(authConfig);
}
@SuppressWarnings("unchecked")
private T withOptionalAuthConfig(AuthConfig authConfig) {
this.authConfig = authConfig;
return (T)this;
}
protected String registryAuth() {
try {
return Base64.encodeBase64String(new ObjectMapper().writeValueAsString(authConfig).getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy