Skip to content

Commit

Permalink
More formatting corrections to better adhere to Google Java Style Guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
norrisjeremy committed Jan 22, 2024
1 parent 11b3fe7 commit e15238d
Show file tree
Hide file tree
Showing 81 changed files with 371 additions and 524 deletions.
7 changes: 1 addition & 6 deletions examples/AES.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -153,5 +150,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}


1 change: 0 additions & 1 deletion examples/ChangePassphrase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions examples/Compression.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -152,5 +151,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}


1 change: 0 additions & 1 deletion examples/Daemon.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/Exec.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/JumpHosts.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/KeyGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions examples/KnownHosts.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -173,5 +172,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}


8 changes: 2 additions & 6 deletions examples/Logger.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -55,6 +52,7 @@ public static void main(String[] arg) {

public static class MyLogger implements com.jcraft.jsch.Logger {
static java.util.Map<Integer, String> name = new java.util.HashMap<>();

static {
name.put(DEBUG, "DEBUG: ");
name.put(INFO, "INFO: ");
Expand Down Expand Up @@ -169,5 +167,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}


3 changes: 1 addition & 2 deletions examples/OpenSSHConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/PortForwardingL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/PortForwardingR.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/ScpFrom.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/ScpTo.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/ScpToNoneCipher.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/Sftp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions examples/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions examples/SocketForwardingL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions examples/StreamForwarding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -155,5 +154,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}


5 changes: 1 addition & 4 deletions examples/Subsystem.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 1 addition & 5 deletions examples/Sudo.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion examples/UserAuthKI.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 0 additions & 2 deletions examples/UserAuthPubKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,7 +64,6 @@ public static void main(String[] arg) {
}
}


public static class MyUserInfo implements UserInfo, UIKeyboardInteractive {
@Override
public String getPassword() {
Expand Down
4 changes: 0 additions & 4 deletions examples/ViaHTTP.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -156,7 +155,4 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}

}


3 changes: 0 additions & 3 deletions examples/ViaSOCKS5.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -157,5 +156,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}


3 changes: 0 additions & 3 deletions examples/X11Forwarding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -160,5 +159,3 @@ public String[] promptKeyboardInteractive(String destination, String name, Strin
}
}
}


1 change: 0 additions & 1 deletion src/main/java/com/jcraft/jsch/Buffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<tmp_buffer_index; i++){
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/jcraft/jsch/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ private synchronized void init() throws IOException {
} catch (JSchException e) {
throw new IOException("failed to initialize the channel.", e);
}

}

byte[] b = new byte[1];
Expand Down Expand Up @@ -340,7 +339,6 @@ public void flush() throws IOException {
close();
throw new IOException(e.toString(), e);
}

}

@Override
Expand Down Expand Up @@ -701,6 +699,7 @@ public void close() throws IOException {
this.os = null;
}
}

static class PassiveOutputStream extends PipedOutputStream {
private MyPipedInputStream _sink = null;

Expand Down
Loading

0 comments on commit e15238d

Please sign in to comment.