Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions docker-java-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import javax.annotation.CheckForNull;
import java.io.Serializable;
import java.util.Base64;
import java.util.Map;

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ public String getData() {
* @see #data
*/
public SecretSpec withData(String data) {
this.data = Base64.encodeBase64String(data.getBytes());
this.data = Base64.getEncoder().encodeToString(data.getBytes());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had issues with encoders, are they 100% same?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you had issues, why did you add a test? ;)

It should be. Any idea how to test?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure with this case, but they are generally not same - with JDK encoder you have better API and you need only to select the right encoder for the purpose. They differ in splitting to lines, for example. See Base64 sources and RFC or write some trivial test to compare.

Btw, problems are usually connected with the usage String.getBytes, because it depends on default system encoding (UTF-8/ISO-8859-2/ISO-8859-1/...?).

return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.api.model.AuthConfigurations;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;

Expand All @@ -15,6 +14,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -204,7 +204,7 @@ private static void decodeAuth(AuthConfig config) throws IOException {
return;
}

String str = new String(Base64.decodeBase64(config.getAuth()), StandardCharsets.UTF_8);
String str = new String(Base64.getDecoder().decode(config.getAuth()), StandardCharsets.UTF_8);
String[] parts = str.split(":", 2);
if (parts.length != 2) {
throw new IOException("Invalid auth configuration file");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import static com.google.common.base.Preconditions.checkNotNull;

import java.io.IOException;
import java.util.Base64;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.slf4j.Logger;
Expand Down Expand Up @@ -46,7 +46,7 @@ public String toString() {

protected String registryAuth(AuthConfig authConfig) {
try {
return Base64.encodeBase64String(new ObjectMapper().writeValueAsString(authConfig).getBytes());
return Base64.getEncoder().encodeToString(new ObjectMapper().writeValueAsBytes(authConfig));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
1 change: 0 additions & 1 deletion docker-java/template.mf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Import-Template:
com.google.common.*;version="${guava.version:short}",
io.netty.*;version="${netty.version:default}";resolution:=optional,
javax.ws.rs.*;version="[2.0.0, 2.1.0)",
org.apache.commons.codec.*;version="${commons-codec.version:short}",
org.apache.commons.compress.*;version="${commons-compress.version:short}",
org.apache.commons.io.*;version="${commons-io.version:short}",
org.apache.commons.lang.*;version="${commons-lang.version:short}",
Expand Down