Repository: mina-sshd Updated Branches: refs/heads/master 5383da460 -> 6a615d7e1
Activated a few more Checkstyle rules Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/6a615d7e Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/6a615d7e Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/6a615d7e Branch: refs/heads/master Commit: 6a615d7e19970231c048bc9ded2b5641e2eb7146 Parents: 5383da4 Author: Goldstein Lyor <l...@c-b4.com> Authored: Mon Jun 25 09:53:42 2018 +0300 Committer: Goldstein Lyor <l...@c-b4.com> Committed: Mon Jun 25 09:54:38 2018 +0300 ---------------------------------------------------------------------- sshd-checkstyle.xml | 23 +++++--- .../sshd/cli/client/SshClientCliSupport.java | 1 + .../auth/hostbased/UserAuthHostBased.java | 24 +++++---- .../keyboard/UserAuthKeyboardInteractive.java | 20 +++---- .../client/auth/password/UserAuthPassword.java | 15 +++--- .../client/auth/pubkey/UserAuthPublicKey.java | 22 ++++---- .../org/apache/sshd/client/kex/DHGClient.java | 8 +-- .../org/apache/sshd/client/kex/DHGEXClient.java | 3 +- .../common/session/helpers/AbstractSession.java | 2 + .../auth/hostbased/UserAuthHostBased.java | 27 +++++----- .../keyboard/UserAuthKeyboardInteractive.java | 24 +++++---- .../server/auth/password/UserAuthPassword.java | 11 ++-- .../server/auth/pubkey/UserAuthPublicKey.java | 54 ++++++++++--------- .../common/config/SshConfigFileReaderTest.java | 5 +- .../sshd/common/file/util/BasePathTest.java | 55 +++++++------------- .../sshd/common/util/SecurityUtilsTest.java | 1 + .../sftp/AbstractSftpEventListenerAdapter.java | 25 ++++----- .../sftp/AbstractSftpSubsystemHelper.java | 2 + .../subsystem/sftp/SftpEventListener.java | 7 +-- .../sshd/client/subsystem/sftp/ClientTest.java | 1 + .../subsystem/sftp/SftpFileSystemTest.java | 1 + .../sshd/client/subsystem/sftp/SftpTest.java | 6 ++- 22 files changed, 182 insertions(+), 155 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-checkstyle.xml ---------------------------------------------------------------------- diff --git a/sshd-checkstyle.xml b/sshd-checkstyle.xml index e95e89c..b1301cd 100644 --- a/sshd-checkstyle.xml +++ b/sshd-checkstyle.xml @@ -99,12 +99,16 @@ <property name="max" value="150" /> <property name="countEmpty" value="false" /> </module> - - <!-- DISABLED - <module name="ParameterNumber"> - <property name="max" value="7" /> - </module> - --> + <module name="ParameterNumber"> + <property name="max" value="8" /> + </module> + <module name="OuterTypeNumber"> + <property name="max" value="2"/> + </module> + <module name="MethodCount"> + <property name="maxPrivate" value="5"/> + <property name="maxPackage" value="5"/> + </module> <!-- Checks for whitespace --> <!-- See http://checkstyle.sf.net/config_whitespace.html --> @@ -184,6 +188,9 @@ <module name="NestedTryDepth"> <property name="max" value="3" /> </module> + <module name="NestedForDepth"> + <property name="max" value="3"/> + </module> <module name="SuperClone" /> <module name="SuperFinalize" /> <!--<module name="IllegalCatch" />--> @@ -209,9 +216,9 @@ <!--<module name="MissingCtor" />--> <module name="FallThrough" /> <!--<module name="MultipleStringLiterals" />--> - <!--<module name="VariableDeclarationUsageDistance"> + <module name="VariableDeclarationUsageDistance"> <property name="allowedDistance" value="8" /> - </module>--> + </module> <module name="MultipleVariableDeclarations" /> <!--<module name="RequireThis" />--> <module name="UnnecessaryParentheses" /> http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java ---------------------------------------------------------------------- diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java index 5cf4fd3..35d8717 100644 --- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java +++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java @@ -273,6 +273,7 @@ public abstract class SshClientCliSupport extends CliSupport { } // returns null if error encountered + @SuppressWarnings("checkstyle:ParameterNumber") public static SshClient setupClient( Map<String, Object> options, List<NamedFactory<Cipher>> ciphers, http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java ---------------------------------------------------------------------- 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 d19dcfe..1204fdd 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 @@ -94,8 +94,9 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact @Override protected boolean sendAuthDataRequest(ClientSession session, String service) throws Exception { String name = getName(); + boolean debugEnabled = log.isDebugEnabled(); if ((keys == null) || (!keys.hasNext())) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("sendAuthDataRequest({})[{}][{}] no more keys to send", session, service, name); } @@ -112,10 +113,10 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact } Collection<NamedFactory<Signature>> factories = - ValidateUtils.checkNotNullAndNotEmpty( - SignatureFactoriesManager.resolveSignatureFactories(this, session), - "No signature factories for session=%s", - session); + ValidateUtils.checkNotNullAndNotEmpty( + SignatureFactoriesManager.resolveSignatureFactories(this, session), + "No signature factories for session=%s", + session); Signature verifier = ValidateUtils.checkNotNull( NamedFactory.create(factories, keyType), "No signer could be located for key type=%s", @@ -125,7 +126,7 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact String username = session.getUsername(); String clientUsername = resolveClientUsername(); String clientHostname = resolveClientHostname(); - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("sendAuthDataRequest({})[{}][{}] client={}@{}", session, service, name, clientUsername, clientHostname); } @@ -155,16 +156,21 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact buffer.putBytes(keyBytes); buffer.putString(clientHostname); buffer.putString(clientUsername); - appendSignature(session, service, name, username, keyType, pub, keyBytes, clientHostname, clientUsername, verifier, buffer); + appendSignature(session, service, keyType, pub, keyBytes, clientHostname, clientUsername, verifier, buffer); session.writePacket(buffer); return true; } - protected void appendSignature(ClientSession session, String service, String name, String username, + @SuppressWarnings("checkstyle:ParameterNumber") + protected void appendSignature( + ClientSession session, String service, String keyType, PublicKey key, byte[] keyBytes, String clientHostname, String clientUsername, - Signature verifier, Buffer buffer) throws Exception { + Signature verifier, Buffer buffer) + throws Exception { 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() http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java ---------------------------------------------------------------------- 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 522eedd..d765b11 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 @@ -95,8 +95,9 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { @Override protected boolean sendAuthDataRequest(ClientSession session, String service) throws Exception { String name = getName(); + boolean debugEnabled = log.isDebugEnabled(); if (requestPending.get()) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("sendAuthDataRequest({})[{}] no reply for previous request for {}", session, service, name); } @@ -110,15 +111,15 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { String username = session.getUsername(); String lang = getExchangeLanguageTag(session); String subMethods = getExchangeSubMethods(session); - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("sendAuthDataRequest({})[{}] send SSH_MSG_USERAUTH_REQUEST for {}: lang={}, methods={}", 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 */); + username.length() + service.length() + name.length() + + GenericUtils.length(lang) + GenericUtils.length(subMethods) + + Long.SIZE /* a bit extra for the lengths */); buffer.putString(username); buffer.putString(service); buffer.putString(name); @@ -246,8 +247,9 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { protected String[] getUserResponses(String name, String instruction, String lang, String[] prompt, boolean[] echo) { ClientSession session = getClientSession(); int num = GenericUtils.length(prompt); + boolean debugEnabled = log.isDebugEnabled(); if (num == 0) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("getUserResponses({}) no prompts for interaction={}", session, name); } return GenericUtils.EMPTY_STRING_ARRAY; @@ -255,7 +257,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { String candidate = getCurrentPasswordCandidate(); if (useCurrentPassword(candidate, name, instruction, lang, prompt, echo)) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("getUserResponses({}) use password candidate for interaction={}", session, name); } return new String[]{candidate}; @@ -269,14 +271,14 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { } catch (Error e) { log.warn("getUserResponses({}) failed ({}) to consult interaction: {}", session, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("getUserResponses(" + session + ") interaction consultation failure details", e); } throw new RuntimeSshException(e); } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("getUserResponses({}) no user interaction for name={}", session, name); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/client/auth/password/UserAuthPassword.java ---------------------------------------------------------------------- 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 46cf2d9..53ec529 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 @@ -64,7 +64,7 @@ public class UserAuthPassword extends AbstractUserAuth { current = passwords.next(); String username = session.getUsername(); Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, - username.length() + service.length() + getName().length() + current.length() + Integer.SIZE); + username.length() + service.length() + getName().length() + current.length() + Integer.SIZE); sendPassword(buffer, session, current, current); return true; } @@ -82,13 +82,14 @@ public class UserAuthPassword extends AbstractUserAuth { UserInteraction ui = session.getUserInteraction(); boolean interactive; String password; + boolean debugEnabled = log.isDebugEnabled(); try { interactive = (ui != null) && ui.isInteractionAllowed(session); password = interactive ? ui.getUpdatedPassword(session, prompt, lang) : null; } catch (Error e) { log.warn("processAuthDataRequest({})[{}] failed ({}) to consult interaction: {}", - session, service, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + session, service, e.getClass().getSimpleName(), e.getMessage()); + if (debugEnabled) { log.debug("processAuthDataRequest(" + session + ")[" + service + "] interaction consultation failure details", e); } @@ -97,9 +98,9 @@ public class UserAuthPassword extends AbstractUserAuth { if (interactive) { if (GenericUtils.isEmpty(password)) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("processAuthDataRequest({})[{}] No updated password for prompt={}, lang={}", - session, service, prompt, lang); + session, service, prompt, lang); } return false; } else { @@ -108,9 +109,9 @@ public class UserAuthPassword extends AbstractUserAuth { } } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("processAuthDataRequest({})[{}] no UI for password change request for prompt={}, lang={}", - session, service, prompt, lang); + session, service, prompt, lang); } return false; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java ---------------------------------------------------------------------- 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 2bd6472..c4eda0a 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 @@ -88,9 +88,10 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact @Override protected boolean sendAuthDataRequest(ClientSession session, String service) throws Exception { + boolean debugEnabled = log.isDebugEnabled(); try { if ((keys == null) || (!keys.hasNext())) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("sendAuthDataRequest({})[{}] no more keys to send", session, service); } @@ -101,7 +102,7 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact } catch (Error e) { log.warn("sendAuthDataRequest({})[{}] failed ({}) to get next key: {}", session, service, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("sendAuthDataRequest(" + session + ")[" + service + "] next key fetch failure details", e); } @@ -117,8 +118,8 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact key = current.getPublicKey(); } catch (Error e) { log.warn("sendAuthDataRequest({})[{}] failed ({}) to retrieve public key: {}", - session, service, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + session, service, e.getClass().getSimpleName(), e.getMessage()); + if (debugEnabled) { log.debug("sendAuthDataRequest(" + session + ")[" + service + "] public key retrieval failure details", e); } @@ -127,9 +128,9 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact String algo = KeyUtils.getKeyType(key); String name = getName(); - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("sendAuthDataRequest({})[{}] send SSH_MSG_USERAUTH_REQUEST request {} type={} - fingerprint={}", - session, service, name, algo, KeyUtils.getFingerPrint(key)); + session, service, name, algo, KeyUtils.getFingerPrint(key)); } Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST); @@ -157,12 +158,13 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact * sanctioned by RFC4252 section 7 */ PublicKey key; + boolean debugEnabled = log.isDebugEnabled(); try { key = current.getPublicKey(); } catch (Error e) { log.warn("processAuthDataRequest({})[{}][{}] failed ({}) to retrieve public key: {}", - session, service, name, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + session, service, name, e.getClass().getSimpleName(), e.getMessage()); + if (debugEnabled) { log.debug("processAuthDataRequest(" + session + ")[" + service + "][" + name + "] public key retrieval failure details", e); } @@ -182,9 +184,9 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact + " mismatched " + algo + " keys: expected=" + KeyUtils.getFingerPrint(key) + ", actual=" + KeyUtils.getFingerPrint(rspKey)); } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("processAuthDataRequest({})[{}][{}] SSH_MSG_USERAUTH_PK_OK type={}, fingerprint={}", - session, service, name, rspKeyType, KeyUtils.getFingerPrint(rspKey)); + session, service, name, rspKeyType, KeyUtils.getFingerPrint(rspKey)); } String username = session.getUsername(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java ---------------------------------------------------------------------- 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 7ac5ea9..be18517 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 @@ -43,7 +43,6 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer; * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> */ public class DHGClient extends AbstractDHClientKeyExchange { - protected final DHFactory factory; protected AbstractDH dh; @@ -56,7 +55,7 @@ public class DHGClient extends AbstractDHClientKeyExchange { return factory.getName(); } - public static KeyExchangeFactory newFactory(final DHFactory delegate) { + public static KeyExchangeFactory newFactory(DHFactory delegate) { return new KeyExchangeFactory() { @Override public String getName() { @@ -99,6 +98,7 @@ public class DHGClient extends AbstractDHClientKeyExchange { } @Override + @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance") public boolean next(int cmd, Buffer buffer) throws Exception { Session session = getSession(); if (log.isDebugEnabled()) { @@ -117,9 +117,9 @@ public class DHGClient extends AbstractDHClientKeyExchange { buffer = new ByteArrayBuffer(k_s); serverKey = buffer.getRawPublicKey(); - final String keyAlg = KeyUtils.getKeyType(serverKey); + String keyAlg = KeyUtils.getKeyType(serverKey); if (GenericUtils.isEmpty(keyAlg)) { - throw new SshException("Unsupported server key type"); + throw new SshException("Unsupported server key type: " + serverKey.getAlgorithm()); } buffer = new ByteArrayBuffer(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java ---------------------------------------------------------------------- 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 f2efa8b..0ad7150 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 @@ -64,7 +64,7 @@ public class DHGEXClient extends AbstractDHClientKeyExchange { return factory.getName(); } - public static KeyExchangeFactory newFactory(final DHFactory delegate) { + public static KeyExchangeFactory newFactory(DHFactory delegate) { return new KeyExchangeFactory() { @Override public String getName() { @@ -101,6 +101,7 @@ public class DHGEXClient extends AbstractDHClientKeyExchange { } @Override + @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance") public boolean next(int cmd, Buffer buffer) throws Exception { Session session = getSession(); boolean debugEnabled = log.isDebugEnabled(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java ---------------------------------------------------------------------- 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 9b343f3..32ef21b 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 @@ -111,6 +111,7 @@ import org.apache.sshd.common.util.net.SshdSocketAddress; * * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> */ +@SuppressWarnings("checkstyle:MethodCount") // TODO split this big class and remove the suppression public abstract class AbstractSession extends AbstractKexFactoryManager implements Session { /** * Name of the property where this session is stored in the attributes of the @@ -1827,6 +1828,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen * * @throws Exception if an error occurs */ + @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance") protected void receiveNewKeys() throws Exception { byte[] k = kex.getK(); byte[] h = kex.getH(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/server/auth/hostbased/UserAuthHostBased.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/hostbased/UserAuthHostBased.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/hostbased/UserAuthHostBased.java index 156eb70..c191876 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/auth/hostbased/UserAuthHostBased.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/hostbased/UserAuthHostBased.java @@ -71,6 +71,7 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact } @Override + @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance") protected Boolean doAuth(Buffer buffer, boolean init) throws Exception { ValidateUtils.checkTrue(init, "Instance not initialized"); @@ -101,16 +102,16 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact boolean debugEnabled = log.isDebugEnabled(); if (debugEnabled) { log.debug("doAuth({}@{}) authenticate key type={}, fingerprint={}, client={}@{}, num-certs={}", - username, session, keyType, KeyUtils.getFingerPrint(clientKey), - clientUsername, clientHostName, GenericUtils.size(certs)); + username, session, keyType, KeyUtils.getFingerPrint(clientKey), + clientUsername, clientHostName, GenericUtils.size(certs)); } HostBasedAuthenticator authenticator = session.getHostBasedAuthenticator(); if (authenticator == null) { if (debugEnabled) { log.debug("doAuth({}@{}) key type={}, fingerprint={}, client={}@{}, num-certs={} - no authenticator", - username, session, keyType, KeyUtils.getFingerPrint(clientKey), - clientUsername, clientHostName, GenericUtils.size(certs)); + username, session, keyType, KeyUtils.getFingerPrint(clientKey), + clientUsername, clientHostName, GenericUtils.size(certs)); } return Boolean.FALSE; } @@ -131,8 +132,8 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact if (debugEnabled) { log.debug("doAuth({}@{}) key type={}, fingerprint={}, client={}@{}, num-certs={} - authentication result: {}", - username, session, keyType, KeyUtils.getFingerPrint(clientKey), - clientUsername, clientHostName, GenericUtils.size(certs), authed); + username, session, keyType, KeyUtils.getFingerPrint(clientKey), + clientUsername, clientHostName, GenericUtils.size(certs), authed); } if (!authed) { return Boolean.FALSE; @@ -140,14 +141,14 @@ public class UserAuthHostBased extends AbstractUserAuth implements SignatureFact // verify signature Collection<NamedFactory<Signature>> factories = - ValidateUtils.checkNotNullAndNotEmpty( - SignatureFactoriesManager.resolveSignatureFactories(this, session), - "No signature factories for session=%s", - session); + ValidateUtils.checkNotNullAndNotEmpty( + SignatureFactoriesManager.resolveSignatureFactories(this, session), + "No signature factories for session=%s", + session); Signature verifier = ValidateUtils.checkNotNull( - NamedFactory.create(factories, keyType), - "No verifier located for algorithm=%s", - keyType); + NamedFactory.create(factories, keyType), + "No verifier located for algorithm=%s", + keyType); verifier.initVerifier(clientKey); byte[] id = session.getSessionId(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/UserAuthKeyboardInteractive.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/UserAuthKeyboardInteractive.java index 536883e..f73cd5d 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/UserAuthKeyboardInteractive.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/UserAuthKeyboardInteractive.java @@ -59,8 +59,9 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { throws Exception { String lang = buffer.getString(); String subMethods = buffer.getString(); + boolean debugEnabled = log.isDebugEnabled(); if (auth == null) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{})[methods={}, lang={}] - no interactive authenticator to generate challenge", username, session, subMethods, lang); } @@ -72,26 +73,26 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { challenge = auth.generateChallenge(session, username, lang, subMethods); } catch (Error e) { log.warn("doAuth({}@{}) failed ({}) to generate authenticator challenge: {}", - username, session, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + username, session, e.getClass().getSimpleName(), e.getMessage()); + if (debugEnabled) { log.debug("doAuth(" + username + "@" + session + ") authenticator challenge failure details", e); } throw new RuntimeSshException(e); } if (challenge == null) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{})[methods={}, lang={}] - no interactive challenge generated", username, session, subMethods, lang); } return false; } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{})[methods={}, lang={}] challenge name={}, instruction={}, lang={}, num. prompts={}", - username, session, subMethods, lang, - challenge.getInteractionName(), challenge.getInteractionInstruction(), - challenge.getLanguageTag(), GenericUtils.size(challenge.getPrompts())); + username, session, subMethods, lang, + challenge.getInteractionName(), challenge.getInteractionInstruction(), + challenge.getLanguageTag(), GenericUtils.size(challenge.getPrompts())); } // Prompt for password @@ -120,8 +121,9 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { responses.add(value); } + boolean debugEnabled = log.isDebugEnabled(); if (auth == null) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{}) no interactive authenticator to validate {} responses", username, session, num); } @@ -134,13 +136,13 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { } catch (Error e) { log.warn("doAuth({}@{}) failed ({}) to consult authenticator: {}", username, session, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth(" + username + "@" + session + ") authenticator consultation failure details", e); } throw new RuntimeSshException(e); } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{}) authenticate {} responses result: {}", username, session, num, authed); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/server/auth/password/UserAuthPassword.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/password/UserAuthPassword.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/UserAuthPassword.java index 750fea4..4a39af7 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/auth/password/UserAuthPassword.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/password/UserAuthPassword.java @@ -70,8 +70,9 @@ public class UserAuthPassword extends AbstractUserAuth { */ protected Boolean checkPassword(Buffer buffer, ServerSession session, String username, String password) throws Exception { PasswordAuthenticator auth = session.getPasswordAuthenticator(); + boolean debugEnabled = log.isDebugEnabled(); if (auth == null) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("checkPassword({}) no password authenticator", session); } return false; @@ -84,18 +85,18 @@ public class UserAuthPassword extends AbstractUserAuth { } catch (Error e) { log.warn("checkPassword({}) failed ({}) to consult authenticator: {}", session, e.getClass().getSimpleName(), e.getMessage()); - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("checkPassword(" + session + ") authenticator failure details", e); } throw new RuntimeSshException(e); } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("checkPassword({}) authentication result: {}", session, authed); } return authed; } catch (PasswordChangeRequiredException e) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("checkPassword({}) password change required: {}", session, e.getMessage()); } return handleServerPasswordChangeRequest(buffer, session, username, password, e); @@ -117,7 +118,7 @@ public class UserAuthPassword extends AbstractUserAuth { */ protected Boolean handleClientPasswordChangeRequest( Buffer buffer, ServerSession session, String username, String oldPassword, String newPassword) - throws Exception { + throws Exception { throw new UnsupportedOperationException("Password change not supported"); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/UserAuthPublicKey.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/UserAuthPublicKey.java index aa65835..0ea0dfa 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/UserAuthPublicKey.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/UserAuthPublicKey.java @@ -82,28 +82,29 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact String username = getUsername(); PublicKey key = buffer.getRawPublicKey(); Collection<NamedFactory<Signature>> factories = - ValidateUtils.checkNotNullAndNotEmpty( - SignatureFactoriesManager.resolveSignatureFactories(this, session), - "No signature factories for session=%s", - session); - if (log.isDebugEnabled()) { + ValidateUtils.checkNotNullAndNotEmpty( + SignatureFactoriesManager.resolveSignatureFactories(this, session), + "No signature factories for session=%s", + session); + boolean debugEnabled = log.isDebugEnabled(); + if (debugEnabled) { log.debug("doAuth({}@{}) verify key type={}, factories={}, fingerprint={}", - username, session, alg, NamedResource.getNames(factories), KeyUtils.getFingerPrint(key)); + username, session, alg, NamedResource.getNames(factories), KeyUtils.getFingerPrint(key)); } Signature verifier = ValidateUtils.checkNotNull( - NamedFactory.create(factories, alg), - "No verifier located for algorithm=%s", - alg); + NamedFactory.create(factories, alg), + "No verifier located for algorithm=%s", + alg); verifier.initVerifier(key); buffer.wpos(oldLim); byte[] sig = hasSig ? buffer.getBytes() : null; PublickeyAuthenticator authenticator = session.getPublickeyAuthenticator(); if (authenticator == null) { - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{}) key type={}, fingerprint={} - no authenticator", - username, session, alg, KeyUtils.getFingerPrint(key)); + username, session, alg, KeyUtils.getFingerPrint(key)); } return Boolean.FALSE; } @@ -113,17 +114,17 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact authed = authenticator.authenticate(username, key, session); } catch (Error e) { log.warn("doAuth({}@{}) failed ({}) to consult delegate for {} key={}: {}", - username, session, e.getClass().getSimpleName(), alg, KeyUtils.getFingerPrint(key), e.getMessage()); - if (log.isDebugEnabled()) { + username, session, e.getClass().getSimpleName(), alg, KeyUtils.getFingerPrint(key), e.getMessage()); + if (debugEnabled) { log.debug("doAuth(" + username + "@" + session + ") delegate failure details", e); } throw new RuntimeSshException(e); } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{}) key type={}, fingerprint={} - authentication result: {}", - username, session, alg, KeyUtils.getFingerPrint(key), authed); + username, session, alg, KeyUtils.getFingerPrint(key), authed); } if (!authed) { @@ -137,21 +138,24 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact buffer.rpos(oldPos); buffer.wpos(oldPos + 4 + len); - if (!verifySignature(session, getService(), getName(), username, alg, key, buffer, verifier, sig)) { + if (!verifySignature(session, username, alg, key, buffer, verifier, sig)) { throw new SignatureException("Key verification failed"); } - if (log.isDebugEnabled()) { + if (debugEnabled) { log.debug("doAuth({}@{}) key type={}, fingerprint={} - verified", - username, session, alg, KeyUtils.getFingerPrint(key)); + username, session, alg, KeyUtils.getFingerPrint(key)); } return Boolean.TRUE; } - protected boolean verifySignature(ServerSession session, String service, String name, String username, - String alg, PublicKey key, Buffer buffer, Signature verifier, byte[] sig) throws Exception { + protected boolean verifySignature( + ServerSession session, String username, String alg, PublicKey key, Buffer buffer, Signature verifier, byte[] sig) + throws Exception { byte[] id = session.getSessionId(); + String service = getService(); + String name = getName(); Buffer buf = new ByteArrayBuffer(id.length + username.length() + service.length() + name.length() + alg.length() + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE, false); buf.putBytes(id); @@ -165,17 +169,19 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact if (log.isTraceEnabled()) { log.trace("verifySignature({}@{})[{}][{}] key type={}, fingerprint={} - verification data={}", - username, session, service, name, alg, KeyUtils.getFingerPrint(key), buf.toHex()); + username, session, service, name, alg, KeyUtils.getFingerPrint(key), buf.toHex()); log.trace("verifySignature({}@{})[{}][{}] key type={}, fingerprint={} - expected signature={}", - username, session, service, name, alg, KeyUtils.getFingerPrint(key), BufferUtils.toHex(sig)); + username, session, service, name, alg, KeyUtils.getFingerPrint(key), BufferUtils.toHex(sig)); } verifier.update(buf.array(), buf.rpos(), buf.available()); return verifier.verify(sig); } - protected void sendPublicKeyResponse(ServerSession session, String username, String alg, PublicKey key, - byte[] keyBlob, int offset, int blobLen, Buffer buffer) throws Exception { + protected void sendPublicKeyResponse( + ServerSession session, String username, String alg, PublicKey key, + byte[] keyBlob, int offset, int blobLen, Buffer buffer) + throws Exception { if (log.isDebugEnabled()) { log.debug("doAuth({}@{}) send SSH_MSG_USERAUTH_PK_OK for key type={}, fingerprint={}", username, session, alg, KeyUtils.getFingerPrint(key)); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java index 1cb11ba..f9de9b1 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java @@ -60,6 +60,7 @@ import org.junit.runners.MethodSorters; */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Category({ NoIoTestCase.class }) +@SuppressWarnings("checkstyle:MethodCount") public class SshConfigFileReaderTest extends BaseTestSupport { public SshConfigFileReaderTest() { super(); @@ -136,11 +137,11 @@ public class SshConfigFileReaderTest extends BaseTestSupport { testKnownDefaultFactoriesList(SshConfigFileReader.DEFAULT_KEX_ALGORITHMS, BuiltinDHFactories::fromFactoryName); } - private void testKnownDefaultFactoriesList(String factories, Function<? super String, ? extends NamedResource> resolver) { + private static void testKnownDefaultFactoriesList(String factories, Function<? super String, ? extends NamedResource> resolver) { testKnownDefaultFactoriesList(factories, resolver, Collections.emptySet()); } - private void testKnownDefaultFactoriesList( + private static void testKnownDefaultFactoriesList( String factories, Function<? super String, ? extends NamedResource> resolver, Collection<String> excludedNames) { String[] names = GenericUtils.split(factories, ','); assertTrue("No default names", GenericUtils.length(names) > 0); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java b/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java index 64af8f1..cd95c4e 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java @@ -44,8 +44,8 @@ import org.mockito.Mockito; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Category({ NoIoTestCase.class }) +@SuppressWarnings("checkstyle:MethodCount") public class BasePathTest extends BaseTestSupport { - private TestFileSystem fileSystem; public BasePathTest() { @@ -333,7 +333,6 @@ public class BasePathTest extends BaseTestSupport { } private static class TestFileSystem extends BaseFileSystem<TestPath> { - TestFileSystem(FileSystemProvider fileSystemProvider) { super(fileSystemProvider); } @@ -365,7 +364,6 @@ public class BasePathTest extends BaseTestSupport { } private static class TestPath extends BasePath<TestPath, TestFileSystem> { - TestPath(TestFileSystem fileSystem, String root, List<String> names) { super(fileSystem, root, names); } @@ -387,7 +385,6 @@ public class BasePathTest extends BaseTestSupport { } public static class PathTester { - private final FileSystem fileSystem; private final String string; private String root; @@ -428,7 +425,7 @@ public class BasePathTest extends BaseTestSupport { testSubpaths(path); } - private void testRoot(Path path) { + protected void testRoot(Path path) { if (root != null) { assertTrue(path + ".isAbsolute() should be true", path.isAbsolute()); assertNotNull(path + ".getRoot() should not be null", path.getRoot()); @@ -439,7 +436,7 @@ public class BasePathTest extends BaseTestSupport { } } - private void testNames(Path path) { + protected void testNames(Path path) { assertEquals(names.size(), path.getNameCount()); assertEquals(names, names(path)); for (int i = 0; i < names.size(); i++) { @@ -463,9 +460,8 @@ public class BasePathTest extends BaseTestSupport { } } - private void testParents(Path path) { + protected void testParents(Path path) { Path parent = path.getParent(); - if (((root != null) && (names.size() >= 1)) || (names.size() > 1)) { assertNotNull(parent); } @@ -479,35 +475,36 @@ public class BasePathTest extends BaseTestSupport { } } - private void testSubpaths(Path path) { + protected void testSubpaths(Path path) { + int nameCount = path.getNameCount(); if (path.getRoot() == null) { - assertEquals(path, path.subpath(0, path.getNameCount())); + assertEquals(path, path.subpath(0, nameCount)); } - if (path.getNameCount() > 1) { + if (nameCount > 1) { String stringWithoutRoot = root == null ? string : string.substring(root.length()); // test start + 1 to end and start to end - 1 subpaths... this recursively tests all subpaths // actually tests most possible subpaths multiple times but... eh - Path startSubpath = path.subpath(1, path.getNameCount()); - List<String> startNames = split(stringWithoutRoot, "/") - .subList(1, path.getNameCount()); + Path startSubpath = path.subpath(1, nameCount); + List<String> startNames = split(stringWithoutRoot, '/') + .subList(1, nameCount); - new PathTester(fileSystem, join(startNames, "/")) + new PathTester(fileSystem, GenericUtils.join(startNames, '/')) .names(startNames) .test(startSubpath); - Path endSubpath = path.subpath(0, path.getNameCount() - 1); - List<String> endNames = split(stringWithoutRoot, "/") - .subList(0, path.getNameCount() - 1); + Path endSubpath = path.subpath(0, nameCount - 1); + List<String> endNames = split(stringWithoutRoot, '/') + .subList(0, nameCount - 1); - new PathTester(fileSystem, join(endNames, "/")) + new PathTester(fileSystem, GenericUtils.join(endNames, '/')) .names(endNames) .test(endSubpath); } } - private void testStartsWith(Path path) { + protected void testStartsWith(Path path) { // empty path doesn't start with any path if (root != null || !names.isEmpty()) { Path other = path; @@ -521,7 +518,7 @@ public class BasePathTest extends BaseTestSupport { } } - private void testEndsWith(Path path) { + protected void testEndsWith(Path path) { // empty path doesn't start with any path if (root != null || !names.isEmpty()) { Path other = path; @@ -549,20 +546,8 @@ public class BasePathTest extends BaseTestSupport { return list; } - private List<String> split(String string, String sep) { - return Arrays.asList(string.split(sep)); - } - - private static String join(Iterable<String> strings, String sep) { - StringBuilder sb = new StringBuilder(); - for (String s : strings) { - if (sb.length() > 0) { - sb.append(sep); - } - sb.append(s); - } - return sb.toString(); + private static List<String> split(String string, char sep) { + return Arrays.asList(GenericUtils.split(string, sep)); } } - } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java index 841902e..c4e521c 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java @@ -60,6 +60,7 @@ import org.junit.runners.MethodSorters; */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Category({ NoIoTestCase.class }) +@SuppressWarnings("checkstyle:MethodCount") public class SecurityUtilsTest extends BaseTestSupport { public static final String BC_NAMED_USAGE_PROP = SecurityProviderRegistrar.CONFIG_PROP_BASE http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerAdapter.java ---------------------------------------------------------------------- diff --git a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerAdapter.java b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerAdapter.java index a052c4d..7251dff 100644 --- a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerAdapter.java +++ b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerAdapter.java @@ -95,9 +95,10 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe } @Override + @SuppressWarnings("checkstyle:ParameterNumber") public void read(ServerSession session, String remoteHandle, FileHandle localHandle, - long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) - throws IOException { + long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) + throws IOException { if (log.isTraceEnabled()) { log.trace("read(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", requested=" + dataLen + ", read=" + readLen @@ -107,8 +108,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe @Override public void writing(ServerSession session, String remoteHandle, FileHandle localHandle, - long offset, byte[] data, int dataOffset, int dataLen) - throws IOException { + long offset, byte[] data, int dataOffset, int dataLen) + throws IOException { if (log.isTraceEnabled()) { log.trace("write(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", requested=" + dataLen); } @@ -116,8 +117,8 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe @Override public void written(ServerSession session, String remoteHandle, FileHandle localHandle, - long offset, byte[] data, int dataOffset, int dataLen, Throwable thrown) - throws IOException { + long offset, byte[] data, int dataOffset, int dataLen, Throwable thrown) + throws IOException { if (log.isTraceEnabled()) { log.trace("written(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", requested=" + dataLen + ((thrown == null) ? "" : (": " + thrown.getClass().getSimpleName() + ": " + thrown.getMessage()))); @@ -134,9 +135,9 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe } @Override - public void blocked(ServerSession session, String remoteHandle, FileHandle localHandle, - long offset, long length, int mask, Throwable thrown) - throws IOException { + public void blocked( + ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, int mask, Throwable thrown) + throws IOException { if (log.isTraceEnabled()) { log.trace("blocked(" + session + ")[" + localHandle.getFile() + "]" + " offset=" + offset + ", length=" + length + ", mask=0x" + Integer.toHexString(mask) @@ -153,9 +154,9 @@ public abstract class AbstractSftpEventListenerAdapter extends AbstractLoggingBe } @Override - public void unblocked(ServerSession session, String remoteHandle, FileHandle localHandle, - long offset, long length, Throwable thrown) - throws IOException { + public void unblocked( + ServerSession session, String remoteHandle, FileHandle localHandle, long offset, long length, Throwable thrown) + throws IOException { if (log.isTraceEnabled()) { log.trace("unblocked(" + session + ")[" + localHandle.getFile() + "]" + " offset=" + offset + ", length=" + length http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java ---------------------------------------------------------------------- diff --git a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java index cc6621e..86dc171 100644 --- a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java +++ b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java @@ -104,6 +104,7 @@ import org.apache.sshd.server.session.ServerSession; /** * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> */ +@SuppressWarnings("checkstyle:MethodCount") // TODO split this big class and remove the suppression public abstract class AbstractSftpSubsystemHelper extends AbstractLoggingBean implements SftpEventListenerManager, SftpSubsystemEnvironment { @@ -1924,6 +1925,7 @@ public abstract class AbstractSftpSubsystemHelper * @see SftpConstants#EXT_SUPPORTED * @see <A HREF="https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#page-10">DRAFT 13 section 5.4</A> */ + @SuppressWarnings("checkstyle:VariableDeclarationUsageDistance") protected void appendSupported2Extension(Buffer buffer, Collection<String> extras) { buffer.putString(SftpConstants.EXT_SUPPORTED2); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpEventListener.java ---------------------------------------------------------------------- diff --git a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpEventListener.java b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpEventListener.java index 2b5759f..6033a38 100644 --- a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpEventListener.java +++ b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpEventListener.java @@ -145,10 +145,11 @@ public interface SftpEventListener extends SshdEventListener { * @param thrown Non-{@code null} if read failed due to this exception * @throws IOException If failed to handle the call */ + @SuppressWarnings("checkstyle:ParameterNumber") default void read(ServerSession session, String remoteHandle, FileHandle localHandle, - long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) - throws IOException { - // ignored + long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) + throws IOException { + // ignored } /** http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/ClientTest.java ---------------------------------------------------------------------- diff --git a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/ClientTest.java b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/ClientTest.java index 7524878..ba72d73 100644 --- a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/ClientTest.java +++ b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/ClientTest.java @@ -80,6 +80,7 @@ import org.junit.runners.MethodSorters; * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@SuppressWarnings("checkstyle:MethodCount") public class ClientTest extends BaseTestSupport { private SshServer sshd; private SshClient client; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java ---------------------------------------------------------------------- diff --git a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java index 95f9b66..80428eb 100644 --- a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java +++ b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java @@ -79,6 +79,7 @@ import org.junit.Test; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@SuppressWarnings("checkstyle:MethodCount") public class SftpFileSystemTest extends BaseTestSupport { private static SshServer sshd; private static int port; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6a615d7e/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java ---------------------------------------------------------------------- diff --git a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java index 5170264..5b284a3 100644 --- a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java +++ b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java @@ -115,6 +115,7 @@ import org.junit.runners.MethodSorters; * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@SuppressWarnings("checkstyle:MethodCount") public class SftpTest extends AbstractSftpClientTestSupport { private static final Map<String, OptionalFeature> EXPECTED_EXTENSIONS = AbstractSftpSubsystemHelper.DEFAULT_SUPPORTED_CLIENT_EXTENSIONS; @@ -683,8 +684,9 @@ public class SftpTest extends AbstractSftpClientTestSupport { } @Override - public void read(ServerSession session, String remoteHandle, FileHandle localHandle, long offset, byte[] data, - int dataOffset, int dataLen, int readLen, Throwable thrown) { + @SuppressWarnings("checkstyle:ParameterNumber") + public void read(ServerSession session, String remoteHandle, FileHandle localHandle, + long offset, byte[] data, int dataOffset, int dataLen, int readLen, Throwable thrown) { readSize.addAndGet(readLen); if (log.isDebugEnabled()) { log.debug("read(" + session + ")[" + localHandle.getFile() + "] offset=" + offset + ", requested=" + dataLen + ", read=" + readLen);