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-vfs.git
commit 84af4ea0f5747a9576ce1e85567cf2991affca82 Author: Gary Gregory <[email protected]> AuthorDate: Mon Mar 2 08:09:27 2026 -0500 Deprecate UserAuthenticatorUtils.toChar(String) --- .../commons/vfs2/provider/webdav/WebdavFileProvider.java | 5 +++-- .../org/apache/commons/vfs2/provider/smb/SmbFileObject.java | 12 +++++++----- .../apache/commons/vfs2/auth/StaticUserAuthenticator.java | 8 ++++---- .../apache/commons/vfs2/provider/ftp/FTPClientWrapper.java | 5 +++-- .../apache/commons/vfs2/provider/ftps/FtpsClientWrapper.java | 5 +++-- .../apache/commons/vfs2/provider/http/HttpFileProvider.java | 5 +++-- .../commons/vfs2/provider/http4/Http4FileProvider.java | 5 +++-- .../commons/vfs2/provider/http5/Http5FileProvider.java | 5 +++-- .../apache/commons/vfs2/provider/sftp/SftpFileProvider.java | 5 +++-- .../org/apache/commons/vfs2/util/UserAuthenticatorUtils.java | 8 ++++---- src/changes/changes.xml | 1 + 11 files changed, 37 insertions(+), 27 deletions(-) diff --git a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileProvider.java b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileProvider.java index 93b57eb0a..c3df5132e 100644 --- a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileProvider.java +++ b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileProvider.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.vfs2.Capability; import org.apache.commons.vfs2.FileName; import org.apache.commons.vfs2.FileObject; @@ -90,9 +91,9 @@ public class WebdavFileProvider extends HttpFileProvider { httpClient = HttpClientFactory.createConnection(WebdavFileSystemConfigBuilder.getInstance(), "http", rootName.getHostName(), rootName.getPort(), UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))), + UserAuthenticationData.USERNAME, CharSequenceUtils.toCharArray(rootName.getUserName()))), UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))), + UserAuthenticationData.PASSWORD, CharSequenceUtils.toCharArray(rootName.getPassword()))), fsOpts); } finally { UserAuthenticatorUtils.cleanup(authData); diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java index 87b10bfa1..25b749221 100644 --- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java +++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java @@ -19,10 +19,12 @@ package org.apache.commons.vfs2.provider.smb; import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; +import java.nio.file.FileSystemException; +import javax.tools.FileObject; + +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.vfs2.FileName; -import org.apache.commons.vfs2.FileObject; -import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.FileType; import org.apache.commons.vfs2.FileTypeHasNoContentException; import org.apache.commons.vfs2.RandomAccessContent; @@ -75,13 +77,13 @@ public class SmbFileObject extends AbstractFileObject<SmbFileSystem> { if (authData != null) { auth = new NtlmPasswordAuthentication( UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(smbFileName.getDomain()))), + UserAuthenticationData.DOMAIN, CharSequenceUtils.toCharArray(smbFileName.getDomain()))), UserAuthenticatorUtils .toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, - UserAuthenticatorUtils.toChar(smbFileName.getUserName()))), + CharSequenceUtils.toCharArray(smbFileName.getUserName()))), UserAuthenticatorUtils .toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, - UserAuthenticatorUtils.toChar(smbFileName.getPassword())))); + CharSequenceUtils.toCharArray(smbFileName.getPassword())))); } // if auth == null SmbFile uses default credentials diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/auth/StaticUserAuthenticator.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/auth/StaticUserAuthenticator.java index 8e4e9c85a..ec63ae5ac 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/auth/StaticUserAuthenticator.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/auth/StaticUserAuthenticator.java @@ -18,11 +18,11 @@ package org.apache.commons.vfs2.auth; import java.util.Objects; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.vfs2.UserAuthenticationData; import org.apache.commons.vfs2.UserAuthenticator; -import org.apache.commons.vfs2.util.UserAuthenticatorUtils; /** * Provides always the same credentials data passed in with the constructor. @@ -117,11 +117,11 @@ public class StaticUserAuthenticator implements UserAuthenticator, Comparable<St final UserAuthenticationData data = new UserAuthenticationData(); for (final UserAuthenticationData.Type type : types) { if (type == UserAuthenticationData.DOMAIN) { - data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain)); + data.setData(UserAuthenticationData.DOMAIN, CharSequenceUtils.toCharArray(domain)); } else if (type == UserAuthenticationData.USERNAME) { - data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(userName)); + data.setData(UserAuthenticationData.USERNAME, CharSequenceUtils.toCharArray(userName)); } else if (type == UserAuthenticationData.PASSWORD) { - data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(password)); + data.setData(UserAuthenticationData.PASSWORD, CharSequenceUtils.toCharArray(password)); } else if (LOG.isDebugEnabled()) { LOG.debug(StaticUserAuthenticator.class.getSimpleName() + " does not support authentication data type '" + type diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java index 033d20b94..604db2fe0 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java @@ -21,6 +21,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.time.Instant; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.net.ftp.FTPClient; @@ -126,9 +127,9 @@ public class FTPClientWrapper implements FtpClient { throws FileSystemException { return FtpClientFactory.createConnection(rootFileName.getHostName(), rootFileName.getPort(), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, - UserAuthenticatorUtils.toChar(rootFileName.getUserName())), + CharSequenceUtils.toCharArray(rootFileName.getUserName())), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, - UserAuthenticatorUtils.toChar(rootFileName.getPassword())), + CharSequenceUtils.toCharArray(rootFileName.getPassword())), rootFileName.getPath(), getFileSystemOptions()); } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientWrapper.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientWrapper.java index 8aa7123e9..12ae83522 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientWrapper.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientWrapper.java @@ -16,6 +16,7 @@ */ package org.apache.commons.vfs2.provider.ftps; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPSClient; import org.apache.commons.vfs2.FileSystemException; @@ -46,9 +47,9 @@ final class FtpsClientWrapper extends FTPClientWrapper { throws FileSystemException { return FtpsClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, - UserAuthenticatorUtils.toChar(rootName.getUserName())), + CharSequenceUtils.toCharArray(rootName.getUserName())), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, - UserAuthenticatorUtils.toChar(rootName.getPassword())), + CharSequenceUtils.toCharArray(rootName.getPassword())), rootName.getPath(), getFileSystemOptions()); } } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileProvider.java index 01be1f30e..624646bb0 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileProvider.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileProvider.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.vfs2.Capability; import org.apache.commons.vfs2.FileName; import org.apache.commons.vfs2.FileSystem; @@ -75,9 +76,9 @@ public class HttpFileProvider extends AbstractOriginatingFileProvider { httpClient = HttpClientFactory.createConnection(internalScheme, rootName.getHostName(), rootName.getPort(), UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))), + UserAuthenticationData.USERNAME, CharSequenceUtils.toCharArray(rootName.getUserName()))), UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))), + UserAuthenticationData.PASSWORD, CharSequenceUtils.toCharArray(rootName.getPassword()))), fileSystemOptions); } finally { UserAuthenticatorUtils.cleanup(authData); diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileProvider.java index c10512e6c..54a6a94da 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileProvider.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileProvider.java @@ -33,6 +33,7 @@ import java.util.stream.Stream; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DurationUtils; import org.apache.commons.vfs2.Capability; @@ -241,9 +242,9 @@ public class Http4FileProvider extends AbstractOriginatingFileProvider { clientContext.setCredentialsProvider(credsProvider); final String username = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))); + UserAuthenticationData.USERNAME, CharSequenceUtils.toCharArray(rootName.getUserName()))); final String password = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))); + UserAuthenticationData.PASSWORD, CharSequenceUtils.toCharArray(rootName.getPassword()))); if (!StringUtils.isEmpty(username)) { credsProvider.setCredentials(new AuthScope(rootName.getHostName(), rootName.getPort()), diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java index ff8d8fe9a..27a711528 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileProvider.java @@ -34,6 +34,7 @@ import java.util.stream.Stream; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.vfs2.Capability; import org.apache.commons.vfs2.FileName; @@ -232,9 +233,9 @@ public class Http5FileProvider extends AbstractOriginatingFileProvider { clientContext.setCredentialsProvider(credsProvider); final String username = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))); + UserAuthenticationData.USERNAME, CharSequenceUtils.toCharArray(rootName.getUserName()))); final char[] password = UserAuthenticatorUtils.getData(authData, - UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword())); + UserAuthenticationData.PASSWORD, CharSequenceUtils.toCharArray(rootName.getPassword())); if (!StringUtils.isEmpty(username)) { // set root port diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java index d5b8bb150..8e06b3967 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.vfs2.Capability; import org.apache.commons.vfs2.FileName; import org.apache.commons.vfs2.FileSystem; @@ -63,9 +64,9 @@ public class SftpFileProvider extends AbstractOriginatingFileProvider { return SftpClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, - UserAuthenticatorUtils.toChar(rootName.getUserName())), + CharSequenceUtils.toCharArray(rootName.getUserName())), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, - UserAuthenticatorUtils.toChar(rootName.getPassword())), + CharSequenceUtils.toCharArray(rootName.getPassword())), fileSystemOptions); } catch (final Exception e) { throw new FileSystemException("vfs.provider.sftp/connect.error", rootName, e); diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java index 5db5dfc39..ef997243e 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java @@ -16,6 +16,7 @@ */ package org.apache.commons.vfs2.util; +import org.apache.commons.lang3.CharSequenceUtils; import org.apache.commons.vfs2.FileSystemOptions; import org.apache.commons.vfs2.UserAuthenticationData; import org.apache.commons.vfs2.UserAuthenticator; @@ -88,12 +89,11 @@ public final class UserAuthenticatorUtils { * * @param string The String to convert. * @return The character array. + * @deprecated Use {@link CharSequenceUtils#toCharArray(CharSequence)} instead. */ + @Deprecated public static char[] toChar(final String string) { - if (string == null) { - return null; - } - return string.toCharArray(); + return CharSequenceUtils.toCharArray(string); } /** diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 20f14dcaf..7cac4c559 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -61,6 +61,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Gary Gregory">DefaultFileMonitor now restores the current thread's interrupt flag when catching InterruptedException.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">SftpFileSystem.executeCommand(String, StringBuilder) now restores the current thread's interrupt flag when catching InterruptedException.</action> <action type="fix" dev="ggregory" due-to="Vaishnavi Kumbhar, Gary Gregory" issue="VFS-861">Http5FileProvider Basic authentication fails: UserAuthenticationData.setData(Type, char[]) should clone its array input.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate UserAuthenticatorUtils.toChar(String).</action> <!-- ADD --> <action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.sendOptions(String, String).</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add FtpFileSystemConfigBuilder.getControlEncodingCharset(FileSystemOptions) and deprecate getControlEncoding(FileSystemOptions).</action>
