From e15238dfbd409bc35e92320249d865739132d4b0 Mon Sep 17 00:00:00 2001 From: Jeremy Norris Date: Fri, 19 Jan 2024 00:36:28 -0600 Subject: [PATCH] More formatting corrections to better adhere to Google Java Style Guide. --- examples/AES.java | 7 +- examples/ChangePassphrase.java | 1 - examples/Compression.java | 3 - examples/Daemon.java | 1 - examples/Exec.java | 1 - examples/JumpHosts.java | 1 - examples/KeyGen.java | 1 - examples/KnownHosts.java | 3 - examples/Logger.java | 8 +- examples/OpenSSHConfig.java | 3 +- examples/PortForwardingL.java | 1 - examples/PortForwardingR.java | 1 - examples/ScpFrom.java | 1 - examples/ScpTo.java | 1 - examples/ScpToNoneCipher.java | 1 - examples/Sftp.java | 1 - examples/Shell.java | 3 +- examples/SocketForwardingL.java | 4 +- examples/StreamForwarding.java | 3 - examples/Subsystem.java | 5 +- examples/Sudo.java | 6 +- examples/UserAuthKI.java | 1 - examples/UserAuthPubKey.java | 2 - examples/ViaHTTP.java | 4 - examples/ViaSOCKS5.java | 3 - examples/X11Forwarding.java | 3 - src/main/java/com/jcraft/jsch/Buffer.java | 1 - src/main/java/com/jcraft/jsch/Channel.java | 3 +- .../jcraft/jsch/ChannelAgentForwarding.java | 46 +++--- .../jcraft/jsch/ChannelDirectStreamLocal.java | 7 +- .../com/jcraft/jsch/ChannelDirectTCPIP.java | 6 +- .../jcraft/jsch/ChannelForwardedTCPIP.java | 10 +- .../java/com/jcraft/jsch/ChannelSftp.java | 31 ++-- src/main/java/com/jcraft/jsch/ChannelX11.java | 6 +- .../java/com/jcraft/jsch/Compression.java | 4 +- src/main/java/com/jcraft/jsch/Identity.java | 10 +- .../java/com/jcraft/jsch/IdentityFile.java | 4 +- src/main/java/com/jcraft/jsch/JSch.java | 33 +---- .../com/jcraft/jsch/JUnixSocketFactory.java | 2 +- src/main/java/com/jcraft/jsch/KeyPair.java | 5 +- src/main/java/com/jcraft/jsch/KeyPairDSA.java | 1 - .../java/com/jcraft/jsch/KeyPairECDSA.java | 2 - .../java/com/jcraft/jsch/KeyPairPKCS8.java | 1 - .../java/com/jcraft/jsch/OpenSSHConfig.java | 2 + src/main/java/com/jcraft/jsch/PBKDF.java | 4 +- .../java/com/jcraft/jsch/PortWatcher.java | 2 +- src/main/java/com/jcraft/jsch/Session.java | 7 +- .../java/com/jcraft/jsch/SftpStatVFS.java | 4 +- .../java/com/jcraft/jsch/Slf4jLogger.java | 4 +- .../jcraft/jsch/UserAuthGSSAPIWithMIC.java | 2 - .../com/jcraft/jsch/UserAuthPassword.java | 1 - src/main/java/com/jcraft/jsch/Util.java | 6 +- .../annotations/SuppressForbiddenApi.java | 2 +- .../java/com/jcraft/jsch/jbcrypt/BCrypt.java | 26 ++-- src/main/java/com/jcraft/jsch/jce/PBKDF.java | 8 +- src/main/java/com/jcraft/jsch/jce/PBKDF2.java | 2 +- .../com/jcraft/jsch/jce/SignatureECDSAN.java | 2 +- .../java/com/jcraft/jsch/juz/Compression.java | 5 +- .../java/com/jcraft/jsch/jzlib/Adler32.java | 4 +- .../java/com/jcraft/jsch/jzlib/CRC32.java | 1 + .../com/jcraft/jsch/jzlib/Compression.java | 2 +- .../java/com/jcraft/jsch/jzlib/Deflate.java | 133 +++++++++--------- .../java/com/jcraft/jsch/jzlib/Deflater.java | 40 +++--- .../java/com/jcraft/jsch/jzlib/InfBlocks.java | 49 +++---- .../java/com/jcraft/jsch/jzlib/InfCodes.java | 42 +++--- .../java/com/jcraft/jsch/jzlib/InfTree.java | 23 ++- .../java/com/jcraft/jsch/jzlib/Inflate.java | 89 ++++++------ .../java/com/jcraft/jsch/jzlib/Inflater.java | 40 +++--- .../jsch/jzlib/InflaterInputStream.java | 2 +- .../com/jcraft/jsch/jzlib/StaticTree.java | 12 +- src/main/java/com/jcraft/jsch/jzlib/Tree.java | 20 ++- .../java/com/jcraft/jsch/jzlib/ZStream.java | 41 +++--- src/main/java9/module-info.java | 18 +-- src/test/java/com/jcraft/jsch/JSchTest.java | 2 +- src/test/java/com/jcraft/jsch/KeyPair2IT.java | 6 +- src/test/java/com/jcraft/jsch/KeyPairIT.java | 6 +- .../java/com/jcraft/jsch/KeyPairTest.java | 1 - .../java/com/jcraft/jsch/KnownHostsTest.java | 19 ++- .../com/jcraft/jsch/OpenSSHConfigTest.java | 1 - .../java/com/jcraft/jsch/SessionTest.java | 2 +- .../com/jcraft/jsch/jbcrypt/BCryptTest.java | 24 +--- 81 files changed, 371 insertions(+), 524 deletions(-) diff --git a/examples/AES.java b/examples/AES.java index 5723ea58..7a918fc9 100644 --- a/examples/AES.java +++ b/examples/AES.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to use "aes128-cbc". - * - */ +/** This program will demonstrate how to use "aes128-cbc". */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; @@ -153,5 +150,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/ChangePassphrase.java b/examples/ChangePassphrase.java index 193b1718..c1dd39ac 100644 --- a/examples/ChangePassphrase.java +++ b/examples/ChangePassphrase.java @@ -3,7 +3,6 @@ * a new private key. A passphrase will be prompted if the given private-key has been encrypted. * After successfully loading the content of the private-key, the new passphrase will be prompted * and the given private-key will be re-encrypted with that new passphrase. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.KeyPair; diff --git a/examples/Compression.java b/examples/Compression.java index d5630a96..81b1814b 100644 --- a/examples/Compression.java +++ b/examples/Compression.java @@ -2,7 +2,6 @@ * This program will demonstrate the packet compression. You will be asked username, hostname and * passwd. If everything works fine, you will get the shell prompt. In this program, all data from * sshd server to jsch will be compressed. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -152,5 +151,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/Daemon.java b/examples/Daemon.java index 197083b5..58f4c996 100644 --- a/examples/Daemon.java +++ b/examples/Daemon.java @@ -1,7 +1,6 @@ /** * This program will demonstrate how to provide a network service like inetd by using remote * port-forwarding functionality. - * */ import com.jcraft.jsch.ChannelForwardedTCPIP; import com.jcraft.jsch.ForwardedTCPIPDaemon; diff --git a/examples/Exec.java b/examples/Exec.java index 1635d68b..dc8348de 100644 --- a/examples/Exec.java +++ b/examples/Exec.java @@ -2,7 +2,6 @@ * This program will demonstrate remote exec. You will be asked username, hostname, displayname, * passwd and command. If everything works fine, given command will be invoked on the remote side * and outputs will be printed out. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/JumpHosts.java b/examples/JumpHosts.java index 905d8abc..e2bd0aaf 100644 --- a/examples/JumpHosts.java +++ b/examples/JumpHosts.java @@ -3,7 +3,6 @@ * to host2 and host3. java JumpHosts usr1@host1 usr2@host2 usr3@host3. You will be asked passwords * for those destinations. If everything works fine, you will get file lists of your home-directory * at host3. - * */ import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; diff --git a/examples/KeyGen.java b/examples/KeyGen.java index 9f1810d0..3a2cde3d 100644 --- a/examples/KeyGen.java +++ b/examples/KeyGen.java @@ -2,7 +2,6 @@ * This progam will demonstrate the keypair generation. You will be asked a passphrase for * output_keyfile. If everything works fine, you will get the keypair, output_keyfile and * output_keyfile+".pub". The private key and public key are in the OpenSSH format. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.KeyPair; diff --git a/examples/KnownHosts.java b/examples/KnownHosts.java index bc720710..7de50ce8 100644 --- a/examples/KnownHosts.java +++ b/examples/KnownHosts.java @@ -3,7 +3,6 @@ * hostname, a path for 'known_hosts' and passwd. If everything works fine, you will get the shell * prompt. In current implementation, jsch only reads 'known_hosts' for checking and does not modify * it. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.HostKey; @@ -173,5 +172,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/Logger.java b/examples/Logger.java index 862453c6..5c391004 100644 --- a/examples/Logger.java +++ b/examples/Logger.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to enable logging mechanism and get logging messages. - * - */ +/** This program will demonstrate how to enable logging mechanism and get logging messages. */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; @@ -55,6 +52,7 @@ public static void main(String[] arg) { public static class MyLogger implements com.jcraft.jsch.Logger { static java.util.Map name = new java.util.HashMap<>(); + static { name.put(DEBUG, "DEBUG: "); name.put(INFO, "INFO: "); @@ -169,5 +167,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/OpenSSHConfig.java b/examples/OpenSSHConfig.java index c9890eda..e5c7db45 100644 --- a/examples/OpenSSHConfig.java +++ b/examples/OpenSSHConfig.java @@ -2,7 +2,6 @@ * This program demonsrates how to use OpenSSHConfig class. You will be asked username, hostname and * passwd. If everything works fine, you will get the shell prompt. Output may be ugly because of * lacks of terminal-emulation, but you can issue commands. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ConfigRepository; @@ -100,7 +99,7 @@ public boolean promptYesNo(String message) { } } - public static abstract class MyUserInfo implements UserInfo, UIKeyboardInteractive { + public abstract static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { return null; diff --git a/examples/PortForwardingL.java b/examples/PortForwardingL.java index efdeaa96..c217bd99 100644 --- a/examples/PortForwardingL.java +++ b/examples/PortForwardingL.java @@ -3,7 +3,6 @@ * on the local host will be forwarded to the given remote host and port on the remote side. You * will be asked username, hostname, port:host:hostport and passwd. If everything works fine, you * will get the shell prompt. Try the port on localhost. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; diff --git a/examples/PortForwardingR.java b/examples/PortForwardingR.java index 242ca1d7..7eba1e6c 100644 --- a/examples/PortForwardingR.java +++ b/examples/PortForwardingR.java @@ -3,7 +3,6 @@ * on the remote host will be forwarded to the given host and port on the local side. You will be * asked username, hostname, port:host:hostport and passwd. If everything works fine, you will get * the shell prompt. Try the port on remote host. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; diff --git a/examples/ScpFrom.java b/examples/ScpFrom.java index bfdd86dd..611ecc5a 100644 --- a/examples/ScpFrom.java +++ b/examples/ScpFrom.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the file transfer from remote to local. If everything works fine, a * file 'file1' on 'remotehost' will copied to local 'file1'. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/ScpTo.java b/examples/ScpTo.java index 1184a170..79d09a44 100644 --- a/examples/ScpTo.java +++ b/examples/ScpTo.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the file transfer from local to remote. You will be asked passwd. * If everything works fine, a local file 'file1' will copied to 'file2' on 'remotehost'. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/ScpToNoneCipher.java b/examples/ScpToNoneCipher.java index b61bdd45..4a102b0b 100644 --- a/examples/ScpToNoneCipher.java +++ b/examples/ScpToNoneCipher.java @@ -1,7 +1,6 @@ /** * This program will demonstrate how to enable none cipher. You will be asked passwd. If everything * works fine, a local file 'file1' will copied to 'file2' on 'remotehost'. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; diff --git a/examples/Sftp.java b/examples/Sftp.java index 5de20143..8084bcdd 100644 --- a/examples/Sftp.java +++ b/examples/Sftp.java @@ -2,7 +2,6 @@ * This program will demonstrate the sftp protocol support. If everything works fine, you will get a * prompt 'sftp>'. 'help' command will show available command. In current implementation, the * destination path for 'get' and 'put' commands must be a file, not a directory. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; diff --git a/examples/Shell.java b/examples/Shell.java index 090e6148..6ba9f730 100644 --- a/examples/Shell.java +++ b/examples/Shell.java @@ -2,7 +2,6 @@ * This program enables you to connect to sshd server and get the shell prompt. You will be asked * username, hostname and passwd. If everything works fine, you will get the shell prompt. Output * may be ugly because of lacks of terminal-emulation, but you can issue commands. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -94,7 +93,7 @@ public boolean promptYesNo(String message) { } } - public static abstract class MyUserInfo implements UserInfo, UIKeyboardInteractive { + public abstract static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { return null; diff --git a/examples/SocketForwardingL.java b/examples/SocketForwardingL.java index 336d2c39..a1071a47 100644 --- a/examples/SocketForwardingL.java +++ b/examples/SocketForwardingL.java @@ -2,7 +2,6 @@ * This program enables you to connect to sshd server and forward the docker socket. You will be * asked username, hostname and passwd. If everything works fine, you will get the response code to * the _ping endpoint of the dockerd. - * */ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; @@ -77,13 +76,12 @@ public boolean promptYesNo(String message) { HttpURLConnection myURLConnection2 = (HttpURLConnection) myURL.openConnection(); System.out.println("Docker Ping http response code: " + myURLConnection2.getResponseCode()); - } catch (Exception e) { System.out.println(e); } } - public static abstract class MyUserInfo implements UserInfo, UIKeyboardInteractive { + public abstract static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { return null; diff --git a/examples/StreamForwarding.java b/examples/StreamForwarding.java index 89ca3315..7fdd4842 100644 --- a/examples/StreamForwarding.java +++ b/examples/StreamForwarding.java @@ -4,7 +4,6 @@ * command, but you don't have to assign and open a local tcp port. You will be asked username, * hostname, host:hostport and passwd. If everything works fine, System.in and System.out streams * will be forwared to remote port and you can send messages from command line. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -155,5 +154,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/Subsystem.java b/examples/Subsystem.java index ac5f7f36..2f3e85e9 100644 --- a/examples/Subsystem.java +++ b/examples/Subsystem.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to use the Subsystem channel. - * - */ +/** This program will demonstrate how to use the Subsystem channel. */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSubsystem; import com.jcraft.jsch.JSch; diff --git a/examples/Sudo.java b/examples/Sudo.java index cb42d6f3..cb3da7c8 100644 --- a/examples/Sudo.java +++ b/examples/Sudo.java @@ -1,7 +1,4 @@ -/** - * This program will demonstrate how to exec 'sudo' on the remote. - * - */ +/** This program will demonstrate how to exec 'sudo' on the remote. */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.JSch; @@ -65,7 +62,6 @@ public static void main(String[] arg) { // password prompt and use a custom one. ((ChannelExec) channel).setCommand("sudo -S -p '' " + command); - InputStream in = channel.getInputStream(); OutputStream out = channel.getOutputStream(); ((ChannelExec) channel).setErrStream(System.err); diff --git a/examples/UserAuthKI.java b/examples/UserAuthKI.java index f2e62870..81699dbf 100644 --- a/examples/UserAuthKI.java +++ b/examples/UserAuthKI.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the keyboard-interactive authentication. If the remote sshd * supports keyboard-interactive authentication, you will be prompted. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; diff --git a/examples/UserAuthPubKey.java b/examples/UserAuthPubKey.java index 03437280..adc6a3c0 100644 --- a/examples/UserAuthPubKey.java +++ b/examples/UserAuthPubKey.java @@ -2,7 +2,6 @@ * This program will demonstrate the user authentification by public key. You will be asked * username, hostname, privatekey(id_dsa) and passphrase. If everything works fine, you will get the * shell prompt. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -65,7 +64,6 @@ public static void main(String[] arg) { } } - public static class MyUserInfo implements UserInfo, UIKeyboardInteractive { @Override public String getPassword() { diff --git a/examples/ViaHTTP.java b/examples/ViaHTTP.java index ca943a96..ab4e8759 100644 --- a/examples/ViaHTTP.java +++ b/examples/ViaHTTP.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the ssh session via HTTP proxy. You will be asked username, * hostname, proxy-server and passwd. If everything works fine, you will get the shell prompt. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -156,7 +155,4 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - } - - diff --git a/examples/ViaSOCKS5.java b/examples/ViaSOCKS5.java index 06d31811..d232c97b 100644 --- a/examples/ViaSOCKS5.java +++ b/examples/ViaSOCKS5.java @@ -1,7 +1,6 @@ /** * This program will demonstrate the ssh session via SOCKS proxy. You will be asked username, * hostname, proxy-server and passwd. If everything works fine, you will get the shell prompt. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -157,5 +156,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/examples/X11Forwarding.java b/examples/X11Forwarding.java index a82438f1..5a819fe5 100644 --- a/examples/X11Forwarding.java +++ b/examples/X11Forwarding.java @@ -2,7 +2,6 @@ * This program will demonstrate X11 forwarding. You will be asked username, hostname, displayname * and passwd. If your X server does not run at 127.0.0.1, please enter correct displayname. If * everything works fine, you will get the shell prompt. Try X applications; for example, xlogo. - * */ import com.jcraft.jsch.Channel; import com.jcraft.jsch.JSch; @@ -160,5 +159,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin } } } - - diff --git a/src/main/java/com/jcraft/jsch/Buffer.java b/src/main/java/com/jcraft/jsch/Buffer.java index e19b8000..e57fef60 100644 --- a/src/main/java/com/jcraft/jsch/Buffer.java +++ b/src/main/java/com/jcraft/jsch/Buffer.java @@ -290,7 +290,6 @@ static Buffer fromBytes(byte[][] args) { return buf; } - /* * static String[] chars={ "0","1","2","3","4","5","6","7","8","9", "a","b","c","d","e","f" }; * static void dump_buffer(){ int foo; for(int i=0; i * https://raw.githubusercontent.com/openssh/openssh-portable/master/PROTOCOL */ public class ChannelDirectStreamLocal extends ChannelDirectTCPIP { - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final byte[] _type = Util.str2byte("direct-streamlocal@openssh.com"); + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final byte[] _type = Util.str2byte("direct-streamlocal@openssh.com"); private String socketPath; diff --git a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java index 37a2e94a..c1522efb 100644 --- a/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java @@ -31,9 +31,9 @@ public class ChannelDirectTCPIP extends Channel { - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final byte[] _type = Util.str2byte("direct-tcpip"); + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final byte[] _type = Util.str2byte("direct-tcpip"); String host; int port; diff --git a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java index d168b976..15de3829 100644 --- a/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java +++ b/src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java @@ -34,11 +34,11 @@ public class ChannelForwardedTCPIP extends Channel { private static Vector pool = new Vector<>(); - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; // static private final int LOCAL_WINDOW_SIZE_MAX=0x100000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final int TIMEOUT = 10 * 1000; + private static final int TIMEOUT = 10 * 1000; private Socket socket = null; private ForwardedTCPIPDaemon daemon = null; @@ -278,7 +278,7 @@ static void delPort(Session session, String address_to_bind, int rport) { // string address_to_bind (e.g. "127.0.0.1") // uint32 port number to bind packet.reset(); - buf.putByte((byte) 80/* SSH_MSG_GLOBAL_REQUEST */); + buf.putByte((byte) 80 /* SSH_MSG_GLOBAL_REQUEST */); buf.putString(Util.str2byte("cancel-tcpip-forward")); buf.putByte((byte) 0); buf.putString(Util.str2byte(address_to_bind)); @@ -315,7 +315,7 @@ private void setSocketFactory(SocketFactory factory) { ((ConfigLHost) config).factory = factory; } - static abstract class Config { + abstract static class Config { Session session; int rport; int allocated_rport; diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index 00a4d167..6c7b6e3b 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -41,8 +41,8 @@ public class ChannelSftp extends ChannelSession { - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 32 * 1024; - static private final int LOCAL_WINDOW_SIZE_MAX = (64 * LOCAL_MAXIMUM_PACKET_SIZE); + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 32 * 1024; + private static final int LOCAL_WINDOW_SIZE_MAX = (64 * LOCAL_MAXIMUM_PACKET_SIZE); private static final byte SSH_FXP_INIT = 1; private static final byte SSH_FXP_VERSION = 2; @@ -1076,12 +1076,10 @@ private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int length -= 4; int length_of_data = buf.getInt(); // length of data - /** - * Since sftp protocol version 6, "end-of-file" has been defined, - * - * byte SSH_FXP_DATA uint32 request-id string data bool end-of-file [optional] - * - * but some sftpd server will send such a field in the sftp protocol 3 ;-( + /* + * Since sftp protocol version 6, "end-of-file" has been defined, byte SSH_FXP_DATA uint32 + * request-id string data bool end-of-file [optional] but some sftpd server will send such a + * field in the sftp protocol 3 ;-( */ int optional_data = length - length_of_data; @@ -1110,7 +1108,6 @@ private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int break loop; } } - } // System.err.println("length: "+length); // length should be 0 @@ -1143,7 +1140,6 @@ private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int } } - private class RequestQueue { class OutOfOrderException extends Exception { private static final long serialVersionUID = -1L; @@ -1153,6 +1149,7 @@ class OutOfOrderException extends Exception { this.offset = offset; } } + class Request { int id; long offset; @@ -1435,12 +1432,10 @@ public int read(byte[] d, int s, int len) throws IOException { int length_of_data = buf.getInt(); rest_length -= 4; - /** - * Since sftp protocol version 6, "end-of-file" has been defined, - * - * byte SSH_FXP_DATA uint32 request-id string data bool end-of-file [optional] - * - * but some sftpd server will send such a field in the sftp protocol 3 ;-( + /* + * Since sftp protocol version 6, "end-of-file" has been defined, byte SSH_FXP_DATA uint32 + * request-id string data bool end-of-file [optional] but some sftpd server will send such + * a field in the sftp protocol 3 ;-( */ int optional_data = rest_length - length_of_data; @@ -1593,7 +1588,6 @@ public void ls(String path, LsEntrySelector selector) throws SftpException { _pattern = Util.unquote(_pattern); pattern = Util.str2byte(_pattern, fEncoding); } - } } @@ -2522,7 +2516,7 @@ private void sendOPENW(byte[] path) throws Exception { } private void sendOPENA(byte[] path) throws Exception { - sendOPEN(path, SSH_FXF_WRITE | /* SSH_FXF_APPEND| */SSH_FXF_CREAT); + sendOPEN(path, SSH_FXF_WRITE | /* SSH_FXF_APPEND | */ SSH_FXF_CREAT); } private void sendOPEN(byte[] path, int mode) throws Exception { @@ -3034,7 +3028,6 @@ public interface LsEntrySelector { public final int BREAK = 1; /** - *

* The select method will be invoked in ls method for each file entry. * If this method returns BREAK, ls will be canceled. * diff --git a/src/main/java/com/jcraft/jsch/ChannelX11.java b/src/main/java/com/jcraft/jsch/ChannelX11.java index da6683b6..92e29d26 100644 --- a/src/main/java/com/jcraft/jsch/ChannelX11.java +++ b/src/main/java/com/jcraft/jsch/ChannelX11.java @@ -32,10 +32,10 @@ class ChannelX11 extends Channel { - static private final int LOCAL_WINDOW_SIZE_MAX = 0x20000; - static private final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; + private static final int LOCAL_WINDOW_SIZE_MAX = 0x20000; + private static final int LOCAL_MAXIMUM_PACKET_SIZE = 0x4000; - static private final int TIMEOUT = 10 * 1000; + private static final int TIMEOUT = 10 * 1000; private static String host = "127.0.0.1"; private static int port = 6000; diff --git a/src/main/java/com/jcraft/jsch/Compression.java b/src/main/java/com/jcraft/jsch/Compression.java index a961efd6..0c084409 100644 --- a/src/main/java/com/jcraft/jsch/Compression.java +++ b/src/main/java/com/jcraft/jsch/Compression.java @@ -27,8 +27,8 @@ package com.jcraft.jsch; public interface Compression { - static public final int INFLATER = 0; - static public final int DEFLATER = 1; + public static final int INFLATER = 0; + public static final int DEFLATER = 1; default void init(int type, int level, Session session) { init(type, level); diff --git a/src/main/java/com/jcraft/jsch/Identity.java b/src/main/java/com/jcraft/jsch/Identity.java index f27c36bb..2520cd2c 100644 --- a/src/main/java/com/jcraft/jsch/Identity.java +++ b/src/main/java/com/jcraft/jsch/Identity.java @@ -45,12 +45,12 @@ public interface Identity { /** * Signs on data with this identity, and returns the result. + * *

* IMPORTANT NOTE:
* The {@link #getSignature(byte[], String)} method should be overridden to ensure {@code ssh-rsa} * type public keys function with the {@code rsa-sha2-256} or {@code rsa-sha2-512} signature * algorithms. - *

* * @param data data to be signed * @return the signature @@ -60,17 +60,17 @@ public interface Identity { /** * Signs on data with this identity, and returns the result. + * *

* IMPORTANT NOTE:
* The default implementation of this method simply calls {@link #getSignature(byte[])}, which * will fail with {@code ssh-rsa} type public keys when utilized with the {@code rsa-sha2-256} or * {@code rsa-sha2-512} signature algorithms:
* it exists only to maintain backwards compatibility of this interface. - *

+ * *

* This default method should be overridden by implementations to ensure the {@code rsa-sha2-256} * and {@code rsa-sha2-512} signature algorithms function correctly. - *

* * @param data data to be signed * @param alg signature algorithm to use @@ -117,8 +117,6 @@ public default boolean decrypt() { */ public boolean isEncrypted(); - /** - * Disposes internally allocated data, like byte array for the private key. - */ + /** Disposes internally allocated data, like byte array for the private key. */ public void clear(); } diff --git a/src/main/java/com/jcraft/jsch/IdentityFile.java b/src/main/java/com/jcraft/jsch/IdentityFile.java index f9aead36..caf40135 100644 --- a/src/main/java/com/jcraft/jsch/IdentityFile.java +++ b/src/main/java/com/jcraft/jsch/IdentityFile.java @@ -123,9 +123,7 @@ public boolean isEncrypted() { return kpair.isEncrypted(); } - /** - * Disposes internally allocated data, like byte array for the private key. - */ + /** Disposes internally allocated data, like byte array for the private key. */ @Override public void clear() { kpair.dispose(); diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index 14d0f656..b5d642d3 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -32,12 +32,11 @@ import java.util.Vector; public class JSch { - /** - * The version number. - */ + /** The version number. */ public static final String VERSION = Version.getVersion(); static Hashtable config = new Hashtable<>(); + static { config.put("kex", Util.getSystemProperty("jsch.kex", "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256")); @@ -269,7 +268,6 @@ public class JSch { * * @param identityRepository if null is given, the default repository, which usually * refers to ~/.ssh/, will be used. - * * @see #getIdentityRepository() */ public synchronized void setIdentityRepository(IdentityRepository identityRepository) { @@ -313,11 +311,8 @@ public JSch() {} * "user.name" will be referred. * * @param host hostname - * * @throws JSchException if username or host are invalid. - * * @return the instance of Session class. - * * @see #getSession(String username, String host, int port) * @see com.jcraft.jsch.Session * @see com.jcraft.jsch.ConfigRepository @@ -333,11 +328,8 @@ public Session getSession(String host) throws JSchException { * * @param username user name * @param host hostname - * * @throws JSchException if username or host are invalid. - * * @return the instance of Session class. - * * @see #getSession(String username, String host, int port) * @see com.jcraft.jsch.Session */ @@ -353,11 +345,8 @@ public Session getSession(String username, String host) throws JSchException { * @param username user name * @param host hostname * @param port port number - * * @throws JSchException if username or host are invalid. - * * @return the instance of Session class. - * * @see #getSession(String username, String host, int port) * @see com.jcraft.jsch.Session */ @@ -385,7 +374,6 @@ protected boolean removeSession(Session session) { * Sets the hostkey repository. * * @param hkrepo - * * @see com.jcraft.jsch.HostKeyRepository * @see com.jcraft.jsch.KnownHosts */ @@ -397,9 +385,7 @@ public void setHostKeyRepository(HostKeyRepository hkrepo) { * Sets the instance of KnownHosts, which refers to filename. * * @param filename filename of known_hosts file. - * * @throws JSchException if the given filename is invalid. - * * @see com.jcraft.jsch.KnownHosts */ public void setKnownHosts(String filename) throws JSchException { @@ -416,9 +402,7 @@ public void setKnownHosts(String filename) throws JSchException { * Sets the instance of KnownHosts generated with stream. * * @param stream the instance of InputStream from known_hosts file. - * * @throws JSchException if an I/O error occurs. - * * @see com.jcraft.jsch.KnownHosts */ public void setKnownHosts(InputStream stream) throws JSchException { @@ -436,7 +420,6 @@ public void setKnownHosts(InputStream stream) throws JSchException { * KnownHosts. * * @return current hostkey repository. - * * @see com.jcraft.jsch.HostKeyRepository * @see com.jcraft.jsch.KnownHosts */ @@ -450,9 +433,7 @@ public HostKeyRepository getHostKeyRepository() { * Sets the private key, which will be referred in the public key authentication. * * @param prvkey filename of the private key. - * * @throws JSchException if prvkey is invalid. - * * @see #addIdentity(String prvkey, String passphrase) */ public void addIdentity(String prvkey) throws JSchException { @@ -465,9 +446,7 @@ public void addIdentity(String prvkey) throws JSchException { * * @param prvkey filename of the private key. * @param passphrase passphrase for prvkey. - * * @throws JSchException if passphrase is not right. - * * @see #addIdentity(String prvkey, byte[] passphrase) */ public void addIdentity(String prvkey, String passphrase) throws JSchException { @@ -486,9 +465,7 @@ public void addIdentity(String prvkey, String passphrase) throws JSchException { * * @param prvkey filename of the private key. * @param passphrase passphrase for prvkey. - * * @throws JSchException if passphrase is not right. - * * @see #addIdentity(String prvkey, String pubkey, byte[] passphrase) */ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException { @@ -503,7 +480,6 @@ public void addIdentity(String prvkey, byte[] passphrase) throws JSchException { * @param prvkey filename of the private key. * @param pubkey filename of the public key. * @param passphrase passphrase for prvkey. - * * @throws JSchException if passphrase is not right. */ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws JSchException { @@ -519,7 +495,6 @@ public void addIdentity(String prvkey, String pubkey, byte[] passphrase) throws * @param prvkey private key in byte array. * @param pubkey public key in byte array. * @param passphrase passphrase for prvkey. - * */ public void addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passphrase) throws JSchException { @@ -533,7 +508,6 @@ public void addIdentity(String name, byte[] prvkey, byte[] pubkey, byte[] passph * * @param identity private key. * @param passphrase passphrase for identity. - * * @throws JSchException if passphrase is not right. */ public void addIdentity(Identity identity, byte[] passphrase) throws JSchException { @@ -583,7 +557,6 @@ public void removeIdentity(String name) throws JSchException { * Removes the identity from identityRepository. * * @param identity the indentity to be removed. - * * @throws JSchException if identity is invalid. */ public void removeIdentity(Identity identity) throws JSchException { @@ -594,7 +567,6 @@ public void removeIdentity(Identity identity) throws JSchException { * Lists names of identities included in the identityRepository. * * @return names of identities - * * @throws JSchException if identityReposory has problems. */ public Vector getIdentityNames() throws JSchException { @@ -665,7 +637,6 @@ public static void setConfig(String key, String value) { * Sets the logger * * @param logger logger or null if no logging should take place - * * @see com.jcraft.jsch.Logger */ public static void setLogger(Logger logger) { diff --git a/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java b/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java index af15017f..053e4947 100644 --- a/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java +++ b/src/main/java/com/jcraft/jsch/JUnixSocketFactory.java @@ -31,8 +31,8 @@ import java.nio.channels.SocketChannel; import java.nio.file.Path; import org.newsclub.net.unix.AFUNIXServerSocketChannel; -import org.newsclub.net.unix.AFUNIXSocketChannel; import org.newsclub.net.unix.AFUNIXSocketAddress; +import org.newsclub.net.unix.AFUNIXSocketChannel; public class JUnixSocketFactory implements USocketFactory { diff --git a/src/main/java/com/jcraft/jsch/KeyPair.java b/src/main/java/com/jcraft/jsch/KeyPair.java index ecdc3516..5492b469 100644 --- a/src/main/java/com/jcraft/jsch/KeyPair.java +++ b/src/main/java/com/jcraft/jsch/KeyPair.java @@ -41,6 +41,7 @@ public abstract class KeyPair { /** DEFERRED should not be be used. */ public static final int DEFERRED = -1; + public static final int ERROR = 0; public static final int DSA = 1; public static final int RSA = 2; @@ -1221,13 +1222,13 @@ private static boolean isOpenSSHPrivateKey(byte[] buf, int i, int len) { && ident.equals(Util.byte2str(Arrays.copyOfRange(buf, i, i + ident.length()))); } - static private byte a2b(byte c) { + private static byte a2b(byte c) { if ('0' <= c && c <= '9') return (byte) (c - '0'); return (byte) (c - 'a' + 10); } - static private byte b2a(byte c) { + private static byte b2a(byte c) { if (0 <= c && c <= 9) return (byte) (c + '0'); return (byte) (c - 10 + 'A'); diff --git a/src/main/java/com/jcraft/jsch/KeyPairDSA.java b/src/main/java/com/jcraft/jsch/KeyPairDSA.java index e7400f15..d030525c 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairDSA.java @@ -165,7 +165,6 @@ else if (vendor == VENDOR_OPENSSH_V1) { publicKeyComment = Util.byte2str(prvKEyBuffer.getString()); // if(P_array!=null) key_size = (new BigInteger(P_array)).bitLength(); return true; - } int index = 0; diff --git a/src/main/java/com/jcraft/jsch/KeyPairECDSA.java b/src/main/java/com/jcraft/jsch/KeyPairECDSA.java index 1d315856..c3221353 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairECDSA.java +++ b/src/main/java/com/jcraft/jsch/KeyPairECDSA.java @@ -201,7 +201,6 @@ boolean parse(byte[] plain) { prvKeyBuffer.getByte(x); prvKeyBuffer.getByte(y); - prv_array = prvKeyBuffer.getString(); publicKeyComment = Util.byte2str(prvKeyBuffer.getString()); r_array = x; @@ -209,7 +208,6 @@ boolean parse(byte[] plain) { key_size = x.length >= 64 ? 521 : (x.length >= 48 ? 384 : 256); return true; - } int index = 0; diff --git a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java index 9a2c0fce..131dd6db 100644 --- a/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java +++ b/src/main/java/com/jcraft/jsch/KeyPairPKCS8.java @@ -122,7 +122,6 @@ class KeyPairPKCS8 extends KeyPair { private static final byte[] pbeWithSHA1AndRC2CBC = {(byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x05, (byte) 0x0b}; - private KeyPair kpair = null; KeyPairPKCS8(JSch.InstanceLogger instLogger) { diff --git a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java index c56f63a8..aab20e09 100644 --- a/src/main/java/com/jcraft/jsch/OpenSSHConfig.java +++ b/src/main/java/com/jcraft/jsch/OpenSSHConfig.java @@ -45,6 +45,7 @@ /** * This class implements ConfigRepository interface, and parses OpenSSH's configuration file. The * following keywords will be recognized, + * *
    *
  • Host
  • *
  • User
  • @@ -160,6 +161,7 @@ static Hashtable getKeymap() { } private static final Hashtable keymap = new Hashtable<>(); + static { keymap.put("kex", "KexAlgorithms"); keymap.put("server_host_key", "HostKeyAlgorithms"); diff --git a/src/main/java/com/jcraft/jsch/PBKDF.java b/src/main/java/com/jcraft/jsch/PBKDF.java index abd09ce6..67e6c9cf 100644 --- a/src/main/java/com/jcraft/jsch/PBKDF.java +++ b/src/main/java/com/jcraft/jsch/PBKDF.java @@ -26,9 +26,7 @@ package com.jcraft.jsch; -/** - * Use PBKDF2 instead. - */ +/** Use PBKDF2 instead. */ @Deprecated public interface PBKDF { byte[] getKey(byte[] pass, byte[] salt, int iteration, int size); diff --git a/src/main/java/com/jcraft/jsch/PortWatcher.java b/src/main/java/com/jcraft/jsch/PortWatcher.java index 4616fc52..0508f5d5 100644 --- a/src/main/java/com/jcraft/jsch/PortWatcher.java +++ b/src/main/java/com/jcraft/jsch/PortWatcher.java @@ -37,6 +37,7 @@ class PortWatcher { private static Vector pool = new Vector<>(); private static InetAddress anyLocalAddress = null; + static { // 0.0.0.0 /* @@ -49,7 +50,6 @@ class PortWatcher { } } - Session session; int lport; int rport; diff --git a/src/main/java/com/jcraft/jsch/Session.java b/src/main/java/com/jcraft/jsch/Session.java index 4ac75dbe..8c348b44 100644 --- a/src/main/java/com/jcraft/jsch/Session.java +++ b/src/main/java/com/jcraft/jsch/Session.java @@ -40,7 +40,6 @@ import java.util.Locale; import java.util.Properties; import java.util.Vector; - import javax.crypto.AEADBadTagException; public class Session { @@ -1597,7 +1596,6 @@ private void updateKeys(KeyExchange kex) throws Exception { } } - /* * RFC 4253 7.2. Output from Key Exchange If the key length needed is longer than the output of * the HASH, the key is extended by computing HASH of the concatenation of K and H and the entire @@ -1639,7 +1637,6 @@ private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, continue; } synchronized (c) { - if (c.rwsize < length) { try { c.notifyme++; @@ -1658,7 +1655,6 @@ private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, c.rwsize -= length; break; } - } if (c.close || !c.isConnected()) { throw new IOException("channel is broken"); @@ -1786,7 +1782,7 @@ void run() { try { buf = read(buf); stimeout = 0; - } catch (InterruptedIOException/* SocketTimeoutException */ ee) { + } catch (InterruptedIOException /* SocketTimeoutException */ ee) { if (!in_kex && stimeout < serverAliveCountMax) { sendKeepAliveMsg(); stimeout++; @@ -3292,7 +3288,6 @@ private void applyConfig() throws JSchException { if (value != null) { setConfig("ClearAllForwardings", value); } - } private void applyConfigChannel(ChannelSession channel) throws JSchException { diff --git a/src/main/java/com/jcraft/jsch/SftpStatVFS.java b/src/main/java/com/jcraft/jsch/SftpStatVFS.java index 193e97b0..3054d6d3 100644 --- a/src/main/java/com/jcraft/jsch/SftpStatVFS.java +++ b/src/main/java/com/jcraft/jsch/SftpStatVFS.java @@ -71,8 +71,8 @@ static SftpStatVFS getStatVFS(Buffer buf) { int flag = (int) buf.getLong(); statvfs.namemax = buf.getLong(); - statvfs.flag = (flag & 1/* SSH2_FXE_STATVFS_ST_RDONLY */) != 0 ? 1/* ST_RDONLY */ : 0; - statvfs.flag |= (flag & 2/* SSH2_FXE_STATVFS_ST_NOSUID */) != 0 ? 2/* ST_NOSUID */ : 0; + statvfs.flag = (flag & 1 /* SSH2_FXE_STATVFS_ST_RDONLY */) != 0 ? 1 /* ST_RDONLY */ : 0; + statvfs.flag |= (flag & 2 /* SSH2_FXE_STATVFS_ST_NOSUID */) != 0 ? 2 /* ST_NOSUID */ : 0; return statvfs; } diff --git a/src/main/java/com/jcraft/jsch/Slf4jLogger.java b/src/main/java/com/jcraft/jsch/Slf4jLogger.java index c24c1563..0fccd2c9 100644 --- a/src/main/java/com/jcraft/jsch/Slf4jLogger.java +++ b/src/main/java/com/jcraft/jsch/Slf4jLogger.java @@ -3,9 +3,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * JSch logger to log entries using the SLF4J framework - */ +/** JSch logger to log entries using the SLF4J framework */ public class Slf4jLogger implements com.jcraft.jsch.Logger { private static final Logger logger = LoggerFactory.getLogger(JSch.class); diff --git a/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java b/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java index 7a10780e..92e9cd76 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java +++ b/src/main/java/com/jcraft/jsch/UserAuthGSSAPIWithMIC.java @@ -221,5 +221,3 @@ public boolean start(Session session) throws Exception { return false; } } - - diff --git a/src/main/java/com/jcraft/jsch/UserAuthPassword.java b/src/main/java/com/jcraft/jsch/UserAuthPassword.java index 111e0def..375f11e4 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthPassword.java +++ b/src/main/java/com/jcraft/jsch/UserAuthPassword.java @@ -174,7 +174,6 @@ public boolean start(Session session) throws Exception { Util.bzero(password); password = null; } - } } finally { diff --git a/src/main/java/com/jcraft/jsch/Util.java b/src/main/java/com/jcraft/jsch/Util.java index dde331e7..b7ef747d 100644 --- a/src/main/java/com/jcraft/jsch/Util.java +++ b/src/main/java/com/jcraft/jsch/Util.java @@ -28,8 +28,8 @@ import java.io.File; import java.io.FileInputStream; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketTimeoutException; @@ -152,7 +152,7 @@ static boolean glob(byte[] pattern, byte[] name) { return glob0(pattern, 0, name, 0); } - static private boolean glob0(byte[] pattern, int pattern_index, byte[] name, int name_index) { + private static boolean glob0(byte[] pattern, int pattern_index, byte[] name, int name_index) { if (name.length > 0 && name[0] == '.') { if (pattern.length > 0 && pattern[0] == '.') { if (pattern.length == 2 && pattern[1] == '*') @@ -164,7 +164,7 @@ static private boolean glob0(byte[] pattern, int pattern_index, byte[] name, int return glob(pattern, pattern_index, name, name_index); } - static private boolean glob(byte[] pattern, int pattern_index, byte[] name, int name_index) { + private static boolean glob(byte[] pattern, int pattern_index, byte[] name, int name_index) { // System.err.println("glob: "+new String(pattern)+", "+pattern_index+" "+new String(name)+", // "+name_index); diff --git a/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java b/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java index b3494689..fb9a3569 100644 --- a/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java +++ b/src/main/java/com/jcraft/jsch/annotations/SuppressForbiddenApi.java @@ -1,9 +1,9 @@ package com.jcraft.jsch.annotations; +import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.lang.annotation.ElementType; @Retention(RetentionPolicy.CLASS) @Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, diff --git a/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java b/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java index 4f4dab88..332f879b 100644 --- a/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java +++ b/src/main/java/com/jcraft/jsch/jbcrypt/BCrypt.java @@ -23,20 +23,25 @@ /** * BCrypt implements OpenBSD-style Blowfish password hashing using the scheme described in "A * Future-Adaptable Password Scheme" by Niels Provos and David Mazieres. + * *

    * This password hashing system tries to thwart off-line password cracking using a * computationally-intensive hashing algorithm, based on Bruce Schneier's Blowfish cipher. The work * factor of the algorithm is parameterised, so it can be increased as computers get faster. + * *

    * Usage is really simple. To hash a password for the first time, call the hashpw method with a * random salt, like this: + * *

    * * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
    *
    + * *

    * To check whether a plaintext password matches one that has been hashed previously, use the * checkpw method: + * *

    * * if (BCrypt.checkpw(candidate_password, stored_hash))
    @@ -44,14 +49,17 @@ * else
    *     System.out.println("It does not match");
    *
    + * *

    * The gensalt() method takes an optional parameter (log_rounds) that determines the computational * complexity of the hashing: + * *

    * * String strong_salt = BCrypt.gensalt(10)
    * String stronger_salt = BCrypt.gensalt(12)
    *
    + * *

    * The amount of work increases exponentially (2**log_rounds), so each increment is twice as much * work. The default log_rounds is 10, and the valid range is 4 to 30. @@ -226,17 +234,17 @@ public class BCrypt { // bcrypt IV: "OrpheanBeholderScryDoubt". The C implementation calls // this "ciphertext", but it is really plaintext or an IV. We keep // the name to make code comparison easier. - static private final int bf_crypt_ciphertext[] = + private static final int bf_crypt_ciphertext[] = {0x4f727068, 0x65616e42, 0x65686f6c, 0x64657253, 0x63727944, 0x6f756274}; // Table for Base64 encoding - static private final char base64_code[] = {'.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', + private static final char base64_code[] = {'.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; // Table for Base64 decoding - static private final byte index_64[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + private static final byte index_64[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, @@ -400,9 +408,7 @@ private static int streamtoword(byte data[], int offp[]) { return word; } - /** - * Initialise the Blowfish key schedule - */ + /** Initialise the Blowfish key schedule */ private void init_key() { P = P_orig.clone(); S = S_orig.clone(); @@ -468,9 +474,7 @@ private void ekskey(byte data[], byte key[]) { } } - /** - * Compatibility with new OpenBSD function. - */ + /** Compatibility with new OpenBSD function. */ public void hash(byte[] hpass, byte[] hsalt, byte[] output) { init_key(); ekskey(hsalt, hpass); @@ -496,9 +500,7 @@ public void hash(byte[] hpass, byte[] hsalt, byte[] output) { } } - /** - * Compatibility with new OpenBSD function. - */ + /** Compatibility with new OpenBSD function. */ public void pbkdf(byte[] password, byte[] salt, int rounds, byte[] output) { try { MessageDigest sha512 = MessageDigest.getInstance("SHA-512"); diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF.java b/src/main/java/com/jcraft/jsch/jce/PBKDF.java index 85a031df..2cfb574b 100644 --- a/src/main/java/com/jcraft/jsch/jce/PBKDF.java +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF.java @@ -26,14 +26,12 @@ package com.jcraft.jsch.jce; -import java.security.spec.InvalidKeySpecException; import java.security.NoSuchAlgorithmException; -import javax.crypto.spec.PBEKeySpec; +import java.security.spec.InvalidKeySpecException; import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; -/** - * Use PBKDF2 instead. - */ +/** Use PBKDF2 instead. */ @Deprecated public class PBKDF implements com.jcraft.jsch.PBKDF { @Override diff --git a/src/main/java/com/jcraft/jsch/jce/PBKDF2.java b/src/main/java/com/jcraft/jsch/jce/PBKDF2.java index 527661f4..8279d69a 100644 --- a/src/main/java/com/jcraft/jsch/jce/PBKDF2.java +++ b/src/main/java/com/jcraft/jsch/jce/PBKDF2.java @@ -27,8 +27,8 @@ package com.jcraft.jsch.jce; import java.security.spec.InvalidKeySpecException; -import javax.crypto.spec.PBEKeySpec; import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; abstract class PBKDF2 implements com.jcraft.jsch.PBKDF2 { private SecretKeyFactory skf; diff --git a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java index 40c2b6df..307a043f 100644 --- a/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java +++ b/src/main/java/com/jcraft/jsch/jce/SignatureECDSAN.java @@ -108,7 +108,7 @@ public byte[] sign() throws Exception { // so we have to convert it. if (sig[0] == 0x30 && // in ASN.1 ((sig[1] + 2 == sig.length) - || ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length))) {// 2bytes for len + || ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length))) { // 2bytes for len int index = 3; if ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length) diff --git a/src/main/java/com/jcraft/jsch/juz/Compression.java b/src/main/java/com/jcraft/jsch/juz/Compression.java index ad32869a..990c40e3 100644 --- a/src/main/java/com/jcraft/jsch/juz/Compression.java +++ b/src/main/java/com/jcraft/jsch/juz/Compression.java @@ -11,6 +11,7 @@ /** * This example demonstrates the packet compression without using jzlib[1]. * + *

    * The ssh protocol adopts zlib[2] for the packet compression. Fortunately, JDK has provided wrapper * classes for zlib(j.u.z.{Deflater, Inflater}), but it does not expose enough functionality of * zlib, unfortunately; it must not allow to compress data with SYNC_FLUSH. So, JSch has been using @@ -18,12 +19,12 @@ * j.u.z.Deflater, and SYNC_FLUSH has been supported at last. This example shows how to enable the * packet compression by using JDK's java.util.zip package. * - * + *

    * [1] http://www.jcraft.com/jzlib/ [2] http://www.zlib.net/ [3] * https://bugs.openjdk.java.net/browse/JDK-4206909 */ public class Compression implements com.jcraft.jsch.Compression { - static private final int BUF_SIZE = 4096; + private static final int BUF_SIZE = 4096; private final int buffer_margin = 32 + 20; // AES256 + HMACSHA1 private Deflater deflater; private Inflater inflater; diff --git a/src/main/java/com/jcraft/jsch/jzlib/Adler32.java b/src/main/java/com/jcraft/jsch/jzlib/Adler32.java index 6fbfad83..a20b8907 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Adler32.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Adler32.java @@ -33,9 +33,9 @@ final class Adler32 implements Checksum { // largest prime smaller than 65536 - static final private int BASE = 65521; + private static final int BASE = 65521; // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 - static final private int NMAX = 5552; + private static final int NMAX = 5552; private long s1 = 1L; private long s2 = 0L; diff --git a/src/main/java/com/jcraft/jsch/jzlib/CRC32.java b/src/main/java/com/jcraft/jsch/jzlib/CRC32.java index 7c311a8d..6e9591ec 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/CRC32.java +++ b/src/main/java/com/jcraft/jsch/jzlib/CRC32.java @@ -37,6 +37,7 @@ final class CRC32 implements Checksum { */ private int v = 0; private static int[] crc_table = null; + static { crc_table = new int[256]; for (int n = 0; n < 256; n++) { diff --git a/src/main/java/com/jcraft/jsch/jzlib/Compression.java b/src/main/java/com/jcraft/jsch/jzlib/Compression.java index 747b5eca..279ee189 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Compression.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Compression.java @@ -33,7 +33,7 @@ import java.util.function.Supplier; public class Compression implements com.jcraft.jsch.Compression { - static private final int BUF_SIZE = 4096; + private static final int BUF_SIZE = 4096; private final int buffer_margin = 32 + 20; // AES256 + HMACSHA1 private Deflater deflater; private Inflater inflater; diff --git a/src/main/java/com/jcraft/jsch/jzlib/Deflate.java b/src/main/java/com/jcraft/jsch/jzlib/Deflate.java index b79b22cc..4e15b04c 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Deflate.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Deflate.java @@ -32,12 +32,12 @@ final class Deflate implements Cloneable { - static final private int MAX_MEM_LEVEL = 9; + private static final int MAX_MEM_LEVEL = 9; - static final private int Z_DEFAULT_COMPRESSION = -1; + private static final int Z_DEFAULT_COMPRESSION = -1; - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_MEM_LEVEL = 8; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_MEM_LEVEL = 8; static class Config { int good_length; // reduce lazy search above this match length @@ -55,10 +55,11 @@ static class Config { } } - static final private int STORED = 0; - static final private int FAST = 1; - static final private int SLOW = 2; - static final private Config[] config_table; + private static final int STORED = 0; + private static final int FAST = 1; + private static final int SLOW = 2; + private static final Config[] config_table; + static { config_table = new Config[10]; // good lazy nice chain @@ -75,7 +76,7 @@ static class Config { config_table[9] = new Config(32, 258, 258, 4096, SLOW); } - static final private String[] z_errmsg = {"need dictionary", // Z_NEED_DICT 2 + private static final String[] z_errmsg = {"need dictionary", // Z_NEED_DICT 2 "stream end", // Z_STREAM_END 1 "", // Z_OK 0 "file error", // Z_ERRNO (-1) @@ -87,80 +88,80 @@ static class Config { ""}; // block not completed, need more input or more output - static final private int NeedMore = 0; + private static final int NeedMore = 0; // block flush performed - static final private int BlockDone = 1; + private static final int BlockDone = 1; // finish started, need only more output at next deflate - static final private int FinishStarted = 2; + private static final int FinishStarted = 2; // finish done, accept no more input or output - static final private int FinishDone = 3; + private static final int FinishDone = 3; // preset dictionary flag in zlib header - static final private int PRESET_DICT = 0x20; - - static final private int Z_FILTERED = 1; - static final private int Z_HUFFMAN_ONLY = 2; - static final private int Z_DEFAULT_STRATEGY = 0; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; - - static final private int INIT_STATE = 42; - static final private int BUSY_STATE = 113; - static final private int FINISH_STATE = 666; + private static final int PRESET_DICT = 0x20; + + private static final int Z_FILTERED = 1; + private static final int Z_HUFFMAN_ONLY = 2; + private static final int Z_DEFAULT_STRATEGY = 0; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; + + private static final int INIT_STATE = 42; + private static final int BUSY_STATE = 113; + private static final int FINISH_STATE = 666; // The deflate compression method - static final private int Z_DEFLATED = 8; + private static final int Z_DEFLATED = 8; - static final private int STORED_BLOCK = 0; - static final private int STATIC_TREES = 1; - static final private int DYN_TREES = 2; + private static final int STORED_BLOCK = 0; + private static final int STATIC_TREES = 1; + private static final int DYN_TREES = 2; // The three kinds of block type - static final private int Z_BINARY = 0; - static final private int Z_ASCII = 1; - static final private int Z_UNKNOWN = 2; + private static final int Z_BINARY = 0; + private static final int Z_ASCII = 1; + private static final int Z_UNKNOWN = 2; - static final private int Buf_size = 8 * 2; + private static final int Buf_size = 8 * 2; // repeat previous bit length 3-6 times (2 bits of repeat count) - static final private int REP_3_6 = 16; + private static final int REP_3_6 = 16; // repeat a zero length 3-10 times (3 bits of repeat count) - static final private int REPZ_3_10 = 17; + private static final int REPZ_3_10 = 17; // repeat a zero length 11-138 times (7 bits of repeat count) - static final private int REPZ_11_138 = 18; + private static final int REPZ_11_138 = 18; - static final private int MIN_MATCH = 3; - static final private int MAX_MATCH = 258; - static final private int MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); + private static final int MIN_MATCH = 3; + private static final int MAX_MATCH = 258; + private static final int MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); - static final private int MAX_BITS = 15; - static final private int D_CODES = 30; - static final private int BL_CODES = 19; - static final private int LENGTH_CODES = 29; - static final private int LITERALS = 256; - static final private int L_CODES = (LITERALS + 1 + LENGTH_CODES); - static final private int HEAP_SIZE = (2 * L_CODES + 1); + private static final int MAX_BITS = 15; + private static final int D_CODES = 30; + private static final int BL_CODES = 19; + private static final int LENGTH_CODES = 29; + private static final int LITERALS = 256; + private static final int L_CODES = (LITERALS + 1 + LENGTH_CODES); + private static final int HEAP_SIZE = (2 * L_CODES + 1); - static final private int END_BLOCK = 256; + private static final int END_BLOCK = 256; ZStream strm; // pointer back to this zlib stream int status; // as the name implies @@ -487,7 +488,6 @@ int build_bl_tree() { return max_blindex; } - // Send the header for a block using dynamic Huffman trees: the counts, the // lengths of the bit length codes, the literal tree and the distance tree. // IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. @@ -572,13 +572,13 @@ final void put_byte(byte c) { } final void put_short(int w) { - put_byte((byte) (w/* &0xff */)); + put_byte((byte) (w /* &0xff */)); put_byte((byte) (w >>> 8)); } final void putShortMSB(int b) { put_byte((byte) (b >> 8)); - put_byte((byte) (b/* &0xff */)); + put_byte((byte) (b /* &0xff */)); } final void send_code(int c, short[] tree) { @@ -629,7 +629,6 @@ void _tr_align() { last_eob_len = 7; } - // Save the match info and tally the frequency counts. Return true if // the current block must be flushed. boolean _tr_tally(int dist, // distance of matched string @@ -835,7 +834,6 @@ int deflate_stored(int flush) { flush_block_only(false); if (strm.avail_out == 0) return NeedMore; - } // Flush if we may have to slide, otherwise block_start may become @@ -869,7 +867,7 @@ void _tr_flush_block(int buf, // input block, or NULL if too old int stored_len, // length of input block boolean eof // true if this is the last block for a file ) { - int opt_lenb, static_lenb;// opt_len and static_len in bytes + int opt_lenb, static_lenb; // opt_len and static_len in bytes int max_blindex = 0; // index of last bit length code of non zero freq // Build the Huffman trees unless a stored block is forced @@ -1541,7 +1539,6 @@ int deflate(int flush) { status = BUSY_STATE; putShortMSB(header); - // Save the adler32 of the preset dictionary: if (strstart != 0) { long adler = strm.adler.getValue(); @@ -1620,7 +1617,7 @@ int deflate(int flush) { // as a special marker by inflate_sync(). if (flush == Z_FULL_FLUSH) { // state.head[s.hash_size-1]=0; - for (int i = 0; i < hash_size/*-1*/; i++) // forget history + for (int i = 0; i < hash_size /*-1*/; i++) // forget history head[i] = 0; } } diff --git a/src/main/java/com/jcraft/jsch/jzlib/Deflater.java b/src/main/java/com/jcraft/jsch/jzlib/Deflater.java index af2a74da..0941a214 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Deflater.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Deflater.java @@ -32,26 +32,26 @@ final class Deflater extends ZStream { - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_WBITS = MAX_WBITS; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int MAX_MEM_LEVEL = 9; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_WBITS = MAX_WBITS; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int MAX_MEM_LEVEL = 9; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; private boolean finished = false; diff --git a/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java b/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java index 02a8aba6..458ff5d2 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InfBlocks.java @@ -31,10 +31,10 @@ package com.jcraft.jsch.jzlib; final class InfBlocks { - static final private int MANY = 1440; + private static final int MANY = 1440; // And'ing with mask[n] masks the lower n bits - static final private int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, + private static final int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff}; @@ -42,26 +42,26 @@ final class InfBlocks { static final int[] border = { // Order of the bit length code lengths 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; - - static final private int TYPE = 0; // get type bits (3, including end bit) - static final private int LENS = 1; // get lengths for stored - static final private int STORED = 2;// processing stored block - static final private int TABLE = 3; // get table lengths - static final private int BTREE = 4; // get bit lengths tree for a dynamic block - static final private int DTREE = 5; // get length, distance trees for a dynamic block - static final private int CODES = 6; // processing fixed or dynamic block - static final private int DRY = 7; // output remaining window bytes - static final private int DONE = 8; // finished last block, done - static final private int BAD = 9; // ot a data error--stuck here + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; + + private static final int TYPE = 0; // get type bits (3, including end bit) + private static final int LENS = 1; // get lengths for stored + private static final int STORED = 2; // processing stored block + private static final int TABLE = 3; // get table lengths + private static final int BTREE = 4; // get bit lengths tree for a dynamic block + private static final int DTREE = 5; // get length, distance trees for a dynamic block + private static final int CODES = 6; // processing fixed or dynamic block + private static final int DRY = 7; // output remaining window bytes + private static final int DONE = 8; // finished last block, done + private static final int BAD = 9; // ot a data error--stuck here int mode; // current inflate_block mode @@ -151,7 +151,6 @@ int proc(int r) { while (true) { switch (mode) { case TYPE: - while (k < (3)) { if (n != 0) { r = Z_OK; @@ -197,7 +196,6 @@ int proc(int r) { mode = CODES; break; case 2: // dynamic - { b >>>= (3); k -= (3); @@ -206,7 +204,6 @@ int proc(int r) { mode = TABLE; break; case 3: // illegal - { b >>>= (3); k -= (3); @@ -225,7 +222,6 @@ int proc(int r) { } break; case LENS: - while (k < (32)) { if (n != 0) { r = Z_OK; @@ -313,7 +309,6 @@ int proc(int r) { mode = last != 0 ? DRY : TYPE; break; case TABLE: - while (k < (14)) { if (n != 0) { r = Z_OK; diff --git a/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java b/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java index 028b222e..edfd0891 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InfCodes.java @@ -32,33 +32,33 @@ final class InfCodes { - static final private int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, + private static final int[] inflate_mask = {0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff}; - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; // waiting for "i:"=input, // "o:"=output, // "x:"=nothing - static final private int START = 0; // x: set up for LEN - static final private int LEN = 1; // i: get length/literal/eob next - static final private int LENEXT = 2; // i: getting length extra (have base) - static final private int DIST = 3; // i: get distance next - static final private int DISTEXT = 4;// i: getting distance extra - static final private int COPY = 5; // o: copying bytes in window, waiting for space - static final private int LIT = 6; // o: got literal, waiting for output space - static final private int WASH = 7; // o: got eob, possibly still output waiting - static final private int END = 8; // x: got eob and all data flushed - static final private int BADCODE = 9;// x: got error + private static final int START = 0; // x: set up for LEN + private static final int LEN = 1; // i: get length/literal/eob next + private static final int LENEXT = 2; // i: getting length extra (have base) + private static final int DIST = 3; // i: get distance next + private static final int DISTEXT = 4; // i: getting distance extra + private static final int COPY = 5; // o: copying bytes in window, waiting for space + private static final int LIT = 6; // o: got literal, waiting for output space + private static final int WASH = 7; // o: got eob, possibly still output waiting + private static final int END = 8; // x: got eob and all data flushed + private static final int BADCODE = 9; // x: got error int mode; // current inflate_codes mode @@ -433,7 +433,6 @@ int proc(int r) { return s.inflate_flush(r); case BADCODE: // x: got error - r = Z_DATA_ERROR; s.bitb = b; @@ -599,7 +598,6 @@ int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, } r = 0; // copy rest from start of window } - } // copy all or what's left diff --git a/src/main/java/com/jcraft/jsch/jzlib/InfTree.java b/src/main/java/com/jcraft/jsch/jzlib/InfTree.java index 0c8f0ba0..26b6fa6d 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InfTree.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InfTree.java @@ -32,17 +32,17 @@ final class InfTree { - static final private int MANY = 1440; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MANY = 1440; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; static final int fixed_bl = 9; static final int fixed_bd = 5; @@ -77,7 +77,6 @@ final class InfTree { 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, - 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, diff --git a/src/main/java/com/jcraft/jsch/jzlib/Inflate.java b/src/main/java/com/jcraft/jsch/jzlib/Inflate.java index b6f487fc..c937d6a9 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Inflate.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Inflate.java @@ -34,10 +34,10 @@ final class Inflate { - static final private int MAX_WBITS = 15; // 32K LZ77 window + private static final int MAX_WBITS = 15; // 32K LZ77 window // preset dictionary flag in zlib header - static final private int PRESET_DICT = 0x20; + private static final int PRESET_DICT = 0x20; static final int Z_NO_FLUSH = 0; static final int Z_PARTIAL_FLUSH = 1; @@ -45,43 +45,43 @@ final class Inflate { static final int Z_FULL_FLUSH = 3; static final int Z_FINISH = 4; - static final private int Z_DEFLATED = 8; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; - - static final private int METHOD = 0; // waiting for method byte - static final private int FLAG = 1; // waiting for flag byte - static final private int DICT4 = 2; // four dictionary check bytes to go - static final private int DICT3 = 3; // three dictionary check bytes to go - static final private int DICT2 = 4; // two dictionary check bytes to go - static final private int DICT1 = 5; // one dictionary check byte to go - static final private int DICT0 = 6; // waiting for inflateSetDictionary - static final private int BLOCKS = 7; // decompressing blocks - static final private int CHECK4 = 8; // four check bytes to go - static final private int CHECK3 = 9; // three check bytes to go - static final private int CHECK2 = 10; // two check bytes to go - static final private int CHECK1 = 11; // one check byte to go - static final private int DONE = 12; // finished check, done - static final private int BAD = 13; // got an error--stay here - - static final private int HEAD = 14; - static final private int LENGTH = 15; - static final private int TIME = 16; - static final private int OS = 17; - static final private int EXLEN = 18; - static final private int EXTRA = 19; - static final private int NAME = 20; - static final private int COMMENT = 21; - static final private int HCRC = 22; - static final private int FLAGS = 23; + private static final int Z_DEFLATED = 8; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; + + private static final int METHOD = 0; // waiting for method byte + private static final int FLAG = 1; // waiting for flag byte + private static final int DICT4 = 2; // four dictionary check bytes to go + private static final int DICT3 = 3; // three dictionary check bytes to go + private static final int DICT2 = 4; // two dictionary check bytes to go + private static final int DICT1 = 5; // one dictionary check byte to go + private static final int DICT0 = 6; // waiting for inflateSetDictionary + private static final int BLOCKS = 7; // decompressing blocks + private static final int CHECK4 = 8; // four check bytes to go + private static final int CHECK3 = 9; // three check bytes to go + private static final int CHECK2 = 10; // two check bytes to go + private static final int CHECK1 = 11; // one check byte to go + private static final int DONE = 12; // finished check, done + private static final int BAD = 13; // got an error--stay here + + private static final int HEAD = 14; + private static final int LENGTH = 15; + private static final int TIME = 16; + private static final int OS = 17; + private static final int EXLEN = 18; + private static final int EXTRA = 19; + private static final int NAME = 20; + private static final int COMMENT = 21; + private static final int HCRC = 22; + private static final int FLAGS = 23; static final int INFLATE_ANY = 0x40000000; @@ -288,7 +288,6 @@ int inflate(int f) { } this.mode = DICT4; case DICT4: - if (z.avail_in == 0) return r; r = f; @@ -298,7 +297,6 @@ int inflate(int f) { this.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & 0xff000000L; this.mode = DICT3; case DICT3: - if (z.avail_in == 0) return r; r = f; @@ -308,7 +306,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L; this.mode = DICT2; case DICT2: - if (z.avail_in == 0) return r; r = f; @@ -318,7 +315,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L; this.mode = DICT1; case DICT1: - if (z.avail_in == 0) return r; r = f; @@ -356,7 +352,6 @@ int inflate(int f) { } this.mode = CHECK4; case CHECK4: - if (z.avail_in == 0) return r; r = f; @@ -366,7 +361,6 @@ int inflate(int f) { this.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & 0xff000000L; this.mode = CHECK3; case CHECK3: - if (z.avail_in == 0) return r; r = f; @@ -376,7 +370,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L; this.mode = CHECK2; case CHECK2: - if (z.avail_in == 0) return r; r = f; @@ -386,7 +379,6 @@ int inflate(int f) { this.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L; this.mode = CHECK1; case CHECK1: - if (z.avail_in == 0) return r; r = f; @@ -447,7 +439,6 @@ int inflate(int f) { return Z_DATA_ERROR; case FLAGS: - try { r = readBytes(2, r, f); } catch (Return e) { @@ -625,7 +616,7 @@ int inflateSetDictionary(byte[] dictionary, int dictLength) { return Z_OK; } - static private byte[] mark = {(byte) 0, (byte) 0, (byte) 0xff, (byte) 0xff}; + private static byte[] mark = {(byte) 0, (byte) 0, (byte) 0xff, (byte) 0xff}; int inflateSync() { int n; // number of bytes to look at diff --git a/src/main/java/com/jcraft/jsch/jzlib/Inflater.java b/src/main/java/com/jcraft/jsch/jzlib/Inflater.java index 6e8d97d7..d4aede85 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Inflater.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Inflater.java @@ -32,26 +32,26 @@ final class Inflater extends ZStream { - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_WBITS = MAX_WBITS; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int MAX_MEM_LEVEL = 9; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_WBITS = MAX_WBITS; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int MAX_MEM_LEVEL = 9; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; private int param_w = -1; private JZlib.WrapperType param_wrapperType = null; diff --git a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java index a6f08be2..28e92360 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java +++ b/src/main/java/com/jcraft/jsch/jzlib/InflaterInputStream.java @@ -243,7 +243,7 @@ void readHeader() throws IOException { throw new IOException("no input"); inflater.setInput(b1); err = inflater.inflate(JZlib.Z_NO_FLUSH); - if (err != 0/* Z_OK */) + if (err != 0 /* Z_OK */) throw new IOException(inflater.msg); } while (inflater.istate.inParsingHeader()); } diff --git a/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java b/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java index 41f8fcc7..12a1f863 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java +++ b/src/main/java/com/jcraft/jsch/jzlib/StaticTree.java @@ -31,13 +31,13 @@ package com.jcraft.jsch.jzlib; final class StaticTree { - static final private int MAX_BITS = 15; + private static final int MAX_BITS = 15; - static final private int BL_CODES = 19; - static final private int D_CODES = 30; - static final private int LITERALS = 256; - static final private int LENGTH_CODES = 29; - static final private int L_CODES = (LITERALS + 1 + LENGTH_CODES); + private static final int BL_CODES = 19; + private static final int D_CODES = 30; + private static final int LITERALS = 256; + private static final int LENGTH_CODES = 29; + private static final int L_CODES = (LITERALS + 1 + LENGTH_CODES); // Bit length codes must not exceed MAX_BL_BITS bits static final int MAX_BL_BITS = 7; diff --git a/src/main/java/com/jcraft/jsch/jzlib/Tree.java b/src/main/java/com/jcraft/jsch/jzlib/Tree.java index abb55a4e..9668bdf2 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/Tree.java +++ b/src/main/java/com/jcraft/jsch/jzlib/Tree.java @@ -31,13 +31,13 @@ package com.jcraft.jsch.jzlib; final class Tree { - static final private int MAX_BITS = 15; - static final private int BL_CODES = 19; - static final private int D_CODES = 30; - static final private int LITERALS = 256; - static final private int LENGTH_CODES = 29; - static final private int L_CODES = (LITERALS + 1 + LENGTH_CODES); - static final private int HEAP_SIZE = (2 * L_CODES + 1); + private static final int MAX_BITS = 15; + private static final int BL_CODES = 19; + private static final int D_CODES = 30; + private static final int LITERALS = 256; + private static final int LENGTH_CODES = 29; + private static final int L_CODES = (LITERALS + 1 + LENGTH_CODES); + private static final int HEAP_SIZE = (2 * L_CODES + 1); // Bit length codes must not exceed MAX_BL_BITS bits static final int MAX_BL_BITS = 7; @@ -67,7 +67,6 @@ final class Tree { static final byte[] bl_order = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - // The lengths of the bit length codes are sent in order of decreasing // probability, to avoid transmitting the lengths for unused bit // length codes. @@ -304,7 +303,7 @@ void build_tree(Deflate s) { // the given tree and the field len is set for all tree elements. // OUT assertion: the field code is set for all tree elements of non // zero code length. - private final static void gen_codes(short[] tree, // the tree to decorate + private static final void gen_codes(short[] tree, // the tree to decorate int max_code, // largest code with non zero frequency short[] bl_count, // number of codes at each bit length short[] next_code) { @@ -337,7 +336,7 @@ private final static void gen_codes(short[] tree, // the tree to decorate // Reverse the first len bits of a code, using straightforward code (a faster // method would use a table) // IN assertion: 1 <= len <= 15 - private final static int bi_reverse(int code, // the value to invert + private static final int bi_reverse(int code, // the value to invert int len // its bit length ) { int res = 0; @@ -349,4 +348,3 @@ private final static int bi_reverse(int code, // the value to invert return res >>> 1; } } - diff --git a/src/main/java/com/jcraft/jsch/jzlib/ZStream.java b/src/main/java/com/jcraft/jsch/jzlib/ZStream.java index 5064ca3e..bffc0938 100644 --- a/src/main/java/com/jcraft/jsch/jzlib/ZStream.java +++ b/src/main/java/com/jcraft/jsch/jzlib/ZStream.java @@ -32,26 +32,26 @@ class ZStream { - static final private int MAX_WBITS = 15; // 32K LZ77 window - static final private int DEF_WBITS = MAX_WBITS; - - static final private int Z_NO_FLUSH = 0; - static final private int Z_PARTIAL_FLUSH = 1; - static final private int Z_SYNC_FLUSH = 2; - static final private int Z_FULL_FLUSH = 3; - static final private int Z_FINISH = 4; - - static final private int MAX_MEM_LEVEL = 9; - - static final private int Z_OK = 0; - static final private int Z_STREAM_END = 1; - static final private int Z_NEED_DICT = 2; - static final private int Z_ERRNO = -1; - static final private int Z_STREAM_ERROR = -2; - static final private int Z_DATA_ERROR = -3; - static final private int Z_MEM_ERROR = -4; - static final private int Z_BUF_ERROR = -5; - static final private int Z_VERSION_ERROR = -6; + private static final int MAX_WBITS = 15; // 32K LZ77 window + private static final int DEF_WBITS = MAX_WBITS; + + private static final int Z_NO_FLUSH = 0; + private static final int Z_PARTIAL_FLUSH = 1; + private static final int Z_SYNC_FLUSH = 2; + private static final int Z_FULL_FLUSH = 3; + private static final int Z_FINISH = 4; + + private static final int MAX_MEM_LEVEL = 9; + + private static final int Z_OK = 0; + private static final int Z_STREAM_END = 1; + private static final int Z_NEED_DICT = 2; + private static final int Z_ERRNO = -1; + private static final int Z_STREAM_ERROR = -2; + private static final int Z_DATA_ERROR = -3; + private static final int Z_MEM_ERROR = -4; + private static final int Z_BUF_ERROR = -5; + private static final int Z_VERSION_ERROR = -6; byte[] next_in; // next input byte int next_in_index; @@ -358,7 +358,6 @@ void setNextOutIndex(int next_out_index) { int getAvailOut() { return avail_out; - } void setAvailOut(int avail_out) { diff --git a/src/main/java9/module-info.java b/src/main/java9/module-info.java index dadf75b7..10139cc9 100644 --- a/src/main/java9/module-info.java +++ b/src/main/java9/module-info.java @@ -1,12 +1,12 @@ module com.jcraft.jsch { - exports com.jcraft.jsch; + exports com.jcraft.jsch; - requires static com.sun.jna; - requires static com.sun.jna.platform; - requires static java.logging; - requires static java.security.jgss; - requires static org.apache.logging.log4j; - requires static org.bouncycastle.provider; - requires static org.newsclub.net.unix; - requires static org.slf4j; + requires static com.sun.jna; + requires static com.sun.jna.platform; + requires static java.logging; + requires static java.security.jgss; + requires static org.apache.logging.log4j; + requires static org.bouncycastle.provider; + requires static org.newsclub.net.unix; + requires static org.slf4j; } diff --git a/src/test/java/com/jcraft/jsch/JSchTest.java b/src/test/java/com/jcraft/jsch/JSchTest.java index 04c54422..e2735a7a 100644 --- a/src/test/java/com/jcraft/jsch/JSchTest.java +++ b/src/test/java/com/jcraft/jsch/JSchTest.java @@ -64,7 +64,7 @@ void checkLoggerBehavior() throws Exception { assertSame(JSch.DEVNULL, jsch.getInstanceLogger(), "instance logger should be DEVNULL"); } - final static class TestLogger implements Logger { + static final class TestLogger implements Logger { @Override public boolean isEnabled(int level) { return true; diff --git a/src/test/java/com/jcraft/jsch/KeyPair2IT.java b/src/test/java/com/jcraft/jsch/KeyPair2IT.java index 393c66a1..f2b66b9a 100644 --- a/src/test/java/com/jcraft/jsch/KeyPair2IT.java +++ b/src/test/java/com/jcraft/jsch/KeyPair2IT.java @@ -55,7 +55,6 @@ void connectWithPublicKey(String path, String password, String keyType) throws E } finally { session.disconnect(); } - } @ParameterizedTest @@ -96,9 +95,7 @@ public boolean promptYesNo(String message) { } @Override - public void showMessage(String message) { - - } + public void showMessage(String message) {} }); if (keyType != null) { @@ -110,7 +107,6 @@ public void showMessage(String message) { } finally { session.disconnect(); } - } private JSch createIdentity(String path, String password) diff --git a/src/test/java/com/jcraft/jsch/KeyPairIT.java b/src/test/java/com/jcraft/jsch/KeyPairIT.java index a0f8c95c..a356dd49 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairIT.java +++ b/src/test/java/com/jcraft/jsch/KeyPairIT.java @@ -38,7 +38,6 @@ void connectWithPublicKey(String path, String password, String keyType) throws E } finally { session.disconnect(); } - } @ParameterizedTest @@ -79,9 +78,7 @@ public boolean promptYesNo(String message) { } @Override - public void showMessage(String message) { - - } + public void showMessage(String message) {} }); if (keyType != null) { @@ -93,7 +90,6 @@ public void showMessage(String message) { } finally { session.disconnect(); } - } private JSch createIdentity(String path, String password) diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index 12a19bef..46823322 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -178,5 +178,4 @@ void decryptEncryptedOpensshKey(String keyFile) throws URISyntaxException, JSchE assertTrue(identity.getKeyPair().decrypt((byte[]) null)); assertTrue(identity.getKeyPair().decrypt((String) null)); } - } diff --git a/src/test/java/com/jcraft/jsch/KnownHostsTest.java b/src/test/java/com/jcraft/jsch/KnownHostsTest.java index 3ca101d5..c74df310 100644 --- a/src/test/java/com/jcraft/jsch/KnownHostsTest.java +++ b/src/test/java/com/jcraft/jsch/KnownHostsTest.java @@ -11,6 +11,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import com.jcraft.jsch.KnownHosts.HashedHostKey; +import com.jcraft.jsch.jce.HMACSHA256; +import com.jcraft.jsch.jce.HMACSHA512; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -36,22 +39,19 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.jcraft.jsch.KnownHosts.HashedHostKey; -import com.jcraft.jsch.jce.HMACSHA256; -import com.jcraft.jsch.jce.HMACSHA512; class KnownHostsTest { - private final static String rsaKey = + private static final String rsaKey = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkc" + "cKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81e" + "FzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpI" + "oaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G" + "3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="; - private final static String hashValue = + private static final String hashValue = "|1|F1E1KeoE/eEWhi10WpGv4OdiO6Y=|3988QV0VE8wmZL7suNrYQLITLCg="; - private final static String hostLine = "ssh.example.com,192.168.1.61"; - private final static byte[] dsaKeyBytes = Util.str2byte(" ssh-dsa"); - private final static byte[] rsaKeyBytes = Util.str2byte(" ssh-rsa"); + private static final String hostLine = "ssh.example.com,192.168.1.61"; + private static final byte[] dsaKeyBytes = Util.str2byte(" ssh-dsa"); + private static final byte[] rsaKeyBytes = Util.str2byte(" ssh-rsa"); private LinkedList messages; private JSch jsch; private Hashtable orgConfig; @@ -201,7 +201,6 @@ MAC createHMAC(String hmacClassname) { assertEquals(HMACSHA512.class.getName(), kh.hmacsha1.getClass().getName(), "hmac class mismatch"); assertEquals("", messages.stream().collect(Collectors.joining("\r\n"))); - } @Test @@ -977,7 +976,6 @@ void sync() throws IOException { assertEquals(1, hosts.length, "unexpected number of host keys: " + getHostKeysString(hosts)); assertEquals("[192.277.325.5]:123: key type ssh-rsa", getHostKeysString(hosts), "unexpected hosts"); - } private String getMessagesAsString() { @@ -1142,5 +1140,4 @@ public boolean isEnabled(int level) { return true; } } - } diff --git a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java index b357c72e..99567500 100644 --- a/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java +++ b/src/test/java/com/jcraft/jsch/OpenSSHConfigTest.java @@ -88,5 +88,4 @@ void replaceKexAlgorithms() throws IOException { ConfigRepository.Config kex = parse.getConfig(""); assertEquals("diffie-hellman-group1-sha1", kex.getValue("kex")); } - } diff --git a/src/test/java/com/jcraft/jsch/SessionTest.java b/src/test/java/com/jcraft/jsch/SessionTest.java index 3bf5987c..ebc12d98 100644 --- a/src/test/java/com/jcraft/jsch/SessionTest.java +++ b/src/test/java/com/jcraft/jsch/SessionTest.java @@ -36,7 +36,7 @@ private static Stream sshConfigs() { Arguments.of(":42 host:99", "0.0.0.0", "host", 99, null), // bind is empty Arguments.of("*:42 host:99", "0.0.0.0", "host", 99, null), // bind is asterisk Arguments.of("bind_adress:42 socket", "bind_adress", null, -1, "socket"), // socket - Arguments.of("42 socket", "127.0.0.1", null, -1, "socket")// socket wo bind + Arguments.of("42 socket", "127.0.0.1", null, -1, "socket") // socket wo bind ); } diff --git a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java index 607f4a1e..2c34f3ff 100644 --- a/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java +++ b/src/test/java/com/jcraft/jsch/jbcrypt/BCryptTest.java @@ -71,9 +71,7 @@ public class BCryptTest { {"~!@#$%^&*() ~!@#$%^&*()PNBFRD", "$2a$12$WApznUOJfkEGSmYRfnkrPO", "$2a$12$WApznUOJfkEGSmYRfnkrPOr466oFDCaj4b6HY3EXGvfxm43seyhgC"},}; - /** - * Test method for 'BCrypt.hashpw(String, String)' - */ + /** Test method for 'BCrypt.hashpw(String, String)' */ @Test public void testHashpw() { // System.out.print("BCrypt.hashpw(): "); @@ -88,9 +86,7 @@ public void testHashpw() { // System.out.println(""); } - /** - * Test method for 'BCrypt.gensalt(int)' - */ + /** Test method for 'BCrypt.gensalt(int)' */ @Test public void testGensaltInt() { // System.out.print("BCrypt.gensalt(log_rounds):"); @@ -108,9 +104,7 @@ public void testGensaltInt() { // System.out.println(""); } - /** - * Test method for 'BCrypt.gensalt()' - */ + /** Test method for 'BCrypt.gensalt()' */ @Test public void testGensalt() { // System.out.print("BCrypt.gensalt(): "); @@ -125,9 +119,7 @@ public void testGensalt() { // System.out.println(""); } - /** - * Test method for 'BCrypt.checkpw(String, String)' expecting success - */ + /** Test method for 'BCrypt.checkpw(String, String)' expecting success */ @Test public void testCheckpw_success() { // System.out.print("BCrypt.checkpw w/ good passwords: "); @@ -140,9 +132,7 @@ public void testCheckpw_success() { // System.out.println(""); } - /** - * Test method for 'BCrypt.checkpw(String, String)' expecting failure - */ + /** Test method for 'BCrypt.checkpw(String, String)' expecting failure */ @Test public void testCheckpw_failure() { // System.out.print("BCrypt.checkpw w/ bad passwords: "); @@ -156,9 +146,7 @@ public void testCheckpw_failure() { // System.out.println(""); } - /** - * Test for correct hashing of non-US-ASCII passwords - */ + /** Test for correct hashing of non-US-ASCII passwords */ @Test public void testInternationalChars() { // System.out.print("BCrypt.hashpw w/ international chars: ");