This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-net.git
commit 15e58bbf74825e8b77db6520ddb1e20937b92423 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Sep 18 08:58:20 2023 -0400 Replace use of org.apache.commons.net.util.Base64 with java.util.Base64 in org.apache.commons.net.pop3 --- src/changes/changes.xml | 3 +++ .../java/org/apache/commons/net/pop3/ExtendedPOP3Client.java | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1ac9d939..8fd7e670 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -160,6 +160,9 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Gary Gregory"> Replace use of org.apache.commons.net.util.Base64 with java.util.Base64 in org.apache.commons.net.imap. </action> + <action type="fix" dev="ggregory" due-to="Gary Gregory"> + Replace use of org.apache.commons.net.util.Base64 with java.util.Base64 in org.apache.commons.net.pop3. + </action> <!-- UPDATE --> <action type="update" dev="ggregory" due-to="Dependabot"> Bump commons-parent from 54 to 62 #132, #137, #153. diff --git a/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java b/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java index 6b796a4b..7007e54f 100644 --- a/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java +++ b/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java @@ -21,12 +21,11 @@ import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; +import java.util.Base64; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -import org.apache.commons.net.util.Base64; - /** * A POP3 Cilent class with protocol and authentication extensions support (RFC2449 and RFC2195). * @@ -89,10 +88,11 @@ public class ExtendedPOP3Client extends POP3SClient { switch (method) { case PLAIN: // the server sends an empty response ("+ "), so we don't have to read it. - return sendCommand(new String(Base64.encodeBase64(("\000" + username + "\000" + password).getBytes(getCharset())), getCharset())) == POP3Reply.OK; + return sendCommand( + new String(Base64.getEncoder().encode(("\000" + username + "\000" + password).getBytes(getCharset())), getCharset())) == POP3Reply.OK; case CRAM_MD5: // get the CRAM challenge - final byte[] serverChallenge = Base64.decodeBase64(getReplyString().substring(2).trim()); + final byte[] serverChallenge = Base64.getDecoder().decode(getReplyString().substring(2).trim()); // get the Mac instance final Mac hmacMd5 = Mac.getInstance("HmacMD5"); hmacMd5.init(new SecretKeySpec(password.getBytes(getCharset()), "HmacMD5")); @@ -105,7 +105,7 @@ public class ExtendedPOP3Client extends POP3SClient { toEncode[usernameBytes.length] = ' '; System.arraycopy(hmacResult, 0, toEncode, usernameBytes.length + 1, hmacResult.length); // send the reply and read the server code: - return sendCommand(Base64.encodeBase64StringUnChunked(toEncode)) == POP3Reply.OK; + return sendCommand(Base64.getEncoder().encodeToString(toEncode)) == POP3Reply.OK; default: return false; }