You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2015/07/17 18:18:40 UTC
[20/25] mina-sshd git commit: [SSHD-542] Checkstyle validation
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/OpenSSHStatPathExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/OpenSSHStatPathExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/OpenSSHStatPathExtension.java
index a2450af..a268f1f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/OpenSSHStatPathExtension.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/OpenSSHStatPathExtension.java
@@ -25,6 +25,7 @@ import org.apache.sshd.client.subsystem.sftp.extensions.SftpClientExtension;
/**
* Implements the "statvfs@openssh.com" extension command
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
* @see <A HREF="http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/ssh/PROTOCOL?rev=1.28&content-type=text/plain">OpenSSH section 3.4</A>
*/
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java
index 51b6817..23d4e80 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/AbstractOpenSSHStatCommandExtension.java
@@ -34,17 +34,17 @@ import org.apache.sshd.common.util.buffer.BufferUtils;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public abstract class AbstractOpenSSHStatCommandExtension extends AbstractSftpClientExtension {
- protected AbstractOpenSSHStatCommandExtension(String name, SftpClient client, RawSftpClient raw, Map<String,byte[]> extensions) {
+ protected AbstractOpenSSHStatCommandExtension(String name, SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
super(name, client, raw, extensions);
}
-
+
protected OpenSSHStatExtensionInfo doGetStat(Object target) throws IOException {
Buffer buffer = getCommandBuffer(target);
putTarget(buffer, target);
-
+
if (log.isDebugEnabled()) {
log.debug("doGetStat({})[{}]", getName(),
- (target instanceof CharSequence) ? target : BufferUtils.printHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target));
+ (target instanceof CharSequence) ? target : BufferUtils.printHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target));
}
buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java
index 5032fc0..207962d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHFsyncExtensionImpl.java
@@ -35,7 +35,7 @@ import org.apache.sshd.common.util.buffer.Buffer;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class OpenSSHFsyncExtensionImpl extends AbstractSftpClientExtension implements OpenSSHFsyncExtension {
- public OpenSSHFsyncExtensionImpl(SftpClient client, RawSftpClient raw, Map<String,byte[]> extensions) {
+ public OpenSSHFsyncExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
super(FsyncExtensionParser.NAME, client, raw, extensions);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java
index ec0ab90..355eec4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatHandleExtensionImpl.java
@@ -33,7 +33,7 @@ import org.apache.sshd.common.subsystem.sftp.extensions.openssh.FstatVfsExtensio
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class OpenSSHStatHandleExtensionImpl extends AbstractOpenSSHStatCommandExtension implements OpenSSHStatHandleExtension {
- public OpenSSHStatHandleExtensionImpl(SftpClient client, RawSftpClient raw, Map<String,byte[]> extensions) {
+ public OpenSSHStatHandleExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
super(FstatVfsExtensionParser.NAME, client, raw, extensions);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java
index 7ed085c..cf3a215 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/impl/OpenSSHStatPathExtensionImpl.java
@@ -32,7 +32,7 @@ import org.apache.sshd.common.subsystem.sftp.extensions.openssh.StatVfsExtension
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class OpenSSHStatPathExtensionImpl extends AbstractOpenSSHStatCommandExtension implements OpenSSHStatPathExtension {
- public OpenSSHStatPathExtensionImpl(SftpClient client, RawSftpClient raw, Map<String,byte[]> extensions) {
+ public OpenSSHStatPathExtensionImpl(SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
super(StatVfsExtensionParser.NAME, client, raw, extensions);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
index 4a3598f..67de78e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/AbstractFactoryManager.java
@@ -45,7 +45,6 @@ import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.session.SessionTimeoutListener;
import org.apache.sshd.common.signature.Signature;
import org.apache.sshd.common.util.CloseableUtils;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.threads.ThreadUtils;
import org.apache.sshd.server.forward.ForwardingFilter;
@@ -57,7 +56,7 @@ import org.apache.sshd.server.forward.ForwardingFilter;
*/
public abstract class AbstractFactoryManager extends CloseableUtils.AbstractInnerCloseable implements FactoryManager {
- protected Map<String,Object> properties = new HashMap<String,Object>();
+ protected Map<String, Object> properties = new HashMap<String, Object>();
protected IoServiceFactoryFactory ioServiceFactoryFactory;
protected IoServiceFactory ioServiceFactory;
protected List<NamedFactory<KeyExchange>> keyExchangeFactories;
@@ -188,7 +187,7 @@ public abstract class AbstractFactoryManager extends CloseableUtils.AbstractInne
}
public int getNioWorkers() {
- int nb=FactoryManagerUtils.getIntProperty(this, NIO_WORKERS, DEFAULT_NIO_WORKERS);
+ int nb = FactoryManagerUtils.getIntProperty(this, NIO_WORKERS, DEFAULT_NIO_WORKERS);
if (nb > 0) {
return nb;
} else { // it may have been configured to a negative value
@@ -303,7 +302,7 @@ public abstract class AbstractFactoryManager extends CloseableUtils.AbstractInne
}
sessionTimeoutListener = null;
}
-
+
protected void checkConfig() {
ValidateUtils.checkNotNullAndNotEmpty(getKeyExchangeFactories(), "KeyExchangeFactories not set");
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
index c79acbc..f4629d8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
@@ -49,9 +49,89 @@ import org.apache.sshd.server.forward.RejectAllForwardingFilter;
/**
* Base class for dedicated client/server instance builders
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder<T, S>> implements ObjectBuilder<T> {
+
+ // Compression is not enabled by default
+ public static final List<NamedFactory<Compression>> DEFAULT_COMPRESSION_FACTORIES =
+ Collections.unmodifiableList(Arrays.<NamedFactory<Compression>>asList(BuiltinCompressions.none));
+
+ public static final FileSystemFactory DEFAULT_FILE_SYSTEM_FACTORY = NativeFileSystemFactory.INSTANCE;
+
+ public static final ForwardingFilter DEFAULT_FORWARDING_FILTER = RejectAllForwardingFilter.INSTANCE;
+
+ public static final TcpipForwarderFactory DEFAULT_FORWARDER_FACTORY = DefaultTcpipForwarderFactory.INSTANCE;
+
+ /**
+ * The default {@link BuiltinCiphers} setup in order of preference
+ * as specified by <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">
+ * ssh_config(5)</A>
+ */
+ public static final List<BuiltinCiphers> DEFAULT_CIPHERS_PREFERENCE =
+ Collections.unmodifiableList(Arrays.asList(
+ BuiltinCiphers.aes128ctr,
+ BuiltinCiphers.aes192ctr,
+ BuiltinCiphers.aes256ctr,
+ BuiltinCiphers.arcfour256,
+ BuiltinCiphers.arcfour128,
+ BuiltinCiphers.aes128cbc,
+ BuiltinCiphers.tripledescbc,
+ BuiltinCiphers.blowfishcbc,
+ // TODO add support for cast128-cbc cipher
+ BuiltinCiphers.aes192cbc,
+ BuiltinCiphers.aes256cbc
+ // TODO add support for arcfour cipher
+ ));
+
+ /**
+ * The default {@link BuiltinDHFactories} setup in order of preference
+ * as specified by <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">
+ * ssh_config(5)</A>
+ */
+ public static final List<BuiltinDHFactories> DEFAULT_KEX_PREFERENCE =
+ Collections.unmodifiableList(Arrays.asList(
+ BuiltinDHFactories.ecdhp521,
+ BuiltinDHFactories.ecdhp384,
+ BuiltinDHFactories.ecdhp256,
+
+ BuiltinDHFactories.dhgex256,
+ BuiltinDHFactories.dhgex,
+
+ BuiltinDHFactories.dhg14,
+ BuiltinDHFactories.dhg1
+ ));
+
+ /**
+ * The default {@link BuiltinMacs} setup in order of preference
+ * as specified by <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">
+ * ssh_config(5)</A>
+ */
+ public static final List<BuiltinMacs> DEFAULT_MAC_PREFERENCE =
+ Collections.unmodifiableList(Arrays.asList(
+ BuiltinMacs.hmacmd5,
+ BuiltinMacs.hmacsha1,
+ BuiltinMacs.hmacsha256,
+ BuiltinMacs.hmacsha512,
+ BuiltinMacs.hmacsha196,
+ BuiltinMacs.hmacmd596
+ ));
+
+ /**
+ * Preferred {@link BuiltinSignatures} according to
+ * <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5>sshd_config(5)</A>
+ * {@code HostKeyAlgorithms} recommendation
+ */
+ public static final List<BuiltinSignatures> DEFAULT_SIGNATURE_PREFERENCE =
+ Collections.unmodifiableList(Arrays.asList(
+ BuiltinSignatures.nistp256,
+ BuiltinSignatures.nistp384,
+ BuiltinSignatures.nistp521,
+ BuiltinSignatures.rsa,
+ BuiltinSignatures.dsa
+ ));
+
protected Factory<T> factory;
protected List<NamedFactory<KeyExchange>> keyExchangeFactories;
protected List<NamedFactory<Cipher>> cipherFactories;
@@ -69,13 +149,6 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
super();
}
- // Compression is not enabled by default
- public static final List<NamedFactory<Compression>> DEFAULT_COMPRESSION_FACTORIES =
- Collections.unmodifiableList(Arrays.<NamedFactory<Compression>>asList(BuiltinCompressions.none));
- public static final FileSystemFactory DEFAULT_FILE_SYSTEM_FACTORY = NativeFileSystemFactory.INSTANCE;
- public static final ForwardingFilter DEFAULT_FORWARDING_FILTER = RejectAllForwardingFilter.INSTANCE;
- public static final TcpipForwarderFactory DEFAULT_FORWARDER_FACTORY = DefaultTcpipForwarderFactory.INSTANCE;
-
protected S fillWithDefaultValues() {
if (signatureFactories == null) {
signatureFactories = setUpDefaultSignatures(false);
@@ -204,32 +277,10 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
}
/**
- * The default {@link BuiltinCiphers} setup in order of preference
- * as specified by <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">
- * ssh_config(5)</A>
- */
- public static final List<BuiltinCiphers> DEFAULT_CIPHERS_PREFERENCE =
- Collections.unmodifiableList(
- Arrays.asList(
- BuiltinCiphers.aes128ctr,
- BuiltinCiphers.aes192ctr,
- BuiltinCiphers.aes256ctr,
- BuiltinCiphers.arcfour256,
- BuiltinCiphers.arcfour128,
- BuiltinCiphers.aes128cbc,
- BuiltinCiphers.tripledescbc,
- BuiltinCiphers.blowfishcbc,
- // TODO add support for cast128-cbc cipher
- BuiltinCiphers.aes192cbc,
- BuiltinCiphers.aes256cbc
- // TODO add support for arcfour cipher
- ));
-
- /**
* @param ignoreUnsupported If {@code true} then all the default
- * ciphers are included, regardless of whether they are currently
- * supported by the JCE. Otherwise, only the supported ones out of the
- * list are included
+ * ciphers are included, regardless of whether they are currently
+ * supported by the JCE. Otherwise, only the supported ones out of the
+ * list are included
* @return A {@link List} of the default {@link NamedFactory}
* instances of the {@link Cipher}s according to the preference
* order defined by {@link #DEFAULT_CIPHERS_PREFERENCE}.
@@ -240,45 +291,11 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
public static List<NamedFactory<Cipher>> setUpDefaultCiphers(boolean ignoreUnsupported) {
return NamedFactory.Utils.setUpBuiltinFactories(ignoreUnsupported, DEFAULT_CIPHERS_PREFERENCE);
}
-
- /**
- * The default {@link BuiltinDHFactories} setup in order of preference
- * as specified by <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">
- * ssh_config(5)</A>
- */
- public static final List<BuiltinDHFactories> DEFAULT_KEX_PREFERENCE=
- Collections.unmodifiableList(
- Arrays.asList(
- BuiltinDHFactories.ecdhp521,
- BuiltinDHFactories.ecdhp384,
- BuiltinDHFactories.ecdhp256,
-
- BuiltinDHFactories.dhgex256,
- BuiltinDHFactories.dhgex,
-
- BuiltinDHFactories.dhg14,
- BuiltinDHFactories.dhg1
- ));
/**
- * The default {@link BuiltinMacs} setup in order of preference
- * as specified by <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">
- * ssh_config(5)</A>
- */
- public static final List<BuiltinMacs> DEFAULT_MAC_PREFERENCE=
- Collections.unmodifiableList(
- Arrays.asList(
- BuiltinMacs.hmacmd5,
- BuiltinMacs.hmacsha1,
- BuiltinMacs.hmacsha256,
- BuiltinMacs.hmacsha512,
- BuiltinMacs.hmacsha196,
- BuiltinMacs.hmacmd596
- ));
- /**
* @param ignoreUnsupported If {@code true} all the available built-in
- * {@link Mac} factories are added, otherwise only those that are supported
- * by the current JDK setup
+ * {@link Mac} factories are added, otherwise only those that are supported
+ * by the current JDK setup
* @return A {@link List} of the default {@link NamedFactory}
* instances of the {@link Mac}s according to the preference
* order defined by {@link #DEFAULT_MAC_PREFERENCE}.
@@ -289,26 +306,11 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
public static List<NamedFactory<Mac>> setUpDefaultMacs(boolean ignoreUnsupported) {
return NamedFactory.Utils.setUpBuiltinFactories(ignoreUnsupported, DEFAULT_MAC_PREFERENCE);
}
-
- /**
- * Preferred {@link BuiltinSignatures} according to
- * <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5>sshd_config(5)</A>
- * {@code HostKeyAlgorithms} recommendation
- */
- public static final List<BuiltinSignatures> DEFAULT_SIGNATURE_PREFERENCE=
- Collections.unmodifiableList(
- Arrays.asList(
- BuiltinSignatures.nistp256,
- BuiltinSignatures.nistp384,
- BuiltinSignatures.nistp521,
- BuiltinSignatures.rsa,
- BuiltinSignatures.dsa
- ));
/**
* @param ignoreUnsupported If {@code true} all the available built-in
- * {@link Signature} factories are added, otherwise only those that are supported
- * by the current JDK setup
+ * {@link Signature} factories are added, otherwise only those that are supported
+ * by the current JDK setup
* @return A {@link List} of the default {@link NamedFactory}
* instances of the {@link Signature}s according to the preference
* order defined by {@link #DEFAULT_SIGNATURE_PREFERENCE}.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/BuiltinFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/BuiltinFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/BuiltinFactory.java
new file mode 100644
index 0000000..788a4ca
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/BuiltinFactory.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A named optional factory.
+ *
+ * @param <T> The create object instance type
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public interface BuiltinFactory<T> extends NamedFactory<T>, OptionalFeature {
+
+ final class Utils {
+
+ private Utils() {
+ throw new UnsupportedOperationException("No instance allowed");
+ }
+
+ public static <T, E extends BuiltinFactory<T>> List<NamedFactory<T>> setUpFactories(
+ boolean ignoreUnsupported, Collection<? extends E> preferred) {
+ List<NamedFactory<T>> avail = new ArrayList<>(preferred.size());
+ for (E f : preferred) {
+ if (ignoreUnsupported || f.isSupported()) {
+ avail.add(f);
+ }
+ }
+ return avail;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/Factory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/Factory.java b/sshd-core/src/main/java/org/apache/sshd/common/Factory.java
index 3d3590e..5fccf45 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/Factory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/Factory.java
@@ -23,7 +23,6 @@ package org.apache.sshd.common;
* Fatory is a simple interface that is used to create other objects.
*
* @param <T> type of objets this factory will create
- *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface Factory<T> {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/FactoryManager.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/FactoryManager.java b/sshd-core/src/main/java/org/apache/sshd/common/FactoryManager.java
index bdb63d3..b9ed1e6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/FactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/FactoryManager.java
@@ -153,6 +153,12 @@ public interface FactoryManager {
String NIO2_READ_BUFFER_SIZE = "nio2-read-buf-size";
/**
+ * The default reported version of {@link #getVersion()} if the built-in
+ * version information cannot be accessed
+ */
+ String DEFAULT_VERSION = "SSHD-UNKNOWN";
+
+ /**
* <P>A map of properties that can be used to configure the SSH server
* or client. This map will never be changed by either the server or
* client and is not supposed to be changed at runtime (changes are not
@@ -167,21 +173,17 @@ public interface FactoryManager {
* value is a {@code long} then it will be parsed into one. Also, if
* the mapped value is an {@code Integer} but a {@code long} is expected,
* then it will be converted into one.
+ *
* @return a valid <code>Map</code> containing configuration values, never {@code null}
*/
- Map<String,Object> getProperties();
-
- /**
- * The default reported version of {@link #getVersion()} if the built-in
- * version information cannot be accessed
- */
- String DEFAULT_VERSION = "SSHD-UNKNOWN";
+ Map<String, Object> getProperties();
/**
* An upper case string identifying the version of the
* software used on client or server side.
* This version includes the name of the software and usually
* looks like: <code>SSHD-1.0</code>
+ *
* @return the version of the software
*/
String getVersion();
@@ -279,7 +281,7 @@ public interface FactoryManager {
* Retrieve the <code>FileSystemFactory</code> to be used to traverse the file system.
*
* @return a valid <code>FileSystemFactory</code> object or {@code null} if file based
- * interactions are not supported on this server
+ * interactions are not supported on this server
*/
FileSystemFactory getFileSystemFactory();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/FactoryManagerUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/FactoryManagerUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/FactoryManagerUtils.java
index 10ecbd9..f3eee61 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/FactoryManagerUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/FactoryManagerUtils.java
@@ -27,7 +27,12 @@ import org.apache.sshd.common.util.GenericUtils;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class FactoryManagerUtils {
+public final class FactoryManagerUtils {
+
+ private FactoryManagerUtils() {
+ throw new UnsupportedOperationException("No instance allowed");
+ }
+
/**
* @param session The {@link Session} instance
* @param name The property name
@@ -60,7 +65,7 @@ public class FactoryManagerUtils {
* @return The resolved property
* @throws NumberFormatException if malformed value
*/
- public static long getLongProperty(Map<String,?> props, String name, long defaultValue) {
+ public static long getLongProperty(Map<String, ?> props, String name, long defaultValue) {
Object value = GenericUtils.isEmpty(props) ? null : props.get(name);
if (value == null) {
return defaultValue;
@@ -98,7 +103,7 @@ public class FactoryManagerUtils {
* empty string
* @throws NumberFormatException if malformed value
*/
- public static Long getLong(Map<String,?> props, String name) {
+ public static Long getLong(Map<String, ?> props, String name) {
Object value = GenericUtils.isEmpty(props) ? null : props.get(name);
if (value == null) {
return null;
@@ -117,7 +122,7 @@ public class FactoryManagerUtils {
return updateProperty(manager.getProperties(), name, value);
}
- public static Object updateProperty(Map<String,Object> props, String name, long value) {
+ public static Object updateProperty(Map<String, Object> props, String name, long value) {
return updateProperty(props, name, Long.valueOf(value));
}
@@ -129,7 +134,7 @@ public class FactoryManagerUtils {
return getIntProperty(manager.getProperties(), name, defaultValue);
}
- public static int getIntProperty(Map<String,?> props, String name, int defaultValue) {
+ public static int getIntProperty(Map<String, ?> props, String name, int defaultValue) {
Object value = GenericUtils.isEmpty(props) ? null : props.get(name);
if (value == null) {
return defaultValue;
@@ -148,7 +153,7 @@ public class FactoryManagerUtils {
return getInteger(manager.getProperties(), name);
}
- public static Integer getInteger(Map<String,?> props, String name) {
+ public static Integer getInteger(Map<String, ?> props, String name) {
Object value = GenericUtils.isEmpty(props) ? null : props.get(name);
if (value == null) {
return null;
@@ -167,7 +172,7 @@ public class FactoryManagerUtils {
return updateProperty(manager.getProperties(), name, value);
}
- public static Object updateProperty(Map<String,Object> props, String name, int value) {
+ public static Object updateProperty(Map<String, Object> props, String name, int value) {
return updateProperty(props, name, Integer.valueOf(value));
}
@@ -179,7 +184,7 @@ public class FactoryManagerUtils {
return getBooleanProperty(manager.getProperties(), name, defaultValue);
}
- public static boolean getBooleanProperty(Map<String,?> props, String name, boolean defaultValue) {
+ public static boolean getBooleanProperty(Map<String, ?> props, String name, boolean defaultValue) {
Boolean value = getBoolean(props, name);
if (value == null) {
return defaultValue;
@@ -196,8 +201,8 @@ public class FactoryManagerUtils {
return getBoolean(manager.getProperties(), name);
}
- public static Boolean getBoolean(Map<String,?> props, String name) {
- Object value = GenericUtils.isEmpty(props) ? null : props.get(name);
+ public static Boolean getBoolean(Map<String, ?> props, String name) {
+ Object value = GenericUtils.isEmpty(props) ? null : props.get(name);
if (value == null) {
return null;
} else if (value instanceof Boolean) {
@@ -215,7 +220,7 @@ public class FactoryManagerUtils {
return updateProperty(manager.getProperties(), name, value);
}
- public static Object updateProperty(Map<String,Object> props, String name, boolean value) {
+ public static Object updateProperty(Map<String, Object> props, String name, boolean value) {
return updateProperty(props, name, Boolean.valueOf(value));
}
@@ -235,11 +240,11 @@ public class FactoryManagerUtils {
return getStringProperty(manager.getProperties(), name, defaultValue);
}
- public static String getString(Map<String,?> props, String name) {
+ public static String getString(Map<String, ?> props, String name) {
return getStringProperty(props, name, null);
}
- public static String getStringProperty(Map<String,?> props, String name, String defaultValue) {
+ public static String getStringProperty(Map<String, ?> props, String name, String defaultValue) {
Object value = GenericUtils.isEmpty(props) ? null : props.get(name);
String s = (value == null) ? null : value.toString();
if (GenericUtils.isEmpty(s)) {
@@ -261,10 +266,10 @@ public class FactoryManagerUtils {
* @param props The {@link Map} of properties to update
* @param name The property name
* @param value The property value - if {@code null}/empty then the
- * specified property is <U>removed</U> from the properties map
+ * specified property is <U>removed</U> from the properties map
* @return The removed or previous value (if any)
*/
- public static Object updateProperty(Map<String,Object> props, String name, Object value) {
+ public static Object updateProperty(Map<String, Object> props, String name, Object value) {
if ((value == null) || ((value instanceof CharSequence) && GenericUtils.isEmpty((CharSequence) value))) {
return props.remove(name);
} else {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
index 647fbbf..5eb6ff2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/NamedFactory.java
@@ -27,6 +27,7 @@ import org.apache.sshd.common.util.Transformer;
/**
* A named factory is a factory identified by a name.
* Such names are used mainly in the algorithm negotiation at the beginning of the SSH connection.
+ *
* @param <T> The create object instance type
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -35,16 +36,22 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
* Utility class to help using NamedFactories
*/
final class Utils {
+
+ private Utils() {
+ throw new UnsupportedOperationException("No instance allowed");
+ }
+
/**
* Create an instance of the specified name by looking up the needed factory
* in the list.
+ *
* @param factories list of available factories
- * @param name the factory name to use
- * @param <T> type of object to create
+ * @param name the factory name to use
+ * @param <T> type of object to create
* @return a newly created object or {@code null} if the factory is not in the list
*/
public static <T> T create(Collection<? extends NamedFactory<T>> factories, String name) {
- NamedFactory<? extends T> f=NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
+ NamedFactory<? extends T> f = NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, factories);
if (f != null) {
return f.create();
} else {
@@ -52,27 +59,26 @@ public interface NamedFactory<T> extends Factory<T>, NamedResource {
}
}
- public static <S extends OptionalFeature,T,E extends NamedFactory<T>> List<NamedFactory<T>> setUpTransformedFactories(
- boolean ignoreUnsupported, Collection<? extends S> preferred, Transformer<? super S,? extends E> xform) {
- List<NamedFactory<T>> avail=new ArrayList<>(preferred.size());
+ public static <S extends OptionalFeature, T, E extends NamedFactory<T>> List<NamedFactory<T>> setUpTransformedFactories(
+ boolean ignoreUnsupported, Collection<? extends S> preferred, Transformer<? super S, ? extends E> xform) {
+ List<NamedFactory<T>> avail = new ArrayList<>(preferred.size());
for (S f : preferred) {
if (ignoreUnsupported || f.isSupported()) {
avail.add(xform.transform(f));
}
}
-
return avail;
}
- public static <T,E extends NamedFactory<T> & OptionalFeature> List<NamedFactory<T>> setUpBuiltinFactories(
+ public static <T, E extends NamedFactory<T> & OptionalFeature> List<NamedFactory<T>> setUpBuiltinFactories(
boolean ignoreUnsupported, Collection<? extends E> preferred) {
- List<NamedFactory<T>> avail=new ArrayList<>(preferred.size());
+ List<NamedFactory<T>> avail = new ArrayList<>(preferred.size());
for (E f : preferred) {
if (ignoreUnsupported || f.isSupported()) {
avail.add(f);
}
}
-
+
return avail;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java b/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
index 6c59134..c1bf654 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/NamedResource.java
@@ -32,41 +32,48 @@ import org.apache.sshd.common.util.Transformer;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface NamedResource {
- /**
- * @return The resource name
- */
- String getName();
-
+
/**
* Compares 2 {@link NamedResource}s according to their {@link #getName()}
* value case <U>insensitive</U>
*/
- Comparator<NamedResource> BY_NAME_COMPARATOR=new Comparator<NamedResource>() {
- @Override
- public int compare(NamedResource r1, NamedResource r2) {
- String n1=r1.getName(), n2=r2.getName();
- return String.CASE_INSENSITIVE_ORDER.compare(n1, n2);
- }
- };
+ Comparator<NamedResource> BY_NAME_COMPARATOR = new Comparator<NamedResource>() {
+ @Override
+ public int compare(NamedResource r1, NamedResource r2) {
+ String n1 = r1.getName();
+ String n2 = r2.getName();
+ return String.CASE_INSENSITIVE_ORDER.compare(n1, n2);
+ }
+ };
/**
* Returns the value of {@link #getName()} - or {@code null} if argument is {@code null}
*/
- Transformer<NamedResource,String> NAME_EXTRACTOR=new Transformer<NamedResource,String>() {
- @Override
- public String transform(NamedResource input) {
- if (input == null) {
- return null;
- } else {
- return input.getName();
- }
+ Transformer<NamedResource, String> NAME_EXTRACTOR = new Transformer<NamedResource, String>() {
+ @Override
+ public String transform(NamedResource input) {
+ if (input == null) {
+ return null;
+ } else {
+ return input.getName();
}
- };
+ }
+ };
+
+ /**
+ * @return The resource name
+ */
+ String getName();
/**
* Utility class to help using {@link NamedResource}s
*/
final class Utils {
+
+ private Utils() {
+ throw new UnsupportedOperationException("No instance allowed");
+ }
+
/**
* @param resources The named resources
* @return A {@link List} of all the factories names - in same order
@@ -84,7 +91,7 @@ public interface NamedResource {
return names;
}
-
+
/**
* @param resources list of available resources
* @return A comma separated list of factory names
@@ -92,12 +99,13 @@ public interface NamedResource {
public static String getNames(Collection<? extends NamedResource> resources) {
return GenericUtils.join(getNameList(resources), ',');
}
-
+
/**
* Remove the resource identified by the name from the list.
- * @param name Name of the resource - ignored if {@code null}/empty
- * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
- * matches the <tt>name</tt> parameter
+ *
+ * @param name Name of the resource - ignored if {@code null}/empty
+ * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
+ * matches the <tt>name</tt> parameter
* @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
* @return the removed resource from the list or {@code null} if not in the list
*/
@@ -106,14 +114,14 @@ public interface NamedResource {
if (r != null) {
resources.remove(r);
}
-
+
return r;
}
/**
- * @param name Name of the resource - ignored if {@code null}/empty
- * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
- * matches the <tt>name</tt> parameter
+ * @param name Name of the resource - ignored if {@code null}/empty
+ * @param c The {@link Comparator} to decide whether the {@link NamedResource#getName()}
+ * matches the <tt>name</tt> parameter
* @param resources The {@link NamedResource} to check - ignored if {@code null}/empty
* @return The <U>first</U> resource whose name matches the parameter (by invoking
* {@link Comparator#compare(Object, Object)} - {@code null} if no match found
@@ -122,7 +130,7 @@ public interface NamedResource {
if (GenericUtils.isEmpty(name) || GenericUtils.isEmpty(resources)) {
return null;
}
-
+
for (R r : resources) {
String n = r.getName();
int nRes = c.compare(name, n);
@@ -130,7 +138,7 @@ public interface NamedResource {
return r;
}
}
-
+
return null;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/Service.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/Service.java b/sshd-core/src/main/java/org/apache/sshd/common/Service.java
index 054816b..c11fdc0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/Service.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/Service.java
@@ -18,7 +18,6 @@
*/
package org.apache.sshd.common;
-import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.buffer.Buffer;
@@ -37,7 +36,8 @@ public interface Service extends Closeable {
/**
* Service the request.
- * @param cmd The incoming command type
+ *
+ * @param cmd The incoming command type
* @param buffer The {@link Buffer} containing optional command parameters
* @throws Exception If failed to process the command
*/
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
index c2be440..6df16cc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/ServiceFactory.java
@@ -29,12 +29,18 @@ public interface ServiceFactory extends NamedResource {
/**
* Utility class to help using NamedFactories
*/
- class Utils {
+ final class Utils {
+
+ private Utils() {
+ throw new UnsupportedOperationException("No instance allowed");
+ }
+
/**
* Create an instance of the specified name by looking up the needed factory
* in the list (case <U>insensitive</U>.
+ *
* @param factories list of available factories
- * @param name the factory name to use
+ * @param name the factory name to use
* @return a newly created object or {@code null} if the factory is not in the list
* @throws IOException if session creation failed
* @see ServiceFactory#create(Session)
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
index 606e774..3242077 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
@@ -30,84 +30,88 @@ public final class SshConstants {
// SSH message identifiers
//
- public static final byte SSH_MSG_DISCONNECT= 1;
- public static final byte SSH_MSG_IGNORE= 2;
- public static final byte SSH_MSG_UNIMPLEMENTED= 3;
- public static final byte SSH_MSG_DEBUG= 4;
- public static final byte SSH_MSG_SERVICE_REQUEST= 5;
- public static final byte SSH_MSG_SERVICE_ACCEPT= 6;
- public static final byte SSH_MSG_KEXINIT= 20;
- public static final int MSG_KEX_COOKIE_SIZE = 16;
- public static final byte SSH_MSG_NEWKEYS= 21;
-
- public static final byte SSH_MSG_KEX_FIRST= 30;
- public static final byte SSH_MSG_KEX_LAST= 49;
-
- public static final byte SSH_MSG_KEXDH_INIT= 30;
- public static final byte SSH_MSG_KEXDH_REPLY= 31;
-
- public static final byte SSH_MSG_KEX_DH_GEX_REQUEST_OLD= 30;
- public static final byte SSH_MSG_KEX_DH_GEX_GROUP= 31;
- public static final byte SSH_MSG_KEX_DH_GEX_INIT= 32;
- public static final byte SSH_MSG_KEX_DH_GEX_REPLY= 33;
- public static final byte SSH_MSG_KEX_DH_GEX_REQUEST= 34;
-
- public static final byte SSH_MSG_USERAUTH_REQUEST= 50;
- public static final byte SSH_MSG_USERAUTH_FAILURE= 51;
- public static final byte SSH_MSG_USERAUTH_SUCCESS= 52;
- public static final byte SSH_MSG_USERAUTH_BANNER= 53;
-
- public static final byte SSH_MSG_USERAUTH_INFO_REQUEST= 60;
- public static final byte SSH_MSG_USERAUTH_INFO_RESPONSE= 61;
-
- public static final byte SSH_MSG_USERAUTH_PK_OK= 60;
-
- public static final byte SSH_MSG_USERAUTH_PASSWD_CHANGEREQ= 60;
-
- public static final byte SSH_MSG_USERAUTH_GSSAPI_MIC= 66;
-
- public static final byte SSH_MSG_GLOBAL_REQUEST= 80;
- public static final byte SSH_MSG_REQUEST_SUCCESS= 81;
- public static final byte SSH_MSG_REQUEST_FAILURE= 82;
- public static final byte SSH_MSG_CHANNEL_OPEN= 90;
- public static final byte SSH_MSG_CHANNEL_OPEN_CONFIRMATION= 91;
- public static final byte SSH_MSG_CHANNEL_OPEN_FAILURE= 92;
- public static final byte SSH_MSG_CHANNEL_WINDOW_ADJUST= 93;
- public static final byte SSH_MSG_CHANNEL_DATA= 94;
- public static final byte SSH_MSG_CHANNEL_EXTENDED_DATA= 95;
- public static final byte SSH_MSG_CHANNEL_EOF= 96;
- public static final byte SSH_MSG_CHANNEL_CLOSE= 97;
- public static final byte SSH_MSG_CHANNEL_REQUEST= 98;
- public static final byte SSH_MSG_CHANNEL_SUCCESS= 99;
- public static final byte SSH_MSG_CHANNEL_FAILURE= 100;
+ public static final byte SSH_MSG_DISCONNECT = 1;
+ public static final byte SSH_MSG_IGNORE = 2;
+ public static final byte SSH_MSG_UNIMPLEMENTED = 3;
+ public static final byte SSH_MSG_DEBUG = 4;
+ public static final byte SSH_MSG_SERVICE_REQUEST = 5;
+ public static final byte SSH_MSG_SERVICE_ACCEPT = 6;
+ public static final byte SSH_MSG_KEXINIT = 20;
+ public static final int MSG_KEX_COOKIE_SIZE = 16;
+ public static final byte SSH_MSG_NEWKEYS = 21;
+
+ public static final byte SSH_MSG_KEX_FIRST = 30;
+ public static final byte SSH_MSG_KEX_LAST = 49;
+
+ public static final byte SSH_MSG_KEXDH_INIT = 30;
+ public static final byte SSH_MSG_KEXDH_REPLY = 31;
+
+ public static final byte SSH_MSG_KEX_DH_GEX_REQUEST_OLD = 30;
+ public static final byte SSH_MSG_KEX_DH_GEX_GROUP = 31;
+ public static final byte SSH_MSG_KEX_DH_GEX_INIT = 32;
+ public static final byte SSH_MSG_KEX_DH_GEX_REPLY = 33;
+ public static final byte SSH_MSG_KEX_DH_GEX_REQUEST = 34;
+
+ public static final byte SSH_MSG_USERAUTH_REQUEST = 50;
+ public static final byte SSH_MSG_USERAUTH_FAILURE = 51;
+ public static final byte SSH_MSG_USERAUTH_SUCCESS = 52;
+ public static final byte SSH_MSG_USERAUTH_BANNER = 53;
+
+ public static final byte SSH_MSG_USERAUTH_INFO_REQUEST = 60;
+ public static final byte SSH_MSG_USERAUTH_INFO_RESPONSE = 61;
+
+ public static final byte SSH_MSG_USERAUTH_PK_OK = 60;
+
+ public static final byte SSH_MSG_USERAUTH_PASSWD_CHANGEREQ = 60;
+
+ public static final byte SSH_MSG_USERAUTH_GSSAPI_MIC = 66;
+
+ public static final byte SSH_MSG_GLOBAL_REQUEST = 80;
+ public static final byte SSH_MSG_REQUEST_SUCCESS = 81;
+ public static final byte SSH_MSG_REQUEST_FAILURE = 82;
+ public static final byte SSH_MSG_CHANNEL_OPEN = 90;
+ public static final byte SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91;
+ public static final byte SSH_MSG_CHANNEL_OPEN_FAILURE = 92;
+ public static final byte SSH_MSG_CHANNEL_WINDOW_ADJUST = 93;
+ public static final byte SSH_MSG_CHANNEL_DATA = 94;
+ public static final byte SSH_MSG_CHANNEL_EXTENDED_DATA = 95;
+ public static final byte SSH_MSG_CHANNEL_EOF = 96;
+ public static final byte SSH_MSG_CHANNEL_CLOSE = 97;
+ public static final byte SSH_MSG_CHANNEL_REQUEST = 98;
+ public static final byte SSH_MSG_CHANNEL_SUCCESS = 99;
+ public static final byte SSH_MSG_CHANNEL_FAILURE = 100;
//
// Disconnect error codes
//
- public static final int SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1;
- public static final int SSH2_DISCONNECT_PROTOCOL_ERROR = 2;
- public static final int SSH2_DISCONNECT_KEY_EXCHANGE_FAILED = 3;
- public static final int SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED = 4;
- public static final int SSH2_DISCONNECT_RESERVED = 4;
- public static final int SSH2_DISCONNECT_MAC_ERROR = 5;
- public static final int SSH2_DISCONNECT_COMPRESSION_ERROR = 6;
- public static final int SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE = 7;
- public static final int SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8;
- public static final int SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9;
- public static final int SSH2_DISCONNECT_CONNECTION_LOST = 10;
- public static final int SSH2_DISCONNECT_BY_APPLICATION = 11;
- public static final int SSH2_DISCONNECT_TOO_MANY_CONNECTIONS = 12;
- public static final int SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER = 13;
+ public static final int SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1;
+ public static final int SSH2_DISCONNECT_PROTOCOL_ERROR = 2;
+ public static final int SSH2_DISCONNECT_KEY_EXCHANGE_FAILED = 3;
+ public static final int SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED = 4;
+ public static final int SSH2_DISCONNECT_RESERVED = 4;
+ public static final int SSH2_DISCONNECT_MAC_ERROR = 5;
+ public static final int SSH2_DISCONNECT_COMPRESSION_ERROR = 6;
+ public static final int SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE = 7;
+ public static final int SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8;
+ public static final int SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9;
+ public static final int SSH2_DISCONNECT_CONNECTION_LOST = 10;
+ public static final int SSH2_DISCONNECT_BY_APPLICATION = 11;
+ public static final int SSH2_DISCONNECT_TOO_MANY_CONNECTIONS = 12;
+ public static final int SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER = 13;
public static final int SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14;
- public static final int SSH2_DISCONNECT_ILLEGAL_USER_NAME = 15;
+ public static final int SSH2_DISCONNECT_ILLEGAL_USER_NAME = 15;
//
// Open error codes
//
- public static final int SSH_OPEN_ADMINISTRATIVELY_PROHIBITED= 1;
- public static final int SSH_OPEN_CONNECT_FAILED= 2;
- public static final int SSH_OPEN_UNKNOWN_CHANNEL_TYPE= 3;
- public static final int SSH_OPEN_RESOURCE_SHORTAGE= 4;
+ public static final int SSH_OPEN_ADMINISTRATIVELY_PROHIBITED = 1;
+ public static final int SSH_OPEN_CONNECT_FAILED = 2;
+ public static final int SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3;
+ public static final int SSH_OPEN_RESOURCE_SHORTAGE = 4;
+
+ private SshConstants() {
+ throw new UnsupportedOperationException("No instance allowed");
+ }
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java b/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java
index d7d6234..e4aab99 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java
@@ -29,26 +29,30 @@ import org.apache.sshd.common.util.ValidateUtils;
* <P>A simple socket address holding the host name and port number. The reason
* it does not extend {@link InetSocketAddress} is twofold:</P></BR>
* <OL>
- * <LI><P>
- * The {@link InetSocketAddress} performs a DNS resolution on the
- * provided host name - which we don't want do use until we want to
- * create a connection using this address (thus the {@link #toInetSocketAddress()}
- * call which executes this query
- * </P></LI>
- *
- * <LI><P>
- * If empty host name is provided we replace it with the <I>any</I>
- * address of 0.0.0.0
- * </P></LI>
+ * <LI><P>
+ * The {@link InetSocketAddress} performs a DNS resolution on the
+ * provided host name - which we don't want do use until we want to
+ * create a connection using this address (thus the {@link #toInetSocketAddress()}
+ * call which executes this query
+ * </P></LI>
+ * <p/>
+ * <LI><P>
+ * If empty host name is provided we replace it with the <I>any</I>
+ * address of 0.0.0.0
+ * </P></LI>
* </OL>
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class SshdSocketAddress extends SocketAddress {
- private static final long serialVersionUID = 6461645947151952729L;
+
/**
- * A dummy placeholder that can be used instead of {@code null}s
+ * A dummy placeholder that can be used instead of {@code null}s
*/
public static final SshdSocketAddress LOCALHOST_ADDRESS = new SshdSocketAddress("localhost", 0);
+
+ private static final long serialVersionUID = 6461645947151952729L;
+
private final String hostName;
private final int port;
@@ -57,7 +61,7 @@ public class SshdSocketAddress extends SocketAddress {
this.hostName = GenericUtils.isEmpty(hostName) ? "0.0.0.0" : hostName;
ValidateUtils.checkTrue(port >= 0, "Port must be >= 0", Integer.valueOf(port));
- this.port = port;
+ this.port = port;
}
public String getHostName() {
@@ -82,21 +86,20 @@ public class SshdSocketAddress extends SocketAddress {
return false;
} else if (that == this) {
return true;
- } else if ((this.getPort() == that.getPort())
- && Objects.equals(this.getHostName(), that.getHostName())) {
- return true;
- } else {
- return false; // debug breakpoint
- }
+ } else {
+ return (this.getPort() == that.getPort())
+ && Objects.equals(this.getHostName(), that.getHostName());
+ }
}
@Override
public boolean equals(Object o) {
- if (o == null)
+ if (o == null) {
return false;
- if (getClass() != o.getClass())
+ }
+ if (getClass() != o.getClass()) {
return false;
-
+ }
return isEquivalent((SshdSocketAddress) o);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index 2ec3f3f..7b613f5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -51,8 +51,8 @@ import org.apache.sshd.common.util.threads.ExecutorServiceConfigurer;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public abstract class AbstractChannel
- extends CloseableUtils.AbstractInnerCloseable
- implements Channel, ExecutorServiceConfigurer {
+ extends CloseableUtils.AbstractInnerCloseable
+ implements Channel, ExecutorServiceConfigurer {
public static final int DEFAULT_WINDOW_SIZE = 0x200000;
public static final int DEFAULT_PACKET_SIZE = 0x8000;
@@ -63,15 +63,15 @@ public abstract class AbstractChannel
Opened, CloseSent, CloseReceived, Closed
}
- private ExecutorService executor;
- private boolean shutdownExecutor;
+ protected ExecutorService executor;
+ protected boolean shutdownExecutor;
protected final Window localWindow = new Window(this, null, getClass().getName().contains(".client."), true);
protected final Window remoteWindow = new Window(this, null, getClass().getName().contains(".client."), false);
protected ConnectionService service;
protected Session session;
protected int id;
protected int recipient;
- private final AtomicBoolean eof = new AtomicBoolean(false);
+ protected final AtomicBoolean eof = new AtomicBoolean(false);
protected AtomicReference<GracefulState> gracefulState = new AtomicReference<GracefulState>(GracefulState.Opened);
protected final DefaultCloseFuture gracefulFuture = new DefaultCloseFuture(lock);
protected final List<RequestHandler<Channel>> handlers = new ArrayList<RequestHandler<Channel>>();
@@ -178,8 +178,7 @@ public abstract class AbstractChannel
byte cmd = RequestHandler.Result.ReplySuccess.equals(result)
? SshConstants.SSH_MSG_CHANNEL_SUCCESS
- : SshConstants.SSH_MSG_CHANNEL_FAILURE
- ;
+ : SshConstants.SSH_MSG_CHANNEL_FAILURE;
buffer.clear();
// leave room for the SSH header
buffer.ensureCapacity(5 + 1 + (Integer.SIZE / Byte.SIZE), Int2IntFunction.Utils.add(Byte.SIZE));
@@ -274,10 +273,10 @@ public abstract class AbstractChannel
AbstractChannel.this.close(true);
}
}
-
+
ExecutorService service = getExecutorService();
if ((service != null) && isShutdownOnExit() && (!service.isShutdown())) {
- Collection<?> running = service.shutdownNow();
+ Collection<?> running = service.shutdownNow();
if (log.isDebugEnabled()) {
log.debug("Shutdown executor service on close - running count=" + GenericUtils.size(running));
}
@@ -341,7 +340,7 @@ public abstract class AbstractChannel
public boolean isEofSignalled() {
return eof.get();
}
-
+
public void setEofSignalled(boolean on) {
eof.set(on);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
index 6dcb31b..b950afc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncInputStream.java
@@ -141,7 +141,7 @@ public class ChannelAsyncInputStream extends CloseableUtils.AbstractCloseable im
@Override // TODO for JDK-8 make this a default method
public void verify(long timeout, TimeUnit unit) throws IOException {
- verify(unit.toMillis(timeout));
+ verify(unit.toMillis(timeout));
}
@Override // TODO for JDK-8 make this a default method
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
index bbfd1ad..142d6a9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelFactory.java
@@ -20,17 +20,11 @@
package org.apache.sshd.common.channel;
import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.util.Transformer;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
+// CHECKSTYLE:OFF
public interface ChannelFactory extends NamedFactory<Channel> {
- // required because of generics issues
- Transformer<ChannelFactory,NamedFactory<Channel>> FAC2NAMED=new Transformer<ChannelFactory,NamedFactory<Channel>>() {
- @Override
- public NamedFactory<Channel> transform(ChannelFactory input) {
- return input;
- }
- };
+
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
index 83aaaff..3888c14 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
@@ -87,8 +87,8 @@ public class ChannelOutputStream extends OutputStream implements Channel {
// out the next packet before we block and wait for space to
// become available again.
//
- int _l = Math.min(l, Math.min(remoteWindow.getSize() + lastSize, remoteWindow.getPacketSize()) - bufferLength);
- if (_l <= 0) {
+ int l2 = Math.min(l, Math.min(remoteWindow.getSize() + lastSize, remoteWindow.getPacketSize()) - bufferLength);
+ if (l2 <= 0) {
if (bufferLength > 0) {
flush();
} else {
@@ -98,15 +98,15 @@ public class ChannelOutputStream extends OutputStream implements Channel {
closed = true;
throw e;
} catch (InterruptedException e) {
- throw (IOException)new InterruptedIOException("Interrupted while waiting for remote space").initCause(e);
+ throw (IOException) new InterruptedIOException("Interrupted while waiting for remote space").initCause(e);
}
}
continue;
}
- buffer.putRawBytes(buf, s, _l);
- bufferLength += _l;
- s += _l;
- l -= _l;
+ buffer.putRawBytes(buf, s, l2);
+ bufferLength += l2;
+ s += l2;
+ l -= l2;
}
if (noDelay) {
flush();
@@ -140,15 +140,15 @@ public class ChannelOutputStream extends OutputStream implements Channel {
remoteWindow.waitAndConsume(length);
if (log.isDebugEnabled()) {
log.debug("Send {} on channel {}",
- (cmd == SshConstants.SSH_MSG_CHANNEL_DATA) ? "SSH_MSG_CHANNEL_DATA" : "SSH_MSG_CHANNEL_EXTENDED_DATA",
- Integer.valueOf(channel.getId()));
+ (cmd == SshConstants.SSH_MSG_CHANNEL_DATA) ? "SSH_MSG_CHANNEL_DATA" : "SSH_MSG_CHANNEL_EXTENDED_DATA",
+ Integer.valueOf(channel.getId()));
}
channel.writePacket(buf);
}
- } catch(WindowClosedException e) {
+ } catch (WindowClosedException e) {
closed = true;
throw e;
- } catch(Exception e) {
+ } catch (Exception e) {
if (e instanceof IOException) {
throw (IOException) e;
} else {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java
index e68ac88..84874bc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedInputStream.java
@@ -29,7 +29,6 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
@@ -94,7 +93,7 @@ public class ChannelPipedInputStream extends InputStream implements ChannelPiped
if (l == -1) {
return -1;
}
- return (b[0] & 0xff);
+ return b[0] & 0xff;
}
}
@@ -103,7 +102,7 @@ public class ChannelPipedInputStream extends InputStream implements ChannelPiped
long startTime = System.currentTimeMillis();
lock.lock();
try {
- for (int index=0;; index++) {
+ for (int index = 0;; index++) {
if ((closed && writerClosed && eofSent) || (closed && !writerClosed)) {
throw new IOException("Pipe closed after " + index + " cycles");
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedSink.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedSink.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedSink.java
index 62dacaf..840c560 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedSink.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelPipedSink.java
@@ -27,8 +27,8 @@ import java.io.IOException;
public interface ChannelPipedSink {
/**
* @param bytes Bytes to be sent to the sink
- * @param off Offset in buffer
- * @param len Number of bytes
+ * @param off Offset in buffer
+ * @param len Number of bytes
* @throws IOException If failed to send the data
*/
void receive(byte[] bytes, int off, int len) throws IOException;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
index 1871068..e7d5e65 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelRequestHandler.java
@@ -20,17 +20,22 @@
package org.apache.sshd.common.channel;
import org.apache.sshd.common.util.Transformer;
+import org.apache.sshd.common.util.buffer.Buffer;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface ChannelRequestHandler extends RequestHandler<Channel> {
+
// required because of generics issues
- Transformer<ChannelRequestHandler,RequestHandler<Channel>> CHANN2HNDLR =
- new Transformer<ChannelRequestHandler, RequestHandler<Channel>>() {
- @Override
- public RequestHandler<Channel> transform(ChannelRequestHandler input) {
- return input;
- }
- };
+ Transformer<ChannelRequestHandler, RequestHandler<Channel>> CHANN2HNDLR =
+ new Transformer<ChannelRequestHandler, RequestHandler<Channel>>() {
+ @Override
+ public RequestHandler<Channel> transform(ChannelRequestHandler input) {
+ return input;
+ }
+ };
+
+ Result process(Channel channel, String request, boolean wantReply, Buffer buffer) throws Exception;
+
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/IoWriteFutureImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/IoWriteFutureImpl.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/IoWriteFutureImpl.java
index 9bd3cbe..294c970 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/IoWriteFutureImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/IoWriteFutureImpl.java
@@ -20,7 +20,6 @@
package org.apache.sshd.common.channel;
import org.apache.sshd.common.io.AbstractIoWriteFuture;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
index bd2bdbd..b0ec6db 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
@@ -51,6 +51,18 @@ public enum PtyMode {
// Speeed
TTY_OP_ISPEED(128), TTY_OP_OSPEED(129);
+ public static final byte TTY_OP_END = 0x00;
+
+ private static final Map<Integer, PtyMode> COMMANDS;
+
+ static {
+ Map<Integer, PtyMode> commands = new java.util.HashMap<>();
+ for (PtyMode c : PtyMode.values()) {
+ commands.put(c.toInt(), c);
+ }
+ COMMANDS = Collections.unmodifiableMap(commands);
+ }
+
private int v;
PtyMode(int v) {
@@ -61,20 +73,7 @@ public enum PtyMode {
return v;
}
- public static final byte TTY_OP_END = 0x00;
-
- private static final Map<Integer, PtyMode> commands =
- Collections.unmodifiableMap(new HashMap<Integer, PtyMode>() {
- private static final long serialVersionUID = 1L; // we're not serializing it
-
- {
- for (PtyMode c : PtyMode.values()) {
- put(c.toInt(), c);
- }
- }
- });
-
public static PtyMode fromInt(int b) {
- return commands.get(0x00FF & (b + 0x100));
+ return COMMANDS.get(0x00FF & (b + 0x100));
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
index f6f2527..7bdf320 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
@@ -30,12 +30,16 @@ import java.util.TreeMap;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SttySupport {
+public final class SttySupport {
private static String sttyCommand = System.getProperty("sshd.sttyCommand", "stty");
private static String ttyProps;
private static long ttyPropsLastFetched;
+ private SttySupport() {
+ throw new UnsupportedOperationException("No instance allowed");
+ }
+
public static Map<PtyMode, Integer> getUnixPtyModes() throws IOException, InterruptedException {
return parsePtyModes(getTtyProps());
}
@@ -121,12 +125,12 @@ public class SttySupport {
}
/**
- * Returns the value of "stty size" width param.
- *
- * <strong>Note</strong>: this method caches the value from the
- * first time it is called in order to increase speed, which means
- * that changing to size of the terminal will not be reflected
- * in the console.
+ * Returns the value of "stty size" width param.
+ * <p/>
+ * <strong>Note</strong>: this method caches the value from the
+ * first time it is called in order to increase speed, which means
+ * that changing to size of the terminal will not be reflected
+ * in the console.
*/
public static int getTerminalWidth() {
int val = -1;
@@ -145,12 +149,12 @@ public class SttySupport {
}
/**
- * Returns the value of "stty size" height param.
- *
- * <strong>Note</strong>: this method caches the value from the
- * first time it is called in order to increase speed, which means
- * that changing to size of the terminal will not be reflected
- * in the console.
+ * Returns the value of "stty size" height param.
+ * <p/>
+ * <strong>Note</strong>: this method caches the value from the
+ * first time it is called in order to increase speed, which means
+ * that changing to size of the terminal will not be reflected
+ * in the console.
*/
public static int getTerminalHeight() {
int val = -1;
@@ -169,13 +173,12 @@ public class SttySupport {
}
private static int getTerminalProperty(String prop)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
// need to be able handle both output formats:
// speed 9600 baud; 24 rows; 140 columns;
// and:
// speed 38400 baud; rows = 49; columns = 111; ypixels = 0; xpixels = 0;
- for (StringTokenizer tok = new StringTokenizer(getTtyProps(), ";\n");
- tok.hasMoreTokens();) {
+ for (StringTokenizer tok = new StringTokenizer(getTtyProps(), ";\n"); tok.hasMoreTokens();) {
String str = tok.nextToken().trim();
if (str.startsWith(prop)) {
@@ -203,33 +206,33 @@ public class SttySupport {
/**
- * Execute the stty command with the specified arguments
- * against the current active terminal.
+ * Execute the stty command with the specified arguments
+ * against the current active terminal.
*/
public static String stty(final String args)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
return exec("stty " + args + " < /dev/tty").trim();
}
/**
- * Execute the specified command and return the output
- * (both stdout and stderr).
+ * Execute the specified command and return the output
+ * (both stdout and stderr).
*/
public static String exec(final String cmd)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
return exec(new String[] {
- "sh",
- "-c",
- cmd
- });
+ "sh",
+ "-c",
+ cmd
+ });
}
/**
- * Execute the specified command and return the output
- * (both stdout and stderr).
+ * Execute the specified command and return the output
+ * (both stdout and stderr).
*/
private static String exec(final String[] cmd)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
Process p = Runtime.getRuntime().exec(cmd);
@@ -256,16 +259,16 @@ public class SttySupport {
}
/**
- * The command to use to set the terminal options. Defaults
- * to "stty", or the value of the system property "jline.sttyCommand".
+ * The command to use to set the terminal options. Defaults
+ * to "stty", or the value of the system property "jline.sttyCommand".
*/
public static void setSttyCommand(String cmd) {
sttyCommand = cmd;
}
/**
- * The command to use to set the terminal options. Defaults
- * to "stty", or the value of the system property "jline.sttyCommand".
+ * The command to use to set the terminal options. Defaults
+ * to "stty", or the value of the system property "jline.sttyCommand".
*/
public static String getSttyCommand() {
return sttyCommand;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java
index d3b693d..1bd7031 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/Window.java
@@ -25,7 +25,6 @@ import java.util.Map;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.FactoryManagerUtils;
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.common.util.logging.AbstractLoggingBean;
@@ -34,7 +33,7 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
* Windows are used to not overflow the client or server when sending datas.
* Both clients and servers have a local and remote window and won't send
* anymore data until the window has been expanded. When the local window
- * is
+ * is
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -48,7 +47,7 @@ public class Window extends AbstractLoggingBean {
private int packetSize;
private boolean waiting;
private boolean closed;
- private Map<String,?> props = Collections.<String,Object>emptyMap();
+ private Map<String, ?> props = Collections.<String, Object>emptyMap();
public Window(AbstractChannel channel, Object lock, boolean client, boolean local) {
this.channel = ValidateUtils.checkNotNull(channel, "No channel provided");
@@ -56,7 +55,7 @@ public class Window extends AbstractLoggingBean {
this.name = String.valueOf(channel) + ": " + (client ? "client" : "server") + " " + (local ? "local " : "remote") + " window";
}
- public Map<String,?> getProperties() {
+ public Map<String, ?> getProperties() {
return props;
}
@@ -77,18 +76,18 @@ public class Window extends AbstractLoggingBean {
public void init(Session session) {
init(session.getFactoryManager());
}
-
+
public void init(FactoryManager manager) {
init(manager.getProperties());
}
- public void init(Map<String,?> props) {
+ public void init(Map<String, ?> props) {
init(FactoryManagerUtils.getIntProperty(props, FactoryManager.WINDOW_SIZE, AbstractChannel.DEFAULT_WINDOW_SIZE),
- FactoryManagerUtils.getIntProperty(props, FactoryManager.MAX_PACKET_SIZE, AbstractChannel.DEFAULT_PACKET_SIZE),
- props);
+ FactoryManagerUtils.getIntProperty(props, FactoryManager.MAX_PACKET_SIZE, AbstractChannel.DEFAULT_PACKET_SIZE),
+ props);
}
- public void init(int size, int packetSize, Map<String,?> props) {
+ public void init(int size, int packetSize, Map<String, ?> props) {
synchronized (lock) {
this.size = size;
this.maxSize = size;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/channel/WindowClosedException.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/WindowClosedException.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/WindowClosedException.java
index 039a72d..050f8ce 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/WindowClosedException.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/WindowClosedException.java
@@ -22,7 +22,7 @@ import org.apache.sshd.common.SshException;
/**
* Indicates a {@link Window} has been closed.
- *
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class WindowClosedException extends SshException {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java b/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java
index de22140..605515c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseCipher.java
@@ -61,11 +61,10 @@ public class BaseCipher implements Cipher {
iv = resize(iv, ivsize);
try {
cipher = SecurityUtils.getCipher(transformation);
- cipher.init((mode == Mode.Encrypt ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE),
- new SecretKeySpec(key, algorithm),
- new IvParameterSpec(iv));
- }
- catch (Exception e) {
+ cipher.init(mode == Mode.Encrypt ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE,
+ new SecretKeySpec(key, algorithm),
+ new IvParameterSpec(iv));
+ } catch (Exception e) {
cipher = null;
throw new SshException("Unable to initialize cipher " + this, e);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java b/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java
index a6cdc68..45e5a5b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/cipher/BaseRC4Cipher.java
@@ -27,7 +27,7 @@ import org.apache.sshd.common.util.SecurityUtils;
*/
public class BaseRC4Cipher extends BaseCipher {
- public static final int SKIP_SIZE = 1536;
+ public static final int SKIP_SIZE = 1536;
public BaseRC4Cipher(int ivsize, int bsize) {
super(ivsize, bsize, "ARCFOUR", "RC4");
@@ -38,7 +38,7 @@ public class BaseRC4Cipher extends BaseCipher {
key = resize(key, bsize);
try {
cipher = SecurityUtils.getCipher(transformation);
- cipher.init((mode == Mode.Encrypt ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE),
+ cipher.init(mode == Mode.Encrypt ? javax.crypto.Cipher.ENCRYPT_MODE : javax.crypto.Cipher.DECRYPT_MODE,
new SecretKeySpec(key, algorithm));
byte[] foo = new byte[1];