You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tw...@apache.org on 2022/10/29 19:26:46 UTC
[mina-sshd] 03/03: Manual format fixes for column-aligned "+" operators
This is an automated email from the ASF dual-hosted git repository.
twolf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit de72f23cbc53dd699bd7c5a8f270f70af9e82f60
Author: Thomas Wolf <tw...@apache.org>
AuthorDate: Sat Oct 29 19:23:59 2022 +0200
Manual format fixes for column-aligned "+" operators
Column-aligning "+" operators (addition and string concatenation)
sometimes produces strange formatting. Fix those by removing stray
line-breaks in allocator expressions, mostly for exceptions, and
changing the format for arguments of allocator expressions from 32
to 16.
In a few places where column-aligning "+" operator produced strange
results (all in parameter lists) rewrite the code to compute the value
first and store in a local variable, then just pass the variable.
---
.../org/apache/sshd/cli/client/SshKeyScanMain.java | 3 +-
.../sshd/client/config/hosts/HostConfigEntry.java | 3 +-
.../sshd/client/config/hosts/HostPatternValue.java | 3 +-
.../sshd/client/config/hosts/KnownHostEntry.java | 5 ++-
.../client/config/hosts/KnownHostHashValue.java | 4 +--
.../config/keys/LazyClientKeyIdentityProvider.java | 3 +-
.../apache/sshd/common/PropertyResolverUtils.java | 3 +-
.../org/apache/sshd/common/cipher/ECCurves.java | 9 ++---
.../apache/sshd/common/config/TimeValueConfig.java | 4 +--
.../common/config/keys/AuthorizedKeyEntry.java | 3 +-
.../sshd/common/config/keys/KeyEntryResolver.java | 12 +++----
.../keys/impl/ECDSAPublicKeyEntryDecoder.java | 4 +--
.../keys/loader/AESPrivateKeyObfuscator.java | 4 +--
.../keys/loader/AbstractPrivateKeyObfuscator.java | 3 +-
.../openssh/OpenSSHKeyPairResourceParser.java | 6 ++--
.../config/keys/loader/openssh/kdf/BCrypt.java | 6 ++--
.../keys/loader/openssh/kdf/BCryptKdfOptions.java | 9 ++---
.../loader/ssh2/Ssh2PublicKeyEntryDecoder.java | 3 +-
.../common/file/root/RootedFileSystemProvider.java | 3 +-
.../FileHostKeyCertificateProvider.java | 3 +-
.../common/keyprovider/KeyIdentityProvider.java | 3 +-
.../keyprovider/MultiKeyIdentityIterator.java | 3 +-
.../apache/sshd/common/signature/SignatureDSA.java | 6 ++--
.../sshd/common/signature/SignatureECDSA.java | 3 +-
.../sshd/common/signature/SignatureFactory.java | 3 +-
.../org/apache/sshd/common/util/buffer/Buffer.java | 6 ++--
.../sshd/common/util/buffer/BufferUtils.java | 6 ++--
.../util/buffer/keys/ECBufferPublicKeyParser.java | 3 +-
.../buffer/keys/OpenSSHCertPublicKeyParser.java | 3 +-
.../sshd/common/util/net/SshdSocketAddress.java | 3 +-
.../sshd/util/test/CommonTestSupportUtils.java | 15 +++-----
...elIdTrackingUnknownChannelReferenceHandler.java | 5 ++-
.../contrib/common/signature/LegacyDSASigner.java | 3 +-
.../sshd/agent/local/AgentForwardedChannel.java | 5 ++-
.../org/apache/sshd/agent/local/AgentImpl.java | 3 +-
.../sshd/agent/local/ChannelAgentForwarding.java | 3 +-
.../sshd/agent/unix/ChannelAgentForwarding.java | 3 +-
.../java/org/apache/sshd/client/SshClient.java | 6 ++--
.../client/auth/hostbased/UserAuthHostBased.java | 21 ++++-------
.../auth/keyboard/UserAuthKeyboardInteractive.java | 15 +++-----
.../client/auth/password/UserAuthPassword.java | 23 ++++--------
.../sshd/client/auth/pubkey/UserAuthPublicKey.java | 26 ++++++--------
.../auth/pubkey/UserAuthPublicKeyIterator.java | 3 +-
.../sshd/client/channel/AbstractClientChannel.java | 3 +-
.../apache/sshd/client/channel/ClientChannel.java | 4 +--
.../java/org/apache/sshd/client/kex/DHGClient.java | 42 +++++++++-------------
.../org/apache/sshd/client/kex/DHGEXClient.java | 15 ++++----
.../sshd/client/session/AbstractClientSession.java | 6 ++--
.../apache/sshd/client/session/ClientSession.java | 4 +--
.../sshd/client/session/ClientUserAuthService.java | 9 ++---
.../sshd/common/channel/AbstractChannel.java | 6 ++--
.../common/channel/BufferedIoOutputStream.java | 6 ++--
.../sshd/common/channel/ChannelOutputStream.java | 9 ++---
.../sshd/common/forward/DefaultForwarder.java | 36 +++++++------------
.../sshd/common/forward/TcpipClientChannel.java | 3 +-
.../common/io/DefaultIoServiceFactoryFactory.java | 3 +-
.../apache/sshd/common/kex/MontgomeryCurve.java | 3 +-
.../sshd/common/kex/dh/AbstractDHKeyExchange.java | 6 ++--
.../session/helpers/AbstractConnectionService.java | 3 +-
.../common/session/helpers/AbstractSession.java | 13 +++----
.../session/helpers/KeyExchangeMessageHandler.java | 5 +--
.../sshd/common/session/helpers/SessionHelper.java | 12 +++----
.../apache/sshd/server/auth/gss/UserAuthGSS.java | 3 +-
.../sshd/server/channel/AbstractServerChannel.java | 3 +-
.../sshd/server/forward/TcpipServerChannel.java | 10 +++---
.../org/apache/sshd/server/kex/DHGEXServer.java | 15 ++++----
.../java/org/apache/sshd/server/kex/DHGServer.java | 3 +-
.../sshd/server/session/AbstractServerSession.java | 9 ++---
.../sshd/server/x11/ChannelForwardedX11.java | 3 +-
.../common/auth/PasswordAuthenticationTest.java | 6 ++--
.../common/auth/PublicKeyAuthenticationTest.java | 3 +-
.../java/org/apache/sshd/server/ServerTest.java | 6 ++--
sshd-eclipse-formatter-config.xml | 2 +-
.../openpgp/PGPAuthorizedKeyEntriesLoader.java | 6 ++--
.../sshd/openpgp/PGPKeyPairResourceParser.java | 3 +-
.../apache/sshd/openpgp/PGPPublicKeyExtractor.java | 6 ++--
.../apache/sshd/putty/ECDSAPuttyKeyDecoder.java | 6 ++--
.../sshd/putty/PuttyKeyPairResourceParser.java | 3 +-
.../java/org/apache/sshd/scp/common/ScpHelper.java | 6 ++--
.../apache/sshd/scp/common/helpers/ScpIoUtils.java | 4 +--
.../org/apache/sshd/scp/server/ScpCommand.java | 6 ++--
.../apache/sshd/scp/server/ScpCommandFactory.java | 6 ++--
.../java/org/apache/sshd/scp/server/ScpShell.java | 6 ++--
.../helpers/AbstractSftpClientExtension.java | 3 +-
.../apache/sshd/sftp/client/fs/SftpFileSystem.java | 6 ++--
.../sftp/client/fs/SftpFileSystemProvider.java | 7 ++--
.../sshd/sftp/client/impl/AbstractSftpClient.java | 21 ++++-------
.../sftp/client/impl/SftpRemotePathChannel.java | 21 ++++-------
.../sftp/server/AbstractSftpSubsystemHelper.java | 7 ++--
.../org/apache/sshd/sftp/server/FileHandle.java | 6 ++--
.../org/apache/sshd/sftp/server/SftpSubsystem.java | 21 ++++-------
91 files changed, 236 insertions(+), 422 deletions(-)
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
index e3b120515..942101242 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
@@ -339,8 +339,7 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
ConnectFuture future = client.connect(UUID.randomUUID().toString(), host, connectPort);
long waitTime = getTimeout();
if (!future.await(waitTime)) {
- throw new ConnectException(
- "Failed to connect to " + host + ":" + connectPort
+ throw new ConnectException("Failed to connect to " + host + ":" + connectPort
+ " within " + waitTime + " msec."
+ " to retrieve key type=" + kt);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
index 5f4d33d0f..2d661e026 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
@@ -947,8 +947,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
try {
curEntry.processProperty(key, valsList, false);
} catch (RuntimeException e) {
- throw new StreamCorruptedException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to process line #" + lineNumber + " (" + line + ")"
+ ": " + e.getMessage());
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
index c33be090c..7629d582c 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java
@@ -88,8 +88,7 @@ public class HostPatternValue {
try {
KnownHostHashValue.appendHostPattern(sb, purePattern, portValue);
} catch (IOException e) {
- throw new RuntimeException(
- "Unexpected (" + e.getClass().getSimpleName() + ") failure"
+ throw new RuntimeException("Unexpected (" + e.getClass().getSimpleName() + ") failure"
+ " to append host pattern of " + purePattern + ":" + portValue + ": " + e.getMessage(),
e);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java
index 03427c6be..fffeb3c52 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostEntry.java
@@ -204,9 +204,8 @@ public class KnownHostEntry extends HostPatternsHolder {
}
entries.add(entry);
} catch (RuntimeException | Error e) { // TODO consider consulting a user callback
- throw new StreamCorruptedException(
- "Failed (" + e.getClass().getSimpleName() + ")" + " to parse line #" + lineNumber + " '" + line + "': "
- + e.getMessage());
+ throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ") to parse line #"
+ + lineNumber + " '" + line + "': " + e.getMessage());
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
index bb7bd7289..4831541f2 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostHashValue.java
@@ -143,8 +143,8 @@ public class KnownHostHashValue {
try {
return appendHostPattern(new StringBuilder(host.length() + 8 /* port if necessary */), host, port).toString();
} catch (IOException e) {
- throw new RuntimeException(
- "Unexpected (" + e.getClass().getSimpleName() + ") failure" + " to generate host pattern of " + host + ":"
+ throw new RuntimeException("Unexpected (" + e.getClass().getSimpleName() + ") failure"
+ + " to generate host pattern of " + host + ":"
+ port + ": " + e.getMessage(),
e);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
index 3c02d47ff..3658c5dd0 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/keys/LazyClientKeyIdentityProvider.java
@@ -106,8 +106,7 @@ public class LazyClientKeyIdentityProvider
try {
ids = loadClientIdentities(session, l);
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new RuntimeException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to load key from " + l.getName() + ": " + e.getMessage(),
e);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java
index 0c19d8e17..94534dca1 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/PropertyResolverUtils.java
@@ -203,8 +203,7 @@ public final class PropertyResolverUtils {
return null;
} else {
- throw new IllegalArgumentException(
- "Bad value type for enum conversion: " + value.getClass().getSimpleName());
+ throw new IllegalArgumentException("Bad value type for enum conversion: " + value.getClass().getSimpleName());
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
index f8bee2056..12f9e5e5a 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
@@ -487,8 +487,7 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
public ECPoint octetStringToEcPoint(byte[] octets, int startIndex, int len) {
int numElements = len / 2; /* x, y */
if (len != (numElements * 2)) { // make sure length is not odd
- throw new IllegalArgumentException(
- "octetStringToEcPoint(" + name() + ") "
+ throw new IllegalArgumentException("octetStringToEcPoint(" + name() + ") "
+ " invalid remainder octets representation: "
+ " expected=" + (2 * numElements) + ", actual=" + len);
}
@@ -539,8 +538,7 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
writeECPoint(baos, curveName, p);
return baos.toByteArray();
} catch (IOException e) {
- throw new RuntimeException(
- "ecPointToOctetString(" + curveName + ")"
+ throw new RuntimeException("ecPointToOctetString(" + curveName + ")"
+ " failed (" + e.getClass().getSimpleName() + ")"
+ " to write data: " + e.getMessage(),
e);
@@ -567,8 +565,7 @@ public enum ECCurves implements KeyTypeIndicator, KeySizeIndicator, NamedResourc
}
if (vLen > numElements) {
- throw new StreamCorruptedException(
- "writeCoordinate(" + name() + ")[" + n + "]"
+ throw new StreamCorruptedException("writeCoordinate(" + name() + ")[" + n + "]"
+ " value length (" + vLen + ") exceeds max. (" + numElements + ")"
+ " for " + v);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java b/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
index 0e84f86cc..ba56fa106 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
@@ -145,8 +145,8 @@ public enum TimeValueConfig {
Long prev = spec.put(SECONDS, count);
if (prev != null) {
- throw new IllegalArgumentException(
- "parse(" + s + ") last component (" + SECONDS.name() + ") value re-specified: current=" + count
+ throw new IllegalArgumentException("parse(" + s + ") last component (" + SECONDS.name()
+ + ") value re-specified: current=" + count
+ ", previous=" + prev);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java
index 096fd0c30..dc635ddeb 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntry.java
@@ -243,8 +243,7 @@ public class AuthorizedKeyEntry extends PublicKeyEntry {
continue; // null, empty or comment line
}
} catch (RuntimeException | Error e) {
- throw new StreamCorruptedException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to parse key entry=" + line + ": " + e.getMessage());
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
index 3dd5e7b6f..78e268fbd 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyEntryResolver.java
@@ -76,9 +76,9 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
if (pubOriginal != null) {
Class<?> orgType = pubOriginal.getClass();
if (!pubExpected.isAssignableFrom(orgType)) {
- throw new InvalidKeyException(
- "Mismatched public key types: expected=" + pubExpected.getSimpleName() + ", actual="
- + orgType.getSimpleName());
+ throw new InvalidKeyException("Mismatched public key types: expected="
+ + pubExpected.getSimpleName()
+ + ", actual=" + orgType.getSimpleName());
}
PUB castPub = pubExpected.cast(pubOriginal);
@@ -91,9 +91,9 @@ public interface KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>
if (prvOriginal != null) {
Class<?> orgType = prvOriginal.getClass();
if (!prvExpected.isAssignableFrom(orgType)) {
- throw new InvalidKeyException(
- "Mismatched private key types: expected=" + prvExpected.getSimpleName() + ", actual="
- + orgType.getSimpleName());
+ throw new InvalidKeyException("Mismatched private key types: expected="
+ + prvExpected.getSimpleName()
+ + ", actual=" + orgType.getSimpleName());
}
PRV castPrv = prvExpected.cast(prvOriginal);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/ECDSAPublicKeyEntryDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/ECDSAPublicKeyEntryDecoder.java
index 41a9262c8..621b79bd6 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/ECDSAPublicKeyEntryDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/impl/ECDSAPublicKeyEntryDecoder.java
@@ -98,8 +98,8 @@ public class ECDSAPublicKeyEntryDecoder extends AbstractPublicKeyEntryDecoder<EC
"No ECPoint generated for curve=" + keyCurveName + " from octets=" + BufferUtils.toHex(':', octets));
}
} catch (RuntimeException e) {
- throw new InvalidKeySpecException(
- "Failed (" + e.getClass().getSimpleName() + ")" + " to generate ECPoint for curve=" + keyCurveName
+ throw new InvalidKeySpecException("Failed (" + e.getClass().getSimpleName() + ")"
+ + " to generate ECPoint for curve=" + keyCurveName
+ " from octets=" + BufferUtils.toHex(':', octets) + ": " + e.getMessage());
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
index 08a24bbac..f85136162 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
@@ -94,8 +94,8 @@ public class AESPrivateKeyObfuscator extends AbstractPrivateKeyObfuscator {
throw new InvalidKeySpecException(
"Unknown " + getCipherName() + " key length: " + cipherType + " - supported: " + sizes);
} catch (NumberFormatException e) {
- throw new InvalidKeySpecException(
- "Bad " + getCipherName() + " key length (" + cipherType + "): " + e.getMessage(), e);
+ throw new InvalidKeySpecException("Bad " + getCipherName() + " key length (" + cipherType + "): " + e.getMessage(),
+ e);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractPrivateKeyObfuscator.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractPrivateKeyObfuscator.java
index 2bfc9704c..45f694272 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractPrivateKeyObfuscator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AbstractPrivateKeyObfuscator.java
@@ -149,8 +149,7 @@ public abstract class AbstractPrivateKeyObfuscator implements PrivateKeyObfuscat
int maxAllowedBits = Cipher.getMaxAllowedKeyLength(xform);
// see http://www.javamex.com/tutorials/cryptography/unrestricted_policy_files.shtml
if (numBits > maxAllowedBits) {
- throw new InvalidKeySpecException(
- "applyPrivateKeyCipher(" + xform + ")[encrypt=" + encryptIt + "]"
+ throw new InvalidKeySpecException("applyPrivateKeyCipher(" + xform + ")[encrypt=" + encryptIt + "]"
+ " required key length (" + numBits + ")"
+ " exceeds max. available: " + maxAllowedBits);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
index a93018e10..64b32cc23 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
@@ -259,8 +259,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
* can be quickly checked by verifying that both checkint fields hold the same value.
*/
if (check1 != check2) {
- throw new StreamCorruptedException(
- "Mismatched private key check values ("
+ throw new StreamCorruptedException("Mismatched private key check values ("
+ Integer.toHexString(check1) + "/" + Integer.toHexString(check2) + ") in "
+ resourceKey);
}
@@ -301,8 +300,7 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
throws IOException, GeneralSecurityException {
String prvType = KeyEntryResolver.decodeString(stream, MAX_KEY_TYPE_NAME_LENGTH);
if (!Objects.equals(keyType, prvType)) {
- throw new StreamCorruptedException(
- "Mismatched private key type: "
+ throw new StreamCorruptedException("Mismatched private key type: "
+ ", expected=" + keyType + ", actual=" + prvType
+ " in " + resourceKey);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
index 20a8b76d8..56a62bc70 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
@@ -797,8 +797,7 @@ public class BCrypt {
if (rounds < 10)
rs.append("0");
if (rounds > 30) {
- throw new IllegalArgumentException(
- "rounds exceeds maximum (30)");
+ throw new IllegalArgumentException("rounds exceeds maximum (30)");
}
rs.append(Integer.toString(rounds));
rs.append("$");
@@ -826,8 +825,7 @@ public class BCrypt {
if (log_rounds < 10)
rs.append("0");
if (log_rounds > 30) {
- throw new IllegalArgumentException(
- "log_rounds exceeds maximum (30)");
+ throw new IllegalArgumentException("log_rounds exceeds maximum (30)");
}
rs.append(Integer.toString(log_rounds));
rs.append("$");
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCryptKdfOptions.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCryptKdfOptions.java
index 5937b0e85..a48a18fef 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCryptKdfOptions.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCryptKdfOptions.java
@@ -86,8 +86,7 @@ public class BCryptKdfOptions implements OpenSSHKdfOptions {
byte[] saltValue = getSalt();
int actualSaltLength = NumberUtils.length(saltValue);
if (actualSaltLength != expectedSaltLength) {
- throw new StreamCorruptedException(
- "Mismatched salt data length:"
+ throw new StreamCorruptedException("Mismatched salt data length:"
+ " expected=" + expectedSaltLength + ", actual=" + actualSaltLength);
}
}
@@ -117,8 +116,7 @@ public class BCryptKdfOptions implements OpenSSHKdfOptions {
int blockSize = cipherSpec.getCipherBlockSize();
if ((privateDataBytes.length % blockSize) != 0) {
- throw new StreamCorruptedException(
- "Encrypted data size (" + privateDataBytes.length + ")"
+ throw new StreamCorruptedException("Encrypted data size (" + privateDataBytes.length + ")"
+ " is not aligned to " + cipherName + " block size (" + blockSize + ")");
}
@@ -193,8 +191,7 @@ public class BCryptKdfOptions implements OpenSSHKdfOptions {
public void setNumRounds(int numRounds) {
int maxAllowed = getMaxAllowedRounds();
if ((numRounds <= 0) || (numRounds > maxAllowed)) {
- throw new BCryptBadRoundsException(
- numRounds, "Bad rounds value (" + numRounds + ") - max. allowed " + maxAllowed);
+ throw new BCryptBadRoundsException(numRounds, "Bad rounds value (" + numRounds + ") - max. allowed " + maxAllowed);
}
this.numRounds = numRounds;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/ssh2/Ssh2PublicKeyEntryDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/ssh2/Ssh2PublicKeyEntryDecoder.java
index 8a8067381..082f16ddf 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/ssh2/Ssh2PublicKeyEntryDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/ssh2/Ssh2PublicKeyEntryDecoder.java
@@ -220,7 +220,6 @@ public class Ssh2PublicKeyEntryDecoder
headers.put(name, value.trim());
}
- throw new StreamCorruptedException(
- "No viable data lines found in " + resourceKey.getName() + " after " + startLine);
+ throw new StreamCorruptedException("No viable data lines found in " + resourceKey.getName() + " after " + startLine);
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
index f6f1360c5..0855c7751 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
@@ -453,8 +453,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
protected Path unroot(Path path) {
Objects.requireNonNull(path, "No path to unroot");
if (!(path instanceof RootedPath)) {
- throw new ProviderMismatchException(
- "unroot(" + path + ") is not a " + RootedPath.class.getSimpleName()
+ throw new ProviderMismatchException("unroot(" + path + ") is not a " + RootedPath.class.getSimpleName()
+ " but rather a " + path.getClass().getSimpleName());
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/FileHostKeyCertificateProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/FileHostKeyCertificateProvider.java
index 2df3012dd..5df1adb79 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/FileHostKeyCertificateProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/FileHostKeyCertificateProvider.java
@@ -88,8 +88,7 @@ public class FileHostKeyCertificateProvider extends AbstractLoggingBean implemen
}
if (!(publicKey instanceof OpenSshCertificate)) {
- throw new InvalidKeyException(
- "Got unexpected key type in " + file + "; line " + lineNumber
+ throw new InvalidKeyException("Got unexpected key type in " + file + "; line " + lineNumber
+ ". Expected OpenSSHCertificate.");
}
if (!OpenSshCertificate.Type.HOST.equals(((OpenSshCertificate) publicKey).getType())) {
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java
index ea08b6d24..4e94416ce 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/KeyIdentityProvider.java
@@ -145,8 +145,7 @@ public interface KeyIdentityProvider {
try {
return p.loadKeys(session);
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(
- "Unexpected " + e.getClass().getSimpleName() + ")"
+ throw new RuntimeException("Unexpected " + e.getClass().getSimpleName() + ")"
+ " keys loading exception: " + e.getMessage(),
e);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java
index 0316d792d..917f2e6c6 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityIterator.java
@@ -76,8 +76,7 @@ public class MultiKeyIdentityIterator implements Iterator<KeyPair>, SessionConte
try {
keys = (p == null) ? null : p.loadKeys(session);
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(
- "Unexpected " + e.getClass().getSimpleName() + ")"
+ throw new RuntimeException("Unexpected " + e.getClass().getSimpleName() + ")"
+ " keys loading exception: " + e.getMessage(),
e);
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java
index 4ee5785a1..cc48088a4 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java
@@ -72,8 +72,7 @@ public class SignatureDSA extends AbstractSignature {
* least one byte of integer data (zero length is not an option)
*/
if (remainLen < (2 * 3)) {
- throw new StreamCorruptedException(
- "Invalid signature format - not enough encoded data length: " + remainLen);
+ throw new StreamCorruptedException("Invalid signature format - not enough encoded data length: " + remainLen);
}
BigInteger r = parser.readBigInteger();
@@ -113,8 +112,7 @@ public class SignatureDSA extends AbstractSignature {
}
if (sigLen != DSA_SIGNATURE_LENGTH) {
- throw new SignatureException(
- "Bad signature length (" + sigLen + " instead of " + DSA_SIGNATURE_LENGTH + ")"
+ throw new SignatureException("Bad signature length (" + sigLen + " instead of " + DSA_SIGNATURE_LENGTH + ")"
+ " for " + BufferUtils.toHex(':', data));
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureECDSA.java b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureECDSA.java
index 33e425105..3939d3d18 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureECDSA.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureECDSA.java
@@ -85,8 +85,7 @@ public class SignatureECDSA extends AbstractSignature {
* least one byte of integer data (zero length is not an option)
*/
if (remainLen < (2 * 3)) {
- throw new StreamCorruptedException(
- "Invalid signature format - not enough encoded data length: " + remainLen);
+ throw new StreamCorruptedException("Invalid signature format - not enough encoded data length: " + remainLen);
}
BigInteger r = parser.readBigInteger();
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureFactory.java b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureFactory.java
index b88178edb..6876856e5 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureFactory.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureFactory.java
@@ -246,8 +246,7 @@ public interface SignatureFactory extends BuiltinFactory<Signature> {
String name = factory.getName();
if (!algo.equalsIgnoreCase(name)) {
- throw new InvalidKeySpecException(
- "Mismatched factory name (" + name + ")"
+ throw new InvalidKeySpecException("Mismatched factory name (" + name + ")"
+ " for algorithm=" + algo + " when using key type"
+ KeyUtils.getKeyType(pubKey));
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/Buffer.java b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/Buffer.java
index 3c00d5319..46ae793c1 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/Buffer.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/Buffer.java
@@ -606,8 +606,7 @@ public abstract class Buffer implements Readable {
try {
group = ECCurves.octetStringToEcPoint(groupBytes);
} catch (RuntimeException e) {
- throw new InvalidKeySpecException(
- "extractEC(" + expectedCurveName + ")"
+ throw new InvalidKeySpecException("extractEC(" + expectedCurveName + ")"
+ " failed (" + e.getClass().getSimpleName() + ")"
+ " to decode EC group for curve: " + e.getMessage(),
e);
@@ -680,8 +679,7 @@ public abstract class Buffer implements Readable {
} else if (buffer instanceof ByteBuffer) {
putBuffer((ByteBuffer) buffer);
} else {
- throw new IllegalArgumentException(
- "No buffered overload found for "
+ throw new IllegalArgumentException("No buffered overload found for "
+ ((buffer == null) ? null : buffer.getClass().getName()));
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java
index 77b201a25..cdb583153 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java
@@ -386,8 +386,7 @@ public final class BufferUtils {
IoUtils.readFully(input, buf, offset, Integer.BYTES);
return getUInt(buf, offset, len);
} catch (RuntimeException | Error e) {
- throw new StreamCorruptedException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to read UINT value: " + e.getMessage());
}
}
@@ -511,8 +510,7 @@ public final class BufferUtils {
int writeLen = putUInt(value, buf, off, len);
output.write(buf, off, writeLen);
} catch (RuntimeException | Error e) {
- throw new StreamCorruptedException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to write UINT value=" + value + ": " + e.getMessage());
}
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/ECBufferPublicKeyParser.java b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/ECBufferPublicKeyParser.java
index 553afc37c..f389df7d9 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/ECBufferPublicKeyParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/ECBufferPublicKeyParser.java
@@ -72,8 +72,7 @@ public class ECBufferPublicKeyParser extends AbstractBufferPublicKeyParser<ECPub
try {
w = ECCurves.octetStringToEcPoint(octets);
} catch (RuntimeException e) {
- throw new InvalidKeySpecException(
- "getRawECKey(" + expectedCurve + ")"
+ throw new InvalidKeySpecException("getRawECKey(" + expectedCurve + ")"
+ " cannot (" + e.getClass().getSimpleName() + ")"
+ " retrieve W value: " + e.getMessage(),
e);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/OpenSSHCertPublicKeyParser.java b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/OpenSSHCertPublicKeyParser.java
index 0de05a577..7ec03a7f6 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/OpenSSHCertPublicKeyParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/buffer/keys/OpenSSHCertPublicKeyParser.java
@@ -88,8 +88,7 @@ public class OpenSSHCertPublicKeyParser extends AbstractBufferPublicKeyParser<Op
certificate.setSignature(buffer.getBytes());
if (buffer.rpos() != buffer.wpos()) {
- throw new InvalidKeyException(
- "Cannot read OpenSSH certificate, got more data than expected: "
+ throw new InvalidKeyException("Cannot read OpenSSH certificate, got more data than expected: "
+ buffer.rpos() + ", actual: " + buffer.wpos() + ". ID of the ca certificate: "
+ certificate.getId());
}
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java b/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
index 9078570d5..2bbbd3677 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
@@ -401,8 +401,7 @@ public class SshdSocketAddress extends SocketAddress {
InetSocketAddress isockAddress = (InetSocketAddress) addr;
return new SshdSocketAddress(isockAddress.getHostName(), isockAddress.getPort());
} else {
- throw new UnsupportedOperationException(
- "Cannot convert " + addr.getClass().getSimpleName()
+ throw new UnsupportedOperationException("Cannot convert " + addr.getClass().getSimpleName()
+ "=" + addr + " to " + SshdSocketAddress.class.getSimpleName());
}
}
diff --git a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
index d85e7d8f3..6d4758c4a 100644
--- a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
+++ b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
@@ -168,8 +168,7 @@ public final class CommonTestSupportUtils {
try {
url = new URL(srcForm);
} catch (MalformedURLException e) {
- throw new IllegalArgumentException(
- "getClassContainerLocationURL(" + clazz.getName() + ")"
+ throw new IllegalArgumentException("getClassContainerLocationURL(" + clazz.getName() + ")"
+ " Failed to create URL=" + srcForm + " from " + url.toExternalForm()
+ ": " + e.getMessage());
}
@@ -361,8 +360,7 @@ public final class CommonTestSupportUtils {
try {
return toPathSource(url.toURI());
} catch (URISyntaxException e) {
- throw new MalformedURLException(
- "toFileSource(" + url.toExternalForm() + ")"
+ throw new MalformedURLException("toFileSource(" + url.toExternalForm() + ")"
+ " cannot (" + e.getClass().getSimpleName() + ")"
+ " convert to URI: " + e.getMessage());
}
@@ -390,8 +388,7 @@ public final class CommonTestSupportUtils {
try {
return Paths.get(new URI(src));
} catch (URISyntaxException e) {
- throw new MalformedURLException(
- "toFileSource(" + src + ")"
+ throw new MalformedURLException("toFileSource(" + src + ")"
+ " cannot (" + e.getClass().getSimpleName() + ")"
+ " convert to URI: " + e.getMessage());
}
@@ -469,8 +466,7 @@ public final class CommonTestSupportUtils {
try {
pairs = Objects.requireNonNull(provider.loadKeys(null), "No loaded keys");
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(
- "Unexpected " + e.getClass().getSimpleName() + ")"
+ throw new RuntimeException("Unexpected " + e.getClass().getSimpleName() + ")"
+ " keys loading exception: " + e.getMessage(),
e);
}
@@ -561,8 +557,7 @@ public final class CommonTestSupportUtils {
try {
keys = Objects.requireNonNull(provider.loadKeys(null), "No keys loaded");
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(
- "Unexpected " + e.getClass().getSimpleName() + ")"
+ throw new RuntimeException("Unexpected " + e.getClass().getSimpleName() + ")"
+ " keys loading exception: " + e.getMessage(),
e);
}
diff --git a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/session/helpers/ChannelIdTrackingUnknownChannelReferenceHandler.java b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/session/helpers/ChannelIdTrackingUnknownChannelReferenceHandler.java
index 5686a2904..8cfa7198a 100644
--- a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/session/helpers/ChannelIdTrackingUnknownChannelReferenceHandler.java
+++ b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/session/helpers/ChannelIdTrackingUnknownChannelReferenceHandler.java
@@ -76,9 +76,8 @@ public class ChannelIdTrackingUnknownChannelReferenceHandler
return super.handleUnknownChannelCommand(service, cmd, channelId, buffer);
}
- throw new SshChannelNotFoundException(
- channelId,
+ throw new SshChannelNotFoundException(channelId,
"Received " + SshConstants.getCommandMessageName(cmd) + " on unassigned channel " + channelId
- + " (last assigned=" + lastTracked + ")");
+ + " (last assigned=" + lastTracked + ")");
}
}
diff --git a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java
index 8999e1978..63afc604d 100644
--- a/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java
+++ b/sshd-contrib/src/main/java/org/apache/sshd/contrib/common/signature/LegacyDSASigner.java
@@ -223,8 +223,7 @@ public class LegacyDSASigner extends java.security.Signature {
* least one byte of integer data (zero length is not an option)
*/
if (remainLen < (2 * 3)) {
- throw new SignatureException(
- "Invalid signature format - not enough encoded data length: " + remainLen);
+ throw new SignatureException("Invalid signature format - not enough encoded data length: " + remainLen);
}
r = parser.readBigInteger();
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java
index 4fd97e82d..1a01ef89b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentForwardedChannel.java
@@ -132,9 +132,8 @@ public class AgentForwardedChannel extends AbstractClientChannel {
try {
messages.wait(idleTimeout);
} catch (InterruptedException e) {
- throw (IOException) new InterruptedIOException(
- "Interrupted while waiting for messages at iteration #" + count)
- .initCause(e);
+ throw (IOException) new InterruptedIOException("Interrupted while waiting for messages at iteration #" + count)
+ .initCause(e);
}
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java
index b0c27fbe6..e55c3fcfb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java
@@ -85,8 +85,7 @@ public class AgentImpl implements SshAgent {
NamedFactory<Signature> factory = SignatureFactory.resolveSignatureFactoryByPublicKey(pubKey, algo);
Signature verif = (factory == null) ? null : factory.create();
if (verif == null) {
- throw new InvalidKeySpecException(
- "No signer found for " + pubKey.getClass().getSimpleName()
+ throw new InvalidKeySpecException("No signer found for " + pubKey.getClass().getSimpleName()
+ " when algorithm=" + algo + " requested for "
+ KeyUtils.getKeyType(pubKey));
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
index e5f73af6e..d0efedb4e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
@@ -127,8 +127,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
@Override
protected void doWriteExtendedData(byte[] data, int off, long len) throws IOException {
- throw new UnsupportedOperationException(
- "AgentForward channel does not support extended data");
+ throw new UnsupportedOperationException("AgentForward channel does not support extended data");
}
@SuppressWarnings("synthetic-access")
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
index 181ae864b..11091d979 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
@@ -160,8 +160,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
@Override
protected void doWriteExtendedData(byte[] data, int off, long len) throws IOException {
- throw new UnsupportedOperationException(
- "AgentForward channel does not support extended data");
+ throw new UnsupportedOperationException("AgentForward channel does not support extended data");
}
/**
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index eead8d166..3c9cbc1ab 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -466,8 +466,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
Duration maxWait = CoreModuleProperties.STOP_WAIT_TIME.getRequired(this);
boolean successful = close(true).await(maxWait);
if (!successful) {
- throw new SocketTimeoutException(
- "Failed to receive closure confirmation within " + maxWait + " millis");
+ throw new SocketTimeoutException("Failed to receive closure confirmation within " + maxWait + " millis");
}
} catch (IOException e) {
warn("{} while stopping client: {}", e.getClass().getSimpleName(), e.getMessage(), e);
@@ -624,8 +623,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
KeyIdentityProvider identities, HostConfigEntry hostConfig)
throws IOException {
if (connector == null) {
- throw new IllegalStateException(
- "SshClient not started. Please call start() method before connecting to a server");
+ throw new IllegalStateException("SshClient not started. Please call start() method before connecting to a server");
}
ConnectFuture connectFuture = new DefaultConnectFuture(username + "@" + targetAddress, null);
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java
index 4ec21ba75..5dfaebfc1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java
@@ -136,12 +136,9 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact
session, service, name, clientUsername, clientHostname);
}
- Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST,
- id.length + username.length() + service.length()
- + clientUsername.length()
- + clientHostname.length()
- + keyType.length()
- + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE);
+ int length = id.length + username.length() + service.length() + clientUsername.length() + clientHostname.length()
+ + keyType.length() + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE;
+ Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, length);
buffer.clear();
buffer.putRawPublicKey(pub);
@@ -188,12 +185,9 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact
byte[] id = session.getSessionId();
String username = session.getUsername();
String name = getName();
- Buffer bs = new ByteArrayBuffer(
- id.length + username.length() + service.length() + name.length()
- + keyType.length() + keyBytes.length
- + clientHostname.length() + clientUsername.length()
- + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE,
- false);
+ int length = id.length + username.length() + service.length() + name.length() + keyType.length() + keyBytes.length
+ + clientHostname.length() + clientUsername.length() + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE;
+ Buffer bs = new ByteArrayBuffer(length, false);
bs.putBytes(id);
bs.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
bs.putString(username);
@@ -225,8 +219,7 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact
ClientSession session, String service, Buffer buffer)
throws Exception {
int cmd = buffer.getUByte();
- throw new IllegalStateException(
- "processAuthDataRequest(" + session + ")[" + service + "]"
+ throw new IllegalStateException("processAuthDataRequest(" + session + ")[" + service + "]"
+ " received unknown packet: cmd=" + SshConstants.getCommandMessageName(cmd));
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java
index 412c89484..d80556b11 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java
@@ -83,14 +83,10 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
session, service, name, lang, subMethods);
}
- Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST,
- username.length() + service.length() + name.length()
- + GenericUtils.length(lang)
- + GenericUtils.length(subMethods)
- + Long.SIZE /*
- * a bit extra for the
- * lengths
- */);
+ int length = username.length() + service.length() + name.length() + GenericUtils.length(lang)
+ + GenericUtils.length(subMethods) + Long.SIZE; // A bit extra for the length
+
+ Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, length);
buffer.putString(username);
buffer.putString(service);
buffer.putString(name);
@@ -105,8 +101,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
protected boolean processAuthDataRequest(ClientSession session, String service, Buffer buffer) throws Exception {
int cmd = buffer.getUByte();
if (cmd != SshConstants.SSH_MSG_USERAUTH_INFO_REQUEST) {
- throw new IllegalStateException(
- "processAuthDataRequest(" + session + ")[" + service + "]"
+ throw new IllegalStateException("processAuthDataRequest(" + session + ")[" + service + "]"
+ " received unknown packet: cmd=" + SshConstants.getCommandMessageName(cmd));
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/password/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/password/UserAuthPassword.java
index 349000065..6374d70a3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/password/UserAuthPassword.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/password/UserAuthPassword.java
@@ -77,15 +77,8 @@ public class UserAuthPassword extends AbstractUserAuth {
}
String username = session.getUsername();
- Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST,
- username.length() + service.length()
- + GenericUtils.length(getName())
- + current.length()
- + Integer.SIZE /*
- * a few extra
- * encoding fields
- * overhead
- */);
+ int length = username.length() + service.length() + GenericUtils.length(getName()) + current.length() + Integer.SIZE;
+ Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, length);
sendPassword(buffer, session, current, current);
return true;
}
@@ -109,8 +102,7 @@ public class UserAuthPassword extends AbstractUserAuth {
throws Exception {
int cmd = buffer.getUByte();
if (cmd != SshConstants.SSH_MSG_USERAUTH_PASSWD_CHANGEREQ) {
- throw new IllegalStateException(
- "processAuthDataRequest(" + session + ")[" + service + "]"
+ throw new IllegalStateException("processAuthDataRequest(" + session + ")[" + service + "]"
+ " received unknown packet: cmd=" + SshConstants.getCommandMessageName(cmd));
}
@@ -189,12 +181,9 @@ public class UserAuthPassword extends AbstractUserAuth {
session, service, name, modified);
}
- buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST,
- GenericUtils.length(username) + GenericUtils.length(service)
- + GenericUtils.length(name)
- + GenericUtils.length(oldPassword)
- + (modified ? GenericUtils.length(newPassword) : 0)
- + Long.SIZE);
+ int length = GenericUtils.length(username) + GenericUtils.length(service) + GenericUtils.length(name)
+ + GenericUtils.length(oldPassword) + (modified ? GenericUtils.length(newPassword) : 0) + Long.SIZE;
+ buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, length);
buffer.putString(username);
buffer.putString(service);
buffer.putString(name);
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
index 52cbc0e0b..2a15b9b66 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
@@ -273,8 +273,7 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact
if (!OpenSshCertificate.Type.USER.equals(cert.getType())) {
log.warn(
"resolveAttemptedPublicKeyIdentity({})[{}]: public key certificate {} {} (id={}) is not a user certificate",
- session, service, KeyUtils.getKeyType(cert), KeyUtils.getFingerPrint(cert),
- cert.getId());
+ session, service, KeyUtils.getKeyType(cert), KeyUtils.getFingerPrint(cert), cert.getId());
if (reporter != null) {
reporter.signalIdentitySkipped(session, service, identity);
}
@@ -283,8 +282,7 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact
if (!OpenSshCertificate.isValidNow(cert)) {
log.warn(
"resolveAttemptedPublicKeyIdentity({})[{}]: public key certificate {} {} (id={}) is not valid now",
- session, service, KeyUtils.getKeyType(cert), KeyUtils.getFingerPrint(cert),
- cert.getId());
+ session, service, KeyUtils.getKeyType(cert), KeyUtils.getFingerPrint(cert), cert.getId());
if (reporter != null) {
reporter.signalIdentitySkipped(session, service, identity);
}
@@ -352,8 +350,7 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact
}
int cmd = buffer.getUByte();
if (cmd != SshConstants.SSH_MSG_USERAUTH_PK_OK) {
- throw new IllegalStateException(
- "processAuthDataRequest(" + session + ")[" + service + "][" + name + "]"
+ throw new IllegalStateException("processAuthDataRequest(" + session + ")[" + service + "][" + name + "]"
+ " received unknown packet: cmd=" + SshConstants.getCommandMessageName(cmd));
}
@@ -380,8 +377,7 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact
session, service, name, rspKeyType, KeyUtils.getFingerPrint(rspKey));
}
if (!KeyUtils.compareKeys(rspKey, pubKey)) {
- throw new InvalidKeySpecException(
- "processAuthDataRequest(" + session + ")[" + service + "][" + name + "]"
+ throw new InvalidKeySpecException("processAuthDataRequest(" + session + ")[" + service + "][" + name + "]"
+ " mismatched " + rspKeyType + " keys: expected="
+ KeyUtils.getFingerPrint(pubKey)
+ ", actual=" + KeyUtils.getFingerPrint(rspKey));
@@ -394,10 +390,9 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact
String username = session.getUsername();
String algo = chosenAlgorithm;
- buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST,
- GenericUtils.length(username) + GenericUtils.length(service) + GenericUtils.length(name)
- + GenericUtils.length(algo)
- + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE);
+ int length = GenericUtils.length(username) + GenericUtils.length(service) + GenericUtils.length(name)
+ + GenericUtils.length(algo) + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE;
+ buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, length);
buffer.putString(username);
buffer.putString(service);
buffer.putString(name);
@@ -428,10 +423,9 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact
PublicKey serverKey, Buffer buffer)
throws Exception {
byte[] id = session.getSessionId();
- Buffer bs = new ByteArrayBuffer(
- id.length + username.length() + service.length() + name.length()
- + algo.length() + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE,
- false);
+ int length = id.length + username.length() + service.length() + name.length() + algo.length()
+ + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE;
+ Buffer bs = new ByteArrayBuffer(length, false);
bs.putBytes(id);
bs.putByte(SshConstants.SSH_MSG_USERAUTH_REQUEST);
bs.putString(username);
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java
index 970aa7d6a..72ccea6de 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java
@@ -98,8 +98,7 @@ public class UserAuthPublicKeyIterator extends AbstractKeyPairIterator<PublicKey
KeyIdentityProvider sessionKeysProvider = ClientSession.providerOf(session);
keysHolder.set(sessionKeysProvider.loadKeys(session));
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(
- "Unexpected " + e.getClass().getSimpleName() + ")"
+ throw new RuntimeException("Unexpected " + e.getClass().getSimpleName() + ")"
+ " keys loading exception: " + e.getMessage(),
e);
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
index 83cf7f79d..63fec43ae 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
@@ -364,8 +364,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
@Override
public OpenFuture open(long recipient, long rwSize, long packetSize, Buffer buffer) {
- throw new UnsupportedOperationException(
- "open(" + recipient + "," + rwSize + "," + packetSize + ") N/A");
+ throw new UnsupportedOperationException("open(" + recipient + "," + rwSize + "," + packetSize + ") N/A");
}
@Override
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
index cb520a7d0..aad26a385 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
@@ -246,8 +246,8 @@ public interface ClientChannel extends Channel, StreamingChannel, ClientSessionH
throw new RemoteException("No exit status returned for command=" + command);
}
if (exitStatus.intValue() != 0) {
- throw new RemoteException(
- "Remote command failed (" + exitStatus + "): " + command, new ServerException(exitStatus.toString()));
+ throw new RemoteException("Remote command failed (" + exitStatus + "): " + command,
+ new ServerException(exitStatus.toString()));
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
index 9b60e1ab4..294f3c733 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
@@ -121,8 +121,7 @@ public class DHGClient extends AbstractDHClientKeyExchange {
}
if (cmd != SshConstants.SSH_MSG_KEXDH_REPLY) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: expected packet SSH_MSG_KEXDH_REPLY, got " + KeyExchange.getSimpleKexOpcodeName(cmd));
}
@@ -156,8 +155,7 @@ public class DHGClient extends AbstractDHClientKeyExchange {
String keyAlg = session.getNegotiatedKexParameter(KexProposalOption.SERVERKEYS);
if (GenericUtils.isEmpty(keyAlg)) {
- throw new SshException(
- "Unsupported server key type: " + serverPublicHostKey.getAlgorithm()
+ throw new SshException("Unsupported server key type: " + serverPublicHostKey.getAlgorithm()
+ "[" + serverPublicHostKey.getFormat() + "]");
}
@@ -179,8 +177,7 @@ public class DHGClient extends AbstractDHClientKeyExchange {
verif.initVerifier(session, serverPublicHostKey);
verif.update(session, h);
if (!verif.verify(session, sig)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange signature verification failed for key type=" + keyAlg);
}
@@ -203,8 +200,7 @@ public class DHGClient extends AbstractDHClientKeyExchange {
}
keyAlg = variant;
} else {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Found invalid signature alg " + variant + " for key ID=" + keyId);
}
@@ -215,21 +211,19 @@ public class DHGClient extends AbstractDHClientKeyExchange {
verif.update(session, openSshKey.getMessage());
if (!verif.verify(session, openSshKey.getSignature())) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange CA signature verification failed for key type=" + keyAlg + " of key ID=" + keyId);
}
if (!OpenSshCertificate.Type.HOST.equals(openSshKey.getType())) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange signature verification failed, not a host key (2) "
- + openSshKey.getType() + " for key ID=" + keyId);
+ + openSshKey.getType() + " for key ID="
+ + keyId);
}
if (!OpenSshCertificate.isValidNow(openSshKey)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange signature verification failed, CA expired for key ID=" + keyId);
}
@@ -246,25 +240,23 @@ public class DHGClient extends AbstractDHClientKeyExchange {
String hostName = ((InetSocketAddress) connectSocketAddress).getHostString();
Collection<String> principals = openSshKey.getPrincipals();
if (GenericUtils.isEmpty(principals) || (!principals.contains(hostName))) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange signature verification failed, invalid principal "
- + hostName + " for key ID=" + keyId
- + " - allowed=" + principals);
+ + hostName + " for key ID=" + keyId
+ + " - allowed=" + principals);
}
} else {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange signature verification failed, could not determine connect host for key ID=" + keyId);
}
if (!GenericUtils.isEmpty(openSshKey.getCriticalOptions())) {
// no critical option defined for host keys yet
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange signature verification failed, unrecognized critical options "
- + openSshKey.getCriticalOptions() + " for key ID="
- + keyId);
+ + openSshKey.getCriticalOptions()
+ + " for key ID="
+ + keyId);
}
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
index faa26e338..3452bbc0d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
@@ -135,8 +135,7 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
this, s, min, prf, max);
}
if ((max < min) || (prf < min) || (max < prf)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: bad parameters " + min + " !< " + prf + " !< " + max);
}
@@ -161,10 +160,10 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
}
if (cmd != expected) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: expected packet " + KeyExchange.getGroupKexOpcodeName(expected)
- + ", got " + KeyExchange.getGroupKexOpcodeName(cmd));
+ + ", got "
+ + KeyExchange.getGroupKexOpcodeName(cmd));
}
if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_GROUP) {
@@ -210,8 +209,7 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
String keyAlg = session.getNegotiatedKexParameter(KexProposalOption.SERVERKEYS);
if (GenericUtils.isEmpty(keyAlg)) {
- throw new SshException(
- "Unsupported server key type: " + serverKey.getAlgorithm()
+ throw new SshException("Unsupported server key type: " + serverKey.getAlgorithm()
+ " [" + serverKey.getFormat() + "]");
}
@@ -238,8 +236,7 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
verif.initVerifier(session, serverKey);
verif.update(session, h);
if (!verif.verify(session, sig)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"KeyExchange signature verification failed for key type=" + keyAlg);
}
session.setServerKey(serverKey);
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
index d33c9a69b..5411db5af 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
@@ -518,8 +518,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
}
if (!SessionContext.isValidVersionPrefix(serverVersion)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
"Unsupported protocol version: " + serverVersion);
}
@@ -636,8 +635,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
Service service = currentService.getService();
if (!(service instanceof AbstractConnectionService)
|| !GenericUtils.isEmpty(((AbstractConnectionService) service).getChannels())) {
- throw new IllegalStateException(
- "The switch to the none cipher must be done immediately after authentication");
+ throw new IllegalStateException("The switch to the none cipher must be done immediately after authentication");
}
if (kexState.compareAndSet(KexState.DONE, KexState.INIT)) {
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index 4700198d7..836e5bc2a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -215,8 +215,8 @@ public interface ClientSession
} finally {
if (stderr.size() > 0) {
String errorMessage = stderr.toString(StandardCharsets.US_ASCII.name());
- throw new RemoteException(
- "Error reported from remote command=" + command, new ServerException(errorMessage));
+ throw new RemoteException("Error reported from remote command=" + command,
+ new ServerException(errorMessage));
}
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
index 107cd431d..8a6ab721d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
@@ -317,8 +317,7 @@ public class ClientUserAuthService extends AbstractCloseable implements Service,
}
if (userAuth == null) {
- throw new IllegalStateException(
- "Received unknown packet: " + SshConstants.getCommandMessageName(cmd));
+ throw new IllegalStateException("Received unknown packet: " + SshConstants.getCommandMessageName(cmd));
}
if (log.isDebugEnabled()) {
@@ -377,16 +376,14 @@ public class ClientUserAuthService extends AbstractCloseable implements Service,
// also wake up anyone sitting in waitFor
AuthFuture authFuture = Objects.requireNonNull(authFutureHolder.get(), "No current future");
- authFuture.setException(new SshException(
- SshConstants.SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE,
+ authFuture.setException(new SshException(SshConstants.SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE,
"No more authentication methods available"));
return;
}
userAuth = UserAuthMethodFactory.createUserAuth(session, authFactories, method);
if (userAuth == null) {
- throw new UnsupportedOperationException(
- "Failed to find a user-auth factory for method=" + method);
+ throw new UnsupportedOperationException("Failed to find a user-auth factory for method=" + method);
}
if (debugEnabled) {
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index ac3043f91..014cc46c0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -391,8 +391,7 @@ public abstract class AbstractChannel extends AbstractInnerCloseable implements
} else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
- throw new IOException(
- "Failed (" + e.getClass().getSimpleName() + ") to notify channel " + this
+ throw new IOException("Failed (" + e.getClass().getSimpleName() + ") to notify channel " + this
+ " initialization: " + e.getMessage(),
e);
}
@@ -867,8 +866,7 @@ public abstract class AbstractChannel extends AbstractInnerCloseable implements
* whether the max. packet size includes the length field or not
*/
if (len > (maxLocalSize + 4L)) {
- throw new IllegalStateException(
- "Bad length (" + len + ") " + " for cmd="
+ throw new IllegalStateException("Bad length (" + len + ") " + " for cmd="
+ SshConstants.getCommandMessageName(cmd) + " - max. allowed=" + maxLocalSize);
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
index 53b477137..f50f03019 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/BufferedIoOutputStream.java
@@ -129,8 +129,7 @@ public class BufferedIoOutputStream extends AbstractInnerCloseable implements Io
long remTime = expireTime - System.currentTimeMillis();
if (remTime <= 0L) {
pendingException.compareAndSet(null,
- new SshChannelBufferedOutputException(
- channelId,
+ new SshChannelBufferedOutputException(channelId,
"Max. pending write timeout expired after " + writtenBytesCount + " bytes"));
throw pendingException.get();
}
@@ -139,8 +138,7 @@ public class BufferedIoOutputStream extends AbstractInnerCloseable implements Io
pendingBytesCount.wait(remTime);
} catch (InterruptedException e) {
pendingException.compareAndSet(null,
- new SshChannelBufferedOutputException(
- channelId,
+ new SshChannelBufferedOutputException(channelId,
"Waiting for pending writes interrupted after " + writtenBytesCount + " bytes"));
throw pendingException.get();
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
index a84d47b05..d86bd4f77 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
@@ -143,8 +143,7 @@ public class ChannelOutputStream extends OutputStream implements java.nio.channe
// This is the only use of this instance's monitor; it's used exclusively to synchronize concurrent writes.
Channel channel = getChannel();
if (!isOpen()) {
- throw new SshChannelClosedException(
- channel.getChannelId(),
+ throw new SshChannelClosedException(channel.getChannelId(),
"write(" + this + ") len=" + l + " - channel already closed");
}
Session session = channel.getSession();
@@ -249,8 +248,7 @@ public class ChannelOutputStream extends OutputStream implements java.nio.channe
// moment, for instance during KEX.
Channel channel = getChannel();
if (OpenState.CLOSED.equals(openState.get())) {
- throw new SshChannelClosedException(
- channel.getChannelId(),
+ throw new SshChannelClosedException(channel.getChannelId(),
"flush(" + this + ") length=" + bufferLength + " - stream is already closed");
}
@@ -290,8 +288,7 @@ public class ChannelOutputStream extends OutputStream implements java.nio.channe
long lenToSend = Math.min(available, total);
long length = Math.min(lenToSend, remoteWindow.getPacketSize());
if (length > Integer.MAX_VALUE) {
- throw new StreamCorruptedException(
- "Accumulated " + SshConstants.getCommandMessageName(cmd)
+ throw new StreamCorruptedException("Accumulated " + SshConstants.getCommandMessageName(cmd)
+ " command bytes size (" + length + ") exceeds int boundaries");
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
index 264634884..2b7176538 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwarder.java
@@ -198,15 +198,13 @@ public class DefaultForwarder
synchronized (localLock) {
SshdSocketAddress prevRemote = SshdSocketAddress.findByOptionalWildcardAddress(localToRemote, result);
if (prevRemote != null) {
- throw new IOException(
- "Multiple local port forwarding addressing on port=" + result
+ throw new IOException("Multiple local port forwarding addressing on port=" + result
+ ": current=" + remote + ", previous=" + prevRemote);
}
InetSocketAddress prevBound = SshdSocketAddress.findByOptionalWildcardAddress(boundLocals, result);
if (prevBound != null) {
- throw new IOException(
- "Multiple local port forwarding bindings on port=" + result
+ throw new IOException("Multiple local port forwarding bindings on port=" + result
+ ": current=" + bound + ", previous=" + prevBound);
}
@@ -391,8 +389,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal tearing down explicit tunnel for local=" + localForwarding
+ " on bound=" + boundAddress,
t);
@@ -427,8 +424,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal torn down explicit tunnel local=" + localForwarding
+ " on bound=" + boundAddress,
t);
@@ -466,15 +462,13 @@ public class DefaultForwarder
synchronized (dynamicLock) {
SocksProxy prevProxy = dynamicLocal.get(port);
if (prevProxy != null) {
- throw new IOException(
- "Multiple dynamic port mappings found for port=" + port
+ throw new IOException("Multiple dynamic port mappings found for port=" + port
+ ": current=" + proxy + ", previous=" + prevProxy);
}
InetSocketAddress prevBound = boundDynamic.get(port);
if (prevBound != null) {
- throw new IOException(
- "Multiple dynamic port bindings found for port=" + port
+ throw new IOException("Multiple dynamic port bindings found for port=" + port
+ ": current=" + bound + ", previous=" + prevBound);
}
@@ -522,8 +516,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal establishing dynamic tunnel for local=" + local
+ " on bound=" + boundAddress,
t);
@@ -556,8 +549,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal establishing dynamic tunnel for local=" + local,
t);
}
@@ -645,8 +637,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal tearing down dynamic tunnel for address=" + address,
t);
}
@@ -676,8 +667,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal torn down dynamic tunnel for address=" + address,
t);
}
@@ -811,8 +801,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal establishing explicit tunnel for local=" + local
+ ", remote=" + remote + ", localForwarding=" + localForwarding,
t);
@@ -847,8 +836,7 @@ public class DefaultForwarder
} else if (t instanceof IOException) {
throw (IOException) t;
} else {
- throw new IOException(
- "Failed (" + t.getClass().getSimpleName() + ")"
+ throw new IOException("Failed (" + t.getClass().getSimpleName() + ")"
+ " to signal established explicit tunnel for local=" + local
+ ", remote=" + remote + ", localForwarding=" + localForwarding
+ ", bound=" + boundAddress,
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
index 36cf93982..c0c11a818 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
@@ -198,8 +198,7 @@ public class TcpipClientChannel extends AbstractClientChannel implements Forward
@Override
protected void doWriteExtendedData(byte[] data, int off, long len) throws IOException {
- throw new UnsupportedOperationException(
- getChannelType() + " Tcpip channel does not support extended data");
+ throw new UnsupportedOperationException(getChannelType() + " Tcpip channel does not support extended data");
}
@Override
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
index 3695e6daf..4b29d4255 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
@@ -133,8 +133,7 @@ public class DefaultIoServiceFactoryFactory extends AbstractIoServiceFactoryFact
for (T s : services) {
LOGGER.error("===> {}", s.getClass().getName());
}
- throw new IllegalStateException(
- "Multiple (" + numDetected + ")"
+ throw new IllegalStateException("Multiple (" + numDetected + ")"
+ " registered " + IoServiceFactoryFactory.class.getSimpleName()
+ " instances detected."
+ " Please use -D" + propName + "=...factory class.. to select one"
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/MontgomeryCurve.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/MontgomeryCurve.java
index 9e386926e..4358f07ac 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/MontgomeryCurve.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/MontgomeryCurve.java
@@ -172,8 +172,7 @@ public enum MontgomeryCurve implements KeySizeIndicator, OptionalFeature {
throw new InvalidKeySpecException("Provided key has wrong length (" + key.length + " bytes) for " + getAlgorithm());
} else if (offset == 1) {
if (key[0] != 0) {
- throw new InvalidKeySpecException(
- "Provided key for " + getAlgorithm()
+ throw new InvalidKeySpecException("Provided key for " + getAlgorithm()
+ " has extra byte, but it's non-zero: 0x"
+ Integer.toHexString(key[0] & 0xFF));
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
index 1e77c38f7..3843dc974 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/dh/AbstractDHKeyExchange.java
@@ -115,8 +115,7 @@ public abstract class AbstractDHKeyExchange extends AbstractLoggingBean implemen
protected void validateEValue(BigInteger pValue) throws Exception {
BigInteger value = Objects.requireNonNull(getEValue(), "No DH 'e' value set");
if (!KeyExchange.isValidDHValue(value, pValue)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: invalid DH 'e' value");
}
}
@@ -153,8 +152,7 @@ public abstract class AbstractDHKeyExchange extends AbstractLoggingBean implemen
protected void validateFValue(BigInteger pValue) throws Exception {
BigInteger value = Objects.requireNonNull(getFValue(), "No DH 'f' value set");
if (!KeyExchange.isValidDHValue(value, pValue)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: invalid DH 'f' value");
}
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index 5ae527aaa..d585a6ced 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -710,8 +710,7 @@ public abstract class AbstractConnectionService
UnknownChannelReferenceHandler handler = resolveUnknownChannelReferenceHandler();
if (handler == null) {
// Throw a special exception - SSHD-777
- throw new SshChannelNotFoundException(
- recipient,
+ throw new SshChannelNotFoundException(recipient,
"Received " + SshConstants.getCommandMessageName(cmd) + " on unknown channel " + recipient);
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index e35acdf47..22e68c656 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -933,8 +933,7 @@ public abstract class AbstractSession extends SessionHelper {
protected void validateKexState(int cmd, KexState expected) {
KexState actual = kexState.get();
if (!expected.equals(actual)) {
- throw new IllegalStateException(
- "Received KEX command=" + SshConstants.getCommandMessageName(cmd)
+ throw new IllegalStateException("Received KEX command=" + SshConstants.getCommandMessageName(cmd)
+ " while in state=" + actual + " instead of " + expected);
}
}
@@ -1558,8 +1557,7 @@ public abstract class AbstractSession extends SessionHelper {
log.warn("decode({}) Error decoding packet(invalid length): {}", this, decoderLength);
decoderBuffer.dumpHex(getSimplifiedLogger(), Level.FINEST,
"decode(" + this + ") invalid length packet", this);
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
"Invalid packet length: " + decoderLength);
}
// Ok, that's good, we can go to the next step
@@ -2141,8 +2139,8 @@ public abstract class AbstractSession extends SessionHelper {
kexOption);
}
} else {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED, "Illegal KEX option negotiated: " + kexOption);
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ "Illegal KEX option negotiated: " + kexOption);
}
}
} catch (IOException | RuntimeException | Error e) {
@@ -2350,8 +2348,7 @@ public abstract class AbstractSession extends SessionHelper {
debug("reExchangeKeys({}) failed ({}) to request new keys: {}",
this, e.getClass().getSimpleName(), e.getMessage(), e);
throw ValidateUtils.initializeExceptionCause(
- new ProtocolException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ new ProtocolException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to generate keys for exchange: " + e.getMessage()),
e);
} catch (Exception e) {
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
index 398f508f7..59018d6b8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/KeyExchangeMessageHandler.java
@@ -247,8 +247,9 @@ public class KeyExchangeMessageHandler {
log.debug("writePacket({}) failed ({}) to check re-key: {}", session, e.getClass().getSimpleName(),
e.getMessage(), e);
}
- throw ValidateUtils.initializeExceptionCause(new ProtocolException(
- "Failed (" + e.getClass().getSimpleName() + ")" + " to check re-key necessity: " + e.getMessage()),
+ throw ValidateUtils.initializeExceptionCause(
+ new ProtocolException("Failed (" + e.getClass().getSimpleName() + ")"
+ + " to check re-key necessity: " + e.getMessage()),
e);
} catch (Exception e) {
ExceptionUtils.rethrowAsIoException(e);
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
index 2059c25f7..74c0d886a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
@@ -888,8 +888,7 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
* "The null character MUST NOT be sent"
*/
if (b == 0) {
- throw new StreamCorruptedException(
- "Incorrect identification (null characters not allowed) - "
+ throw new StreamCorruptedException("Incorrect identification (null characters not allowed) - "
+ " at line " + (GenericUtils.size(ident) + 1) + " character #"
+ (pos + 1)
+ " after '" + new String(data, 0, pos, StandardCharsets.UTF_8) + "'");
@@ -904,15 +903,13 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
}
if (needLf) {
- throw new StreamCorruptedException(
- "Incorrect identification (bad line ending) "
+ throw new StreamCorruptedException("Incorrect identification (bad line ending) "
+ " at line " + (GenericUtils.size(ident) + 1)
+ ": " + new String(data, 0, pos, StandardCharsets.UTF_8));
}
if (pos >= data.length) {
- throw new StreamCorruptedException(
- "Incorrect identification (line too long): "
+ throw new StreamCorruptedException("Incorrect identification (line too long): "
+ " at line " + (GenericUtils.size(ident) + 1)
+ ": " + new String(data, 0, pos, StandardCharsets.UTF_8));
}
@@ -986,8 +983,7 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
if (initialKexProposal == null) {
String resolvedAlgorithms = resolveAvailableSignaturesProposal();
if (GenericUtils.isEmpty(resolvedAlgorithms)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE,
"getKexProposal() no resolved signatures available");
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
index 9f0b11c36..72fa92cc1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java
@@ -121,8 +121,7 @@ public class UserAuthGSS extends AbstractUserAuth {
int msg = buffer.getUByte();
if (!((msg == SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE)
|| ((msg == SshConstants.SSH_MSG_USERAUTH_GSSAPI_MIC)) && context.isEstablished())) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
"Packet not supported by user authentication method: " + SshConstants.getCommandMessageName(msg));
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
index 8e99bf8f0..3272e35bb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
@@ -71,8 +71,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S
public void handleOpenSuccess(
long recipient, long rwSize, long packetSize, Buffer buffer)
throws IOException {
- throw new UnsupportedOperationException(
- "handleOpenSuccess(" + recipient + "," + rwSize + "," + packetSize + ") N/A");
+ throw new UnsupportedOperationException("handleOpenSuccess(" + recipient + "," + rwSize + "," + packetSize + ") N/A");
}
@Override
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index 1a1aab77a..f4faf24a0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -182,8 +182,7 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
"doInit(" + this + ")[" + type + "][haveFilter=" + (filter != null) + "] filtered out " + address);
}
try {
- f.setException(new SshChannelOpenException(
- getChannelId(),
+ f.setException(new SshChannelOpenException(getChannelId(),
SshConstants.SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, "Connection denied"));
} finally {
super.close(true);
@@ -273,8 +272,8 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
notifyStateChanged(problem.getClass().getSimpleName());
try {
if (problem instanceof ConnectException) {
- f.setException(new SshChannelOpenException(
- getChannelId(), SshConstants.SSH_OPEN_CONNECT_FAILED, problem.getMessage(), problem));
+ f.setException(new SshChannelOpenException(getChannelId(), SshConstants.SSH_OPEN_CONNECT_FAILED,
+ problem.getMessage(), problem));
} else {
f.setException(problem);
}
@@ -324,8 +323,7 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
@Override
protected void doWriteExtendedData(byte[] data, int off, long len) throws IOException {
- throw new UnsupportedOperationException(
- getTcpipChannelType() + " Tcpip channel does not support extended data");
+ throw new UnsupportedOperationException(getTcpipChannelType() + " Tcpip channel does not support extended data");
}
protected ChannelToPortHandler createChannelToPortHandler(IoSession session) {
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
index bda216b68..6ba71ca91 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
@@ -121,8 +121,7 @@ public class DHGEXServer extends AbstractDHServerKeyExchange {
.orElse(SecurityUtils.getMaxDHGroupExchangeKeySize());
if ((max < min) || (prf < min) || (max < prf)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: bad parameters " + min + " !< " + prf + " !< " + max);
}
@@ -157,8 +156,7 @@ public class DHGEXServer extends AbstractDHServerKeyExchange {
max = buffer.getInt();
if ((prf < min) || (max < prf)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: bad parameters " + min + " !< " + prf + " !< " + max);
}
@@ -186,10 +184,10 @@ public class DHGEXServer extends AbstractDHServerKeyExchange {
}
if (cmd != expected) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: expected packet " + KeyExchange.getGroupKexOpcodeName(expected)
- + ", got " + KeyExchange.getGroupKexOpcodeName(cmd));
+ + ", got "
+ + KeyExchange.getGroupKexOpcodeName(cmd));
}
if (cmd == SshConstants.SSH_MSG_KEX_DH_GEX_INIT) {
@@ -277,8 +275,7 @@ public class DHGEXServer extends AbstractDHServerKeyExchange {
if (!CoreModuleProperties.ALLOW_DHG1_KEX_FALLBACK.getRequired(session)) {
log.error("chooseDH({})[{}][prf={}, min={}, max={}] No suitable primes found - failing",
this, session, prf, min, max);
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"No suitable primes found for DH group exchange");
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
index fa30de6da..3d1e02be9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
@@ -94,8 +94,7 @@ public class DHGServer extends AbstractDHServerKeyExchange {
}
if (cmd != SshConstants.SSH_MSG_KEXDH_INIT) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: expected packet SSH_MSG_KEXDH_INIT, got " + KeyExchange.getSimpleKexOpcodeName(cmd));
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
index 9c7031d68..41d1eb0b6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
@@ -296,8 +296,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
throws Exception {
KexState curState = kexState.get();
if (!KexState.DONE.equals(curState)) {
- throw new SshException(
- SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
+ throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
"Authentication success signalled though KEX state=" + curState);
}
@@ -489,13 +488,11 @@ public abstract class AbstractServerSession extends AbstractSession implements S
* beyond the version one, but we check this nevertheless
*/
err = (numLines > 1)
- ? new SshException(
- SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
+ ? new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
"Unexpected extra " + (numLines - 1) + " lines from client=" + clientVersion)
: null;
} else {
- err = new SshException(
- SshConstants.SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
+ err = new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
"Unsupported protocol version: " + clientVersion);
}
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java b/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java
index 0069aa3a2..df50f89bd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java
@@ -79,8 +79,7 @@ public class ChannelForwardedX11 extends AbstractClientChannel {
@Override
protected synchronized void doOpen() throws IOException {
if (Streaming.Async.equals(streaming)) {
- throw new IllegalArgumentException(
- "Asynchronous streaming isn't supported yet on this channel");
+ throw new IllegalArgumentException("Asynchronous streaming isn't supported yet on this channel");
}
out = new ChannelOutputStream(
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/auth/PasswordAuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/common/auth/PasswordAuthenticationTest.java
index c0a81a101..aa47b1346 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/auth/PasswordAuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/auth/PasswordAuthenticationTest.java
@@ -116,8 +116,7 @@ public class PasswordAuthenticationTest extends AuthenticationTestSupport {
@Override
public boolean authenticate(String username, String password, ServerSession session) {
if (attemptsCount.incrementAndGet() == 1) {
- throw new PasswordChangeRequiredException(
- attemptsCount.toString(),
+ throw new PasswordChangeRequiredException(attemptsCount.toString(),
getCurrentTestName(), CoreModuleProperties.WELCOME_BANNER_LANGUAGE.getRequiredDefault());
}
@@ -275,8 +274,7 @@ public class PasswordAuthenticationTest extends AuthenticationTestSupport {
AtomicInteger attemptsCount = new AtomicInteger(0);
sshd.setPasswordAuthenticator((username, password, session) -> {
if (attemptsCount.incrementAndGet() == 1) {
- throw new PasswordChangeRequiredException(
- attemptsCount.toString(),
+ throw new PasswordChangeRequiredException(attemptsCount.toString(),
getCurrentTestName(), CoreModuleProperties.WELCOME_BANNER_LANGUAGE.getRequiredDefault());
}
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/auth/PublicKeyAuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/common/auth/PublicKeyAuthenticationTest.java
index 8a185ce9c..8bbf0c876 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/auth/PublicKeyAuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/auth/PublicKeyAuthenticationTest.java
@@ -108,8 +108,7 @@ public class PublicKeyAuthenticationTest extends AuthenticationTestSupport {
try {
kp = ValidateUtils.checkNotNull(serverKeys.loadKey(null, keyType), "No server key for type=%s", keyType);
} catch (IOException | GeneralSecurityException e) {
- throw new RuntimeException(
- "Unexpected " + e.getClass().getSimpleName() + ")"
+ throw new RuntimeException("Unexpected " + e.getClass().getSimpleName() + ")"
+ " keys loading exception: " + e.getMessage(),
e);
}
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
index b2fe43da0..ec655841d 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
@@ -213,8 +213,7 @@ public class ServerTest extends BaseTestSupport {
TimeoutIndicator prev = timeoutHolder.getAndSet(timeoutStatus);
if (prev != TimeoutIndicator.NONE) {
- throw new StreamCorruptedException(
- "Multiple timeout disconnects: " + timeoutStatus + " / " + prev);
+ throw new StreamCorruptedException("Multiple timeout disconnects: " + timeoutStatus + " / " + prev);
}
return false;
}
@@ -258,8 +257,7 @@ public class ServerTest extends BaseTestSupport {
outputDebugMessage("Session %s timeout reported: %s", session, timeoutStatus);
TimeoutIndicator prev = timeoutHolder.getAndSet(timeoutStatus);
if (prev != TimeoutIndicator.NONE) {
- throw new StreamCorruptedException(
- "Multiple timeout disconnects: " + timeoutStatus + " / " + prev);
+ throw new StreamCorruptedException("Multiple timeout disconnects: " + timeoutStatus + " / " + prev);
}
return false;
}
diff --git a/sshd-eclipse-formatter-config.xml b/sshd-eclipse-formatter-config.xml
index ba98b80ae..589dceda6 100644
--- a/sshd-eclipse-formatter-config.xml
+++ b/sshd-eclipse-formatter-config.xml
@@ -25,7 +25,7 @@
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="18"/>
- <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="32"/>
+ <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="18"/>
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java
index 11fcdacc8..325d365f1 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPAuthorizedKeyEntriesLoader.java
@@ -62,8 +62,7 @@ public interface PGPAuthorizedKeyEntriesLoader extends PGPPublicKeyExtractor, Pu
try {
keys = loadMatchingKeyFingerprints(session, Collections.singletonList(fingerprint));
} catch (PGPException e) {
- throw new InvalidKeyException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new InvalidKeyException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to load key type=" + keyType + " with fingerprint=" + fingerprint
+ ": " + e.getMessage(),
e);
@@ -71,8 +70,7 @@ public interface PGPAuthorizedKeyEntriesLoader extends PGPPublicKeyExtractor, Pu
int numKeys = GenericUtils.size(keys);
if (numKeys > 1) {
- throw new StreamCorruptedException(
- "Multiple matches (" + numKeys + ")"
+ throw new StreamCorruptedException("Multiple matches (" + numKeys + ")"
+ " for " + keyType + " fingerprint=" + fingerprint);
}
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java
index 3ef2d7227..f0d853e21 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPKeyPairResourceParser.java
@@ -130,8 +130,7 @@ public class PGPKeyPairResourceParser
switch (result) {
case TERMINATE:
if (e instanceof PGPException) {
- throw new StreamCorruptedException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new StreamCorruptedException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to decode " + resourceKey + ": " + e.getMessage());
} else if (e instanceof IOException) {
throw (IOException) e;
diff --git a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicKeyExtractor.java b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicKeyExtractor.java
index 71ce865f5..368cec866 100644
--- a/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicKeyExtractor.java
+++ b/sshd-openpgp/src/main/java/org/apache/sshd/openpgp/PGPPublicKeyExtractor.java
@@ -128,13 +128,11 @@ public interface PGPPublicKeyExtractor {
try {
w = ECCurves.octetStringToEcPoint(octets);
if (w == null) {
- throw new InvalidKeySpecException(
- "No ECPoint generated for curve=" + curve.getName()
+ throw new InvalidKeySpecException("No ECPoint generated for curve=" + curve.getName()
+ " from octets=" + BufferUtils.toHex(':', octets));
}
} catch (RuntimeException e) {
- throw new InvalidKeySpecException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new InvalidKeySpecException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to generate ECPoint for curve=" + curve.getName()
+ " from octets=" + BufferUtils.toHex(':', octets)
+ ": " + e.getMessage());
diff --git a/sshd-putty/src/main/java/org/apache/sshd/putty/ECDSAPuttyKeyDecoder.java b/sshd-putty/src/main/java/org/apache/sshd/putty/ECDSAPuttyKeyDecoder.java
index 48bc9212b..92e27ab3a 100644
--- a/sshd-putty/src/main/java/org/apache/sshd/putty/ECDSAPuttyKeyDecoder.java
+++ b/sshd-putty/src/main/java/org/apache/sshd/putty/ECDSAPuttyKeyDecoder.java
@@ -82,13 +82,11 @@ public class ECDSAPuttyKeyDecoder extends AbstractPuttyKeyDecoder<ECPublicKey, E
try {
w = ECCurves.octetStringToEcPoint(octets);
if (w == null) {
- throw new InvalidKeySpecException(
- "No public ECPoint generated for curve=" + keyCurveName
+ throw new InvalidKeySpecException("No public ECPoint generated for curve=" + keyCurveName
+ " from octets=" + BufferUtils.toHex(':', octets));
}
} catch (RuntimeException e) {
- throw new InvalidKeySpecException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new InvalidKeySpecException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to generate public ECPoint for curve=" + keyCurveName
+ " from octets=" + BufferUtils.toHex(':', octets)
+ ": " + e.getMessage());
diff --git a/sshd-putty/src/main/java/org/apache/sshd/putty/PuttyKeyPairResourceParser.java b/sshd-putty/src/main/java/org/apache/sshd/putty/PuttyKeyPairResourceParser.java
index 912695c4e..82999be9c 100644
--- a/sshd-putty/src/main/java/org/apache/sshd/putty/PuttyKeyPairResourceParser.java
+++ b/sshd-putty/src/main/java/org/apache/sshd/putty/PuttyKeyPairResourceParser.java
@@ -174,8 +174,7 @@ public interface PuttyKeyPairResourceParser<PUB extends PublicKey, PRV extends P
int maxAllowedBits = Cipher.getMaxAllowedKeyLength(xform);
// see http://www.javamex.com/tutorials/cryptography/unrestricted_policy_files.shtml
if (numBits > maxAllowedBits) {
- throw new InvalidKeySpecException(
- "decodePrivateKeyBytes(" + xform + ")"
+ throw new InvalidKeySpecException("decodePrivateKeyBytes(" + xform + ")"
+ " required key length (" + numBits + ") exceeds max. available: "
+ maxAllowedBits);
}
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java b/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java
index 980f82802..bcefee69f 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/common/ScpHelper.java
@@ -334,8 +334,7 @@ public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Sess
int bufferSize)
throws IOException {
if (bufferSize < MIN_RECEIVE_BUFFER_SIZE) {
- throw new IOException(
- "receiveStream(" + resolver + ") buffer size (" + bufferSize + ") below minimum ("
+ throw new IOException("receiveStream(" + resolver + ") buffer size (" + bufferSize + ") below minimum ("
+ MIN_RECEIVE_BUFFER_SIZE + ")");
}
@@ -524,8 +523,7 @@ public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Sess
public void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws IOException {
if (bufferSize < MIN_SEND_BUFFER_SIZE) {
- throw new IOException(
- "sendStream(" + resolver + ") buffer size (" + bufferSize + ") below minimum ("
+ throw new IOException("sendStream(" + resolver + ") buffer size (" + bufferSize + ") below minimum ("
+ MIN_SEND_BUFFER_SIZE + ")");
}
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java b/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java
index 640728782..38552befa 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/common/helpers/ScpIoUtils.java
@@ -225,8 +225,8 @@ public final class ScpIoUtils {
}
break;
default:
- throw new ScpException(
- "Failed to run command='" + cmd + "': " + ScpIoUtils.getExitStatusName(exitStatus), exitStatus);
+ throw new ScpException("Failed to run command='" + cmd + "': " + ScpIoUtils.getExitStatusName(exitStatus),
+ exitStatus);
}
}
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommand.java b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommand.java
index 7b25b68fc..41fc6b2d6 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommand.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommand.java
@@ -83,16 +83,14 @@ public class ScpCommand extends AbstractFileSystemCommand implements ServerChann
this.channelSession = Objects.requireNonNull(channelSession, "No channel session provided");
if (sendSize < ScpHelper.MIN_SEND_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "<ScpCommmand>(" + command + ") send buffer size "
+ throw new IllegalArgumentException("<ScpCommmand>(" + command + ") send buffer size "
+ "(" + sendSize + ") below minimum required "
+ "(" + ScpHelper.MIN_SEND_BUFFER_SIZE + ")");
}
sendBufferSize = sendSize;
if (receiveSize < ScpHelper.MIN_RECEIVE_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "<ScpCommmand>(" + command + ") receive buffer size "
+ throw new IllegalArgumentException("<ScpCommmand>(" + command + ") receive buffer size "
+ "(" + sendSize + ") below minimum required "
+ "(" + ScpHelper.MIN_RECEIVE_BUFFER_SIZE + ")");
}
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java
index ecaba2fda..9cb791f59 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpCommandFactory.java
@@ -157,8 +157,7 @@ public class ScpCommandFactory
*/
public void setSendBufferSize(int sendSize) {
if (sendSize < ScpHelper.MIN_SEND_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "<ScpCommandFactory>() send buffer size "
+ throw new IllegalArgumentException("<ScpCommandFactory>() send buffer size "
+ "(" + sendSize + ") below minimum required (" + ScpHelper.MIN_SEND_BUFFER_SIZE
+ ")");
}
@@ -175,8 +174,7 @@ public class ScpCommandFactory
*/
public void setReceiveBufferSize(int receiveSize) {
if (receiveSize < ScpHelper.MIN_RECEIVE_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "<ScpCommandFactory>() receive buffer size "
+ throw new IllegalArgumentException("<ScpCommandFactory>() receive buffer size "
+ "(" + receiveSize + ") below minimum required ("
+ ScpHelper.MIN_RECEIVE_BUFFER_SIZE + ")");
}
diff --git a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpShell.java b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpShell.java
index 0ed311987..316410d50 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpShell.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/scp/server/ScpShell.java
@@ -111,16 +111,14 @@ public class ScpShell extends AbstractFileSystemCommand implements ServerChannel
envVarsEnodingCharset = ScpModuleProperties.SHELL_ENVVARS_ENCODING_CHARSET.getRequired(channelSession);
if (sendSize < ScpHelper.MIN_SEND_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "<ScpShell> send buffer size "
+ throw new IllegalArgumentException("<ScpShell> send buffer size "
+ "(" + sendSize + ") below minimum required "
+ "(" + ScpHelper.MIN_SEND_BUFFER_SIZE + ")");
}
sendBufferSize = sendSize;
if (receiveSize < ScpHelper.MIN_RECEIVE_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "<ScpCommmand> receive buffer size "
+ throw new IllegalArgumentException("<ScpCommmand> receive buffer size "
+ "(" + sendSize + ") below minimum required "
+ "(" + ScpHelper.MIN_RECEIVE_BUFFER_SIZE + ")");
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java
index 61a5cbf02..5a487ed55 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/extensions/helpers/AbstractSftpClientExtension.java
@@ -216,8 +216,7 @@ public abstract class AbstractSftpClientExtension extends AbstractLoggingBean im
throws IOException {
int remaining = buffer.available();
if ((length < 0) || (length > (remaining + 5 /* type + id */))) {
- throw new SshException(
- "Bad length (" + length + ") for remaining data (" + remaining + ")"
+ throw new SshException("Bad length (" + length + ") for remaining data (" + remaining + ")"
+ " in response to " + SftpConstants.getCommandMessageName(cmd)
+ ": type=" + SftpConstants.getCommandMessageName(type) + ", id=" + id);
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java
index a20c1bb54..47f999758 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystem.java
@@ -579,8 +579,7 @@ public class SftpFileSystem
if (delegate instanceof RawSftpClient) {
return ((RawSftpClient) delegate).receive(id, timeout);
} else {
- throw new StreamCorruptedException(
- "receive(id=" + id + ", timeout=" + timeout + ") delegate is not a "
+ throw new StreamCorruptedException("receive(id=" + id + ", timeout=" + timeout + ") delegate is not a "
+ RawSftpClient.class.getSimpleName());
}
}
@@ -594,8 +593,7 @@ public class SftpFileSystem
if (delegate instanceof RawSftpClient) {
return ((RawSftpClient) delegate).receive(id, timeout);
} else {
- throw new StreamCorruptedException(
- "receive(id=" + id + ", timeout=" + timeout + ") delegate is not a "
+ throw new StreamCorruptedException("receive(id=" + id + ", timeout=" + timeout + ") delegate is not a "
+ RawSftpClient.class.getSimpleName());
}
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java
index 0cda4e87e..199664cc2 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java
@@ -755,8 +755,8 @@ public class SftpFileSystemProvider extends FileSystemProvider {
public FileStore getFileStore(Path path) throws IOException {
FileSystem fs = path.getFileSystem();
if (!(fs instanceof SftpFileSystem)) {
- throw new FileSystemException(
- path.toString(), path.toString(), "getFileStore(" + path + ") path not attached to an SFTP file system");
+ throw new FileSystemException(path.toString(), path.toString(),
+ "getFileStore(" + path + ") path not attached to an SFTP file system");
}
SftpFileSystem sftpFs = (SftpFileSystem) fs;
@@ -1410,8 +1410,7 @@ public class SftpFileSystemProvider extends FileSystemProvider {
String userAuth = encodeCredentials(username, password);
return new URI(SftpConstants.SFTP_SUBSYSTEM_NAME, userAuth, host, port, "/", queryPart, null);
} catch (URISyntaxException e) {
- throw new IllegalArgumentException(
- "Failed (" + e.getClass().getSimpleName() + ")"
+ throw new IllegalArgumentException("Failed (" + e.getClass().getSimpleName() + ")"
+ " to create access URI: " + e.getMessage(),
e);
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/AbstractSftpClient.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/AbstractSftpClient.java
index 373fdf3aa..f501b4251 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/AbstractSftpClient.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/AbstractSftpClient.java
@@ -264,8 +264,7 @@ public abstract class AbstractSftpClient
throw err;
}
- throw new SshException(
- "No handling for unexpected handle packet id=" + id
+ throw new SshException("No handling for unexpected handle packet id=" + id
+ ", type=" + SftpConstants.getCommandMessageName(type) + ", length=" + length);
}
@@ -642,8 +641,7 @@ public abstract class AbstractSftpClient
}
buffer.putInt(opts);
} else if (numOptions > 0) {
- throw new UnsupportedOperationException(
- "rename(" + oldPath + " => " + newPath + ")"
+ throw new UnsupportedOperationException("rename(" + oldPath + " => " + newPath + ")"
+ " - copy options can not be used with this SFTP version: " + options);
}
checkCommandStatus(SftpConstants.SSH_FXP_RENAME, buffer);
@@ -741,14 +739,12 @@ public abstract class AbstractSftpClient
public void write(Handle handle, long fileOffset, byte[] src, int srcOffset, int len) throws IOException {
// do some bounds checking first
if ((fileOffset < 0L) || (srcOffset < 0) || (len < 0)) {
- throw new IllegalArgumentException(
- "write(" + handle + ") please ensure all parameters "
+ throw new IllegalArgumentException("write(" + handle + ") please ensure all parameters "
+ " are non-negative values: file-offset=" + fileOffset
+ ", src-offset=" + srcOffset + ", len=" + len);
}
if ((srcOffset + len) > src.length) {
- throw new IllegalArgumentException(
- "write(" + handle + ")"
+ throw new IllegalArgumentException("write(" + handle + ")"
+ " cannot read bytes " + srcOffset + " to " + (srcOffset + len)
+ " when array is only of length " + src.length);
}
@@ -937,8 +933,7 @@ public abstract class AbstractSftpClient
throws IOException {
int remaining = buffer.available();
if ((length < 0) || (length > (remaining + 5 /* type + id */))) {
- throw new SshException(
- "Bad length (" + length + ") for remaining data (" + remaining + ")"
+ throw new SshException("Bad length (" + length + ") for remaining data (" + remaining + ")"
+ " in response to " + SftpConstants.getCommandMessageName(cmd)
+ ": type=" + SftpConstants.getCommandMessageName(type) + ", id=" + id);
}
@@ -1178,8 +1173,7 @@ public abstract class AbstractSftpClient
bufferSize = getReadBufferSize();
}
if (bufferSize < MIN_WRITE_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "Insufficient read buffer size: " + bufferSize + ", min.="
+ throw new IllegalArgumentException("Insufficient read buffer size: " + bufferSize + ", min.="
+ MIN_READ_BUFFER_SIZE);
}
@@ -1202,8 +1196,7 @@ public abstract class AbstractSftpClient
bufferSize = getWriteBufferSize();
}
if (bufferSize < MIN_WRITE_BUFFER_SIZE) {
- throw new IllegalArgumentException(
- "Insufficient write buffer size: " + bufferSize + ", min.="
+ throw new IllegalArgumentException("Insufficient write buffer size: " + bufferSize + ", min.="
+ MIN_WRITE_BUFFER_SIZE);
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpRemotePathChannel.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpRemotePathChannel.java
index 6f3921bed..19e768e16 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpRemotePathChannel.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/SftpRemotePathChannel.java
@@ -100,8 +100,7 @@ public class SftpRemotePathChannel extends FileChannel {
@Override
public int read(ByteBuffer dst, long position) throws IOException {
if (position < 0L) {
- throw new IllegalArgumentException(
- "read(" + getRemotePath() + ")"
+ throw new IllegalArgumentException("read(" + getRemotePath() + ")"
+ " illegal position to read from: " + position);
}
@@ -204,8 +203,7 @@ public class SftpRemotePathChannel extends FileChannel {
@Override
public int write(ByteBuffer src, long position) throws IOException {
if (position < 0L) {
- throw new IllegalArgumentException(
- "write(" + getRemotePath() + ")"
+ throw new IllegalArgumentException("write(" + getRemotePath() + ")"
+ " illegal position to write to: " + position);
}
@@ -291,8 +289,7 @@ public class SftpRemotePathChannel extends FileChannel {
@Override
public FileChannel position(long newPosition) throws IOException {
if (newPosition < 0L) {
- throw new IllegalArgumentException(
- "position(" + getRemotePath() + ")"
+ throw new IllegalArgumentException("position(" + getRemotePath() + ")"
+ " illegal file channel position: " + newPosition);
}
@@ -323,8 +320,7 @@ public class SftpRemotePathChannel extends FileChannel {
@Override
public long transferTo(long position, long count, WritableByteChannel target) throws IOException {
if ((position < 0L) || (count < 0L)) {
- throw new IllegalArgumentException(
- "transferTo(" + getRemotePath() + ")"
+ throw new IllegalArgumentException("transferTo(" + getRemotePath() + ")"
+ " illegal position (" + position + ") or count (" + count + ")");
}
ensureOpen(READ_MODES);
@@ -369,8 +365,7 @@ public class SftpRemotePathChannel extends FileChannel {
@Override
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException {
if ((position < 0L) || (count < 0L)) {
- throw new IllegalArgumentException(
- "transferFrom(" + getRemotePath() + ")"
+ throw new IllegalArgumentException("transferFrom(" + getRemotePath() + ")"
+ " illegal position (" + position + ") or count (" + count + ")");
}
ensureOpen(WRITE_MODES);
@@ -424,8 +419,7 @@ public class SftpRemotePathChannel extends FileChannel {
@Override
public MappedByteBuffer map(MapMode mode, long position, long size) throws IOException {
- throw new UnsupportedOperationException(
- "map(" + getRemotePath() + ")[" + mode + "," + position + "," + size + "] N/A");
+ throw new UnsupportedOperationException("map(" + getRemotePath() + ")[" + mode + "," + position + "," + size + "] N/A");
}
@Override
@@ -522,8 +516,7 @@ public class SftpRemotePathChannel extends FileChannel {
}
}
- throw new IOException(
- "ensureOpen(" + getRemotePath() + ")"
+ throw new IOException("ensureOpen(" + getRemotePath() + ")"
+ " current channel modes (" + this.modes + ")"
+ " do contain any of the required ones: " + reqModes);
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
index f87eb6a15..002ec3eac 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/AbstractSftpSubsystemHelper.java
@@ -1494,8 +1494,7 @@ public abstract class AbstractSftpSubsystemHelper
} else if (status) {
attrs = getAttributes(p, options);
} else {
- throw new NoSuchFileException(
- p.toString(), p.toString(), "Real path N/A for target");
+ throw new NoSuchFileException(p.toString(), p.toString(), "Real path N/A for target");
}
break;
case SftpConstants.SSH_FXP_REALPATH_NO_CHECK:
@@ -2426,8 +2425,8 @@ public abstract class AbstractSftpSubsystemHelper
case Ignore:
break;
case ThrowException:
- throw new AccessDeniedException(
- file.toString(), file.toString(), "Cannot determine existence for attributes of target");
+ throw new AccessDeniedException(file.toString(), file.toString(),
+ "Cannot determine existence for attributes of target");
case Warn:
log.warn("handleUnknownStatusFileAttributes(" + getServerSession() + ")[" + file
+ "] cannot determine existence");
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java
index 8cb4a7dfd..af98a8dbc 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/FileHandle.java
@@ -171,8 +171,7 @@ public class FileHandle extends Handle {
FileLock lock = accessor.tryLock(
subsystem, this, getFile(), getFileHandle(), channel, offset, size, false);
if (lock == null) {
- throw new SftpException(
- SftpConstants.SSH_FX_BYTE_RANGE_LOCK_REFUSED,
+ throw new SftpException(SftpConstants.SSH_FX_BYTE_RANGE_LOCK_REFUSED,
"Overlapping lock held by another program on range [" + offset + "-" + (offset + length));
}
@@ -194,8 +193,7 @@ public class FileHandle extends Handle {
}
}
if (lock == null) {
- throw new SftpException(
- SftpConstants.SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK,
+ throw new SftpException(SftpConstants.SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK,
"No matching lock found on range [" + offset + "-" + (offset + length));
}
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
index 992c02caa..bbfb8f5aa 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/server/SftpSubsystem.java
@@ -399,8 +399,7 @@ public class SftpSubsystem
*/
int access = fileHandle.getAccessMask();
if ((access & SftpConstants.ACE4_READ_DATA) == 0) {
- throw new AccessDeniedException(
- path.toString(), path.toString(), "File not opened for read");
+ throw new AccessDeniedException(path.toString(), path.toString(), "File not opened for read");
}
} else {
path = resolveFile(target);
@@ -594,8 +593,7 @@ public class SftpSubsystem
Path srcPath = srcHandle.getFile();
int srcAccess = srcHandle.getAccessMask();
if ((srcAccess & SftpConstants.ACE4_READ_DATA) != SftpConstants.ACE4_READ_DATA) {
- throw new AccessDeniedException(
- srcPath.toString(), srcPath.toString(), "Source file not opened for read");
+ throw new AccessDeniedException(srcPath.toString(), srcPath.toString(), "Source file not opened for read");
}
ValidateUtils.checkTrue(readLength >= 0L, "Invalid read length: %d", readLength);
@@ -617,8 +615,7 @@ public class SftpSubsystem
FileHandle dstHandle = inPlaceCopy ? srcHandle : validateHandle(writeHandle, wh, FileHandle.class);
int dstAccess = dstHandle.getAccessMask();
if ((dstAccess & SftpConstants.ACE4_WRITE_DATA) != SftpConstants.ACE4_WRITE_DATA) {
- throw new AccessDeniedException(
- srcHandle.toString(), srcHandle.toString(), "Source handle not opened for write");
+ throw new AccessDeniedException(srcHandle.toString(), srcHandle.toString(), "Source handle not opened for write");
}
ValidateUtils.checkTrue(writeOffset >= 0L, "Invalid write offset: %d", writeOffset);
@@ -631,12 +628,10 @@ public class SftpSubsystem
long maxWrite = writeOffset + effectiveLength;
if (maxWrite > readOffset) {
- throw new IllegalArgumentException(
- "Write range end [" + writeOffset + "-" + maxWrite + "]"
+ throw new IllegalArgumentException("Write range end [" + writeOffset + "-" + maxWrite + "]"
+ " overlaps with read range [" + readOffset + "-" + maxRead + "]");
} else if (maxRead > writeOffset) {
- throw new IllegalArgumentException(
- "Read range end [" + readOffset + "-" + maxRead + "]"
+ throw new IllegalArgumentException("Read range end [" + readOffset + "-" + maxRead + "]"
+ " overlaps with write range [" + writeOffset + "-" + maxWrite + "]");
}
}
@@ -833,8 +828,7 @@ public class SftpSubsystem
}
if (remaining < length) {
- throw new IllegalStateException(
- "Not enough buffer data for writing to " + fh
+ throw new IllegalStateException("Not enough buffer data for writing to " + fh
+ ": required=" + length + ", available=" + remaining);
}
@@ -920,8 +914,7 @@ public class SftpSubsystem
int maxHandleCount = SftpModuleProperties.MAX_OPEN_HANDLES_PER_SESSION.getRequired(session);
if (curHandleCount > maxHandleCount) {
throw signalOpenFailure(id, path, file, false,
- new SftpException(
- SftpConstants.SSH_FX_NO_SPACE_ON_FILESYSTEM,
+ new SftpException(SftpConstants.SSH_FX_NO_SPACE_ON_FILESYSTEM,
"Too many open handles: current=" + curHandleCount + ", max.=" + maxHandleCount));
}