[SSHD-740] Add default methods on PropertyResolver to actually do the property resolution
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/d6bb25d6 Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/d6bb25d6 Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/d6bb25d6 Branch: refs/heads/master Commit: d6bb25d6ecabdc9876a2c49a7023c6d84eec41f3 Parents: 655e7db Author: Guillaume Nodet <gno...@apache.org> Authored: Wed Apr 12 20:55:43 2017 +0200 Committer: Guillaume Nodet <gno...@apache.org> Committed: Wed Apr 12 21:18:49 2017 +0200 ---------------------------------------------------------------------- .../sshd/agent/local/AgentServerProxy.java | 5 ++- .../sshd/agent/local/ProxyAgentFactory.java | 3 +- .../sshd/agent/unix/AgentServerProxy.java | 7 ++-- .../sshd/agent/unix/ChannelAgentForwarding.java | 5 ++- .../sshd/agent/unix/UnixAgentFactory.java | 3 +- .../java/org/apache/sshd/client/SshClient.java | 4 +-- .../keyboard/UserAuthKeyboardInteractive.java | 7 ++-- .../client/channel/AbstractClientChannel.java | 2 +- .../apache/sshd/client/channel/ChannelExec.java | 3 +- .../sshd/client/channel/ChannelShell.java | 3 +- .../sshd/client/channel/ChannelSubsystem.java | 3 +- .../channel/PtyCapableChannelSession.java | 3 +- .../sshd/client/scp/AbstractScpClient.java | 5 ++- .../client/session/ClientConnectionService.java | 5 ++- .../client/session/ClientUserAuthService.java | 3 +- .../subsystem/sftp/DefaultSftpClient.java | 3 +- .../client/subsystem/sftp/SftpFileSystem.java | 3 +- .../subsystem/sftp/SftpFileSystemProvider.java | 14 ++++---- .../subsystem/sftp/SftpRemotePathChannel.java | 3 +- .../java/org/apache/sshd/common/Closeable.java | 2 +- .../apache/sshd/common/PropertyResolver.java | 36 ++++++++++++++++++++ .../sshd/common/channel/AbstractChannel.java | 3 +- .../common/channel/ChannelOutputStream.java | 3 +- .../common/channel/ChannelPipedInputStream.java | 3 +- .../org/apache/sshd/common/channel/Window.java | 27 ++++----------- .../common/forward/DefaultTcpipForwarder.java | 3 +- .../common/helpers/AbstractFactoryManager.java | 2 +- .../common/io/AbstractIoServiceFactory.java | 3 +- .../sshd/common/io/mina/MinaAcceptor.java | 5 ++- .../apache/sshd/common/io/mina/MinaService.java | 5 ++- .../sshd/common/io/nio2/Nio2Acceptor.java | 3 +- .../apache/sshd/common/io/nio2/Nio2Service.java | 3 +- .../apache/sshd/common/io/nio2/Nio2Session.java | 7 ++-- .../helpers/AbstractConnectionService.java | 3 +- .../common/session/helpers/AbstractSession.java | 22 ++++++------ .../sshd/common/subsystem/sftp/SftpHelper.java | 3 +- .../sshd/common/util/buffer/BufferUtils.java | 3 +- .../util/io/LoggingFilterOutputStream.java | 3 +- .../security/SecurityProviderRegistrar.java | 4 +-- .../BouncyCastleSecurityProviderRegistrar.java | 5 ++- .../eddsa/EdDSASecurityProviderRegistrar.java | 3 +- .../java/org/apache/sshd/server/SshServer.java | 2 +- ...DefaultKeyboardInteractiveAuthenticator.java | 11 +++--- .../server/channel/AbstractServerChannel.java | 2 +- .../org/apache/sshd/server/kex/DHGEXServer.java | 3 +- .../sshd/server/session/ServerSessionImpl.java | 3 +- .../server/session/ServerUserAuthService.java | 8 ++--- .../sshd/server/shell/InvertedShellWrapper.java | 3 +- .../server/subsystem/sftp/SftpSubsystem.java | 27 +++++++-------- .../server/x11/DefaultX11ForwardSupport.java | 11 +++--- .../subsystem/sftp/SftpFileSystemTest.java | 3 +- .../sshd/common/channel/WindowInitTest.java | 3 +- .../sshd/common/channel/WindowTimeoutTest.java | 5 +-- .../sshd/git/transport/GitSshdSession.java | 6 ++-- 54 files changed, 153 insertions(+), 169 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java index 90e6b9d..24a34cd 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentServerProxy.java @@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.sshd.agent.SshAgent; import org.apache.sshd.agent.SshAgentServer; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.session.ConnectionService; import org.apache.sshd.common.session.Session; import org.apache.sshd.common.util.logging.AbstractLoggingBean; @@ -46,10 +45,10 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer public SshAgent createClient() throws IOException { try { Session session = this.service.getSession(); - String channelType = PropertyResolverUtils.getStringProperty(session, PROXY_CHANNEL_TYPE, DEFAULT_PROXY_CHANNEL_TYPE); + String channelType = session.getStringProperty(PROXY_CHANNEL_TYPE, DEFAULT_PROXY_CHANNEL_TYPE); AgentForwardedChannel channel = new AgentForwardedChannel(channelType); this.service.registerChannel(channel); - channel.open().verify(PropertyResolverUtils.getLongProperty(channel, CHANNEL_OPEN_TIMEOUT_PROP, DEFAULT_CHANNEL_OPEN_TIMEOUT)); + channel.open().verify(channel.getLongProperty(CHANNEL_OPEN_TIMEOUT_PROP, DEFAULT_CHANNEL_OPEN_TIMEOUT)); return channel.getAgent(); } catch (Throwable t) { if (log.isDebugEnabled()) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java index c800f88..4c7a5d3 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java @@ -30,7 +30,6 @@ import org.apache.sshd.agent.SshAgentServer; import org.apache.sshd.agent.unix.UnixAgentFactory; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.channel.Channel; import org.apache.sshd.common.session.ConnectionService; import org.apache.sshd.common.session.Session; @@ -55,7 +54,7 @@ public class ProxyAgentFactory implements SshAgentFactory { @Override public SshAgent createClient(FactoryManager manager) throws IOException { - String proxyId = PropertyResolverUtils.getString(manager, SshAgent.SSH_AUTHSOCKET_ENV_NAME); + String proxyId = manager.getString(SshAgent.SSH_AUTHSOCKET_ENV_NAME); if (GenericUtils.isEmpty(proxyId)) { throw new IllegalStateException("No " + SshAgent.SSH_AUTHSOCKET_ENV_NAME + " environment variable set"); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java index 3a8fa8c..8aac699 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentServerProxy.java @@ -27,7 +27,6 @@ import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.sshd.agent.SshAgentServer; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshException; import org.apache.sshd.common.session.ConnectionService; import org.apache.sshd.common.session.Session; @@ -102,11 +101,11 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer } Session session = AgentServerProxy.this.service.getSession(); - Socket.timeoutSet(clientSock, PropertyResolverUtils.getIntProperty(session, AUTH_SOCKET_TIMEOUT, DEFAULT_AUTH_SOCKET_TIMEOUT)); - String channelType = PropertyResolverUtils.getStringProperty(session, PROXY_CHANNEL_TYPE, DEFAULT_PROXY_CHANNEL_TYPE); + Socket.timeoutSet(clientSock, session.getIntProperty(AUTH_SOCKET_TIMEOUT, DEFAULT_AUTH_SOCKET_TIMEOUT)); + String channelType = session.getStringProperty(PROXY_CHANNEL_TYPE, DEFAULT_PROXY_CHANNEL_TYPE); AgentForwardedChannel channel = new AgentForwardedChannel(clientSock, channelType); AgentServerProxy.this.service.registerChannel(channel); - channel.open().verify(PropertyResolverUtils.getLongProperty(session, CHANNEL_OPEN_TIMEOUT_PROP, DEFAULT_CHANNEL_OPEN_TIMEOUT)); + channel.open().verify(session.getLongProperty(CHANNEL_OPEN_TIMEOUT_PROP, DEFAULT_CHANNEL_OPEN_TIMEOUT)); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("run(open={}) {} while authentication forwarding: {}", http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java ---------------------------------------------------------------------- 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 42bc3d0..969f330 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 @@ -27,7 +27,6 @@ import java.util.concurrent.Future; import org.apache.sshd.agent.SshAgent; import org.apache.sshd.client.future.DefaultOpenFuture; import org.apache.sshd.client.future.OpenFuture; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.channel.ChannelOutputStream; import org.apache.sshd.common.future.CloseFuture; @@ -75,7 +74,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel { OpenFuture f = new DefaultOpenFuture(this); try { out = new ChannelOutputStream(this, getRemoteWindow(), log, SshConstants.SSH_MSG_CHANNEL_DATA, true); - authSocket = PropertyResolverUtils.getString(this, SshAgent.SSH_AUTHSOCKET_ENV_NAME); + authSocket = this.getString(SshAgent.SSH_AUTHSOCKET_ENV_NAME); pool = Pool.create(AprLibrary.getInstance().getRootPool()); handle = Local.create(authSocket, pool); int result = Local.connect(handle, 0); @@ -87,7 +86,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel { forwardService = (service == null) ? ThreadUtils.newSingleThreadExecutor("ChannelAgentForwarding[" + authSocket + "]") : service; shutdownForwarder = service != forwardService || isShutdownOnExit(); - final int copyBufSize = PropertyResolverUtils.getIntProperty(this, FORWARDER_BUFFER_SIZE, DEFAULT_FORWARDER_BUF_SIZE); + final int copyBufSize = this.getIntProperty(FORWARDER_BUFFER_SIZE, DEFAULT_FORWARDER_BUF_SIZE); ValidateUtils.checkTrue(copyBufSize >= MIN_FORWARDER_BUF_SIZE, "Copy buf size below min.: %d", copyBufSize); ValidateUtils.checkTrue(copyBufSize <= MAX_FORWARDER_BUF_SIZE, "Copy buf size above max.: %d", copyBufSize); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java index 282e104..c701dbe 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java @@ -32,7 +32,6 @@ import org.apache.sshd.agent.SshAgentServer; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.NamedResource; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshException; import org.apache.sshd.common.channel.Channel; import org.apache.sshd.common.session.ConnectionService; @@ -110,7 +109,7 @@ public class UnixAgentFactory implements SshAgentFactory, ExecutorServiceConfigu @Override public SshAgent createClient(FactoryManager manager) throws IOException { - String authSocket = PropertyResolverUtils.getString(manager, SshAgent.SSH_AUTHSOCKET_ENV_NAME); + String authSocket = manager.getString(SshAgent.SSH_AUTHSOCKET_ENV_NAME); if (GenericUtils.isEmpty(authSocket)) { throw new SshException("No " + SshAgent.SSH_AUTHSOCKET_ENV_NAME + " value"); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java ---------------------------------------------------------------------- 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 d3f2f3f..c2a8025 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 @@ -433,7 +433,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa public void stop() { try { - long maxWait = PropertyResolverUtils.getLongProperty(this, STOP_WAIT_TIME, DEFAULT_STOP_WAIT_TIME); + long maxWait = this.getLongProperty(STOP_WAIT_TIME, DEFAULT_STOP_WAIT_TIME); boolean successful = close(true).await(maxWait); if (!successful) { throw new SocketTimeoutException("Failed to receive closure confirmation within " + maxWait + " millis"); @@ -541,7 +541,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa } List<KeyPair> ids = new ArrayList<>(locations.size()); - boolean ignoreNonExisting = PropertyResolverUtils.getBooleanProperty(this, IGNORE_INVALID_IDENTITIES, DEFAULT_IGNORE_INVALID_IDENTITIES); + boolean ignoreNonExisting = this.getBooleanProperty(IGNORE_INVALID_IDENTITIES, DEFAULT_IGNORE_INVALID_IDENTITIES); ClientIdentityLoader loader = Objects.requireNonNull(getClientIdentityLoader(), "No ClientIdentityLoader"); FilePasswordProvider provider = Objects.requireNonNull(getFilePasswordProvider(), "No FilePasswordProvider"); for (String l : locations) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/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 0add7ed..04414de 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 @@ -27,7 +27,6 @@ import org.apache.sshd.client.ClientAuthenticationManager; import org.apache.sshd.client.auth.AbstractUserAuth; import org.apache.sshd.client.auth.password.PasswordIdentityProvider; import org.apache.sshd.client.session.ClientSession; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.RuntimeSshException; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.util.GenericUtils; @@ -89,7 +88,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { public void init(ClientSession session, String service) throws Exception { super.init(session, service); passwords = PasswordIdentityProvider.iteratorOf(session); - maxTrials = PropertyResolverUtils.getIntProperty(session, ClientAuthenticationManager.PASSWORD_PROMPTS, ClientAuthenticationManager.DEFAULT_PASSWORD_PROMPTS); + maxTrials = session.getIntProperty(ClientAuthenticationManager.PASSWORD_PROMPTS, ClientAuthenticationManager.DEFAULT_PASSWORD_PROMPTS); ValidateUtils.checkTrue(maxTrials > 0, "Non-positive max. trials: %d", maxTrials); } @@ -203,11 +202,11 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth { } protected String getExchangeLanguageTag(ClientSession session) { - return PropertyResolverUtils.getStringProperty(session, INTERACTIVE_LANGUAGE_TAG, DEFAULT_INTERACTIVE_LANGUAGE_TAG); + return session.getStringProperty(INTERACTIVE_LANGUAGE_TAG, DEFAULT_INTERACTIVE_LANGUAGE_TAG); } protected String getExchangeSubMethods(ClientSession session) { - return PropertyResolverUtils.getStringProperty(session, INTERACTIVE_SUBMETHODS, DEFAULT_INTERACTIVE_SUBMETHODS); + return session.getStringProperty(INTERACTIVE_SUBMETHODS, DEFAULT_INTERACTIVE_SUBMETHODS); } protected String getCurrentPasswordCandidate() { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java ---------------------------------------------------------------------- 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 6adf2f6..4159a53 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 @@ -325,7 +325,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C Session session = getSession(); FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No factory manager"); Window wRemote = getRemoteWindow(); - wRemote.init(rwSize, packetSize, manager.getProperties()); + wRemote.init(rwSize, packetSize, manager); String changeEvent = "SSH_MSG_CHANNEL_OPEN_CONFIRMATION"; try { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java index 414f10d..b5dfa14 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java @@ -21,7 +21,6 @@ package org.apache.sshd.client.channel; import java.io.IOException; import java.util.Date; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.channel.Channel; import org.apache.sshd.common.session.Session; @@ -57,7 +56,7 @@ public class ChannelExec extends PtyCapableChannelSession { } Session session = getSession(); - boolean wantReply = PropertyResolverUtils.getBooleanProperty(this, REQUEST_EXEC_REPLY, DEFAULT_REQUEST_EXEC_REPLY); + boolean wantReply = this.getBooleanProperty(REQUEST_EXEC_REPLY, DEFAULT_REQUEST_EXEC_REPLY); Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, command.length() + Integer.SIZE); buffer.putInt(getRecipient()); buffer.putString(Channel.CHANNEL_EXEC); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java index 6b3047b..32000b8 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java @@ -21,7 +21,6 @@ package org.apache.sshd.client.channel; import java.io.IOException; import java.util.Date; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.channel.Channel; import org.apache.sshd.common.session.Session; @@ -53,7 +52,7 @@ public class ChannelShell extends PtyCapableChannelSession { } Session session = getSession(); - boolean wantReply = PropertyResolverUtils.getBooleanProperty(this, REQUEST_SHELL_REPLY, DEFAULT_REQUEST_SHELL_REPLY); + boolean wantReply = this.getBooleanProperty(REQUEST_SHELL_REPLY, DEFAULT_REQUEST_SHELL_REPLY); Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Integer.SIZE); buffer.putInt(getRecipient()); buffer.putString(Channel.CHANNEL_SHELL); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java index 132e756..7b30e89 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java @@ -21,7 +21,6 @@ package org.apache.sshd.client.channel; import java.io.IOException; import java.util.Date; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.channel.Channel; import org.apache.sshd.common.session.Session; @@ -77,7 +76,7 @@ public class ChannelSubsystem extends ChannelSession { } Session session = getSession(); - boolean wantReply = PropertyResolverUtils.getBooleanProperty(this, REQUEST_SUBSYSTEM_REPLY, DEFAULT_REQUEST_SUBSYSTEM_REPLY); + boolean wantReply = this.getBooleanProperty(REQUEST_SUBSYSTEM_REPLY, DEFAULT_REQUEST_SUBSYSTEM_REPLY); Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Channel.CHANNEL_SUBSYSTEM.length() + systemName.length() + Integer.SIZE); buffer.putInt(getRecipient()); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java index 7b18b90..307c860 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java @@ -25,7 +25,6 @@ import java.util.LinkedHashMap; import java.util.Map; import org.apache.sshd.agent.SshAgentFactory; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.channel.PtyMode; import org.apache.sshd.common.channel.SttySupport; @@ -227,7 +226,7 @@ public class PtyCapableChannelSession extends ChannelSession { log.debug("doOpenPty({}) Send agent forwarding request", this); } - String channelType = PropertyResolverUtils.getStringProperty(session, SshAgentFactory.PROXY_AUTH_CHANNEL_TYPE, SshAgentFactory.DEFAULT_PROXY_AUTH_CHANNEL_TYPE); + String channelType = session.getStringProperty(SshAgentFactory.PROXY_AUTH_CHANNEL_TYPE, SshAgentFactory.DEFAULT_PROXY_AUTH_CHANNEL_TYPE); Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE); buffer.putInt(getRecipient()); buffer.putString(channelType); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java b/sshd-core/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java index 233abf1..2e13046 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java @@ -36,7 +36,6 @@ import org.apache.sshd.client.channel.ClientChannel; import org.apache.sshd.client.channel.ClientChannelEvent; import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.FactoryManager; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshException; import org.apache.sshd.common.file.FileSystemFactory; import org.apache.sshd.common.scp.ScpException; @@ -178,7 +177,7 @@ public abstract class AbstractScpClient extends AbstractLoggingBean implements S */ protected void handleCommandExitStatus(String cmd, ClientChannel channel) throws IOException { // give a chance for the exit status to be received - long timeout = PropertyResolverUtils.getLongProperty(channel, SCP_EXEC_CHANNEL_EXIT_STATUS_TIMEOUT, DEFAULT_EXEC_CHANNEL_EXIT_STATUS_TIMEOUT); + long timeout = channel.getLongProperty(SCP_EXEC_CHANNEL_EXIT_STATUS_TIMEOUT, DEFAULT_EXEC_CHANNEL_EXIT_STATUS_TIMEOUT); if (timeout <= 0L) { handleCommandExitStatus(cmd, (Integer) null); return; @@ -241,7 +240,7 @@ public abstract class AbstractScpClient extends AbstractLoggingBean implements S } protected ChannelExec openCommandChannel(ClientSession session, String cmd) throws IOException { - long waitTimeout = PropertyResolverUtils.getLongProperty(session, SCP_EXEC_CHANNEL_OPEN_TIMEOUT, DEFAULT_EXEC_CHANNEL_OPEN_TIMEOUT); + long waitTimeout = session.getLongProperty(SCP_EXEC_CHANNEL_OPEN_TIMEOUT, DEFAULT_EXEC_CHANNEL_OPEN_TIMEOUT); ChannelExec channel = session.createExecChannel(cmd); long startTime = System.nanoTime(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java index 1377e99..145328e 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java @@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit; import org.apache.sshd.agent.common.AgentForwardSupport; import org.apache.sshd.client.ClientFactoryManager; import org.apache.sshd.common.FactoryManager; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.SshException; import org.apache.sshd.common.io.AbstractIoWriteFuture; @@ -60,7 +59,7 @@ public class ClientConnectionService extends AbstractConnectionService<AbstractC protected void startHeartBeat() { ClientSession session = getClientSession(); - long interval = PropertyResolverUtils.getLongProperty(session, ClientFactoryManager.HEARTBEAT_INTERVAL, ClientFactoryManager.DEFAULT_HEARTBEAT_INTERVAL); + long interval = session.getLongProperty(ClientFactoryManager.HEARTBEAT_INTERVAL, ClientFactoryManager.DEFAULT_HEARTBEAT_INTERVAL); if (interval > 0L) { FactoryManager manager = session.getFactoryManager(); ScheduledExecutorService service = manager.getScheduledExecutorService(); @@ -78,7 +77,7 @@ public class ClientConnectionService extends AbstractConnectionService<AbstractC */ protected IoWriteFuture sendHeartBeat() { ClientSession session = getClientSession(); - String request = PropertyResolverUtils.getStringProperty(session, ClientFactoryManager.HEARTBEAT_REQUEST, ClientFactoryManager.DEFAULT_KEEP_ALIVE_HEARTBEAT_STRING); + String request = session.getStringProperty(ClientFactoryManager.HEARTBEAT_REQUEST, ClientFactoryManager.DEFAULT_KEEP_ALIVE_HEARTBEAT_STRING); try { Buffer buf = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST, request.length() + Byte.SIZE); buf.putString(request); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java ---------------------------------------------------------------------- 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 8b459b1..dbe4202 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 @@ -33,7 +33,6 @@ import org.apache.sshd.client.future.AuthFuture; import org.apache.sshd.client.future.DefaultAuthFuture; import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.NamedResource; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.RuntimeSshException; import org.apache.sshd.common.Service; import org.apache.sshd.common.SshConstants; @@ -75,7 +74,7 @@ public class ClientUserAuthService clientSession.getUserAuthFactories(), "No user auth factories for %s", s); clientMethods = new ArrayList<>(); - String prefs = PropertyResolverUtils.getString(s, ClientAuthenticationManager.PREFERRED_AUTHS); + String prefs = s.getString(ClientAuthenticationManager.PREFERRED_AUTHS); if (GenericUtils.isEmpty(prefs)) { for (NamedFactory<UserAuth> factory : authFactories) { clientMethods.add(factory.getName()); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/DefaultSftpClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/DefaultSftpClient.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/DefaultSftpClient.java index a8a8bf8..35400ae 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/DefaultSftpClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/DefaultSftpClient.java @@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.sshd.client.channel.ChannelSubsystem; import org.apache.sshd.client.channel.ClientChannel; import org.apache.sshd.client.session.ClientSession; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshException; import org.apache.sshd.common.subsystem.sftp.SftpConstants; import org.apache.sshd.common.subsystem.sftp.extensions.ParserUtils; @@ -88,7 +87,7 @@ public class DefaultSftpClient extends AbstractSftpClient { }); this.channel.setErr(new ByteArrayOutputStream(Byte.MAX_VALUE)); - long initializationTimeout = PropertyResolverUtils.getLongProperty(clientSession, SFTP_CHANNEL_OPEN_TIMEOUT, DEFAULT_CHANNEL_OPEN_TIMEOUT); + long initializationTimeout = clientSession.getLongProperty(SFTP_CHANNEL_OPEN_TIMEOUT, DEFAULT_CHANNEL_OPEN_TIMEOUT); this.channel.open().verify(initializationTimeout); this.channel.onClose(() -> { synchronized (messages) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java index a2c01d4..d006d26 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java @@ -41,7 +41,6 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.sshd.client.channel.ClientChannel; import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.client.session.ClientSessionHolder; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.file.util.BaseFileSystem; import org.apache.sshd.common.subsystem.sftp.SftpConstants; import org.apache.sshd.common.util.GenericUtils; @@ -74,7 +73,7 @@ public class SftpFileSystem extends BaseFileSystem<SftpPath> implements ClientSe this.clientSession = Objects.requireNonNull(session, "No client session"); this.selector = selector; this.stores = Collections.unmodifiableList(Collections.<FileStore>singletonList(new SftpFileStore(id, this))); - this.pool = new LinkedBlockingQueue<>(PropertyResolverUtils.getIntProperty(session, POOL_SIZE_PROP, DEFAULT_POOL_SIZE)); + this.pool = new LinkedBlockingQueue<>(session.getIntProperty(POOL_SIZE_PROP, DEFAULT_POOL_SIZE)); try (SftpClient client = getClient()) { version = client.getVersion(); defaultDir = getPath(client.canonicalPath(".")); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java index 280baff..fb24d73 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java @@ -195,7 +195,7 @@ public class SftpFileSystemProvider extends FileSystemProvider { ClientSession session = null; try { session = client.connect(username, host, port) - .verify(PropertyResolverUtils.getLongProperty(resolver, CONNECT_TIME_PROP_NAME, DEFAULT_CONNECT_TIME)) + .verify(resolver.getLongProperty(CONNECT_TIME_PROP_NAME, DEFAULT_CONNECT_TIME)) .getSession(); if (GenericUtils.size(params) > 0) { // Cannot use forEach because the session is not effectively final @@ -210,7 +210,7 @@ public class SftpFileSystemProvider extends FileSystemProvider { } } session.addPasswordIdentity(password); - session.auth().verify(PropertyResolverUtils.getLongProperty(resolver, AUTH_TIME_PROP_NAME, DEFAULT_AUTH_TIME)); + session.auth().verify(resolver.getLongProperty(AUTH_TIME_PROP_NAME, DEFAULT_AUTH_TIME)); fileSystem = new SftpFileSystem(this, id, session, selector); fileSystems.put(id, fileSystem); @@ -238,8 +238,8 @@ public class SftpFileSystemProvider extends FileSystemProvider { } } - fileSystem.setReadBufferSize(PropertyResolverUtils.getIntProperty(resolver, READ_BUFFER_PROP_NAME, DEFAULT_READ_BUFFER_SIZE)); - fileSystem.setWriteBufferSize(PropertyResolverUtils.getIntProperty(resolver, WRITE_BUFFER_PROP_NAME, DEFAULT_WRITE_BUFFER_SIZE)); + fileSystem.setReadBufferSize(resolver.getIntProperty(READ_BUFFER_PROP_NAME, DEFAULT_READ_BUFFER_SIZE)); + fileSystem.setWriteBufferSize(resolver.getIntProperty(WRITE_BUFFER_PROP_NAME, DEFAULT_WRITE_BUFFER_SIZE)); if (log.isDebugEnabled()) { log.debug("newFileSystem({}): {}", uri.toASCIIString(), fileSystem); } @@ -247,7 +247,7 @@ public class SftpFileSystemProvider extends FileSystemProvider { } protected SftpVersionSelector resolveSftpVersionSelector(URI uri, SftpVersionSelector defaultSelector, PropertyResolver resolver) { - String preference = PropertyResolverUtils.getString(resolver, VERSION_PARAM); + String preference = resolver.getString(VERSION_PARAM); if (GenericUtils.isEmpty(preference)) { return defaultSelector; } @@ -339,8 +339,8 @@ public class SftpFileSystemProvider extends FileSystemProvider { fileSystems.put(id, fileSystem); } - fileSystem.setReadBufferSize(PropertyResolverUtils.getIntProperty(session, READ_BUFFER_PROP_NAME, DEFAULT_READ_BUFFER_SIZE)); - fileSystem.setWriteBufferSize(PropertyResolverUtils.getIntProperty(session, WRITE_BUFFER_PROP_NAME, DEFAULT_WRITE_BUFFER_SIZE)); + fileSystem.setReadBufferSize(session.getIntProperty(READ_BUFFER_PROP_NAME, DEFAULT_READ_BUFFER_SIZE)); + fileSystem.setWriteBufferSize(session.getIntProperty(WRITE_BUFFER_PROP_NAME, DEFAULT_WRITE_BUFFER_SIZE)); if (log.isDebugEnabled()) { log.debug("newFileSystem: {}", fileSystem); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java index a3fb210..9195009 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java @@ -40,7 +40,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.subsystem.sftp.SftpConstants; import org.apache.sshd.common.subsystem.sftp.SftpException; import org.apache.sshd.common.util.GenericUtils; @@ -284,7 +283,7 @@ public class SftpRemotePathChannel extends FileChannel { } ensureOpen(WRITE_MODES); - int copySize = PropertyResolverUtils.getIntProperty(sftp.getClientSession(), COPY_BUFSIZE_PROP, DEFAULT_TRANSFER_BUFFER_SIZE); + int copySize = sftp.getClientSession().getIntProperty(COPY_BUFSIZE_PROP, DEFAULT_TRANSFER_BUFFER_SIZE); boolean completed = false; long curPos = (position >= 0L) ? position : posTracker.get(); long totalRead = 0L; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/Closeable.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/Closeable.java b/sshd-core/src/main/java/org/apache/sshd/common/Closeable.java index 4c3e45f..6a6f622 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/Closeable.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/Closeable.java @@ -105,7 +105,7 @@ public interface Closeable extends Channel { static long getMaxCloseWaitTime(PropertyResolver resolver) { return (resolver == null) ? DEFAULT_CLOSE_WAIT_TIMEOUT - : PropertyResolverUtils.getLongProperty(resolver, CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT); + : resolver.getLongProperty(CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT); } static void close(Closeable closeable) throws IOException { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/PropertyResolver.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/PropertyResolver.java b/sshd-core/src/main/java/org/apache/sshd/common/PropertyResolver.java index c3adff4..c333c7f 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/PropertyResolver.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/PropertyResolver.java @@ -85,4 +85,40 @@ public interface PropertyResolver { * {@code null} */ Map<String, Object> getProperties(); + + default long getLongProperty(String name, long def) { + return PropertyResolverUtils.getLongProperty(this, name, def); + } + + default Long getLong(String name) { + return PropertyResolverUtils.getLong(this, name); + } + + default int getIntProperty(String name, int def) { + return PropertyResolverUtils.getIntProperty(this, name, def); + } + + default Integer getInteger(String name) { + return PropertyResolverUtils.getInteger(this, name); + } + + default boolean getBooleanProperty(String name, boolean def) { + return PropertyResolverUtils.getBooleanProperty(this, name, def); + } + + default Boolean getBoolean(String name) { + return PropertyResolverUtils.getBoolean(this, name); + } + + default String getStringProperty(String name, String def) { + return PropertyResolverUtils.getStringProperty(this, name, def); + } + + default String getString(String name) { + return PropertyResolverUtils.getString(this, name); + } + + default Object getObject(String name) { + return PropertyResolverUtils.getObject(this, name); + } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java ---------------------------------------------------------------------- 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 71cb861..de183bc 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 @@ -39,7 +39,6 @@ import org.apache.sshd.common.AttributeStore; import org.apache.sshd.common.Closeable; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.PropertyResolver; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.future.CloseFuture; import org.apache.sshd.common.future.DefaultCloseFuture; @@ -604,7 +603,7 @@ public abstract class AbstractChannel buffer.putInt(getRecipient()); try { - long timeout = PropertyResolverUtils.getLongProperty(channel, FactoryManager.CHANNEL_CLOSE_TIMEOUT, FactoryManager.DEFAULT_CHANNEL_CLOSE_TIMEOUT); + long timeout = channel.getLongProperty(FactoryManager.CHANNEL_CLOSE_TIMEOUT, FactoryManager.DEFAULT_CHANNEL_CLOSE_TIMEOUT); s.writePacket(buffer, timeout, TimeUnit.MILLISECONDS).addListener(future -> { if (future.isWritten()) { handleClosePacketWritten(channel, immediately); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java ---------------------------------------------------------------------- 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 93ebcda..6fdb2d1 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 @@ -26,7 +26,6 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.SshException; import org.apache.sshd.common.session.Session; @@ -58,7 +57,7 @@ public class ChannelOutputStream extends OutputStream implements java.nio.channe private boolean noDelay; public ChannelOutputStream(AbstractChannel channel, Window remoteWindow, Logger log, byte cmd, boolean eofOnClose) { - this(channel, remoteWindow, PropertyResolverUtils.getLongProperty(channel, WAIT_FOR_SPACE_TIMEOUT, DEFAULT_WAIT_FOR_SPACE_TIMEOUT), log, cmd, eofOnClose); + this(channel, remoteWindow, channel.getLongProperty(WAIT_FOR_SPACE_TIMEOUT, DEFAULT_WAIT_FOR_SPACE_TIMEOUT), log, cmd, eofOnClose); } public ChannelOutputStream(AbstractChannel channel, Window remoteWindow, long maxWaitTimeout, Logger log, byte cmd, boolean eofOnClose) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java index 82c8691..544a34f 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java @@ -31,7 +31,6 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.PropertyResolver; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.buffer.Buffer; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; @@ -60,7 +59,7 @@ public class ChannelPipedInputStream extends InputStream implements ChannelPiped private long timeout; public ChannelPipedInputStream(PropertyResolver resolver, Window localWindow) { - this(localWindow, PropertyResolverUtils.getLongProperty(resolver, FactoryManager.WINDOW_TIMEOUT, FactoryManager.DEFAULT_WINDOW_TIMEOUT)); + this(localWindow, resolver.getLongProperty(FactoryManager.WINDOW_TIMEOUT, FactoryManager.DEFAULT_WINDOW_TIMEOUT)); } public ChannelPipedInputStream(Window localWindow, long windowTimeout) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java index f443165..4319b0b 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java @@ -21,8 +21,6 @@ package org.apache.sshd.common.channel; import java.io.IOException; import java.io.StreamCorruptedException; import java.net.SocketTimeoutException; -import java.util.Collections; -import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -31,7 +29,6 @@ import java.util.function.Predicate; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.PropertyResolver; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.BufferUtils; import org.apache.sshd.common.util.logging.AbstractLoggingBean; @@ -45,7 +42,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean; * * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> */ -public class Window extends AbstractLoggingBean implements java.nio.channels.Channel, ChannelHolder, PropertyResolver { +public class Window extends AbstractLoggingBean implements java.nio.channels.Channel, ChannelHolder { /** * Default {@link Predicate} used to test if space became available */ @@ -63,7 +60,6 @@ public class Window extends AbstractLoggingBean implements java.nio.channels.Cha private long maxSize; // actually uint32 private long packetSize; // actually uint32 - private Map<String, Object> props = Collections.emptyMap(); public Window(AbstractChannel channel, Object lock, boolean client, boolean local) { this.channelInstance = Objects.requireNonNull(channel, "No channel provided"); @@ -71,16 +67,6 @@ public class Window extends AbstractLoggingBean implements java.nio.channels.Cha this.suffix = (client ? "client" : "server") + "/" + (local ? "local" : "remote"); } - @Override - public Map<String, Object> getProperties() { - return props; - } - - @Override - public PropertyResolver getParentPropertyResolver() { - return getChannel(); - } - @Override // co-variant return public AbstractChannel getChannel() { return channelInstance; @@ -101,16 +87,16 @@ public class Window extends AbstractLoggingBean implements java.nio.channels.Cha } public void init(PropertyResolver resolver) { - init(PropertyResolverUtils.getLongProperty(resolver, FactoryManager.WINDOW_SIZE, FactoryManager.DEFAULT_WINDOW_SIZE), - PropertyResolverUtils.getLongProperty(resolver, FactoryManager.MAX_PACKET_SIZE, FactoryManager.DEFAULT_MAX_PACKET_SIZE), - resolver.getProperties()); + init(resolver.getLongProperty(FactoryManager.WINDOW_SIZE, FactoryManager.DEFAULT_WINDOW_SIZE), + resolver.getLongProperty(FactoryManager.MAX_PACKET_SIZE, FactoryManager.DEFAULT_MAX_PACKET_SIZE), + resolver); } - public void init(long size, long packetSize, Map<String, Object> props) { + public void init(long size, long packetSize, PropertyResolver resolver) { BufferUtils.validateUint32Value(size, "Illegal initial size: %d"); BufferUtils.validateUint32Value(packetSize, "Illegal packet size: %d"); ValidateUtils.checkTrue(packetSize > 0L, "Packet size must be positive: %d", packetSize); - long limitPacketSize = PropertyResolverUtils.getLongProperty(props, FactoryManager.LIMIT_PACKET_SIZE, FactoryManager.DEFAULT_LIMIT_PACKET_SIZE); + long limitPacketSize = resolver.getLongProperty(FactoryManager.LIMIT_PACKET_SIZE, FactoryManager.DEFAULT_LIMIT_PACKET_SIZE); if (packetSize > limitPacketSize) { throw new IllegalArgumentException("Requested packet size (" + packetSize + ") exceeds max. allowed: " + limitPacketSize); } @@ -118,7 +104,6 @@ public class Window extends AbstractLoggingBean implements java.nio.channels.Cha synchronized (lock) { this.maxSize = size; this.packetSize = packetSize; - this.props = (props == null) ? Collections.emptyMap() : props; updateSize(size); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java index 6288d41..34341e8 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java @@ -38,7 +38,6 @@ import org.apache.sshd.client.channel.ClientChannelEvent; import org.apache.sshd.common.Closeable; import org.apache.sshd.common.Factory; import org.apache.sshd.common.FactoryManager; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.RuntimeSshException; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.SshException; @@ -270,7 +269,7 @@ public class DefaultTcpipForwarder buffer.putString(remoteHost); buffer.putInt(remotePort); - long timeout = PropertyResolverUtils.getLongProperty(session, FORWARD_REQUEST_TIMEOUT, DEFAULT_FORWARD_REQUEST_TIMEOUT); + long timeout = session.getLongProperty(FORWARD_REQUEST_TIMEOUT, DEFAULT_FORWARD_REQUEST_TIMEOUT); Buffer result; int port; signalEstablishingExplicitTunnel(local, remote, false); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java index 03adb22..f4d584e 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/helpers/AbstractFactoryManager.java @@ -177,7 +177,7 @@ public abstract class AbstractFactoryManager extends AbstractKexFactoryManager i } public int getNioWorkers() { - int nb = PropertyResolverUtils.getIntProperty(this, NIO_WORKERS, DEFAULT_NIO_WORKERS); + int nb = this.getIntProperty(NIO_WORKERS, DEFAULT_NIO_WORKERS); if (nb > 0) { return nb; } else { // it may have been configured to a negative value http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java index 33cb7ce..5167365 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactory.java @@ -24,7 +24,6 @@ import java.util.concurrent.TimeUnit; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.FactoryManagerHolder; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.closeable.AbstractCloseable; import org.apache.sshd.common.util.threads.ExecutorServiceCarrier; @@ -81,7 +80,7 @@ public abstract class AbstractIoServiceFactory } public static int getNioWorkers(FactoryManager manager) { - int nb = PropertyResolverUtils.getIntProperty(manager, FactoryManager.NIO_WORKERS, FactoryManager.DEFAULT_NIO_WORKERS); + int nb = manager.getIntProperty(FactoryManager.NIO_WORKERS, FactoryManager.DEFAULT_NIO_WORKERS); if (nb > 0) { return nb; } else { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaAcceptor.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaAcceptor.java b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaAcceptor.java index c49315d..5f540e6 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaAcceptor.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaAcceptor.java @@ -31,7 +31,6 @@ import org.apache.mina.core.service.IoService; import org.apache.mina.transport.socket.nio.NioSession; import org.apache.mina.transport.socket.nio.NioSocketAcceptor; import org.apache.sshd.common.FactoryManager; -import org.apache.sshd.common.PropertyResolverUtils; /** * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> @@ -46,8 +45,8 @@ public class MinaAcceptor extends MinaService implements org.apache.sshd.common. public MinaAcceptor(FactoryManager manager, org.apache.sshd.common.io.IoHandler handler, IoProcessor<NioSession> ioProcessor) { super(manager, handler, ioProcessor); - backlog = PropertyResolverUtils.getIntProperty(manager, FactoryManager.SOCKET_BACKLOG, DEFAULT_BACKLOG); - reuseAddress = PropertyResolverUtils.getBooleanProperty(manager, FactoryManager.SOCKET_REUSEADDR, DEFAULT_REUSE_ADDRESS); + backlog = manager.getIntProperty(FactoryManager.SOCKET_BACKLOG, DEFAULT_BACKLOG); + reuseAddress = manager.getBooleanProperty(FactoryManager.SOCKET_REUSEADDR, DEFAULT_REUSE_ADDRESS); } protected IoAcceptor createAcceptor() { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java index 65014fc..2a6ce7d 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java @@ -33,7 +33,6 @@ import org.apache.mina.transport.socket.SocketSessionConfig; import org.apache.mina.transport.socket.nio.NioSession; import org.apache.sshd.common.Closeable; import org.apache.sshd.common.FactoryManager; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.closeable.AbstractCloseable; @@ -185,10 +184,10 @@ public abstract class MinaService extends AbstractCloseable implements org.apach } protected Integer getInteger(String property) { - return PropertyResolverUtils.getInteger(manager, property); + return manager.getInteger(property); } protected Boolean getBoolean(String property) { - return PropertyResolverUtils.getBoolean(manager, property); + return manager.getBoolean(property); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java index 23be6c1..e942e8a 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java @@ -33,7 +33,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.apache.sshd.common.FactoryManager; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.future.CloseFuture; import org.apache.sshd.common.io.IoAcceptor; import org.apache.sshd.common.io.IoHandler; @@ -48,7 +47,7 @@ public class Nio2Acceptor extends Nio2Service implements IoAcceptor { public Nio2Acceptor(FactoryManager manager, IoHandler handler, AsynchronousChannelGroup group) { super(manager, handler, group); - backlog = PropertyResolverUtils.getIntProperty(manager, FactoryManager.SOCKET_BACKLOG, DEFAULT_BACKLOG); + backlog = manager.getIntProperty(FactoryManager.SOCKET_BACKLOG, DEFAULT_BACKLOG); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java index aab42c4..2686415 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java @@ -36,7 +36,6 @@ import org.apache.sshd.common.Closeable; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.FactoryManagerHolder; import org.apache.sshd.common.PropertyResolver; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.io.IoHandler; import org.apache.sshd.common.io.IoService; import org.apache.sshd.common.io.IoSession; @@ -144,7 +143,7 @@ public abstract class Nio2Service extends AbstractInnerCloseable implements IoSe protected <T> boolean setOption(NetworkChannel socket, String property, SocketOption<T> option, T defaultValue) throws IOException { PropertyResolver manager = getFactoryManager(); - String valStr = PropertyResolverUtils.getString(manager, property); + String valStr = manager.getString(property); T val = defaultValue; if (!GenericUtils.isEmpty(valStr)) { Class<T> type = option.type(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java index a007116..32d39b5 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java @@ -33,7 +33,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import org.apache.sshd.common.FactoryManager; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.RuntimeSshException; import org.apache.sshd.common.future.CloseFuture; import org.apache.sshd.common.io.IoHandler; @@ -225,7 +224,7 @@ public class Nio2Session extends AbstractCloseable implements IoSession { } public void startReading() { - startReading(PropertyResolverUtils.getIntProperty(manager, FactoryManager.NIO2_READ_BUFFER_SIZE, DEFAULT_READBUF_SIZE)); + startReading(manager.getIntProperty(FactoryManager.NIO2_READ_BUFFER_SIZE, DEFAULT_READBUF_SIZE)); } public void startReading(int bufSize) { @@ -301,7 +300,7 @@ public class Nio2Session extends AbstractCloseable implements IoSession { protected void doReadCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer, Object> completion) { AsynchronousSocketChannel socket = getSocket(); - long readTimeout = PropertyResolverUtils.getLongProperty(manager, FactoryManager.NIO2_READ_TIMEOUT, FactoryManager.DEFAULT_NIO2_READ_TIMEOUT); + long readTimeout = manager.getLongProperty(FactoryManager.NIO2_READ_TIMEOUT, FactoryManager.DEFAULT_NIO2_READ_TIMEOUT); socket.read(buffer, readTimeout, TimeUnit.MILLISECONDS, null, completion); } @@ -330,7 +329,7 @@ public class Nio2Session extends AbstractCloseable implements IoSession { protected void doWriteCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer, Object> completion) { AsynchronousSocketChannel socket = getSocket(); - long writeTimeout = PropertyResolverUtils.getLongProperty(manager, FactoryManager.NIO2_MIN_WRITE_TIMEOUT, FactoryManager.DEFAULT_NIO2_MIN_WRITE_TIMEOUT); + long writeTimeout = manager.getLongProperty(FactoryManager.NIO2_MIN_WRITE_TIMEOUT, FactoryManager.DEFAULT_NIO2_MIN_WRITE_TIMEOUT); socket.write(buffer, writeTimeout, TimeUnit.MILLISECONDS, null, completion); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java ---------------------------------------------------------------------- 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 eff3b5d..e3c8ecc 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 @@ -38,7 +38,6 @@ import org.apache.sshd.client.channel.AbstractClientChannel; import org.apache.sshd.common.Closeable; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.SshException; import org.apache.sshd.common.channel.AbstractChannel; @@ -265,7 +264,7 @@ public abstract class AbstractConnectionService<S extends AbstractSession> @Override public int registerChannel(Channel channel) throws IOException { Session session = getSession(); - int maxChannels = PropertyResolverUtils.getIntProperty(session, MAX_CONCURRENT_CHANNELS_PROP, DEFAULT_MAX_CHANNELS); + int maxChannels = session.getIntProperty(MAX_CONCURRENT_CHANNELS_PROP, DEFAULT_MAX_CHANNELS); int curSize = channels.size(); if (curSize > maxChannels) { throw new IllegalStateException("Currently active channels (" + curSize + ") at max.: " + maxChannels); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/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 0215d2b..eccb87f 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 @@ -467,14 +467,14 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen protected void refreshConfiguration() { synchronized (random) { // re-keying configuration - maxRekeyBytes = PropertyResolverUtils.getLongProperty(this, FactoryManager.REKEY_BYTES_LIMIT, maxRekeyBytes); - maxRekeyInterval = PropertyResolverUtils.getLongProperty(this, FactoryManager.REKEY_TIME_LIMIT, maxRekeyInterval); - maxRekyPackets = PropertyResolverUtils.getLongProperty(this, FactoryManager.REKEY_PACKETS_LIMIT, maxRekyPackets); + maxRekeyBytes = this.getLongProperty(FactoryManager.REKEY_BYTES_LIMIT, maxRekeyBytes); + maxRekeyInterval = this.getLongProperty(FactoryManager.REKEY_TIME_LIMIT, maxRekeyInterval); + maxRekyPackets = this.getLongProperty(FactoryManager.REKEY_PACKETS_LIMIT, maxRekyPackets); // intermittent SSH_MSG_IGNORE stream padding - ignorePacketDataLength = PropertyResolverUtils.getIntProperty(this, FactoryManager.IGNORE_MESSAGE_SIZE, FactoryManager.DEFAULT_IGNORE_MESSAGE_SIZE); - ignorePacketsFrequency = PropertyResolverUtils.getLongProperty(this, FactoryManager.IGNORE_MESSAGE_FREQUENCY, FactoryManager.DEFAULT_IGNORE_MESSAGE_FREQUENCY); - ignorePacketsVariance = PropertyResolverUtils.getIntProperty(this, FactoryManager.IGNORE_MESSAGE_VARIANCE, FactoryManager.DEFAULT_IGNORE_MESSAGE_VARIANCE); + ignorePacketDataLength = this.getIntProperty(FactoryManager.IGNORE_MESSAGE_SIZE, FactoryManager.DEFAULT_IGNORE_MESSAGE_SIZE); + ignorePacketsFrequency = this.getLongProperty(FactoryManager.IGNORE_MESSAGE_FREQUENCY, FactoryManager.DEFAULT_IGNORE_MESSAGE_FREQUENCY); + ignorePacketsVariance = this.getIntProperty(FactoryManager.IGNORE_MESSAGE_VARIANCE, FactoryManager.DEFAULT_IGNORE_MESSAGE_VARIANCE); if (ignorePacketsVariance >= ignorePacketsFrequency) { ignorePacketsVariance = 0; } @@ -1436,7 +1436,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen */ protected String resolveIdentificationString(String configPropName) { FactoryManager manager = getFactoryManager(); - String ident = PropertyResolverUtils.getString(manager, configPropName); + String ident = manager.getString(configPropName); return DEFAULT_SSH_VERSION_PREFIX + (GenericUtils.isEmpty(ident) ? manager.getVersion() : ident); } @@ -1814,7 +1814,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen // select the lowest cipher size int avgCipherBlockSize = Math.min(inBlockSize, outBlockSize); long recommendedByteRekeyBlocks = 1L << Math.min((avgCipherBlockSize * Byte.SIZE) / 4, 63); // in case (block-size / 4) > 63 - maxRekeyBlocks.set(PropertyResolverUtils.getLongProperty(this, FactoryManager.REKEY_BLOCKS_LIMIT, recommendedByteRekeyBlocks)); + maxRekeyBlocks.set(this.getLongProperty(FactoryManager.REKEY_BLOCKS_LIMIT, recommendedByteRekeyBlocks)); if (log.isDebugEnabled()) { log.debug("receiveNewKeys({}) inCipher={}, outCipher={}, recommended blocks limit={}, actual={}", this, inCipher, outCipher, recommendedByteRekeyBlocks, maxRekeyBlocks); @@ -1871,7 +1871,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen // Write the packet with a timeout to ensure a timely close of the session // in case the consumer does not read packets anymore. - long disconnectTimeoutMs = PropertyResolverUtils.getLongProperty(this, FactoryManager.DISCONNECT_TIMEOUT, FactoryManager.DEFAULT_DISCONNECT_TIMEOUT); + long disconnectTimeoutMs = this.getLongProperty(FactoryManager.DISCONNECT_TIMEOUT, FactoryManager.DEFAULT_DISCONNECT_TIMEOUT); writePacket(buffer, disconnectTimeoutMs, TimeUnit.MILLISECONDS).addListener(future -> { Throwable t = future.getException(); if (log.isDebugEnabled()) { @@ -2631,12 +2631,12 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen @Override public long getAuthTimeout() { - return PropertyResolverUtils.getLongProperty(this, FactoryManager.AUTH_TIMEOUT, FactoryManager.DEFAULT_AUTH_TIMEOUT); + return this.getLongProperty(FactoryManager.AUTH_TIMEOUT, FactoryManager.DEFAULT_AUTH_TIMEOUT); } @Override public long getIdleTimeout() { - return PropertyResolverUtils.getLongProperty(this, FactoryManager.IDLE_TIMEOUT, FactoryManager.DEFAULT_IDLE_TIMEOUT); + return this.getLongProperty(FactoryManager.IDLE_TIMEOUT, FactoryManager.DEFAULT_IDLE_TIMEOUT); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java index 8023c1b..5b8b143 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java @@ -51,7 +51,6 @@ import java.util.TreeMap; import java.util.concurrent.TimeUnit; import org.apache.sshd.common.PropertyResolver; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.OsUtils; import org.apache.sshd.common.util.ValidateUtils; @@ -141,7 +140,7 @@ public final class SftpHelper { return null; } - if (!PropertyResolverUtils.getBooleanProperty(resolver, APPEND_END_OF_LIST_INDICATOR, DEFAULT_APPEND_END_OF_LIST_INDICATOR)) { + if (!resolver.getBooleanProperty(APPEND_END_OF_LIST_INDICATOR, DEFAULT_APPEND_END_OF_LIST_INDICATOR)) { return null; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java index e04da4d..8b111ca 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java @@ -26,7 +26,6 @@ import java.util.function.IntUnaryOperator; import java.util.logging.Level; import org.apache.sshd.common.PropertyResolver; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.NumberUtils; import org.apache.sshd.common.util.ValidateUtils; @@ -71,7 +70,7 @@ public final class BufferUtils { } public static void dumpHex(SimplifiedLog logger, Level level, String prefix, PropertyResolver resolver, char sep, byte[] data, int offset, int len) { - dumpHex(logger, level, prefix, sep, PropertyResolverUtils.getIntProperty(resolver, HEXDUMP_CHUNK_SIZE, DEFAULT_HEXDUMP_CHUNK_SIZE), data, offset, len); + dumpHex(logger, level, prefix, sep, resolver.getIntProperty(HEXDUMP_CHUNK_SIZE, DEFAULT_HEXDUMP_CHUNK_SIZE), data, offset, len); } public static void dumpHex(SimplifiedLog logger, Level level, String prefix, char sep, int chunkSize, byte... data) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/util/io/LoggingFilterOutputStream.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/io/LoggingFilterOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/util/io/LoggingFilterOutputStream.java index 1b46f13..ff4dbb6 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/util/io/LoggingFilterOutputStream.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/util/io/LoggingFilterOutputStream.java @@ -24,7 +24,6 @@ import java.io.OutputStream; import java.util.concurrent.atomic.AtomicInteger; import org.apache.sshd.common.PropertyResolver; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.buffer.BufferUtils; import org.apache.sshd.common.util.logging.LoggingUtils; import org.apache.sshd.common.util.logging.SimplifiedLog; @@ -42,7 +41,7 @@ public class LoggingFilterOutputStream extends FilterOutputStream { private final AtomicInteger writeCount = new AtomicInteger(0); public LoggingFilterOutputStream(OutputStream out, String msg, Logger log, PropertyResolver resolver) { - this(out, msg, log, PropertyResolverUtils.getIntProperty(resolver, BufferUtils.HEXDUMP_CHUNK_SIZE, BufferUtils.DEFAULT_HEXDUMP_CHUNK_SIZE)); + this(out, msg, log, resolver.getIntProperty(BufferUtils.HEXDUMP_CHUNK_SIZE, BufferUtils.DEFAULT_HEXDUMP_CHUNK_SIZE)); } public LoggingFilterOutputStream(OutputStream out, String msg, Logger log, int chunkSize) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java b/sshd-core/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java index 2254f86..31e428b 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java @@ -106,7 +106,7 @@ public interface SecurityProviderRegistrar extends SecurityProviderChoice, Optio return false; } - return PropertyResolverUtils.getBooleanProperty(this, getConfigurationPropertyName(ENABLED_PROPERTY), true); + return this.getBooleanProperty(getConfigurationPropertyName(ENABLED_PROPERTY), true); } @Override @@ -258,7 +258,7 @@ public interface SecurityProviderRegistrar extends SecurityProviderChoice, Optio return false; } - String propValue = PropertyResolverUtils.getString(resolver, propName); + String propValue = resolver.getString(propName); if (GenericUtils.isEmpty(propValue)) { propValue = defaultValue; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java b/sshd-core/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java index a04e217..b47ca80 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleSecurityProviderRegistrar.java @@ -25,7 +25,6 @@ import java.security.Signature; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ReflectionUtils; import org.apache.sshd.common.util.security.AbstractSecurityProviderRegistrar; @@ -53,7 +52,7 @@ public class BouncyCastleSecurityProviderRegistrar extends AbstractSecurityProvi } // For backward compatibility - return PropertyResolverUtils.getBooleanProperty(this, SecurityUtils.REGISTER_BOUNCY_CASTLE_PROP, true); + return this.getBooleanProperty(SecurityUtils.REGISTER_BOUNCY_CASTLE_PROP, true); } @Override @@ -80,7 +79,7 @@ public class BouncyCastleSecurityProviderRegistrar extends AbstractSecurityProvi } String propName = getConfigurationPropertyName("supportAll"); - allValue = PropertyResolverUtils.getStringProperty(this, propName, ALL_OPTIONS_VALUE); + allValue = this.getStringProperty(propName, ALL_OPTIONS_VALUE); if (GenericUtils.isEmpty(allValue)) { allValue = NO_OPTIONS_VALUE; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java b/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java index 2bb3f95..61f16e9 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/util/security/eddsa/EdDSASecurityProviderRegistrar.java @@ -25,7 +25,6 @@ import java.security.Signature; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ReflectionUtils; import org.apache.sshd.common.util.security.AbstractSecurityProviderRegistrar; @@ -51,7 +50,7 @@ public class EdDSASecurityProviderRegistrar extends AbstractSecurityProviderRegi } // For backward compatibility - return PropertyResolverUtils.getBooleanProperty(this, SecurityUtils.EDDSA_SUPPORTED_PROP, true); + return this.getBooleanProperty(SecurityUtils.EDDSA_SUPPORTED_PROP, true); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java index 7fc8004..c9f348e 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java @@ -339,7 +339,7 @@ public class SshServer extends AbstractFactoryManager implements ServerFactoryMa } public void stop(boolean immediately) throws IOException { - long maxWait = immediately ? PropertyResolverUtils.getLongProperty(this, STOP_WAIT_TIME, DEFAULT_STOP_WAIT_TIME) : Long.MAX_VALUE; + long maxWait = immediately ? this.getLongProperty(STOP_WAIT_TIME, DEFAULT_STOP_WAIT_TIME) : Long.MAX_VALUE; boolean successful = close(immediately).await(maxWait); if (!successful) { throw new SocketTimeoutException("Failed to receive closure confirmation within " + maxWait + " millis"); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/DefaultKeyboardInteractiveAuthenticator.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/DefaultKeyboardInteractiveAuthenticator.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/DefaultKeyboardInteractiveAuthenticator.java index 2423124..32bfeac 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/DefaultKeyboardInteractiveAuthenticator.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/keyboard/DefaultKeyboardInteractiveAuthenticator.java @@ -21,7 +21,6 @@ package org.apache.sshd.server.auth.keyboard; import java.util.List; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.RuntimeSshException; import org.apache.sshd.common.SshException; import org.apache.sshd.common.util.GenericUtils; @@ -103,22 +102,22 @@ public class DefaultKeyboardInteractiveAuthenticator } protected String getInteractionName(ServerSession session) { - return PropertyResolverUtils.getStringProperty(session, KB_INTERACTIVE_NAME_PROP, DEFAULT_KB_INTERACTIVE_NAME); + return session.getStringProperty(KB_INTERACTIVE_NAME_PROP, DEFAULT_KB_INTERACTIVE_NAME); } protected String getInteractionInstruction(ServerSession session) { - return PropertyResolverUtils.getStringProperty(session, KB_INTERACTIVE_INSTRUCTION_PROP, DEFAULT_KB_INTERACTIVE_INSTRUCTION); + return session.getStringProperty(KB_INTERACTIVE_INSTRUCTION_PROP, DEFAULT_KB_INTERACTIVE_INSTRUCTION); } protected String getInteractionLanguage(ServerSession session) { - return PropertyResolverUtils.getStringProperty(session, KB_INTERACTIVE_LANG_PROP, DEFAULT_KB_INTERACTIVE_LANG); + return session.getStringProperty(KB_INTERACTIVE_LANG_PROP, DEFAULT_KB_INTERACTIVE_LANG); } protected String getInteractionPrompt(ServerSession session) { - return PropertyResolverUtils.getStringProperty(session, KB_INTERACTIVE_PROMPT_PROP, DEFAULT_KB_INTERACTIVE_PROMPT); + return session.getStringProperty(KB_INTERACTIVE_PROMPT_PROP, DEFAULT_KB_INTERACTIVE_PROMPT); } protected boolean isInteractionPromptEchoEnabled(ServerSession session) { - return PropertyResolverUtils.getBooleanProperty(session, KB_INTERACTIVE_ECHO_PROMPT_PROP, DEFAULT_KB_INTERACTIVE_ECHO_PROMPT); + return session.getBooleanProperty(KB_INTERACTIVE_ECHO_PROMPT_PROP, DEFAULT_KB_INTERACTIVE_ECHO_PROMPT); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java ---------------------------------------------------------------------- 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 bd8e083..c976c3b 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 @@ -70,7 +70,7 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S Session s = getSession(); FactoryManager manager = Objects.requireNonNull(s.getFactoryManager(), "No factory manager"); Window wRemote = getRemoteWindow(); - wRemote.init(rwSize, packetSize, manager.getProperties()); + wRemote.init(rwSize, packetSize, manager); configureWindow(); return doInit(buffer); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java ---------------------------------------------------------------------- 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 f107165..d6fed30 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 @@ -31,7 +31,6 @@ import java.util.Objects; import org.apache.sshd.common.Factory; import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.SshException; import org.apache.sshd.common.kex.DHFactory; @@ -274,7 +273,7 @@ public class DHGEXServer extends AbstractDHServerKeyExchange { protected List<Moduli.DhGroup> loadModuliGroups() throws IOException { ServerSession session = getServerSession(); - String moduliStr = PropertyResolverUtils.getString(session, ServerFactoryManager.MODULI_URL); + String moduliStr = session.getString(ServerFactoryManager.MODULI_URL); List<Moduli.DhGroup> groups = null; URL moduli; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d6bb25d6/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java index 8ff2810..dbe3019 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java @@ -18,7 +18,6 @@ */ package org.apache.sshd.server.session; -import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.io.IoSession; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.server.ServerFactoryManager; @@ -33,7 +32,7 @@ public class ServerSessionImpl extends AbstractServerSession { super(server, ioSession); signalSessionCreated(ioSession); - String headerConfig = PropertyResolverUtils.getString(this, ServerFactoryManager.SERVER_EXTRA_IDENTIFICATION_LINES); + String headerConfig = this.getString(ServerFactoryManager.SERVER_EXTRA_IDENTIFICATION_LINES); String[] headers = GenericUtils.split(headerConfig, ServerFactoryManager.SERVER_EXTRA_IDENT_LINES_SEPARATOR); sendServerIdentification(headers); }