http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/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 1cf3676..e8ea7c3 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 @@ -26,6 +26,7 @@ import java.net.URL; import java.security.KeyPair; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.apache.sshd.common.Factory; import org.apache.sshd.common.FactoryManager; @@ -65,7 +66,7 @@ public class DHGEXServer extends AbstractDHServerKeyExchange { protected boolean oldRequest; protected DHGEXServer(DHFactory factory) { - this.factory = ValidateUtils.checkNotNull(factory, "No factory"); + this.factory = Objects.requireNonNull(factory, "No factory"); } @Override @@ -173,7 +174,7 @@ public class DHGEXServer extends AbstractDHServerKeyExchange { byte[] k_s; - KeyPair kp = ValidateUtils.checkNotNull(session.getHostKey(), "No server key pair available"); + KeyPair kp = Objects.requireNonNull(session.getHostKey(), "No server key pair available"); String algo = session.getNegotiatedKexParameter(KexProposalOption.SERVERKEYS); Signature sig = ValidateUtils.checkNotNull( NamedFactory.create(session.getSignatureFactories(), algo), @@ -262,9 +263,9 @@ public class DHGEXServer extends AbstractDHServerKeyExchange { return getDH(new BigInteger(DHGroupData.getP1()), new BigInteger(DHGroupData.getG())); } - FactoryManager manager = ValidateUtils.checkNotNull(session.getFactoryManager(), "No factory manager"); - Factory<Random> factory = ValidateUtils.checkNotNull(manager.getRandomFactory(), "No random factory"); - Random random = ValidateUtils.checkNotNull(factory.create(), "No random generator"); + FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No factory manager"); + Factory<Random> factory = Objects.requireNonNull(manager.getRandomFactory(), "No random factory"); + Random random = Objects.requireNonNull(factory.create(), "No random generator"); int which = random.random(selected.size()); Moduli.DhGroup group = selected.get(which); return getDH(group.p, group.g);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java index 3110c29..2830cc3 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java @@ -19,6 +19,7 @@ package org.apache.sshd.server.kex; import java.security.KeyPair; +import java.util.Objects; import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.SshConstants; @@ -45,7 +46,7 @@ public class DHGServer extends AbstractDHServerKeyExchange { protected AbstractDH dh; protected DHGServer(DHFactory factory) { - this.factory = ValidateUtils.checkNotNull(factory, "No factory"); + this.factory = Objects.requireNonNull(factory, "No factory"); } @Override @@ -99,7 +100,7 @@ public class DHGServer extends AbstractDHServerKeyExchange { dh.setF(e); k = dh.getK(); - KeyPair kp = ValidateUtils.checkNotNull(session.getHostKey(), "No server key pair available"); + KeyPair kp = Objects.requireNonNull(session.getHostKey(), "No server key pair available"); String algo = session.getNegotiatedKexParameter(KexProposalOption.SERVERKEYS); Signature sig = ValidateUtils.checkNotNull( NamedFactory.create(session.getSignatureFactories(), algo), http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/scp/UnknownCommand.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/scp/UnknownCommand.java b/sshd-core/src/main/java/org/apache/sshd/server/scp/UnknownCommand.java index 166590f..416203d 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/scp/UnknownCommand.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/scp/UnknownCommand.java @@ -82,7 +82,7 @@ public class UnknownCommand implements Command { @Override public void start(Environment env) throws IOException { - ValidateUtils.checkNotNull(err, "No error stream"); + Objects.requireNonNull(err, "No error stream"); String errorMessage = getMessage(); try { err.write(errorMessage.getBytes(StandardCharsets.UTF_8)); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java index 44869d3..c34a5a8 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java @@ -380,7 +380,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S @Override public KeyPair getHostKey() { String keyType = getNegotiatedKexParameter(KexProposalOption.SERVERKEYS); - KeyPairProvider provider = ValidateUtils.checkNotNull(getKeyPairProvider(), "No host keys provider"); + KeyPairProvider provider = Objects.requireNonNull(getKeyPairProvider(), "No host keys provider"); try { return provider.loadKey(keyType); } catch (Error e) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java index e12adf7..b24f6b0 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java @@ -33,6 +33,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.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -256,7 +257,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service, } protected void handleAuthenticationSuccess(int cmd, Buffer buffer) throws Exception { - String username = ValidateUtils.checkNotNull(currentAuth, "No current auth").getUsername(); + String username = Objects.requireNonNull(currentAuth, "No current auth").getUsername(); ServerSession session = getServerSession(); if (log.isDebugEnabled()) { log.debug("handleAuthenticationSuccess({}@{}) {}", http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java index f810abd..0bf2e27 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java @@ -21,6 +21,7 @@ package org.apache.sshd.server.shell; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Objects; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; @@ -109,7 +110,7 @@ public class InvertedShellWrapper extends AbstractLoggingBean implements Command * @param bufferSize Buffer size to use - must be above min. size ({@link Byte#SIZE}) */ public InvertedShellWrapper(InvertedShell shell, Executor executor, boolean shutdownExecutor, int bufferSize) { - this.shell = ValidateUtils.checkNotNull(shell, "No shell"); + this.shell = Objects.requireNonNull(shell, "No shell"); this.executor = (executor == null) ? ThreadUtils.newSingleThreadExecutor("shell[0x" + Integer.toHexString(shell.hashCode()) + "]") : executor; ValidateUtils.checkTrue(bufferSize > Byte.SIZE, "Copy buffer size too small: %d", bufferSize); this.bufferSize = bufferSize; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java index a74de9b..f4b5717 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/ProcessShell.java @@ -27,6 +27,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import org.apache.sshd.common.channel.PtyMode; import org.apache.sshd.common.util.GenericUtils; @@ -73,7 +74,7 @@ public class ProcessShell extends AbstractLoggingBean implements InvertedShell, @Override public void setSession(ServerSession session) { - this.session = ValidateUtils.checkNotNull(session, "No server session"); + this.session = Objects.requireNonNull(session, "No server session"); ValidateUtils.checkTrue(process == null, "Session set after process started"); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java index 5ec2ae2..85e4707 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java @@ -25,11 +25,11 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.apache.sshd.common.channel.PtyMode; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; /** * Handles the output stream while taking care of the {@link PtyMode} for CR / LF @@ -52,7 +52,7 @@ public class TtyFilterOutputStream extends FilterOutputStream { super(out); // we create a copy of the options so as to avoid concurrent modifications this.ttyOptions = GenericUtils.of(ttyOptions); // TODO validate non-conflicting options - this.echo = this.ttyOptions.contains(PtyMode.ECHO) ? ValidateUtils.checkNotNull(echo, "No echo stream") : echo; + this.echo = this.ttyOptions.contains(PtyMode.ECHO) ? Objects.requireNonNull(echo, "No echo stream") : echo; } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerManager.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerManager.java b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerManager.java index 91bbaf1..15de46a 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerManager.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpEventListenerManager.java @@ -20,9 +20,9 @@ package org.apache.sshd.server.subsystem.sftp; import java.util.Collection; +import java.util.Objects; import org.apache.sshd.common.util.EventListenerUtils; -import org.apache.sshd.common.util.ValidateUtils; /** * @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a> @@ -48,7 +48,7 @@ public abstract class AbstractSftpEventListenerManager implements SftpEventListe @Override public boolean addSftpEventListener(SftpEventListener listener) { - return sftpEventListeners.add(ValidateUtils.checkNotNull(listener, "No listener")); + return sftpEventListeners.add(Objects.requireNonNull(listener, "No listener")); } @Override http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java index dc1de62..d97bf99 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java @@ -328,7 +328,7 @@ public class SftpSubsystem @Override public boolean addSftpEventListener(SftpEventListener listener) { - return sftpEventListeners.add(ValidateUtils.checkNotNull(listener, "No listener")); + return sftpEventListeners.add(Objects.requireNonNull(listener, "No listener")); } @Override @@ -338,7 +338,7 @@ public class SftpSubsystem @Override public void setSession(ServerSession session) { - this.serverSession = ValidateUtils.checkNotNull(session, "No session"); + this.serverSession = Objects.requireNonNull(session, "No session"); FactoryManager manager = session.getFactoryManager(); Factory<? extends Random> factory = manager.getRandomFactory(); @@ -367,8 +367,8 @@ public class SftpSubsystem if (fileSystem != this.fileSystem) { this.fileSystem = fileSystem; - Iterable<Path> roots = ValidateUtils.checkNotNull(fileSystem.getRootDirectories(), "No root directories"); - Iterator<Path> available = ValidateUtils.checkNotNull(roots.iterator(), "No roots iterator"); + Iterable<Path> roots = Objects.requireNonNull(fileSystem.getRootDirectories(), "No root directories"); + Iterator<Path> available = Objects.requireNonNull(roots.iterator(), "No roots iterator"); ValidateUtils.checkTrue(available.hasNext(), "No available root"); this.defaultDir = available.next(); } @@ -779,12 +779,12 @@ public class SftpSubsystem } protected void doCheckFileHash(int id, Path file, NamedFactory<? extends Digest> factory, - long startOffset, long length, int blockSize, Buffer buffer) - throws Exception { + long startOffset, long length, int blockSize, Buffer buffer) + throws Exception { ValidateUtils.checkTrue(startOffset >= 0L, "Invalid start offset: %d", startOffset); ValidateUtils.checkTrue(length >= 0L, "Invalid length: %d", length); ValidateUtils.checkTrue((blockSize == 0) || (blockSize >= SftpConstants.MIN_CHKFILE_BLOCKSIZE), "Invalid block size: %d", blockSize); - ValidateUtils.checkNotNull(factory, "No digest factory provided"); + Objects.requireNonNull(factory, "No digest factory provided"); buffer.putString(factory.getName()); long effectiveLength = length; @@ -1845,7 +1845,7 @@ public class SftpSubsystem return; } - ValidateUtils.checkNotNull(reply, "No reply buffer created"); + Objects.requireNonNull(reply, "No reply buffer created"); } catch (IOException | RuntimeException e) { sendStatus(BufferUtils.clear(buffer), id, e); return; http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/main/java/org/apache/sshd/server/x11/DefaultX11ForwardSupport.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/main/java/org/apache/sshd/server/x11/DefaultX11ForwardSupport.java b/sshd-core/src/main/java/org/apache/sshd/server/x11/DefaultX11ForwardSupport.java index e96f4d1..5758837 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/x11/DefaultX11ForwardSupport.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/x11/DefaultX11ForwardSupport.java @@ -25,6 +25,7 @@ import java.net.BindException; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.Collection; +import java.util.Objects; import org.apache.sshd.common.Closeable; import org.apache.sshd.common.FactoryManager; @@ -37,7 +38,6 @@ import org.apache.sshd.common.session.Session; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.OsUtils; import org.apache.sshd.common.util.Readable; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.Buffer; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; import org.apache.sshd.common.util.closeable.AbstractInnerCloseable; @@ -51,7 +51,7 @@ public class DefaultX11ForwardSupport extends AbstractInnerCloseable implements private IoAcceptor acceptor; public DefaultX11ForwardSupport(ConnectionService service) { - this.service = ValidateUtils.checkNotNull(service, "No connection service"); + this.service = Objects.requireNonNull(service, "No connection service"); } @Override @@ -85,10 +85,10 @@ public class DefaultX11ForwardSupport extends AbstractInnerCloseable implements return null; } - Session session = ValidateUtils.checkNotNull(service.getSession(), "No session"); + Session session = Objects.requireNonNull(service.getSession(), "No session"); if (acceptor == null) { - FactoryManager manager = ValidateUtils.checkNotNull(session.getFactoryManager(), "No factory manager"); - IoServiceFactory factory = ValidateUtils.checkNotNull(manager.getIoServiceFactory(), "No I/O service factory"); + FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No factory manager"); + IoServiceFactory factory = Objects.requireNonNull(manager.getIoServiceFactory(), "No I/O service factory"); acceptor = factory.createAcceptor(this); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java index c4bcdbe..a77e807 100644 --- a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java @@ -21,6 +21,7 @@ package org.apache.sshd.client.simple; import java.io.IOException; import java.security.KeyPair; +import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -28,7 +29,6 @@ import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.session.Session; import org.apache.sshd.common.session.SessionListener; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.server.auth.password.PasswordAuthenticator; import org.apache.sshd.server.auth.password.RejectAllPasswordAuthenticator; import org.apache.sshd.server.auth.pubkey.RejectAllPublickeyAuthenticator; @@ -109,7 +109,7 @@ public class SimpleSessionClientTest extends BaseSimpleClientTestSupport { public void testAuthenticationTimeout() throws Exception { // make sure authentication occurs only for passwords sshd.setPublickeyAuthenticator(RejectAllPublickeyAuthenticator.INSTANCE); - final PasswordAuthenticator delegate = ValidateUtils.checkNotNull(sshd.getPasswordAuthenticator(), "No password authenticator"); + PasswordAuthenticator delegate = Objects.requireNonNull(sshd.getPasswordAuthenticator(), "No password authenticator"); sshd.setPasswordAuthenticator((username, password, session) -> { try { Thread.sleep(AUTH_TIMEOUT + 150L); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java index 007206a..2becc76 100644 --- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java @@ -88,7 +88,6 @@ import org.apache.sshd.common.subsystem.sftp.extensions.VersionsParser.Versions; import org.apache.sshd.common.subsystem.sftp.extensions.openssh.AbstractOpenSSHExtensionParser.OpenSSHExtension; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.OsUtils; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.BufferUtils; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; import org.apache.sshd.common.util.io.IoUtils; @@ -1481,8 +1480,8 @@ public class SftpTest extends AbstractSftpClientTestSupport { private final boolean symLink; LinkData(Path src, Path target, boolean symLink) { - this.source = ValidateUtils.checkNotNull(src, "No source"); - this.target = ValidateUtils.checkNotNull(target, "No target"); + this.source = Objects.requireNonNull(src, "No source"); + this.target = Objects.requireNonNull(target, "No target"); this.symLink = symLink; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java index d83a9b6..fc44049 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java @@ -24,12 +24,12 @@ import java.util.Date; import java.util.EnumSet; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.TreeMap; import java.util.concurrent.TimeUnit; import org.apache.sshd.common.session.Session; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.util.test.BaseTestSupport; import org.junit.FixMethodOrder; import org.junit.Test; @@ -50,7 +50,7 @@ public class PropertyResolverUtilsTest extends BaseTestSupport { final String propName = getCurrentTestName(); final String rootValue = getClass().getPackage().getName(); Session resolver = createMockSession(); - FactoryManager root = ValidateUtils.checkNotNull(resolver.getFactoryManager(), "No manager"); + FactoryManager root = Objects.requireNonNull(resolver.getFactoryManager(), "No manager"); assertNull("Unexpected root previous value", PropertyResolverUtils.updateProperty(root, propName, rootValue)); assertSame("Mismatched root value", rootValue, PropertyResolverUtils.getString(resolver, propName)); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java index 12b15fd..bcf3b8f 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java @@ -29,6 +29,7 @@ import java.util.EnumSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -463,7 +464,7 @@ public class AuthenticationTest extends BaseTestSupport { @Test // see SSHD-196 public void testAuthPasswordChangeRequest() throws Exception { - final PasswordAuthenticator delegate = ValidateUtils.checkNotNull(sshd.getPasswordAuthenticator(), "No password authenticator"); + final PasswordAuthenticator delegate = Objects.requireNonNull(sshd.getPasswordAuthenticator(), "No password authenticator"); final AtomicInteger attemptsCount = new AtomicInteger(0); sshd.setPasswordAuthenticator((username, password, session) -> { if (attemptsCount.incrementAndGet() == 1) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java index 2488b14..ae8483e 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java @@ -32,11 +32,11 @@ import java.nio.file.OpenOption; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.apache.sshd.common.cipher.ECCurves; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.SecurityUtils; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.io.IoUtils; import org.apache.sshd.common.util.io.NoCloseInputStream; import org.apache.sshd.common.util.io.NoCloseReader; @@ -74,7 +74,7 @@ public abstract class AuthorizedKeysTestSupport extends BaseTestSupport { protected List<String> loadDefaultSupportedKeys() throws IOException { return loadSupportedKeys( - ValidateUtils.checkNotNull( + Objects.requireNonNull( getClass().getResource(AuthorizedKeysAuthenticator.STD_AUTHORIZED_KEYS_FILENAME), "Missing resource=" + AuthorizedKeysAuthenticator.STD_AUTHORIZED_KEYS_FILENAME)); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java index c342ea6..410e1f6 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java @@ -33,10 +33,10 @@ import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; +import java.util.Objects; import java.util.Random; import java.util.TreeSet; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.util.test.Utils; import org.junit.BeforeClass; import org.junit.FixMethodOrder; @@ -62,18 +62,20 @@ public class RootedFileSystemProviderTest extends AssertableFile { } @BeforeClass - public static void onlyOnce() throws IOException { - Path targetFolder = ValidateUtils.checkNotNull( + public static void initializeFileSystem() throws IOException { + Path targetFolder = Objects.requireNonNull( Utils.detectTargetFolder(RootedFileSystemProviderTest.class), "Failed to detect target folder").toPath(); rootSandbox = FileHelper.createTestSandbox(targetFolder.resolve(TEMP_SUBFOLDER_NAME)); - fileSystem = (RootedFileSystem) new RootedFileSystemProvider().newFileSystem(rootSandbox, - Collections.emptyMap()); + fileSystem = (RootedFileSystem) new RootedFileSystemProvider().newFileSystem(rootSandbox, Collections.emptyMap()); } @Test public void testRoot() { - assertTrue(exists(fileSystem.getRoot()) && isDir(fileSystem.getRoot()) && isReadable(fileSystem.getRoot()) - && isRootedAt(rootSandbox, fileSystem.getRoot())); + Path root = fileSystem.getRoot(); + assertTrue("Exists? " + root, exists(root)); + assertTrue("Dir? " + root, isDir(root)); + assertTrue("Readable? " + root, isReadable(root)); + assertTrue(root + " rooted at " + rootSandbox + " ?", isRootedAt(rootSandbox, root)); } /* mkdir */ http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java index a0f28f5..fdba7cc 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java @@ -31,6 +31,7 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingDeque; @@ -41,6 +42,7 @@ import java.util.concurrent.atomic.AtomicReference; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; + import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.service.IoAcceptor; import org.apache.mina.core.service.IoHandlerAdapter; @@ -54,7 +56,6 @@ import org.apache.sshd.common.FactoryManager; import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.session.ConnectionService; import org.apache.sshd.common.util.GenericUtils; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.net.SshdSocketAddress; import org.apache.sshd.server.SshServer; import org.apache.sshd.server.forward.AcceptAllForwardingFilter; @@ -161,7 +162,7 @@ public class PortForwardingTest extends BaseTestSupport { REQUESTS_QUEUE.clear(); } - final TcpipForwarderFactory factory = ValidateUtils.checkNotNull(sshd.getTcpipForwarderFactory(), "No TcpipForwarderFactory"); + TcpipForwarderFactory factory = Objects.requireNonNull(sshd.getTcpipForwarderFactory(), "No TcpipForwarderFactory"); sshd.setTcpipForwarderFactory(new TcpipForwarderFactory() { private final Class<?>[] interfaces = {TcpipForwarder.class}; private final Map<String, String> method2req = http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java index c8a8b24..cc41c86 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.apache.sshd.common.Factory; import org.apache.sshd.common.util.GenericUtils; @@ -50,7 +51,7 @@ public class MacVectorsTest extends BaseTestSupport { private final byte[] expected; public MacVectorsTest(VectorSeed seed, String factoryName, String expected) { - this.seed = ValidateUtils.checkNotNull(seed, "No seed"); + this.seed = Objects.requireNonNull(seed, "No seed"); this.macFactory = ValidateUtils.checkNotNull(BuiltinMacs.fromFactoryName(factoryName), "Unknown MAC: %s", factoryName); this.expected = BufferUtils.decodeHex(BufferUtils.EMPTY_HEX_SEPARATOR, expected); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/deprecated/AbstractUserAuth.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/AbstractUserAuth.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/AbstractUserAuth.java index 1b891e7..7bccef6 100644 --- a/sshd-core/src/test/java/org/apache/sshd/deprecated/AbstractUserAuth.java +++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/AbstractUserAuth.java @@ -18,10 +18,11 @@ */ package org.apache.sshd.deprecated; +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; import org.apache.sshd.common.util.logging.AbstractLoggingBean; /** @@ -33,7 +34,7 @@ public abstract class AbstractUserAuth private final String service; protected AbstractUserAuth(ClientSession session, String service) { - this.session = ValidateUtils.checkNotNull(session, "No client session"); + this.session = Objects.requireNonNull(session, "No client session"); this.service = service; } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java index 5f025cc..f72e72f 100644 --- a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java +++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java @@ -85,7 +85,7 @@ public class UserAuthAgent extends AbstractUserAuth { } catch (IOException e) { throw e; } catch (Exception e) { - throw (IOException) new IOException("Error performing public key authentication", e); + throw new IOException("Error performing public key authentication", e); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java index dd73fbd..5ca0afe 100644 --- a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java +++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java @@ -89,7 +89,7 @@ public class UserAuthPublicKey extends AbstractUserAuth { } catch (IOException e) { throw e; } catch (Exception e) { - throw (IOException) new IOException("Error performing public key authentication", e); + throw new IOException("Error performing public key authentication", e); } } else { int cmd = buffer.getUByte(); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java index 58e4407..eff05da 100644 --- a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java @@ -29,13 +29,13 @@ import java.util.Collections; import java.util.Date; import java.util.EnumSet; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.sshd.common.channel.PtyMode; 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.util.test.BaseTestSupport; import org.junit.FixMethodOrder; @@ -60,7 +60,7 @@ public class TtyFilterInputStreamTest extends BaseTestSupport { private final PtyMode mode; public TtyFilterInputStreamTest(PtyMode mode) { - this.mode = ValidateUtils.checkNotNull(mode, "No test modes"); + this.mode = Objects.requireNonNull(mode, "No test modes"); } @Parameters(name = "mode={0}") http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java index 5b41665..7271813 100644 --- a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java @@ -30,10 +30,10 @@ import java.util.Collections; import java.util.Date; import java.util.EnumSet; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import org.apache.sshd.common.channel.PtyMode; -import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.util.test.BaseTestSupport; import org.junit.FixMethodOrder; import org.junit.Test; @@ -51,7 +51,7 @@ public class TtyFilterOutputStreamTest extends BaseTestSupport { private final PtyMode mode; public TtyFilterOutputStreamTest(PtyMode mode) { - this.mode = ValidateUtils.checkNotNull(mode, "No test modes"); + this.mode = Objects.requireNonNull(mode, "No test modes"); } @Parameters(name = "mode={0}") http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java b/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java index 7c328a1..6287a50 100644 --- a/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java +++ b/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java @@ -29,6 +29,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -307,7 +308,7 @@ public final class SshFsMounter { props.putAll(options); sshd.setPort(port); - File targetFolder = ValidateUtils.checkNotNull(Utils.detectTargetFolder(MounterCommandFactory.class), "Failed to detect target folder"); + File targetFolder = Objects.requireNonNull(Utils.detectTargetFolder(MounterCommandFactory.class), "Failed to detect target folder"); if (SecurityUtils.isBouncyCastleRegistered()) { sshd.setKeyPairProvider(SecurityUtils.createGeneratorHostKeyProvider(new File(targetFolder, "key.pem").toPath())); } else { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java index a0fd825..5403173 100644 --- a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java +++ b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java @@ -45,12 +45,12 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.TimeUnit; import org.apache.sshd.client.SshClient; import org.apache.sshd.common.keyprovider.KeyPairProvider; 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.net.SshdSocketAddress; import org.apache.sshd.server.SshServer; @@ -161,7 +161,7 @@ public abstract class BaseTestSupport extends Assert { protected Path getTempTargetFolder() { synchronized (TEMP_SUBFOLDER_NAME) { if (tempFolder == null) { - tempFolder = ValidateUtils.checkNotNull(detectTargetFolder(), "No target folder detected").resolve(TEMP_SUBFOLDER_NAME); + tempFolder = Objects.requireNonNull(detectTargetFolder(), "No target folder detected").resolve(TEMP_SUBFOLDER_NAME); } } @@ -202,7 +202,7 @@ public abstract class BaseTestSupport extends Assert { protected Path detectTargetFolder() throws IllegalArgumentException { synchronized (TEMP_SUBFOLDER_NAME) { if (targetFolder == null) { - targetFolder = ValidateUtils.checkNotNull(Utils.detectTargetFolder(getClass()), "Failed to detect target folder").toPath(); + targetFolder = Objects.requireNonNull(Utils.detectTargetFolder(getClass()), "Failed to detect target folder").toPath(); } } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java ---------------------------------------------------------------------- diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java index 063badb..8aada83 100644 --- a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java +++ b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java @@ -45,6 +45,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; @@ -123,7 +124,7 @@ public final class Utils { return provider; } - File targetFolder = ValidateUtils.checkNotNull(detectTargetFolder(anchor), "Failed to detect target folder"); + File targetFolder = Objects.requireNonNull(detectTargetFolder(anchor), "Failed to detect target folder"); File file = new File(targetFolder, "hostkey." + DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM.toLowerCase()); provider = createTestHostKeyProvider(file); @@ -136,26 +137,26 @@ public final class Utils { } public static KeyPairProvider createTestHostKeyProvider(File file) { - return createTestHostKeyProvider(ValidateUtils.checkNotNull(file, "No file").toPath()); + return createTestHostKeyProvider(Objects.requireNonNull(file, "No file").toPath()); } public static KeyPairProvider createTestHostKeyProvider(Path path) { SimpleGeneratorHostKeyProvider keyProvider = new SimpleGeneratorHostKeyProvider(); - keyProvider.setPath(ValidateUtils.checkNotNull(path, "No path")); + keyProvider.setPath(Objects.requireNonNull(path, "No path")); keyProvider.setAlgorithm(DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM); return validateKeyPairProvider(keyProvider); } public static KeyPair getFirstKeyPair(KeyPairProviderHolder holder) { - return getFirstKeyPair(ValidateUtils.checkNotNull(holder, "No holder").getKeyPairProvider()); + return getFirstKeyPair(Objects.requireNonNull(holder, "No holder").getKeyPairProvider()); } public static KeyPair getFirstKeyPair(KeyIdentityProvider provider) { - ValidateUtils.checkNotNull(provider, "No key pair provider"); - Iterable<? extends KeyPair> pairs = ValidateUtils.checkNotNull(provider.loadKeys(), "No loaded keys"); - Iterator<? extends KeyPair> iter = ValidateUtils.checkNotNull(pairs.iterator(), "No keys iterator"); + Objects.requireNonNull(provider, "No key pair provider"); + Iterable<? extends KeyPair> pairs = Objects.requireNonNull(provider.loadKeys(), "No loaded keys"); + Iterator<? extends KeyPair> iter = Objects.requireNonNull(pairs.iterator(), "No keys iterator"); ValidateUtils.checkTrue(iter.hasNext(), "Empty loaded kyes iterator"); - return ValidateUtils.checkNotNull(iter.next(), "No key pair in iterator"); + return Objects.requireNonNull(iter.next(), "No key pair in iterator"); } public static KeyPair generateKeyPair(String algorithm, int keySize) throws GeneralSecurityException { @@ -194,10 +195,10 @@ public final class Utils { } private static <P extends KeyIdentityProvider> P validateKeyPairProvider(P provider) { - ValidateUtils.checkNotNull(provider, "No provider"); + Objects.requireNonNull(provider, "No provider"); // get the I/O out of the way - Iterable<KeyPair> keys = ValidateUtils.checkNotNull(provider.loadKeys(), "No keys loaded"); + Iterable<KeyPair> keys = Objects.requireNonNull(provider.loadKeys(), "No keys loaded"); if (keys instanceof Collection<?>) { ValidateUtils.checkNotNullAndNotEmpty((Collection<?>) keys, "Empty keys loaded"); } http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java ---------------------------------------------------------------------- diff --git a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java index 3e4ae13..1f2b4db 100644 --- a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java +++ b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java @@ -23,11 +23,11 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Collection; import java.util.EnumSet; +import java.util.Objects; import java.util.concurrent.TimeUnit; import org.apache.sshd.client.channel.ChannelExec; import org.apache.sshd.client.channel.ClientChannelEvent; -import org.apache.sshd.common.util.ValidateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +41,7 @@ public class GitSshdSessionProcess extends Process { protected final Logger log; public GitSshdSessionProcess(ChannelExec channel, String commandName, int timeoutSec) { - this.channel = ValidateUtils.checkNotNull(channel, "No exec channel"); + this.channel = Objects.requireNonNull(channel, "No exec channel"); this.commandName = commandName; this.waitTimeout = (timeoutSec > 0) ? TimeUnit.SECONDS.toMillis(timeoutSec) : Long.MAX_VALUE; this.log = LoggerFactory.getLogger(getClass()); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-ldap/src/main/java/org/apache/sshd/common/util/net/LdapNetworkConnector.java ---------------------------------------------------------------------- diff --git a/sshd-ldap/src/main/java/org/apache/sshd/common/util/net/LdapNetworkConnector.java b/sshd-ldap/src/main/java/org/apache/sshd/common/util/net/LdapNetworkConnector.java index 24f8291..9dbd853 100644 --- a/sshd-ldap/src/main/java/org/apache/sshd/common/util/net/LdapNetworkConnector.java +++ b/sshd-ldap/src/main/java/org/apache/sshd/common/util/net/LdapNetworkConnector.java @@ -286,7 +286,7 @@ public class LdapNetworkConnector<C> extends NetworkConnector { } public void setAuthenticationMode(String mode) { - ldapEnv.put(Context.SECURITY_AUTHENTICATION, ValidateUtils.checkNotNull(mode, "No authentication mode")); + ldapEnv.put(Context.SECURITY_AUTHENTICATION, Objects.requireNonNull(mode, "No authentication mode")); } /** @@ -427,12 +427,12 @@ public class LdapNetworkConnector<C> extends NetworkConnector { if (!anonymous) { Object[] bindParams = {username, password}; if (!env.containsKey(Context.SECURITY_PRINCIPAL)) { - String bindDN = ValidateUtils.checkNotNull(bindDNPattern, "No bind DN pattern").format(bindParams); + String bindDN = Objects.requireNonNull(bindDNPattern, "No bind DN pattern").format(bindParams); env.put(Context.SECURITY_PRINCIPAL, ValidateUtils.checkNotNullAndNotEmpty(bindDN, "No bind DN")); } if (!env.containsKey(Context.SECURITY_CREDENTIALS)) { - String bindPassword = ValidateUtils.checkNotNull(bindPasswordPattern, "No bind password pattern").format(bindParams); + String bindPassword = Objects.requireNonNull(bindPasswordPattern, "No bind password pattern").format(bindParams); env.put(Context.SECURITY_CREDENTIALS, ValidateUtils.checkNotNullAndNotEmpty(bindPassword, "No bind password")); } } @@ -442,12 +442,12 @@ public class LdapNetworkConnector<C> extends NetworkConnector { protected String resolveBaseDN(C queryContext, Map<?, ?> ldapConfig, String username, String password) throws NamingException { Object[] bindParams = {username, password}; - return ValidateUtils.checkNotNull(baseDNPattern, "No base DN pattern").format(bindParams); + return Objects.requireNonNull(baseDNPattern, "No base DN pattern").format(bindParams); } protected String resolveSearchFilter(C queryContext, Map<?, ?> ldapConfig, String username, String password) throws NamingException { Object[] bindParams = {username, password}; - return ValidateUtils.checkNotNull(searchFilterPattern, "No search filter pattern").format(bindParams); + return Objects.requireNonNull(searchFilterPattern, "No search filter pattern").format(bindParams); } protected void processSearchResult(C queryContext, Map<?, ?> ldapConfig, Map<String, Object> attrsMap, http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-ldap/src/main/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticator.java ---------------------------------------------------------------------- diff --git a/sshd-ldap/src/main/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticator.java b/sshd-ldap/src/main/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticator.java index b0b07fb..c976ced 100644 --- a/sshd-ldap/src/main/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticator.java +++ b/sshd-ldap/src/main/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticator.java @@ -199,7 +199,7 @@ public class LdapPublickeyAuthenticator extends LdapAuthenticator implements Pub } AuthorizedKeyEntry entry = AuthorizedKeyEntry.parseAuthorizedKeyEntry(Objects.toString(keyData, null)); - PublicKey key = ValidateUtils.checkNotNull(entry, "No key extracted").resolvePublicKey(PublicKeyEntryResolver.FAILING); + PublicKey key = Objects.requireNonNull(entry, "No key extracted").resolvePublicKey(PublicKeyEntryResolver.FAILING); if (log.isTraceEnabled()) { log.trace("parsePublicKeyValue({}@{}) {}-{}", username, session, KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key)); http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java ---------------------------------------------------------------------- diff --git a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java index 2d0d19e..2af8455 100644 --- a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java +++ b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java @@ -23,6 +23,7 @@ import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.apache.directory.server.constants.ServerDNConstants; import org.apache.directory.server.core.CoreSession; @@ -97,7 +98,7 @@ public abstract class BaseAuthenticatorTest extends BaseTestSupport { @SuppressWarnings("checkstyle:avoidnestedblocks") public static Pair<LdapServer, DirectoryService> startApacheDs(Class<?> anchor) throws Exception { Logger log = LoggerFactory.getLogger(anchor); - File targetFolder = ValidateUtils.checkNotNull(Utils.detectTargetFolder(anchor), "Failed to detect target folder"); + File targetFolder = Objects.requireNonNull(Utils.detectTargetFolder(anchor), "Failed to detect target folder"); File workingDirectory = assertHierarchyTargetFolderExists(Utils.deleteRecursive(Utils.resolve(targetFolder, anchor.getSimpleName(), "apacheds-work"))); DirectoryService directoryService = new DefaultDirectoryService(); @@ -177,9 +178,9 @@ public abstract class BaseAuthenticatorTest extends BaseTestSupport { // see http://users.directory.apache.narkive.com/GkyqAkot/how-to-import-ldif-file-programmatically public static Map<String, String> populateUsers(DirectoryService service, Class<?> anchor, String credentialName) throws Exception { Logger log = LoggerFactory.getLogger(anchor); - CoreSession session = ValidateUtils.checkNotNull(service.getAdminSession(), "No core session"); + CoreSession session = Objects.requireNonNull(service.getAdminSession(), "No core session"); Map<String, String> usersMap = new HashMap<>(); - try (LdifReader reader = new LdifReader(ValidateUtils.checkNotNull(anchor.getResourceAsStream("/auth-users.ldif"), "No users ldif"))) { + try (LdifReader reader = new LdifReader(Objects.requireNonNull(anchor.getResourceAsStream("/auth-users.ldif"), "No users ldif"))) { int id = 1; for (LdifEntry entry : reader) { if (log.isDebugEnabled()) { http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f56963c4/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java ---------------------------------------------------------------------- diff --git a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java index 6eb12fd..bb2ecdd 100644 --- a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java +++ b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java @@ -22,6 +22,7 @@ package org.apache.sshd.server.auth.pubkey; import java.security.PublicKey; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import org.apache.directory.server.core.DirectoryService; @@ -31,7 +32,6 @@ import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.config.keys.PublicKeyEntryResolver; 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.server.auth.BaseAuthenticatorTest; import org.apache.sshd.server.session.ServerSession; import org.junit.AfterClass; @@ -65,7 +65,7 @@ public class LdapPublickeyAuthenticatorTest extends BaseAuthenticatorTest { for (Map.Entry<String, String> ce : credentials.entrySet()) { String username = ce.getKey(); AuthorizedKeyEntry entry = AuthorizedKeyEntry.parseAuthorizedKeyEntry(ce.getValue()); - PublicKey key = ValidateUtils.checkNotNull(entry, "No key extracted").resolvePublicKey(PublicKeyEntryResolver.FAILING); + PublicKey key = Objects.requireNonNull(entry, "No key extracted").resolvePublicKey(PublicKeyEntryResolver.FAILING); KEYS_MAP.put(username, key); } }
