[SSHD-698] Using Objects.requireNonNull instead of ValidateUtils.checkNotNull here applicable
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/f56963c4 Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/f56963c4 Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/f56963c4 Branch: refs/heads/master Commit: f56963c443b0a50e7889dc283ca92e7b180041d6 Parents: 439b71f Author: Lyor Goldstein <[email protected]> Authored: Mon Oct 3 09:11:09 2016 +0300 Committer: Lyor Goldstein <[email protected]> Committed: Mon Oct 3 09:11:09 2016 +0300 ---------------------------------------------------------------------- .../common/DefaultAgentForwardSupport.java | 10 +++--- .../org/apache/sshd/agent/local/AgentImpl.java | 5 +-- .../sshd/agent/local/AgentServerProxy.java | 4 +-- .../agent/local/ChannelAgentForwarding.java | 5 +-- .../sshd/agent/unix/UnixAgentFactory.java | 3 +- .../java/org/apache/sshd/client/SshClient.java | 34 +++++++++---------- .../java/org/apache/sshd/client/SshKeyScan.java | 2 +- .../sshd/client/auth/AbstractUserAuth.java | 4 ++- .../auth/pubkey/AbstractKeyPairIterator.java | 5 +-- .../client/auth/pubkey/KeyAgentIdentity.java | 6 ++-- .../client/auth/pubkey/KeyPairIdentity.java | 3 +- .../auth/pubkey/SshAgentPublicKeyIterator.java | 4 +-- .../auth/pubkey/UserAuthPublicKeyIterator.java | 6 ++-- .../client/channel/AbstractClientChannel.java | 5 +-- .../exit/AbstractChannelExitRequestHandler.java | 6 ++-- .../hosts/ConfigFileHostEntryResolver.java | 6 ++-- .../DefaultConfigFileHostEntryResolver.java | 4 +-- .../client/config/hosts/HostConfigEntry.java | 11 +++--- .../client/config/hosts/KnownHostDigest.java | 3 +- .../keys/BuiltinClientIdentitiesWatcher.java | 8 ++--- .../config/keys/ClientIdentitiesWatcher.java | 10 +++--- .../config/keys/ClientIdentityFileWatcher.java | 14 ++++---- .../keys/DefaultClientIdentitiesWatcher.java | 6 ++-- .../sshd/client/future/DefaultAuthFuture.java | 4 +-- .../client/future/DefaultConnectFuture.java | 5 ++- .../org/apache/sshd/client/kex/DHGClient.java | 4 ++- .../org/apache/sshd/client/kex/DHGEXClient.java | 3 +- .../DefaultKnownHostsServerKeyVerifier.java | 4 +-- .../KnownHostsServerKeyVerifier.java | 13 ++++---- .../sshd/client/scp/DefaultScpClient.java | 3 +- .../client/session/AbstractClientSession.java | 15 +++++---- .../sshd/client/session/ClientSessionImpl.java | 3 +- .../client/session/ClientUserAuthService.java | 5 +-- .../client/simple/AbstractSimpleClient.java | 7 ++-- .../AbstractSimpleClientSessionCreator.java | 5 +-- .../sshd/client/simple/SimpleSessionClient.java | 5 +-- .../sshd/client/simple/SimpleSftpClient.java | 5 +-- .../subsystem/sftp/AbstractSftpClient.java | 19 ++++++----- .../sftp/AbstractSftpFileAttributeView.java | 6 ++-- .../subsystem/sftp/DefaultSftpClient.java | 3 +- .../sshd/client/subsystem/sftp/SftpClient.java | 11 +++--- .../sshd/client/subsystem/sftp/SftpCommand.java | 2 +- .../client/subsystem/sftp/SftpFileSystem.java | 5 ++- .../subsystem/sftp/SftpFileSystemProvider.java | 2 +- .../sftp/SftpInputStreamWithChannel.java | 4 +-- .../sftp/SftpOutputStreamWithChannel.java | 4 +-- .../helpers/AbstractSftpClientExtension.java | 5 +-- .../org/apache/sshd/common/AttributeStore.java | 35 +++----------------- .../java/org/apache/sshd/common/Closeable.java | 2 ++ .../org/apache/sshd/common/SshException.java | 4 +-- .../sshd/common/channel/AbstractChannel.java | 8 ++--- .../common/channel/ChannelAsyncInputStream.java | 6 ++-- .../channel/ChannelAsyncOutputStream.java | 4 +-- .../common/channel/ChannelOutputStream.java | 7 ++-- .../common/channel/ChannelPipedInputStream.java | 4 +-- .../sshd/common/channel/IoWriteFutureImpl.java | 5 +-- .../org/apache/sshd/common/channel/Window.java | 7 ++-- .../sshd/common/cipher/BuiltinCiphers.java | 3 +- .../org/apache/sshd/common/cipher/ECCurves.java | 9 ++--- .../common/compression/BuiltinCompressions.java | 3 +- .../sshd/common/config/SshConfigFileReader.java | 25 +++++++------- .../keys/AbstractPublicKeyEntryDecoder.java | 6 ++-- .../config/keys/DSSPublicKeyEntryDecoder.java | 6 ++-- .../config/keys/ECDSAPublicKeyEntryDecoder.java | 8 ++--- .../sshd/common/config/keys/KeyUtils.java | 10 +++--- .../common/config/keys/RSAPublicKeyDecoder.java | 4 +-- .../apache/sshd/common/digest/BaseDigest.java | 4 +-- .../apache/sshd/common/digest/DigestUtils.java | 7 ++-- .../sshd/common/file/root/RootedFileSystem.java | 4 +-- .../file/root/RootedFileSystemProvider.java | 5 +-- .../sshd/common/file/util/BaseFileSystem.java | 8 ++--- .../apache/sshd/common/file/util/BasePath.java | 7 ++-- .../virtualfs/VirtualFileSystemFactory.java | 3 +- .../common/forward/DefaultTcpipForwarder.java | 24 +++++++------- .../sshd/common/future/DefaultSshFuture.java | 5 +-- .../global/AbstractOpenSshHostKeysHandler.java | 3 +- .../common/helpers/AbstractFactoryManager.java | 11 +++--- .../apache/sshd/common/io/mina/MinaSession.java | 4 +-- .../sshd/common/io/nio2/Nio2Acceptor.java | 3 +- .../io/nio2/Nio2DefaultIoWriteFuture.java | 4 +-- .../apache/sshd/common/io/nio2/Nio2Service.java | 8 ++--- .../io/nio2/Nio2ServiceFactoryFactory.java | 4 +-- .../apache/sshd/common/io/nio2/Nio2Session.java | 14 ++++---- .../sshd/common/kex/BuiltinDHFactories.java | 3 +- .../java/org/apache/sshd/common/kex/ECDH.java | 13 ++++---- .../org/apache/sshd/common/mac/BuiltinMacs.java | 3 +- .../common/random/SingletonRandomFactory.java | 7 ++-- .../apache/sshd/common/scp/ScpException.java | 7 ++-- .../org/apache/sshd/common/scp/ScpHelper.java | 20 +++++------ .../org/apache/sshd/common/scp/ScpLocation.java | 2 +- .../LocalFileScpSourceStreamResolver.java | 4 +-- .../sshd/common/session/SessionWorkBuffer.java | 5 +-- .../helpers/AbstractConnectionService.java | 10 +++--- .../common/session/helpers/AbstractSession.java | 12 +++---- .../session/helpers/AbstractSessionFactory.java | 5 +-- .../session/helpers/PendingWriteFuture.java | 7 ++-- .../common/signature/AbstractSignature.java | 13 ++++---- .../common/signature/BuiltinSignatures.java | 3 +- .../sshd/common/signature/SignatureDSA.java | 3 +- .../sshd/common/signature/SignatureECDSA.java | 3 +- .../sshd/common/signature/SignatureRSA.java | 3 +- .../sshd/common/subsystem/sftp/SftpHelper.java | 8 ++--- .../subsystem/sftp/extensions/ParserUtils.java | 4 +-- .../sshd/common/util/EventListenerUtils.java | 4 +-- .../apache/sshd/common/util/GenericUtils.java | 18 +++------- .../apache/sshd/common/util/SelectorUtils.java | 4 +-- .../apache/sshd/common/util/buffer/Buffer.java | 4 +-- .../keys/AbstractBufferPublicKeyParser.java | 3 +- .../util/closeable/AbstractInnerCloseable.java | 1 - .../sshd/common/util/closeable/Builder.java | 5 ++- .../apache/sshd/common/util/io/DERWriter.java | 5 +-- .../common/util/io/ModifiableFileWatcher.java | 5 ++- .../sshd/common/util/net/SshdSocketAddress.java | 2 +- .../java/org/apache/sshd/server/SshServer.java | 4 +-- .../apache/sshd/server/StandardEnvironment.java | 5 +-- .../sshd/server/auth/AbstractUserAuth.java | 4 ++- .../sshd/server/auth/gss/UserAuthGSS.java | 4 ++- .../auth/keyboard/InteractiveChallenge.java | 4 +-- .../pubkey/CachingPublicKeyAuthenticator.java | 4 +-- .../server/channel/AbstractServerChannel.java | 4 +-- .../sshd/server/channel/ChannelSession.java | 20 +++++------ .../keys/AuthorizedKeysAuthenticator.java | 6 ++-- .../DefaultAuthorizedKeysAuthenticator.java | 5 +-- .../sshd/server/forward/TcpipServerChannel.java | 5 +-- .../global/CancelTcpipForwardHandler.java | 5 +-- .../server/global/OpenSshHostKeysHandler.java | 3 +- .../sshd/server/global/TcpipForwardHandler.java | 5 +-- .../server/kex/AbstractDHServerKeyExchange.java | 4 +-- .../org/apache/sshd/server/kex/DHGEXServer.java | 11 +++--- .../org/apache/sshd/server/kex/DHGServer.java | 5 +-- .../apache/sshd/server/scp/UnknownCommand.java | 2 +- .../server/session/AbstractServerSession.java | 2 +- .../server/session/ServerUserAuthService.java | 3 +- .../sshd/server/shell/InvertedShellWrapper.java | 3 +- .../apache/sshd/server/shell/ProcessShell.java | 3 +- .../server/shell/TtyFilterOutputStream.java | 4 +-- .../sftp/AbstractSftpEventListenerManager.java | 4 +-- .../server/subsystem/sftp/SftpSubsystem.java | 16 ++++----- .../server/x11/DefaultX11ForwardSupport.java | 10 +++--- .../client/simple/SimpleSessionClientTest.java | 4 +-- .../sshd/client/subsystem/sftp/SftpTest.java | 5 ++- .../sshd/common/PropertyResolverUtilsTest.java | 4 +-- .../sshd/common/auth/AuthenticationTest.java | 3 +- .../config/keys/AuthorizedKeysTestSupport.java | 4 +-- .../file/root/RootedFileSystemProviderTest.java | 16 +++++---- .../sshd/common/forward/PortForwardingTest.java | 5 +-- .../apache/sshd/common/mac/MacVectorsTest.java | 3 +- .../sshd/deprecated/AbstractUserAuth.java | 5 +-- .../apache/sshd/deprecated/UserAuthAgent.java | 2 +- .../sshd/deprecated/UserAuthPublicKey.java | 2 +- .../server/shell/TtyFilterInputStreamTest.java | 4 +-- .../server/shell/TtyFilterOutputStreamTest.java | 4 +-- .../server/subsystem/sftp/SshFsMounter.java | 3 +- .../apache/sshd/util/test/BaseTestSupport.java | 6 ++-- .../java/org/apache/sshd/util/test/Utils.java | 21 ++++++------ .../git/transport/GitSshdSessionProcess.java | 4 +-- .../common/util/net/LdapNetworkConnector.java | 10 +++--- .../auth/pubkey/LdapPublickeyAuthenticator.java | 2 +- .../sshd/server/auth/BaseAuthenticatorTest.java | 7 ++-- .../pubkey/LdapPublickeyAuthenticatorTest.java | 4 +-- 160 files changed, 533 insertions(+), 496 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java b/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java index fbbdbcc..9af4a84 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/common/DefaultAgentForwardSupport.java @@ -20,6 +20,7 @@ package org.apache.sshd.agent.common; import java.io.IOException; +import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import org.apache.sshd.agent.SshAgentFactory; @@ -28,7 +29,6 @@ import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.SshException; import org.apache.sshd.common.session.ConnectionService; import org.apache.sshd.common.session.Session; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.closeable.AbstractCloseable; /** @@ -40,7 +40,7 @@ public class DefaultAgentForwardSupport extends AbstractCloseable implements Age private final AtomicReference<SshAgentServer> agentServerHolder = new AtomicReference<>(); public DefaultAgentForwardSupport(ConnectionService service) { - serviceInstance = ValidateUtils.checkNotNull(service, "No connection service"); + serviceInstance = Objects.requireNonNull(service, "No connection service"); } @Override @@ -54,7 +54,7 @@ public class DefaultAgentForwardSupport extends AbstractCloseable implements Age return agentServer.getId(); } - agentServer = ValidateUtils.checkNotNull(createSshAgentServer(serviceInstance, session), "No agent server created"); + agentServer = Objects.requireNonNull(createSshAgentServer(serviceInstance, session), "No agent server created"); agentServerHolder.set(agentServer); } @@ -81,8 +81,8 @@ public class DefaultAgentForwardSupport extends AbstractCloseable implements Age } protected SshAgentServer createSshAgentServer(ConnectionService service, Session session) throws Throwable { - FactoryManager manager = ValidateUtils.checkNotNull(session.getFactoryManager(), "No session factory manager"); - SshAgentFactory factory = ValidateUtils.checkNotNull(manager.getAgentFactory(), "No agent factory"); + FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No session factory manager"); + SshAgentFactory factory = Objects.requireNonNull(manager.getAgentFactory(), "No agent factory"); return factory.createServer(service); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java index 6f7525f..42133a7 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/AgentImpl.java @@ -27,6 +27,7 @@ import java.security.interfaces.RSAPublicKey; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.sshd.agent.SshAgent; @@ -71,7 +72,7 @@ public class AgentImpl implements SshAgent { } try { - Pair<KeyPair, String> pp = ValidateUtils.checkNotNull(getKeyPair(keys, key), "Key not found"); + Pair<KeyPair, String> pp = Objects.requireNonNull(getKeyPair(keys, key), "Key not found"); KeyPair kp = ValidateUtils.checkNotNull(pp.getFirst(), "No key pair for agent=%s", pp.getSecond()); PublicKey pubKey = ValidateUtils.checkNotNull(kp.getPublic(), "No public key for agent=%s", pp.getSecond()); @@ -101,7 +102,7 @@ public class AgentImpl implements SshAgent { if (!isOpen()) { throw new SshException("Agent closed"); } - keys.add(new Pair<>(ValidateUtils.checkNotNull(key, "No key"), comment)); + keys.add(new Pair<>(Objects.requireNonNull(key, "No key"), comment)); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 967fc5a..90e6b9d 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 @@ -19,6 +19,7 @@ package org.apache.sshd.agent.local; import java.io.IOException; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; @@ -27,7 +28,6 @@ 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.ValidateUtils; import org.apache.sshd.common.util.logging.AbstractLoggingBean; /** @@ -39,7 +39,7 @@ public class AgentServerProxy extends AbstractLoggingBean implements SshAgentSer private final AtomicBoolean open = new AtomicBoolean(true); public AgentServerProxy(ConnectionService service) throws IOException { - this.service = ValidateUtils.checkNotNull(service, "No connection service provided"); + this.service = Objects.requireNonNull(service, "No connection service provided"); this.id = UUID.randomUUID().toString(); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java index 66844af..d053a31 100644 --- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java +++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java @@ -20,6 +20,7 @@ package org.apache.sshd.agent.local; import java.io.IOException; import java.io.OutputStream; +import java.util.Objects; import org.apache.sshd.agent.SshAgent; import org.apache.sshd.agent.SshAgentFactory; @@ -58,8 +59,8 @@ public class ChannelAgentForwarding extends AbstractServerChannel { out = new ChannelOutputStream(this, getRemoteWindow(), log, SshConstants.SSH_MSG_CHANNEL_DATA, true); Session session = getSession(); - FactoryManager manager = ValidateUtils.checkNotNull(session.getFactoryManager(), "No factory manager"); - SshAgentFactory factory = ValidateUtils.checkNotNull(manager.getAgentFactory(), "No agent factory"); + FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No factory manager"); + SshAgentFactory factory = Objects.requireNonNull(manager.getAgentFactory(), "No agent factory"); agent = factory.createClient(manager); client = new AgentClient(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 d838d32..97a168f 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 @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.concurrent.ExecutorService; import org.apache.sshd.agent.SshAgent; @@ -119,7 +120,7 @@ public class UnixAgentFactory implements SshAgentFactory, ExecutorServiceConfigu @Override public SshAgentServer createServer(ConnectionService service) throws IOException { - Session session = ValidateUtils.checkNotNull(service.getSession(), "No session"); + Session session = Objects.requireNonNull(service.getSession(), "No session"); ValidateUtils.checkTrue(session instanceof ServerSession, "The session used to create an agent server proxy must be a server session"); return new AgentServerProxy(service, getExecutorService(), isShutdownOnExit()); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 f5df111..7ae4a8f 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 @@ -251,7 +251,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa @Override public void setServerKeyVerifier(ServerKeyVerifier serverKeyVerifier) { - this.serverKeyVerifier = ValidateUtils.checkNotNull(serverKeyVerifier, "No server key verifier"); + this.serverKeyVerifier = Objects.requireNonNull(serverKeyVerifier, "No server key verifier"); } @Override @@ -261,7 +261,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa @Override public void setHostConfigEntryResolver(HostConfigEntryResolver resolver) { - this.hostConfigEntryResolver = ValidateUtils.checkNotNull(resolver, "No host configuration entry resolver"); + this.hostConfigEntryResolver = Objects.requireNonNull(resolver, "No host configuration entry resolver"); } @Override @@ -271,7 +271,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa @Override public void setFilePasswordProvider(FilePasswordProvider provider) { - this.filePasswordProvider = ValidateUtils.checkNotNull(provider, "No file password provider"); + this.filePasswordProvider = Objects.requireNonNull(provider, "No file password provider"); } @Override @@ -281,7 +281,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa @Override public void setClientIdentityLoader(ClientIdentityLoader loader) { - this.clientIdentityLoader = ValidateUtils.checkNotNull(loader, "No client identity loader"); + this.clientIdentityLoader = Objects.requireNonNull(loader, "No client identity loader"); } @Override @@ -344,9 +344,9 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa @Override public void addPublicKeyIdentity(KeyPair kp) { - ValidateUtils.checkNotNull(kp, "No key-pair to add"); - ValidateUtils.checkNotNull(kp.getPublic(), "No public key"); - ValidateUtils.checkNotNull(kp.getPrivate(), "No private key"); + Objects.requireNonNull(kp, "No key-pair to add"); + Objects.requireNonNull(kp.getPublic(), "No public key"); + Objects.requireNonNull(kp.getPrivate(), "No private key"); identities.add(kp); @@ -374,11 +374,11 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa protected void checkConfig() { super.checkConfig(); - ValidateUtils.checkNotNull(getTcpipForwarderFactory(), "TcpipForwarderFactory not set"); - ValidateUtils.checkNotNull(getServerKeyVerifier(), "ServerKeyVerifier not set"); - ValidateUtils.checkNotNull(getHostConfigEntryResolver(), "HostConfigEntryResolver not set"); - ValidateUtils.checkNotNull(getClientIdentityLoader(), "ClientIdentityLoader not set"); - ValidateUtils.checkNotNull(getFilePasswordProvider(), "FilePasswordProvider not set"); + Objects.requireNonNull(getTcpipForwarderFactory(), "TcpipForwarderFactory not set"); + Objects.requireNonNull(getServerKeyVerifier(), "ServerKeyVerifier not set"); + Objects.requireNonNull(getHostConfigEntryResolver(), "HostConfigEntryResolver not set"); + Objects.requireNonNull(getClientIdentityLoader(), "ClientIdentityLoader not set"); + Objects.requireNonNull(getFilePasswordProvider(), "FilePasswordProvider not set"); // if no client identities override use the default KeyPairProvider defaultIdentities = getKeyPairProvider(); @@ -488,7 +488,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa @Override public ConnectFuture connect(String username, SocketAddress address) throws IOException { - ValidateUtils.checkNotNull(address, "No target address"); + Objects.requireNonNull(address, "No target address"); if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; String host = ValidateUtils.checkNotNullAndNotEmpty(inetAddress.getHostString(), "No host"); @@ -520,7 +520,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa @Override public ConnectFuture connect(HostConfigEntry hostConfig) throws IOException { - ValidateUtils.checkNotNull(hostConfig, "No host configuration"); + Objects.requireNonNull(hostConfig, "No host configuration"); String host = ValidateUtils.checkNotNullAndNotEmpty(hostConfig.getHostName(), "No target host"); int port = hostConfig.getPort(); ValidateUtils.checkTrue(port > 0, "Invalid port: %d", port); @@ -536,8 +536,8 @@ 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); - ClientIdentityLoader loader = ValidateUtils.checkNotNull(getClientIdentityLoader(), "No ClientIdentityLoader"); - FilePasswordProvider provider = ValidateUtils.checkNotNull(getFilePasswordProvider(), "No FilePasswordProvider"); + ClientIdentityLoader loader = Objects.requireNonNull(getClientIdentityLoader(), "No ClientIdentityLoader"); + FilePasswordProvider provider = Objects.requireNonNull(getFilePasswordProvider(), "No FilePasswordProvider"); for (String l : locations) { if (!loader.isValidLocation(l)) { if (ignoreNonExisting) { @@ -716,7 +716,7 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa * wrapper is closed the client is also stopped */ public static SimpleClient wrapAsSimpleClient(final SshClient client) { - ValidateUtils.checkNotNull(client, "No client instance"); + Objects.requireNonNull(client, "No client instance"); // wrap the client so that close() is also stop() final java.nio.channels.Channel channel = new java.nio.channels.Channel() { @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java b/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java index da592f3..8ce551c 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java @@ -620,7 +620,7 @@ public class SshKeyScan implements Channel, Callable<Void>, ServerKeyVerifier, S public static <S extends SshKeyScan> S setInputStream(S scanner, Collection<String> hosts) throws IOException { if (GenericUtils.isEmpty(hosts)) { - ValidateUtils.checkNotNull(scanner.getInputStream(), "No hosts or file specified"); + Objects.requireNonNull(scanner.getInputStream(), "No hosts or file specified"); } else { ValidateUtils.checkTrue(scanner.getInputStream() == null, "Both hosts and file specified"); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/auth/AbstractUserAuth.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/AbstractUserAuth.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/AbstractUserAuth.java index 9b22eb7..11c26a4 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/auth/AbstractUserAuth.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/AbstractUserAuth.java @@ -19,6 +19,8 @@ package org.apache.sshd.client.auth; +import java.util.Objects; + import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.Buffer; @@ -57,7 +59,7 @@ public abstract class AbstractUserAuth extends AbstractLoggingBean implements Us @Override public void init(ClientSession session, String service) throws Exception { - this.clientSession = ValidateUtils.checkNotNull(session, "No client session"); + this.clientSession = Objects.requireNonNull(session, "No client session"); this.service = ValidateUtils.checkNotNullAndNotEmpty(service, "No service"); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/AbstractKeyPairIterator.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/AbstractKeyPairIterator.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/AbstractKeyPairIterator.java index ef2fe36..438ba43 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/AbstractKeyPairIterator.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/AbstractKeyPairIterator.java @@ -20,10 +20,11 @@ package org.apache.sshd.client.auth.pubkey; import java.util.Iterator; +import java.util.Objects; + import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.client.session.ClientSessionHolder; import org.apache.sshd.common.session.SessionHolder; -import org.apache.sshd.common.util.ValidateUtils; /** * @param <I> Type of {@link PublicKeyIdentity} being iterated @@ -35,7 +36,7 @@ public abstract class AbstractKeyPairIterator<I extends PublicKeyIdentity> private final ClientSession session; protected AbstractKeyPairIterator(ClientSession session) { - this.session = ValidateUtils.checkNotNull(session, "No session"); + this.session = Objects.requireNonNull(session, "No session"); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyAgentIdentity.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyAgentIdentity.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyAgentIdentity.java index a583e39..6c68135 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyAgentIdentity.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyAgentIdentity.java @@ -19,10 +19,10 @@ package org.apache.sshd.client.auth.pubkey; import java.security.PublicKey; +import java.util.Objects; import org.apache.sshd.agent.SshAgent; import org.apache.sshd.common.config.keys.KeyUtils; -import org.apache.sshd.common.util.ValidateUtils; /** * Uses an {@link SshAgent} to generate the identity signature @@ -35,8 +35,8 @@ public class KeyAgentIdentity implements PublicKeyIdentity { private final String comment; public KeyAgentIdentity(SshAgent agent, PublicKey key, String comment) { - this.agent = ValidateUtils.checkNotNull(agent, "No signing agent"); - this.key = ValidateUtils.checkNotNull(key, "No public key"); + this.agent = Objects.requireNonNull(agent, "No signing agent"); + this.key = Objects.requireNonNull(key, "No public key"); this.comment = comment; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyPairIdentity.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyPairIdentity.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyPairIdentity.java index 2b5531c..b53c111 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyPairIdentity.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/KeyPairIdentity.java @@ -21,6 +21,7 @@ package org.apache.sshd.client.auth.pubkey; import java.security.KeyPair; import java.security.PublicKey; import java.util.Collection; +import java.util.Objects; import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.NamedResource; @@ -42,7 +43,7 @@ public class KeyPairIdentity implements PublicKeyIdentity { this.signatureFactories = ValidateUtils.checkNotNullAndNotEmpty( SignatureFactoriesManager.resolveSignatureFactories(primary, secondary), "No available signature factories"); - this.pair = ValidateUtils.checkNotNull(pair, "No key pair"); + this.pair = Objects.requireNonNull(pair, "No key pair"); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/SshAgentPublicKeyIterator.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/SshAgentPublicKeyIterator.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/SshAgentPublicKeyIterator.java index 8bb18c9..315e245 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/SshAgentPublicKeyIterator.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/SshAgentPublicKeyIterator.java @@ -22,12 +22,12 @@ package org.apache.sshd.client.auth.pubkey; import java.io.IOException; import java.security.PublicKey; import java.util.Iterator; +import java.util.Objects; import org.apache.sshd.agent.SshAgent; import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.Pair; -import org.apache.sshd.common.util.ValidateUtils; /** * @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a> @@ -38,7 +38,7 @@ public class SshAgentPublicKeyIterator extends AbstractKeyPairIterator<KeyAgentI public SshAgentPublicKeyIterator(ClientSession session, SshAgent agent) throws IOException { super(session); - this.agent = ValidateUtils.checkNotNull(agent, "No agent"); + this.agent = Objects.requireNonNull(agent, "No agent"); keys = GenericUtils.iteratorOf(agent.getIdentities()); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java index a75e13a..0ecb740 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKeyIterator.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.sshd.agent.SshAgent; @@ -34,7 +35,6 @@ import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.keyprovider.KeyIdentityProvider; import org.apache.sshd.common.signature.SignatureFactoriesManager; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; /** * @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a> @@ -52,11 +52,11 @@ public class UserAuthPublicKeyIterator extends AbstractKeyPairIterator<PublicKey Collection<Iterator<? extends PublicKeyIdentity>> identities = new LinkedList<>(); identities.add(new SessionKeyPairIterator(session, signatureFactories, KeyIdentityProvider.iteratorOf(session))); - FactoryManager manager = ValidateUtils.checkNotNull(session.getFactoryManager(), "No session factory manager"); + FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No session factory manager"); SshAgentFactory factory = manager.getAgentFactory(); if (factory != null) { try { - agent = ValidateUtils.checkNotNull(factory.createClient(manager), "No agent created"); + agent = Objects.requireNonNull(factory.createClient(manager), "No agent created"); identities.add(new SshAgentPublicKeyIterator(session, agent)); } catch (Exception e) { try { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 86d42d1..4c3aee3 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 @@ -24,6 +24,7 @@ import java.io.OutputStream; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; +import java.util.Objects; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -197,7 +198,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C @Override public Set<ClientChannelEvent> waitFor(Collection<ClientChannelEvent> mask, long timeout) { - ValidateUtils.checkNotNull(mask, "No mask specified"); + Objects.requireNonNull(mask, "No mask specified"); long t = 0; synchronized (lock) { for (Set<ClientChannelEvent> cond = EnumSet.noneOf(ClientChannelEvent.class);; cond.clear()) { @@ -323,7 +324,7 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C setRecipient(recipient); Session session = getSession(); - FactoryManager manager = ValidateUtils.checkNotNull(session.getFactoryManager(), "No factory manager"); + FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No factory manager"); Window wRemote = getRemoteWindow(); wRemote.init(rwSize, packetSize, manager.getProperties()); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java index 13095ed..f25019e 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/exit/AbstractChannelExitRequestHandler.java @@ -18,13 +18,13 @@ */ package org.apache.sshd.client.channel.exit; +import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import org.apache.sshd.common.NamedResource; import org.apache.sshd.common.channel.AbstractChannelRequestHandler; import org.apache.sshd.common.channel.Channel; import org.apache.sshd.common.util.EventNotifier; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.Buffer; /** @@ -48,8 +48,8 @@ public abstract class AbstractChannelExitRequestHandler<V> extends AbstractChann * with the processed request data */ protected AbstractChannelExitRequestHandler(AtomicReference<V> holder, EventNotifier<? super String> notifier) { - this.holder = ValidateUtils.checkNotNull(holder, "No exit status holder"); - this.notifier = ValidateUtils.checkNotNull(notifier, "No event notifier"); + this.holder = Objects.requireNonNull(holder, "No exit status holder"); + this.notifier = Objects.requireNonNull(notifier, "No event notifier"); } @Override // see RFC4254 section 6.10 http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java index 70a4f33..f1c9ea8 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolver.java @@ -25,10 +25,10 @@ import java.nio.file.LinkOption; import java.nio.file.Path; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.io.IoUtils; import org.apache.sshd.common.util.io.ModifiableFileWatcher; @@ -42,7 +42,7 @@ public class ConfigFileHostEntryResolver extends ModifiableFileWatcher implement new AtomicReference<>(HostConfigEntryResolver.EMPTY); public ConfigFileHostEntryResolver(File file) { - this(ValidateUtils.checkNotNull(file, "No file to watch").toPath()); + this(Objects.requireNonNull(file, "No file to watch").toPath()); } public ConfigFileHostEntryResolver(Path file) { @@ -56,7 +56,7 @@ public class ConfigFileHostEntryResolver extends ModifiableFileWatcher implement @Override public HostConfigEntry resolveEffectiveHost(String host, int port, String username) throws IOException { try { - HostConfigEntryResolver delegate = ValidateUtils.checkNotNull(resolveEffectiveResolver(host, port, username), "No delegate"); + HostConfigEntryResolver delegate = Objects.requireNonNull(resolveEffectiveResolver(host, port, username), "No delegate"); HostConfigEntry entry = delegate.resolveEffectiveHost(host, port, username); if (log.isDebugEnabled()) { log.debug("resolveEffectiveHost({}@{}:{}) => {}", username, host, port, entry); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java index 174a14b..954dc50 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/DefaultConfigFileHostEntryResolver.java @@ -25,9 +25,9 @@ import java.nio.file.LinkOption; import java.nio.file.Path; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.apache.sshd.common.util.Pair; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.io.IoUtils; /** @@ -56,7 +56,7 @@ public class DefaultConfigFileHostEntryResolver extends ConfigFileHostEntryResol } public DefaultConfigFileHostEntryResolver(File file, boolean strict) { - this(ValidateUtils.checkNotNull(file, "No file provided").toPath(), strict, IoUtils.getLinkOptions(false)); + this(Objects.requireNonNull(file, "No file provided").toPath(), strict, IoUtils.getLinkOptions(false)); } public DefaultConfigFileHostEntryResolver(Path path, boolean strict, LinkOption ... options) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java index d8c08a6..520b1e1 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java @@ -46,6 +46,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.TreeMap; + import org.apache.sshd.common.auth.MutableUserHolder; import org.apache.sshd.common.config.SshConfigFileReader; import org.apache.sshd.common.config.keys.IdentityUtils; @@ -217,7 +218,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo * @param file A {@link File} that contains an identity key - never {@code null} */ public void addIdentity(File file) { - addIdentity(ValidateUtils.checkNotNull(file, "No file").toPath()); + addIdentity(Objects.requireNonNull(file, "No file").toPath()); } /** @@ -225,7 +226,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo * - never {@code null} */ public void addIdentity(Path path) { - addIdentity(ValidateUtils.checkNotNull(path, "No path").toAbsolutePath().normalize().toString()); + addIdentity(Objects.requireNonNull(path, "No path").toAbsolutePath().normalize().toString()); } /** @@ -1005,7 +1006,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo } public static void writeHostConfigEntries(File file, Collection<? extends HostConfigEntry> entries) throws IOException { - writeHostConfigEntries(ValidateUtils.checkNotNull(file, "No file").toPath(), entries, IoUtils.EMPTY_OPEN_OPTIONS); + writeHostConfigEntries(Objects.requireNonNull(file, "No file").toPath(), entries, IoUtils.EMPTY_OPEN_OPTIONS); } public static void writeHostConfigEntries(Path path, Collection<? extends HostConfigEntry> entries, OpenOption ... options) throws IOException { @@ -1103,7 +1104,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo break; case LOCAL_HOST_MACRO: { - InetAddress address = ValidateUtils.checkNotNull(InetAddress.getLocalHost(), "No local address"); + InetAddress address = Objects.requireNonNull(InetAddress.getLocalHost(), "No local address"); sb.append(ValidateUtils.checkNotNullAndNotEmpty(address.getHostName(), "No local name")); break; } @@ -1134,7 +1135,7 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo } public static StringBuilder appendUserHome(StringBuilder sb, Path userHome) { - return appendUserHome(sb, ValidateUtils.checkNotNull(userHome, "No user home folder").toString()); + return appendUserHome(sb, Objects.requireNonNull(userHome, "No user home folder").toString()); } public static StringBuilder appendUserHome(StringBuilder sb, String userHome) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java index 1710194..2d9a322 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java @@ -21,6 +21,7 @@ package org.apache.sshd.client.config.hosts; import java.util.Collections; import java.util.EnumSet; +import java.util.Objects; import java.util.Set; import org.apache.sshd.common.Factory; @@ -46,7 +47,7 @@ public enum KnownHostDigest implements NamedFactory<Mac> { KnownHostDigest(String name, Factory<Mac> factory) { this.name = ValidateUtils.checkNotNullAndNotEmpty(name, "No name"); - this.factory = ValidateUtils.checkNotNull(factory, "No factory"); + this.factory = Objects.requireNonNull(factory, "No factory"); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java index 29aee8d..e2cc319 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcher.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import java.util.function.Supplier; import org.apache.sshd.common.NamedResource; @@ -33,7 +34,6 @@ import org.apache.sshd.common.config.keys.BuiltinIdentities; import org.apache.sshd.common.config.keys.FilePasswordProvider; import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; /** * @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a> @@ -49,8 +49,8 @@ public class BuiltinClientIdentitiesWatcher extends ClientIdentitiesWatcher { public BuiltinClientIdentitiesWatcher(Path keysFolder, Collection<String> ids, boolean supportedOnly, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) { this(keysFolder, ids, supportedOnly, - GenericUtils.supplierOf(ValidateUtils.checkNotNull(loader, "No client identity loader")), - GenericUtils.supplierOf(ValidateUtils.checkNotNull(provider, "No password provider")), + GenericUtils.supplierOf(Objects.requireNonNull(loader, "No client identity loader")), + GenericUtils.supplierOf(Objects.requireNonNull(provider, "No password provider")), strict); } @@ -104,7 +104,7 @@ public class BuiltinClientIdentitiesWatcher extends ClientIdentitiesWatcher { } public static List<Path> getBuiltinIdentitiesPaths(Path keysFolder, Collection<String> ids) { - ValidateUtils.checkNotNull(keysFolder, "No keys folder"); + Objects.requireNonNull(keysFolder, "No keys folder"); if (GenericUtils.isEmpty(ids)) { return Collections.emptyList(); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java index 3c90060..3a78958 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentitiesWatcher.java @@ -25,13 +25,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.function.Supplier; import org.apache.sshd.common.config.keys.FilePasswordProvider; import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider; import org.apache.sshd.common.keyprovider.KeyPairProvider; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; /** * Watches over a group of files that contains client identities @@ -49,8 +49,8 @@ public class ClientIdentitiesWatcher extends AbstractKeyPairProvider implements public ClientIdentitiesWatcher(Collection<? extends Path> paths, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) { this(paths, - GenericUtils.supplierOf(ValidateUtils.checkNotNull(loader, "No client identity loader")), - GenericUtils.supplierOf(ValidateUtils.checkNotNull(provider, "No password provider")), + GenericUtils.supplierOf(Objects.requireNonNull(loader, "No client identity loader")), + GenericUtils.supplierOf(Objects.requireNonNull(provider, "No password provider")), strict); } @@ -100,8 +100,8 @@ public class ClientIdentitiesWatcher extends AbstractKeyPairProvider implements public static List<ClientIdentityProvider> buildProviders( Collection<? extends Path> paths, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) { return buildProviders(paths, - GenericUtils.supplierOf(ValidateUtils.checkNotNull(loader, "No client identity loader")), - GenericUtils.supplierOf(ValidateUtils.checkNotNull(provider, "No password provider")), + GenericUtils.supplierOf(Objects.requireNonNull(loader, "No client identity loader")), + GenericUtils.supplierOf(Objects.requireNonNull(provider, "No password provider")), strict); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java index 3974930..a051606 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcher.java @@ -24,6 +24,7 @@ import java.nio.file.Path; import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.PublicKey; +import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; @@ -31,7 +32,6 @@ import org.apache.sshd.common.config.keys.FilePasswordProvider; import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.Pair; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.io.IoUtils; import org.apache.sshd.common.util.io.ModifiableFileWatcher; @@ -53,8 +53,8 @@ public class ClientIdentityFileWatcher extends ModifiableFileWatcher implements public ClientIdentityFileWatcher(Path path, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) { this(path, - GenericUtils.supplierOf(ValidateUtils.checkNotNull(loader, "No client identity loader")), - GenericUtils.supplierOf(ValidateUtils.checkNotNull(provider, "No password provider")), + GenericUtils.supplierOf(Objects.requireNonNull(loader, "No client identity loader")), + GenericUtils.supplierOf(Objects.requireNonNull(provider, "No password provider")), strict); } @@ -64,8 +64,8 @@ public class ClientIdentityFileWatcher extends ModifiableFileWatcher implements public ClientIdentityFileWatcher(Path path, Supplier<ClientIdentityLoader> loader, Supplier<FilePasswordProvider> provider, boolean strict) { super(path); - this.loaderHolder = ValidateUtils.checkNotNull(loader, "No client identity loader"); - this.providerHolder = ValidateUtils.checkNotNull(provider, "No password provider"); + this.loaderHolder = Objects.requireNonNull(loader, "No client identity loader"); + this.providerHolder = Objects.requireNonNull(provider, "No password provider"); this.strict = strict; } @@ -115,9 +115,9 @@ public class ClientIdentityFileWatcher extends ModifiableFileWatcher implements } String location = path.toString(); - ClientIdentityLoader idLoader = ValidateUtils.checkNotNull(getClientIdentityLoader(), "No client identity loader"); + ClientIdentityLoader idLoader = Objects.requireNonNull(getClientIdentityLoader(), "No client identity loader"); if (idLoader.isValidLocation(location)) { - KeyPair kp = idLoader.loadClientIdentity(location, ValidateUtils.checkNotNull(getFilePasswordProvider(), "No file password provider")); + KeyPair kp = idLoader.loadClientIdentity(location, Objects.requireNonNull(getFilePasswordProvider(), "No file password provider")); if (log.isTraceEnabled()) { PublicKey key = (kp == null) ? null : kp.getPublic(); if (key != null) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java index b91fa7b..3afa129 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/keys/DefaultClientIdentitiesWatcher.java @@ -21,12 +21,12 @@ package org.apache.sshd.client.config.keys; import java.nio.file.Path; import java.util.List; +import java.util.Objects; import java.util.function.Supplier; import org.apache.sshd.common.config.keys.FilePasswordProvider; import org.apache.sshd.common.config.keys.PublicKeyEntry; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; /** * @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a> @@ -42,8 +42,8 @@ public class DefaultClientIdentitiesWatcher extends BuiltinClientIdentitiesWatch public DefaultClientIdentitiesWatcher(boolean supportedOnly, ClientIdentityLoader loader, FilePasswordProvider provider, boolean strict) { this(supportedOnly, - GenericUtils.supplierOf(ValidateUtils.checkNotNull(loader, "No client identity loader")), - GenericUtils.supplierOf(ValidateUtils.checkNotNull(provider, "No password provider")), + GenericUtils.supplierOf(Objects.requireNonNull(loader, "No client identity loader")), + GenericUtils.supplierOf(Objects.requireNonNull(provider, "No password provider")), strict); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java index 60089f6..da10342 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultAuthFuture.java @@ -19,10 +19,10 @@ package org.apache.sshd.client.future; import java.io.IOException; +import java.util.Objects; import org.apache.sshd.common.SshException; import org.apache.sshd.common.future.DefaultVerifiableSshFuture; -import org.apache.sshd.common.util.ValidateUtils; /** @@ -78,7 +78,7 @@ public class DefaultAuthFuture extends DefaultVerifiableSshFuture<AuthFuture> im @Override public void setException(Throwable exception) { - ValidateUtils.checkNotNull(exception, "No exception provided"); + Objects.requireNonNull(exception, "No exception provided"); setValue(exception); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java index a9361c6..e028690 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/future/DefaultConnectFuture.java @@ -25,7 +25,6 @@ import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.RuntimeSshException; import org.apache.sshd.common.future.DefaultVerifiableSshFuture; import org.apache.sshd.common.io.IoSession; -import org.apache.sshd.common.util.ValidateUtils; /** * A default implementation of {@link ConnectFuture}. @@ -57,7 +56,7 @@ public class DefaultConnectFuture extends DefaultVerifiableSshFuture<ConnectFutu } else if (v instanceof Error) { throw (Error) v; } else if (v instanceof Throwable) { - throw (RuntimeSshException) new RuntimeSshException("Failed to get the session.", (Throwable) v); + throw new RuntimeSshException("Failed to get the session.", (Throwable) v); } else if (v instanceof ClientSession) { return (ClientSession) v; } else { @@ -88,7 +87,7 @@ public class DefaultConnectFuture extends DefaultVerifiableSshFuture<ConnectFutu @Override public void setException(Throwable exception) { - ValidateUtils.checkNotNull(exception, "No exception provided"); + Objects.requireNonNull(exception, "No exception provided"); setValue(exception); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 1641095..7ac5ea9 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 @@ -18,6 +18,8 @@ */ package org.apache.sshd.client.kex; +import java.util.Objects; + import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.SshException; @@ -46,7 +48,7 @@ public class DHGClient extends AbstractDHClientKeyExchange { protected AbstractDH dh; protected DHGClient(DHFactory factory) { - this.factory = ValidateUtils.checkNotNull(factory, "No factory"); + this.factory = Objects.requireNonNull(factory, "No factory"); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 16bfcbe..533d971 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 @@ -20,6 +20,7 @@ package org.apache.sshd.client.kex; import java.math.BigInteger; +import java.util.Objects; import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.SshConstants; @@ -53,7 +54,7 @@ public class DHGEXClient extends AbstractDHClientKeyExchange { protected byte[] g; protected DHGEXClient(DHFactory factory) { - this.factory = ValidateUtils.checkNotNull(factory, "No factory"); + this.factory = Objects.requireNonNull(factory, "No factory"); this.max = SecurityUtils.getMaxDHGroupExchangeKeySize(); this.prf = Math.min(SecurityUtils.PREFERRED_DHGEX_KEY_SIZE, max); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/DefaultKnownHostsServerKeyVerifier.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/DefaultKnownHostsServerKeyVerifier.java b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/DefaultKnownHostsServerKeyVerifier.java index f10645b..623dfdf 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/DefaultKnownHostsServerKeyVerifier.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/DefaultKnownHostsServerKeyVerifier.java @@ -26,10 +26,10 @@ import java.nio.file.Path; import java.security.GeneralSecurityException; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.apache.sshd.client.config.hosts.KnownHostEntry; import org.apache.sshd.common.util.Pair; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.io.IoUtils; /** @@ -51,7 +51,7 @@ public class DefaultKnownHostsServerKeyVerifier extends KnownHostsServerKeyVerif } public DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict, File file) { - this(delegate, strict, ValidateUtils.checkNotNull(file, "No file provided").toPath(), IoUtils.getLinkOptions(false)); + this(delegate, strict, Objects.requireNonNull(file, "No file provided").toPath(), IoUtils.getLinkOptions(false)); } public DefaultKnownHostsServerKeyVerifier(ServerKeyVerifier delegate, boolean strict, Path file, LinkOption... options) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java index eba487a..48f01bf 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifier.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicReference; @@ -88,8 +89,8 @@ public class KnownHostsServerKeyVerifier } public HostEntryPair(KnownHostEntry entry, PublicKey key) { - this.hostEntry = ValidateUtils.checkNotNull(entry, "No entry"); - this.serverKey = ValidateUtils.checkNotNull(key, "No key"); + this.hostEntry = Objects.requireNonNull(entry, "No entry"); + this.serverKey = Objects.requireNonNull(key, "No key"); } public KnownHostEntry getHostEntry() { @@ -126,7 +127,7 @@ public class KnownHostsServerKeyVerifier public KnownHostsServerKeyVerifier(ServerKeyVerifier delegate, Path file, LinkOption... options) { super(file, options); - this.delegate = ValidateUtils.checkNotNull(delegate, "No delegate"); + this.delegate = Objects.requireNonNull(delegate, "No delegate"); } public ServerKeyVerifier getDelegateVerifier() { @@ -680,10 +681,10 @@ public class KnownHostsServerKeyVerifier if (digester != null) { if (rnd == null) { FactoryManager manager = - ValidateUtils.checkNotNull(clientSession.getFactoryManager(), "No factory manager"); + Objects.requireNonNull(clientSession.getFactoryManager(), "No factory manager"); Factory<? extends Random> factory = - ValidateUtils.checkNotNull(manager.getRandomFactory(), "No random factory"); - rnd = ValidateUtils.checkNotNull(factory.create(), "No randomizer created"); + Objects.requireNonNull(manager.getRandomFactory(), "No random factory"); + rnd = Objects.requireNonNull(factory.create(), "No randomizer created"); } Mac mac = digester.create(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java b/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java index f411a01..74d598e 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.logging.Level; @@ -66,7 +67,7 @@ public class DefaultScpClient extends AbstractScpClient { private final ClientSession clientSession; public DefaultScpClient(ClientSession clientSession, ScpFileOpener fileOpener, ScpTransferEventListener eventListener) { - this.clientSession = ValidateUtils.checkNotNull(clientSession, "No client session"); + this.clientSession = Objects.requireNonNull(clientSession, "No client session"); this.opener = (fileOpener == null) ? DefaultScpFileOpener.INSTANCE : fileOpener; this.listener = (eventListener == null) ? ScpTransferEventListener.EMPTY : eventListener; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java index 9894bfd..efe7a67 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java @@ -27,6 +27,7 @@ import java.security.PublicKey; import java.util.EnumMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.CopyOnWriteArrayList; import org.apache.sshd.client.ClientFactoryManager; @@ -190,9 +191,9 @@ public abstract class AbstractClientSession extends AbstractSession implements C @Override public void addPublicKeyIdentity(KeyPair kp) { - ValidateUtils.checkNotNull(kp, "No key-pair to add"); - ValidateUtils.checkNotNull(kp.getPublic(), "No public key"); - ValidateUtils.checkNotNull(kp.getPrivate(), "No private key"); + Objects.requireNonNull(kp, "No key-pair to add"); + Objects.requireNonNull(kp.getPublic(), "No public key"); + Objects.requireNonNull(kp.getPrivate(), "No private key"); identities.add(kp); @@ -413,8 +414,8 @@ public abstract class AbstractClientSession extends AbstractSession implements C } protected TcpipForwarder getTcpipForwarder() { - ConnectionService service = ValidateUtils.checkNotNull(getConnectionService(), "No connection service"); - return ValidateUtils.checkNotNull(service.getTcpipForwarder(), "No forwarder"); + ConnectionService service = Objects.requireNonNull(getConnectionService(), "No connection service"); + return Objects.requireNonNull(service.getTcpipForwarder(), "No forwarder"); } @Override @@ -506,7 +507,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C @Override protected void checkKeys() throws SshException { - ServerKeyVerifier serverKeyVerifier = ValidateUtils.checkNotNull(getServerKeyVerifier(), "No server key verifier"); + ServerKeyVerifier serverKeyVerifier = Objects.requireNonNull(getServerKeyVerifier(), "No server key verifier"); SocketAddress remoteAddress = ioSession.getRemoteAddress(); PublicKey serverKey = kex.getServerKey(); boolean verified = serverKeyVerifier.verifyServerKey(this, remoteAddress, serverKey); @@ -577,7 +578,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C setKexSeed(seed); } - return ValidateUtils.checkNotNull(kexFutureHolder.get(), "No current KEX future"); + return Objects.requireNonNull(kexFutureHolder.get(), "No current KEX future"); } else { throw new SshException("In flight key exchange"); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java index d73a342..28a72ad 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java @@ -26,6 +26,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.apache.sshd.client.ClientFactoryManager; @@ -219,7 +220,7 @@ public class ClientSessionImpl extends AbstractClientSession { @Override public Set<ClientSessionEvent> waitFor(Collection<ClientSessionEvent> mask, long timeout) { - ValidateUtils.checkNotNull(mask, "No mask specified"); + Objects.requireNonNull(mask, "No mask specified"); long t = 0L; synchronized (lock) { for (Set<ClientSessionEvent> cond = EnumSet.noneOf(ClientSessionEvent.class);; cond.clear()) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 e9a019a..b67efc0 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 @@ -23,6 +23,7 @@ import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import org.apache.sshd.client.ClientAuthenticationManager; @@ -226,7 +227,7 @@ public class ClientUserAuthService session.setAuthenticated(); ((ClientSessionImpl) session).switchToNextService(); - AuthFuture authFuture = ValidateUtils.checkNotNull(authFutureHolder.get(), "No current future"); + AuthFuture authFuture = Objects.requireNonNull(authFutureHolder.get(), "No current future"); // Will wake up anyone sitting in waitFor authFuture.setAuthed(true); return; @@ -313,7 +314,7 @@ public class ClientUserAuthService } // also wake up anyone sitting in waitFor - AuthFuture authFuture = ValidateUtils.checkNotNull(authFutureHolder.get(), "No current future"); + AuthFuture authFuture = Objects.requireNonNull(authFutureHolder.get(), "No current future"); authFuture.setException(new SshException(SshConstants.SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE, "No more authentication methods available")); return; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClient.java b/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClient.java index 90007c5..904b7ec 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClient.java @@ -25,6 +25,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.security.KeyPair; +import java.util.Objects; import org.apache.sshd.client.scp.CloseableScpClient; import org.apache.sshd.client.scp.ScpClient; @@ -167,7 +168,7 @@ public abstract class AbstractSimpleClient extends AbstractLoggingBean implement @Override public CloseableScpClient scpLogin(InetAddress host, int port, String username, String password) throws IOException { - return scpLogin(new InetSocketAddress(ValidateUtils.checkNotNull(host, "No host address"), port), username, password); + return scpLogin(new InetSocketAddress(Objects.requireNonNull(host, "No host address"), port), username, password); } @Override @@ -177,7 +178,7 @@ public abstract class AbstractSimpleClient extends AbstractLoggingBean implement @Override public CloseableScpClient scpLogin(InetAddress host, int port, String username, KeyPair identity) throws IOException { - return scpLogin(new InetSocketAddress(ValidateUtils.checkNotNull(host, "No host address"), port), username, identity); + return scpLogin(new InetSocketAddress(Objects.requireNonNull(host, "No host address"), port), username, identity); } @Override @@ -192,7 +193,7 @@ public abstract class AbstractSimpleClient extends AbstractLoggingBean implement protected CloseableScpClient createScpClient(final ClientSession session) throws IOException { try { - final ScpClient client = ValidateUtils.checkNotNull(session, "No client session").createScpClient(); + ScpClient client = Objects.requireNonNull(session, "No client session").createScpClient(); ClassLoader loader = getClass().getClassLoader(); Class<?>[] interfaces = {CloseableScpClient.class}; return (CloseableScpClient) Proxy.newProxyInstance(loader, interfaces, (proxy, method, args) -> { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java b/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java index 0a44c22..b929c6f 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/simple/AbstractSimpleClientSessionCreator.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.net.SocketAddress; import java.nio.channels.Channel; import java.security.KeyPair; +import java.util.Objects; import org.apache.sshd.client.config.hosts.HostConfigEntry; import org.apache.sshd.client.future.AuthFuture; @@ -136,8 +137,8 @@ public abstract class AbstractSimpleClientSessionCreator extends AbstractSimpleC * also closes the underlying sessions creator. */ public static SimpleClient wrap(final ClientSessionCreator creator, final Channel channel) { - ValidateUtils.checkNotNull(creator, "No sessions creator"); - ValidateUtils.checkNotNull(channel, "No channel"); + Objects.requireNonNull(creator, "No sessions creator"); + Objects.requireNonNull(channel, "No channel"); return new AbstractSimpleClientSessionCreator() { @Override public ConnectFuture connect(String username, String host, int port) throws IOException { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSessionClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSessionClient.java b/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSessionClient.java index d15a496..3820e1b 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSessionClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSessionClient.java @@ -25,6 +25,7 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.channels.Channel; import java.security.KeyPair; +import java.util.Objects; import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.util.ValidateUtils; @@ -113,7 +114,7 @@ public interface SimpleSessionClient extends SimpleClientConfigurator, Channel { * @throws IOException If failed to login or authenticate */ default ClientSession sessionLogin(InetAddress host, int port, String username, String password) throws IOException { - return sessionLogin(new InetSocketAddress(ValidateUtils.checkNotNull(host, "No host address"), port), username, password); + return sessionLogin(new InetSocketAddress(Objects.requireNonNull(host, "No host address"), port), username, password); } /** @@ -140,7 +141,7 @@ public interface SimpleSessionClient extends SimpleClientConfigurator, Channel { * @throws IOException If failed to login or authenticate */ default ClientSession sessionLogin(InetAddress host, int port, String username, KeyPair identity) throws IOException { - return sessionLogin(new InetSocketAddress(ValidateUtils.checkNotNull(host, "No host address"), port), username, identity); + return sessionLogin(new InetSocketAddress(Objects.requireNonNull(host, "No host address"), port), username, identity); } /** http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSftpClient.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSftpClient.java b/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSftpClient.java index 8776ad3..119b9e2 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSftpClient.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/simple/SimpleSftpClient.java @@ -25,6 +25,7 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.channels.Channel; import java.security.KeyPair; +import java.util.Objects; import org.apache.sshd.client.subsystem.sftp.SftpClient; import org.apache.sshd.common.util.ValidateUtils; @@ -119,7 +120,7 @@ public interface SimpleSftpClient extends SimpleClientConfigurator, Channel { * @throws IOException If failed to login or authenticate */ default SftpClient sftpLogin(InetAddress host, int port, String username, String password) throws IOException { - return sftpLogin(new InetSocketAddress(ValidateUtils.checkNotNull(host, "No host address"), port), username, password); + return sftpLogin(new InetSocketAddress(Objects.requireNonNull(host, "No host address"), port), username, password); } /** @@ -148,7 +149,7 @@ public interface SimpleSftpClient extends SimpleClientConfigurator, Channel { * @throws IOException If failed to login or authenticate */ default SftpClient sftpLogin(InetAddress host, int port, String username, KeyPair identity) throws IOException { - return sftpLogin(new InetSocketAddress(ValidateUtils.checkNotNull(host, "No host address"), port), username, identity); + return sftpLogin(new InetSocketAddress(Objects.requireNonNull(host, "No host address"), port), username, identity); } /**
