mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
mass auto-format
This commit is contained in:
@@ -18,7 +18,8 @@ package net.schmizz.sshj;
|
||||
import net.schmizz.sshj.transport.random.JCERandom;
|
||||
import net.schmizz.sshj.transport.random.SingletonRandomFactory;
|
||||
|
||||
public class AndroidConfig extends DefaultConfig {
|
||||
public class AndroidConfig
|
||||
extends DefaultConfig {
|
||||
|
||||
@Override
|
||||
protected void initRandomFactory(boolean ignored) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.List;
|
||||
* {@link Compression}, {@link MAC}, {@link Signature}, {@link Random}, and {@link FileKeyProvider}.
|
||||
*/
|
||||
public interface Config {
|
||||
|
||||
/**
|
||||
* Retrieve the list of named factories for {@code Cipher}.
|
||||
*
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package net.schmizz.sshj;
|
||||
|
||||
import net.schmizz.sshj.common.DisconnectReason;
|
||||
import net.schmizz.sshj.common.Factory;
|
||||
import net.schmizz.sshj.common.SSHException;
|
||||
import net.schmizz.sshj.common.SecurityUtils;
|
||||
@@ -50,7 +49,6 @@ import net.schmizz.sshj.userauth.keyprovider.FileKeyProvider;
|
||||
import net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper;
|
||||
import net.schmizz.sshj.userauth.keyprovider.KeyProvider;
|
||||
import net.schmizz.sshj.userauth.keyprovider.KeyProviderUtil;
|
||||
import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile;
|
||||
import net.schmizz.sshj.userauth.method.AuthKeyboardInteractive;
|
||||
import net.schmizz.sshj.userauth.method.AuthMethod;
|
||||
import net.schmizz.sshj.userauth.method.AuthPassword;
|
||||
@@ -65,8 +63,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.net.SocketAddress;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PublicKey;
|
||||
@@ -505,8 +501,8 @@ public class SSHClient
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link KeyProvider} instance from passed strings. Currently only PKCS8 format
|
||||
* private key files are supported (OpenSSH uses this format).
|
||||
* Creates a {@link KeyProvider} instance from passed strings. Currently only PKCS8 format private key files are
|
||||
* supported (OpenSSH uses this format).
|
||||
* <p/>
|
||||
*
|
||||
* @param privateKey the private key as a string
|
||||
|
||||
@@ -32,7 +32,8 @@ public class Base64 {
|
||||
* @see Base64
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class InputStream extends java.io.FilterInputStream {
|
||||
public static class InputStream
|
||||
extends java.io.FilterInputStream {
|
||||
|
||||
private final boolean encode; // Encoding or decoding
|
||||
private int position; // Current position in the buffer
|
||||
@@ -99,7 +100,8 @@ public class Base64 {
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public int read() throws java.io.IOException {
|
||||
public int read()
|
||||
throws java.io.IOException {
|
||||
|
||||
// Do we need to get data?
|
||||
if (position < 0)
|
||||
@@ -197,7 +199,8 @@ public class Base64 {
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public int read(byte[] dest, int off, int len) throws java.io.IOException {
|
||||
public int read(byte[] dest, int off, int len)
|
||||
throws java.io.IOException {
|
||||
int i;
|
||||
int b;
|
||||
for (i = 0; i < len; i++) {
|
||||
@@ -222,7 +225,8 @@ public class Base64 {
|
||||
* @see Base64
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class OutputStream extends java.io.FilterOutputStream {
|
||||
public static class OutputStream
|
||||
extends java.io.FilterOutputStream {
|
||||
|
||||
private final boolean encode;
|
||||
private int position;
|
||||
@@ -289,7 +293,8 @@ public class Base64 {
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public void close() throws java.io.IOException {
|
||||
public void close()
|
||||
throws java.io.IOException {
|
||||
// 1. Ensure that pending characters are written
|
||||
flush();
|
||||
|
||||
@@ -308,7 +313,8 @@ public class Base64 {
|
||||
* @since 2.3
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws java.io.IOException {
|
||||
public void flush()
|
||||
throws java.io.IOException {
|
||||
flushBase64();
|
||||
super.flush();
|
||||
}
|
||||
@@ -318,7 +324,8 @@ public class Base64 {
|
||||
*
|
||||
* @throws java.io.IOException if there's an error.
|
||||
*/
|
||||
public void flushBase64() throws java.io.IOException {
|
||||
public void flushBase64()
|
||||
throws java.io.IOException {
|
||||
if (position > 0)
|
||||
if (encode) {
|
||||
out.write(encode3to4(b4, buffer, position, options));
|
||||
@@ -346,7 +353,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException if there's an error flushing
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public void suspendEncoding() throws java.io.IOException {
|
||||
public void suspendEncoding()
|
||||
throws java.io.IOException {
|
||||
flushBase64();
|
||||
suspendEncoding = true;
|
||||
} // end suspendEncoding
|
||||
@@ -361,7 +369,8 @@ public class Base64 {
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] theBytes, int off, int len) throws java.io.IOException {
|
||||
public void write(byte[] theBytes, int off, int len)
|
||||
throws java.io.IOException {
|
||||
// Encoding suspended?
|
||||
if (suspendEncoding) {
|
||||
super.out.write(theBytes, off, len);
|
||||
@@ -383,7 +392,8 @@ public class Base64 {
|
||||
* @since 1.3
|
||||
*/
|
||||
@Override
|
||||
public void write(int theByte) throws java.io.IOException {
|
||||
public void write(int theByte)
|
||||
throws java.io.IOException {
|
||||
// Encoding suspended?
|
||||
if (suspendEncoding) {
|
||||
super.out.write(theByte);
|
||||
@@ -673,7 +683,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException If bogus characters exist in source data
|
||||
* @since 1.3
|
||||
*/
|
||||
public static byte[] decode(byte[] source, int off, int len, int options) throws java.io.IOException {
|
||||
public static byte[] decode(byte[] source, int off, int len, int options)
|
||||
throws java.io.IOException {
|
||||
|
||||
// Lots of error checking and exception throwing
|
||||
if (source == null)
|
||||
@@ -743,7 +754,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException If there is a problem
|
||||
* @since 1.4
|
||||
*/
|
||||
public static byte[] decode(String s) throws java.io.IOException {
|
||||
public static byte[] decode(String s)
|
||||
throws java.io.IOException {
|
||||
return decode(s, NO_OPTIONS);
|
||||
}
|
||||
|
||||
@@ -759,7 +771,8 @@ public class Base64 {
|
||||
* @throws NullPointerException if <tt>s</tt> is null
|
||||
* @since 1.4
|
||||
*/
|
||||
public static byte[] decode(String s, int options) throws java.io.IOException {
|
||||
public static byte[] decode(String s, int options)
|
||||
throws java.io.IOException {
|
||||
|
||||
if (s == null)
|
||||
throw new NullPointerException("Input string was null.");
|
||||
@@ -833,7 +846,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException if there is an error
|
||||
* @since 2.2
|
||||
*/
|
||||
public static void decodeFileToFile(String infile, String outfile) throws java.io.IOException {
|
||||
public static void decodeFileToFile(String infile, String outfile)
|
||||
throws java.io.IOException {
|
||||
|
||||
byte[] decoded = Base64.decodeFromFile(infile);
|
||||
java.io.OutputStream out = null;
|
||||
@@ -864,7 +878,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException if there is an error
|
||||
* @since 2.1
|
||||
*/
|
||||
public static byte[] decodeFromFile(String filename) throws java.io.IOException {
|
||||
public static byte[] decodeFromFile(String filename)
|
||||
throws java.io.IOException {
|
||||
|
||||
byte[] decodedData = null;
|
||||
Base64.InputStream bis = null;
|
||||
@@ -918,7 +933,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException if there is an error
|
||||
* @since 2.1
|
||||
*/
|
||||
public static void decodeToFile(String dataToDecode, String filename) throws java.io.IOException {
|
||||
public static void decodeToFile(String dataToDecode, String filename)
|
||||
throws java.io.IOException {
|
||||
|
||||
Base64.OutputStream bos = null;
|
||||
try {
|
||||
@@ -950,7 +966,8 @@ public class Base64 {
|
||||
* @throws ClassNotFoundException if the decoded object is of a class that cannot be found by the JVM
|
||||
* @since 1.5
|
||||
*/
|
||||
public static Object decodeToObject(String encodedObject) throws java.io.IOException,
|
||||
public static Object decodeToObject(String encodedObject)
|
||||
throws java.io.IOException,
|
||||
java.lang.ClassNotFoundException {
|
||||
|
||||
// Decode and gunzip if necessary
|
||||
@@ -1078,7 +1095,8 @@ public class Base64 {
|
||||
* @see Base64#DO_BREAK_LINES
|
||||
* @since 2.0
|
||||
*/
|
||||
public static String encodeBytes(byte[] source, int options) throws java.io.IOException {
|
||||
public static String encodeBytes(byte[] source, int options)
|
||||
throws java.io.IOException {
|
||||
return encodeBytes(source, 0, source.length, options);
|
||||
} // end encodeBytes
|
||||
|
||||
@@ -1137,7 +1155,8 @@ public class Base64 {
|
||||
* @see Base64#DO_BREAK_LINES
|
||||
* @since 2.0
|
||||
*/
|
||||
public static String encodeBytes(byte[] source, int off, int len, int options) throws java.io.IOException {
|
||||
public static String encodeBytes(byte[] source, int off, int len, int options)
|
||||
throws java.io.IOException {
|
||||
byte[] encoded = encodeBytesToBytes(source, off, len, options);
|
||||
|
||||
// Return value according to relevant encoding.
|
||||
@@ -1189,7 +1208,8 @@ public class Base64 {
|
||||
* @see Base64#DO_BREAK_LINES
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public static byte[] encodeBytesToBytes(byte[] source, int off, int len, int options) throws java.io.IOException {
|
||||
public static byte[] encodeBytesToBytes(byte[] source, int off, int len, int options)
|
||||
throws java.io.IOException {
|
||||
|
||||
if (source == null)
|
||||
throw new NullPointerException("Cannot serialize a null array.");
|
||||
@@ -1302,7 +1322,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException if there is an error
|
||||
* @since 2.2
|
||||
*/
|
||||
public static void encodeFileToFile(String infile, String outfile) throws java.io.IOException {
|
||||
public static void encodeFileToFile(String infile, String outfile)
|
||||
throws java.io.IOException {
|
||||
|
||||
String encoded = Base64.encodeFromFile(infile);
|
||||
java.io.OutputStream out = null;
|
||||
@@ -1333,7 +1354,8 @@ public class Base64 {
|
||||
* @throws java.io.IOException if there is an error
|
||||
* @since 2.1
|
||||
*/
|
||||
public static String encodeFromFile(String filename) throws java.io.IOException {
|
||||
public static String encodeFromFile(String filename)
|
||||
throws java.io.IOException {
|
||||
|
||||
String encodedData = null;
|
||||
Base64.InputStream bis = null;
|
||||
@@ -1387,7 +1409,8 @@ public class Base64 {
|
||||
* @throws NullPointerException if serializedObject is null
|
||||
* @since 1.4
|
||||
*/
|
||||
public static String encodeObject(java.io.Serializable serializableObject) throws java.io.IOException {
|
||||
public static String encodeObject(java.io.Serializable serializableObject)
|
||||
throws java.io.IOException {
|
||||
return encodeObject(serializableObject, NO_OPTIONS);
|
||||
} // end encodeObject
|
||||
|
||||
@@ -1420,7 +1443,8 @@ public class Base64 {
|
||||
* @see Base64#DO_BREAK_LINES
|
||||
* @since 2.0
|
||||
*/
|
||||
public static String encodeObject(java.io.Serializable serializableObject, int options) throws java.io.IOException {
|
||||
public static String encodeObject(java.io.Serializable serializableObject, int options)
|
||||
throws java.io.IOException {
|
||||
|
||||
if (serializableObject == null)
|
||||
throw new NullPointerException("Cannot serialize a null object.");
|
||||
@@ -1481,7 +1505,8 @@ public class Base64 {
|
||||
* @throws NullPointerException if dataToEncode is null
|
||||
* @since 2.1
|
||||
*/
|
||||
public static void encodeToFile(byte[] dataToEncode, String filename) throws java.io.IOException {
|
||||
public static void encodeToFile(byte[] dataToEncode, String filename)
|
||||
throws java.io.IOException {
|
||||
|
||||
if (dataToEncode == null)
|
||||
throw new NullPointerException("Data to encode was null.");
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
*/
|
||||
package net.schmizz.sshj.common;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** Utility functions for byte arrays. */
|
||||
public class ByteArrayUtils {
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public interface ErrorNotifiable {
|
||||
|
||||
/** Utility functions. */
|
||||
class Util {
|
||||
|
||||
/** Notify all {@code notifiables} of given {@code error}. */
|
||||
public static void alertAll(SSHException error, ErrorNotifiable... notifiables) {
|
||||
for (ErrorNotifiable notifiable : notifiables)
|
||||
|
||||
@@ -32,7 +32,6 @@ public enum KeyType {
|
||||
|
||||
/** SSH identifier for RSA keys */
|
||||
RSA("ssh-rsa") {
|
||||
|
||||
@Override
|
||||
public PublicKey readPubKeyFromBuffer(String type, Buffer<?> buf)
|
||||
throws GeneralSecurityException {
|
||||
@@ -64,7 +63,6 @@ public enum KeyType {
|
||||
|
||||
/** SSH identifier for DSA keys */
|
||||
DSA("ssh-dss") {
|
||||
|
||||
@Override
|
||||
public PublicKey readPubKeyFromBuffer(String type, Buffer<?> buf)
|
||||
throws GeneralSecurityException {
|
||||
@@ -100,7 +98,6 @@ public enum KeyType {
|
||||
|
||||
/** Unrecognized */
|
||||
UNKNOWN("unknown") {
|
||||
|
||||
@Override
|
||||
public PublicKey readPubKeyFromBuffer(String type, Buffer<?> buf)
|
||||
throws GeneralSecurityException {
|
||||
|
||||
@@ -58,6 +58,7 @@ import java.security.Signature;
|
||||
public class SecurityUtils {
|
||||
|
||||
private static class BouncyCastleRegistration {
|
||||
|
||||
public void run()
|
||||
throws Exception {
|
||||
if (java.security.Security.getProvider(BOUNCY_CASTLE) == null) {
|
||||
|
||||
@@ -89,8 +89,8 @@ public interface Connection {
|
||||
* @param wantReply whether a reply is requested
|
||||
* @param specifics {@link SSHPacket} containing fields specific to the request
|
||||
*
|
||||
* @return a {@link net.schmizz.concurrent.Promise} for the reply data (in case {@code wantReply} is true) which allows waiting on the
|
||||
* reply, or {@code null} if a reply is not requested.
|
||||
* @return a {@link net.schmizz.concurrent.Promise} for the reply data (in case {@code wantReply} is true) which
|
||||
* allows waiting on the reply, or {@code null} if a reply is not requested.
|
||||
*
|
||||
* @throws TransportException if there is an error sending the request
|
||||
*/
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
*/
|
||||
package net.schmizz.sshj.connection.channel;
|
||||
|
||||
import net.schmizz.concurrent.Event;
|
||||
import net.schmizz.concurrent.ErrorDeliveryUtil;
|
||||
import net.schmizz.concurrent.Event;
|
||||
import net.schmizz.sshj.common.Buffer;
|
||||
import net.schmizz.sshj.common.ByteArrayUtils;
|
||||
import net.schmizz.sshj.common.DisconnectReason;
|
||||
@@ -313,7 +313,8 @@ public abstract class AbstractChannel
|
||||
handleRequest(reqType, buf);
|
||||
}
|
||||
|
||||
private void gotWindowAdjustment(SSHPacket buf) throws ConnectionException {
|
||||
private void gotWindowAdjustment(SSHPacket buf)
|
||||
throws ConnectionException {
|
||||
final int howMuch;
|
||||
try {
|
||||
howMuch = buf.readUInt32AsInt();
|
||||
|
||||
@@ -32,6 +32,7 @@ public interface Channel
|
||||
/** Direct channels are those that are initiated by us. */
|
||||
interface Direct
|
||||
extends Channel {
|
||||
|
||||
/**
|
||||
* Request opening this channel from remote end.
|
||||
*
|
||||
|
||||
@@ -82,10 +82,12 @@ public interface Session
|
||||
throws TransportException;
|
||||
|
||||
@Deprecated
|
||||
String getOutputAsString() throws IOException;
|
||||
String getOutputAsString()
|
||||
throws IOException;
|
||||
|
||||
@Deprecated
|
||||
String getErrorAsString() throws IOException;
|
||||
String getErrorAsString()
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -132,6 +134,7 @@ public interface Session
|
||||
/** Subsystem API. */
|
||||
interface Subsystem
|
||||
extends Channel {
|
||||
|
||||
Integer getExitStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,18 +39,18 @@ public class RemotePortForwarder
|
||||
* address (or domain name) and port on which connections for forwarding
|
||||
* are to be accepted. Some strings used for 'address to bind' have
|
||||
* special-case semantics.
|
||||
* <p/>
|
||||
*
|
||||
* o "" means that connections are to be accepted on all protocol
|
||||
* families supported by the SSH implementation.
|
||||
* <p/>
|
||||
*
|
||||
* o "0.0.0.0" means to listen on all IPv4 addresses.
|
||||
* <p/>
|
||||
*
|
||||
* o "::" means to listen on all IPv6 addresses.
|
||||
* <p/>
|
||||
*
|
||||
* o "localhost" means to listen on all protocol families supported by
|
||||
* the SSH implementation on loopback addresses only ([RFC3330] and
|
||||
* [RFC3513]).
|
||||
* <p/>
|
||||
*
|
||||
* o "127.0.0.1" and "::1" indicate listening on the loopback
|
||||
* interfaces for IPv4 and IPv6, respectively.
|
||||
* </pre>
|
||||
|
||||
@@ -51,7 +51,8 @@ public class Response
|
||||
private final PacketType type;
|
||||
private final long reqID;
|
||||
|
||||
public Response(Buffer<Response> pk, int protocolVersion) throws SFTPException {
|
||||
public Response(Buffer<Response> pk, int protocolVersion)
|
||||
throws SFTPException {
|
||||
super(pk);
|
||||
this.protocolVersion = protocolVersion;
|
||||
this.type = readType();
|
||||
@@ -74,7 +75,8 @@ public class Response
|
||||
return type;
|
||||
}
|
||||
|
||||
public StatusCode readStatusCode() throws SFTPException {
|
||||
public StatusCode readStatusCode()
|
||||
throws SFTPException {
|
||||
try {
|
||||
return StatusCode.fromInt(readUInt32AsInt());
|
||||
} catch (BufferException be) {
|
||||
|
||||
@@ -56,7 +56,8 @@ public class SFTPEngine
|
||||
this(ssh, PathHelper.DEFAULT_PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
public SFTPEngine(SessionFactory ssh, String pathSep) throws SSHException {
|
||||
public SFTPEngine(SessionFactory ssh, String pathSep)
|
||||
throws SSHException {
|
||||
sub = ssh.startSession().startSubsystem("sftp");
|
||||
out = sub.getOutputStream();
|
||||
reader = new PacketReader(this);
|
||||
|
||||
@@ -47,7 +47,7 @@ import net.schmizz.sshj.transport.mac.MAC;
|
||||
* <p/>
|
||||
* <pre>
|
||||
* Each packet is in the following format:
|
||||
* <p/>
|
||||
*
|
||||
* uint32 packet_length
|
||||
* byte padding_length
|
||||
* byte[n1] payload; n1 = packet_length - padding_length - 1
|
||||
|
||||
@@ -124,7 +124,7 @@ final class Decoder
|
||||
if (log.isTraceEnabled())
|
||||
log.trace("Received packet #{}: {}", seq, plain.printHex());
|
||||
|
||||
packetHandler.handle(plain.readMessageID(), plain); // Process the decoded packet //
|
||||
packetHandler.handle(plain.readMessageID(), plain); // Process the decoded packet
|
||||
|
||||
inputBuffer.clear();
|
||||
packetLength = -1;
|
||||
|
||||
@@ -92,15 +92,15 @@ public final class NegotiatedAlgorithms {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("[ " + //
|
||||
"kex=" + kex + "; " + //
|
||||
"sig=" + sig + "; " + //
|
||||
"c2sCipher=" + c2sCipher + "; " + //
|
||||
"s2cCipher=" + s2cCipher + "; " + //
|
||||
"c2sMAC=" + c2sMAC + "; " + //
|
||||
"s2cMAC=" + s2cMAC + "; " + //
|
||||
"c2sComp=" + c2sComp + "; " + //
|
||||
"s2cComp=" + s2cComp + //
|
||||
return ("[ " +
|
||||
"kex=" + kex + "; " +
|
||||
"sig=" + sig + "; " +
|
||||
"c2sCipher=" + c2sCipher + "; " +
|
||||
"s2cCipher=" + s2cCipher + "; " +
|
||||
"c2sMAC=" + c2sMAC + "; " +
|
||||
"s2cMAC=" + s2cMAC + "; " +
|
||||
"c2sComp=" + c2sComp + "; " +
|
||||
"s2cComp=" + s2cComp +
|
||||
" ]");
|
||||
}
|
||||
|
||||
|
||||
@@ -178,12 +178,14 @@ public interface Transport
|
||||
*/
|
||||
void join()
|
||||
throws TransportException;
|
||||
|
||||
/**
|
||||
* Joins the thread calling this method to the transport's death.
|
||||
*
|
||||
* @throws TransportException if the transport dies of an exception
|
||||
*/
|
||||
void join(int timeout, TimeUnit unit) throws TransportException;
|
||||
void join(int timeout, TimeUnit unit)
|
||||
throws TransportException;
|
||||
|
||||
/** Send a disconnection packet with reason as {@link DisconnectReason#BY_APPLICATION}, and closes this transport. */
|
||||
void disconnect();
|
||||
@@ -226,9 +228,7 @@ public interface Transport
|
||||
*/
|
||||
void setDisconnectListener(DisconnectListener listener);
|
||||
|
||||
/**
|
||||
* @return the current disconnect listener.
|
||||
*/
|
||||
/** @return the current disconnect listener. */
|
||||
DisconnectListener getDisconnectListener();
|
||||
|
||||
}
|
||||
@@ -35,8 +35,8 @@
|
||||
*/
|
||||
package net.schmizz.sshj.transport;
|
||||
|
||||
import net.schmizz.concurrent.Event;
|
||||
import net.schmizz.concurrent.ErrorDeliveryUtil;
|
||||
import net.schmizz.concurrent.Event;
|
||||
import net.schmizz.sshj.AbstractService;
|
||||
import net.schmizz.sshj.Config;
|
||||
import net.schmizz.sshj.Service;
|
||||
@@ -62,12 +62,14 @@ public final class TransportImpl
|
||||
|
||||
private static final class NullService
|
||||
extends AbstractService {
|
||||
|
||||
NullService(Transport trans) {
|
||||
super("null-service", trans);
|
||||
}
|
||||
}
|
||||
|
||||
static final class ConnInfo {
|
||||
|
||||
final String host;
|
||||
final int port;
|
||||
final InputStream in;
|
||||
@@ -501,7 +503,8 @@ public final class TransportImpl
|
||||
}
|
||||
}
|
||||
|
||||
private void gotDebug(SSHPacket buf) throws TransportException {
|
||||
private void gotDebug(SSHPacket buf)
|
||||
throws TransportException {
|
||||
try {
|
||||
final boolean display = buf.readBoolean();
|
||||
final String message = buf.readString();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AES128CBC
|
||||
/** Named factory for AES128CBC Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new AES128CBC();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AES128CTR
|
||||
/** Named factory for AES128CBC Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new AES128CTR();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AES192CBC
|
||||
/** Named factory for AES192CBC Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new AES192CBC();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AES192CTR
|
||||
/** Named factory for AES192CTR Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new AES192CTR();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AES256CBC
|
||||
/** Named factory for AES256CBC Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new AES256CBC();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AES256CTR
|
||||
/** Named factory for AES256CBC Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new AES256CTR();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class BlowfishCBC
|
||||
/** Named factory for BlowfishCBC Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new BlowfishCBC();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class NoneCipher
|
||||
/** Named factory for the no-op Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new NoneCipher();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class TripleDESCBC
|
||||
/** Named factory for TripleDESCBC Cipher */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Cipher> {
|
||||
|
||||
@Override
|
||||
public Cipher create() {
|
||||
return new TripleDESCBC();
|
||||
|
||||
@@ -46,6 +46,7 @@ public class DelayedZlibCompression
|
||||
/** Named factory for the ZLib Delayed Compression. */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Compression> {
|
||||
|
||||
@Override
|
||||
public Compression create() {
|
||||
return new DelayedZlibCompression();
|
||||
|
||||
@@ -42,6 +42,7 @@ public abstract class NoneCompression
|
||||
/** Named factory for the no-op <code>Compression</code> */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Compression> {
|
||||
|
||||
@Override
|
||||
public Compression create() {
|
||||
return null;
|
||||
|
||||
@@ -49,6 +49,7 @@ public class ZlibCompression
|
||||
/** Named factory for the ZLib Compression. */
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<Compression> {
|
||||
|
||||
@Override
|
||||
public Compression create() {
|
||||
return new ZlibCompression();
|
||||
|
||||
@@ -63,7 +63,8 @@ public class DHG14
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDH(DH dh) throws GeneralSecurityException {
|
||||
protected void initDH(DH dh)
|
||||
throws GeneralSecurityException {
|
||||
dh.init(DHGroupData.P14, DHGroupData.G);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.schmizz.sshj.common.Factory;
|
||||
/** A random factory wrapper that uses a single random instance. The underlying random instance has to be thread safe. */
|
||||
public class SingletonRandomFactory
|
||||
implements Random, Factory<Random> {
|
||||
|
||||
private final Random random;
|
||||
|
||||
public SingletonRandomFactory(Factory<Random> factory) {
|
||||
|
||||
@@ -139,11 +139,13 @@ public class UserAuthImpl
|
||||
|
||||
case USERAUTH_BANNER: {
|
||||
banner = buf.readString();
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case USERAUTH_SUCCESS: {
|
||||
authenticated.set();
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case USERAUTH_FAILURE: {
|
||||
allowedMethods.clear();
|
||||
@@ -154,7 +156,8 @@ public class UserAuthImpl
|
||||
} else {
|
||||
authenticated.deliverError(new UserAuthException(currentMethod.getName() + " auth failed"));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
log.debug("Asking `{}` method to handle {} packet", currentMethod.getName(), msg);
|
||||
|
||||
@@ -22,18 +22,13 @@ import net.schmizz.sshj.userauth.password.PasswordUtils;
|
||||
import net.schmizz.sshj.userauth.password.PrivateKeyFileResource;
|
||||
import net.schmizz.sshj.userauth.password.PrivateKeyStringResource;
|
||||
import net.schmizz.sshj.userauth.password.Resource;
|
||||
|
||||
import org.bouncycastle.openssl.EncryptionException;
|
||||
import org.bouncycastle.openssl.PEMReader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
@@ -44,6 +39,7 @@ public class PKCS8KeyFile
|
||||
|
||||
public static class Factory
|
||||
implements net.schmizz.sshj.common.Factory.Named<FileKeyProvider> {
|
||||
|
||||
@Override
|
||||
public FileKeyProvider create() {
|
||||
return new PKCS8KeyFile();
|
||||
|
||||
@@ -51,6 +51,7 @@ public class AuthKeyboardInteractive
|
||||
}
|
||||
|
||||
private static class CharArrWrap {
|
||||
|
||||
private final char[] arr;
|
||||
|
||||
private CharArrWrap(char[] arr) {
|
||||
|
||||
@@ -67,7 +67,8 @@ public abstract class KeyedAuthMethod
|
||||
throw new UserAuthException("Could not create signature instance for " + kt + " key");
|
||||
|
||||
sigger.init(null, key);
|
||||
sigger.update(new Buffer.PlainBuffer().putString(params.getTransport().getSessionID()) //
|
||||
sigger.update(new Buffer.PlainBuffer()
|
||||
.putString(params.getTransport().getSessionID())
|
||||
.putBuffer(reqBuf) // & rest of the data for sig
|
||||
.getCompactData());
|
||||
reqBuf.putSignature(kt, sigger.sign());
|
||||
|
||||
@@ -27,7 +27,8 @@ public class AccountResource
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getReader() throws IOException {
|
||||
public Reader getReader()
|
||||
throws IOException {
|
||||
return new StringReader(getDetail());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,16 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
public class PrivateKeyStringResource extends Resource<String> {
|
||||
public class PrivateKeyStringResource
|
||||
extends Resource<String> {
|
||||
|
||||
public PrivateKeyStringResource(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getReader() throws IOException {
|
||||
public Reader getReader()
|
||||
throws IOException {
|
||||
return new StringReader(getDetail());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileSystemFile
|
||||
implements LocalSourceFile, LocalDestFile {
|
||||
|
||||
@@ -34,7 +34,8 @@ public interface LocalSourceFile {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
int getPermissions() throws IOException;
|
||||
int getPermissions()
|
||||
throws IOException;
|
||||
|
||||
boolean isFile();
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.schmizz.sshj.common.SSHException;
|
||||
|
||||
public class SCPException
|
||||
extends SSHException {
|
||||
|
||||
public SCPException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package net.schmizz.sshj.xfer.scp;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.schmizz.sshj.connection.channel.direct.SessionFactory;
|
||||
import net.schmizz.sshj.xfer.AbstractFileTransfer;
|
||||
import net.schmizz.sshj.xfer.FileSystemFile;
|
||||
@@ -24,6 +22,8 @@ import net.schmizz.sshj.xfer.FileTransfer;
|
||||
import net.schmizz.sshj.xfer.LocalDestFile;
|
||||
import net.schmizz.sshj.xfer.LocalSourceFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SCPFileTransfer
|
||||
extends AbstractFileTransfer
|
||||
implements FileTransfer {
|
||||
|
||||
@@ -50,7 +50,8 @@ public class SmokeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void authenticated() throws UserAuthException, TransportException {
|
||||
public void authenticated()
|
||||
throws UserAuthException, TransportException {
|
||||
fixture.dummyAuth();
|
||||
assertTrue(fixture.getClient().isAuthenticated());
|
||||
}
|
||||
|
||||
@@ -136,7 +136,6 @@ public class OpenSSHKeyFileTest {
|
||||
|
||||
private String readFile(String pathname)
|
||||
throws IOException {
|
||||
|
||||
StringBuilder fileContents = new StringBuilder();
|
||||
Scanner scanner = new Scanner(new File(pathname));
|
||||
String lineSeparator = System.getProperty("line.separator");
|
||||
|
||||
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
/** Tests {@link Buffer} functionality */
|
||||
public class BufferTest {
|
||||
|
||||
private Buffer.PlainBuffer posBuf;
|
||||
private Buffer.PlainBuffer handyBuf;
|
||||
|
||||
|
||||
@@ -29,34 +29,38 @@ import java.security.spec.RSAPublicKeySpec;
|
||||
public class KeyUtil {
|
||||
|
||||
/** Creates a DSA private key. */
|
||||
public static PrivateKey newDSAPrivateKey(String x, String p, String q, String g) throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("DSA").generatePrivate(new DSAPrivateKeySpec //
|
||||
(new BigInteger(x, 16), //
|
||||
new BigInteger(p, 16), //
|
||||
new BigInteger(q, 16), //
|
||||
new BigInteger(g, 16)));
|
||||
public static PrivateKey newDSAPrivateKey(String x, String p, String q, String g)
|
||||
throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("DSA").generatePrivate(new DSAPrivateKeySpec(new BigInteger(x, 16),
|
||||
new BigInteger(p, 16),
|
||||
new BigInteger(q, 16),
|
||||
new BigInteger(g, 16))
|
||||
);
|
||||
}
|
||||
|
||||
/** Creates a DSA public key. */
|
||||
public static PublicKey newDSAPublicKey(String y, String p, String q, String g) throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("DSA").generatePublic(new DSAPublicKeySpec //
|
||||
(new BigInteger(y, 16), //
|
||||
new BigInteger(p, 16), //
|
||||
new BigInteger(q, 16), //
|
||||
new BigInteger(g, 16)));
|
||||
public static PublicKey newDSAPublicKey(String y, String p, String q, String g)
|
||||
throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("DSA").generatePublic(new DSAPublicKeySpec(new BigInteger(y, 16),
|
||||
new BigInteger(p, 16),
|
||||
new BigInteger(q, 16),
|
||||
new BigInteger(g, 16))
|
||||
);
|
||||
}
|
||||
|
||||
/** Creates an RSA private key. */
|
||||
public static PrivateKey newRSAPrivateKey(String modulus, String exponent) throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("RSA").generatePrivate(new RSAPrivateKeySpec //
|
||||
(new BigInteger(modulus, 16), //
|
||||
new BigInteger(exponent, 16)));
|
||||
public static PrivateKey newRSAPrivateKey(String modulus, String exponent)
|
||||
throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("RSA").generatePrivate(new RSAPrivateKeySpec(new BigInteger(modulus, 16),
|
||||
new BigInteger(exponent, 16))
|
||||
);
|
||||
}
|
||||
|
||||
/** Creates an RSA public key. */
|
||||
public static PublicKey newRSAPublicKey(String modulus, String exponent) throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("RSA").generatePublic(new RSAPublicKeySpec //
|
||||
(new BigInteger(modulus, 16), new BigInteger(exponent, 16)));
|
||||
public static PublicKey newRSAPublicKey(String modulus, String exponent)
|
||||
throws GeneralSecurityException {
|
||||
return SecurityUtils.getKeyFactory("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(modulus, 16),
|
||||
new BigInteger(exponent, 16)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user