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:37 UTC
[17/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/common/config/keys/PublicKeyEntry.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java
index a7c07de..60c91c6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java
@@ -39,21 +39,34 @@ import org.apache.sshd.common.util.buffer.BufferUtils;
* <P>Represents a {@link PublicKey} whose data is formatted according to
* the <A HREF="http://en.wikibooks.org/wiki/OpenSSH">OpenSSH</A> format:</P></BR>
* <CODE><PRE>
- * <key-type> <base64-encoded-public-key-data>
+ * <key-type> <base64-encoded-public-key-data>
* </CODE></PRE>
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class PublicKeyEntry implements Serializable {
+
+ /**
+ * Character used to denote a comment line in the keys file
+ */
+ public static final char COMMENT_CHAR = '#';
+
+
+ /**
+ * Standard folder name used by OpenSSH to hold key files
+ */
+ public static final String STD_KEYFILE_FOLDER_NAME = ".ssh";
+
private static final long serialVersionUID = -585506072687602760L;
- private String keyType;
- private byte[] keyData;
+ private String keyType;
+ private byte[] keyData;
public PublicKeyEntry() {
super();
}
- public PublicKeyEntry(String keyType, byte ... keyData) {
+ public PublicKeyEntry(String keyType, byte... keyData) {
this.keyType = keyType;
this.keyData = keyData;
}
@@ -78,29 +91,29 @@ public class PublicKeyEntry implements Serializable {
* @return The resolved {@link PublicKey} - never {@code null}.
* <B>Note:</B> may be called only after key type and data bytes have
* been set or exception(s) may be thrown
- * @throws IOException If failed to decode the key
+ * @throws IOException If failed to decode the key
* @throws GeneralSecurityException If failed to generate the key
*/
public PublicKey resolvePublicKey() throws IOException, GeneralSecurityException {
String kt = getKeyType();
- PublicKeyEntryDecoder<?,?> decoder = KeyUtils.getPublicKeyEntryDecoder(kt);
+ PublicKeyEntryDecoder<?, ?> decoder = KeyUtils.getPublicKeyEntryDecoder(kt);
if (decoder == null) {
throw new InvalidKeySpecException("No decoder registered for key type=" + kt);
}
-
+
byte[] data = getKeyData();
PublicKey key = decoder.decodePublicKey(data);
if (key == null) {
throw new InvalidKeyException("No key of type=" + kt + " decoded for data=" + BufferUtils.printHex(':', data));
}
-
+
return key;
}
/**
* @param sb The {@link Appendable} instance to encode the data into
* @return The {@link PublicKey}
- * @throws IOException If failed to decode/encode the key
+ * @throws IOException If failed to decode/encode the key
* @throws GeneralSecurityException If failed to generate the key
* @see #resolvePublicKey()
*/
@@ -113,8 +126,7 @@ public class PublicKeyEntry implements Serializable {
@Override
public int hashCode() {
return Objects.hashCode(getKeyType())
- + Arrays.hashCode(getKeyData())
- ;
+ + Arrays.hashCode(getKeyData());
}
/*
@@ -125,40 +137,33 @@ public class PublicKeyEntry implements Serializable {
if (this == e) {
return true;
}
-
- if (Objects.equals(getKeyType(), e.getKeyType())
- && Arrays.equals(getKeyData(), e.getKeyData())) {
- return true;
- } else {
- return false;
- }
+ return Objects.equals(getKeyType(), e.getKeyType())
+ && Arrays.equals(getKeyData(), e.getKeyData());
}
@Override
public boolean equals(Object obj) {
- if (obj == null)
+ if (obj == null) {
return false;
- if (this == obj)
- return true;
- if (getClass() != obj.getClass())
- return false;
-
- if (isEquivalent((PublicKeyEntry) obj)) {
+ }
+ if (this == obj) {
return true;
- } else {
+ }
+ if (getClass() != obj.getClass()) {
return false;
}
+ return isEquivalent((PublicKeyEntry) obj);
}
-
+
@Override
public String toString() {
byte[] data = getKeyData();
return getKeyType() + " " + (GenericUtils.isEmpty(data) ? "<no-key>" : Base64.encodeToString(data));
}
-
+
/**
* @param data Assumed to contain at least {@code key-type base64-data} (anything
- * beyond the BASE64 data is ignored) - ignored if {@code null}/empty
+ * beyond the BASE64 data is ignored) - ignored if {@code null}/empty
* @return A {@link PublicKeyEntry} or {@code null} if no data
* @throws IllegalArgumentException if bad format found
* @see #parsePublicKeyEntry(PublicKeyEntry, String)
@@ -173,9 +178,9 @@ public class PublicKeyEntry implements Serializable {
/**
* @param entry The {@link PublicKeyEntry} whose contents are to be
- * updated - ignored if {@code null}
- * @param data Assumed to contain at least {@code key-type base64-data} (anything
- * beyond the BASE64 data is ignored) - ignored if {@code null}/empty
+ * updated - ignored if {@code null}
+ * @param data Assumed to contain at least {@code key-type base64-data} (anything
+ * beyond the BASE64 data is ignored) - ignored if {@code null}/empty
* @return The updated entry instance
* @throws IllegalArgumentException if bad format found
*/
@@ -183,7 +188,7 @@ public class PublicKeyEntry implements Serializable {
if (GenericUtils.isEmpty(data) || (entry == null)) {
return entry;
}
-
+
int startPos = data.indexOf(' ');
if (startPos <= 0) {
throw new IllegalArgumentException("Bad format (no key data delimiter): " + data);
@@ -194,13 +199,13 @@ public class PublicKeyEntry implements Serializable {
endPos = data.length();
}
- String keyType = data.substring(0, startPos);
- String b64Data = data.substring(startPos + 1, endPos).trim();
- byte[] keyData = Base64.decodeString(b64Data);
+ String keyType = data.substring(0, startPos);
+ String b64Data = data.substring(startPos + 1, endPos).trim();
+ byte[] keyData = Base64.decodeString(b64Data);
if (GenericUtils.isEmpty(keyData)) {
throw new IllegalArgumentException("Bad format (no BASE64 key data): " + data);
}
-
+
entry.setKeyType(keyType);
entry.setKeyData(keyData);
return entry;
@@ -214,47 +219,38 @@ public class PublicKeyEntry implements Serializable {
public static String toString(PublicKey key) throws IllegalArgumentException {
try {
return appendPublicKeyEntry(new StringBuilder(Byte.MAX_VALUE), key).toString();
- } catch(IOException e) {
+ } catch (IOException e) {
throw new IllegalArgumentException("Failed (" + e.getClass().getSimpleName() + ") to encode: " + e.getMessage(), e);
}
}
/**
* Encodes a public key data the same way as the {@link #parsePublicKeyEntry(String)} expects it
- * @param sb The {@link Appendable} instance to encode the data into
+ *
+ * @param sb The {@link Appendable} instance to encode the data into
* @param key The {@link PublicKey}
* @return The updated appendable instance
* @throws IOException If failed to append the data
*/
public static <A extends Appendable> A appendPublicKeyEntry(A sb, PublicKey key) throws IOException {
@SuppressWarnings("unchecked")
- PublicKeyEntryDecoder<PublicKey,?> decoder = (PublicKeyEntryDecoder<PublicKey,?>) KeyUtils.getPublicKeyEntryDecoder(key);
+ PublicKeyEntryDecoder<PublicKey, ?> decoder = (PublicKeyEntryDecoder<PublicKey, ?>) KeyUtils.getPublicKeyEntryDecoder(key);
if (decoder == null) {
throw new StreamCorruptedException("Cannot retrived decoder for key=" + key.getAlgorithm());
}
-
- try(ByteArrayOutputStream s=new ByteArrayOutputStream(Byte.MAX_VALUE)) {
+
+ try (ByteArrayOutputStream s = new ByteArrayOutputStream(Byte.MAX_VALUE)) {
String keyType = decoder.encodePublicKey(s, key);
byte[] bytes = s.toByteArray();
String b64Data = Base64.encodeToString(bytes);
sb.append(keyType).append(' ').append(b64Data);
}
-
+
return sb;
}
- /**
- * Character used to denote a comment line in the keys file
- */
- public static final char COMMENT_CHAR='#';
-
-
- /**
- * Standard folder name used by OpenSSH to hold key files
- */
- public static final String STD_KEYFILE_FOLDER_NAME=".ssh";
private static final class LazyDefaultKeysFolderHolder {
- private static final File folder=
+ private static final File FOLDER =
new File(System.getProperty("user.home") + File.separator + STD_KEYFILE_FOLDER_NAME);
}
@@ -264,6 +260,6 @@ public class PublicKeyEntry implements Serializable {
*/
@SuppressWarnings("synthetic-access")
public static File getDefaultKeysFolder() {
- return LazyDefaultKeysFolderHolder.folder;
+ return LazyDefaultKeysFolderHolder.FOLDER;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntryDecoder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntryDecoder.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntryDecoder.java
index dbff853..97bb62f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntryDecoder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntryDecoder.java
@@ -32,15 +32,16 @@ import java.util.Collection;
/**
* Represents a decoder of an {@code OpenSSH} encoded key data
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey> {
+public interface PublicKeyEntryDecoder<PUB extends PublicKey, PRV extends PrivateKey> {
/**
* @return The {@link Class} of the {@link PublicKey} that is the result
* of decoding
*/
Class<PUB> getPublicKeyType();
-
+
/**
* @return The {@link Class} of the {@link PrivateKey} that matches the
* public one
@@ -65,9 +66,9 @@ public interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends Private
* @param kp The {@link KeyPair} to be cloned - ignored if {@code null}
* @return A cloned pair (or {@code null} if no original pair)
* @throws GeneralSecurityException If failed to clone - e.g., provided key
- * pair does not contain keys of the expected type
+ * pair does not contain keys of the expected type
* @see #getPublicKeyType()
- * @see #getPrivateKeyType()
+ * @see #getPrivateKeyType()
*/
KeyPair cloneKeyPair(KeyPair kp) throws GeneralSecurityException;
@@ -93,19 +94,22 @@ public interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends Private
/**
* @param keyData The key data bytes in {@code OpenSSH} format (after
- * BASE64 decoding) - ignored if {@code null}/empty
+ * BASE64 decoding) - ignored if {@code null}/empty
* @return The decoded {@link PublicKey} - or {@code null} if no data
- * @throws IOException If failed to decode the key
+ * @throws IOException If failed to decode the key
* @throws GeneralSecurityException If failed to generate the key
*/
- PUB decodePublicKey(byte ... keyData) throws IOException, GeneralSecurityException;
+ PUB decodePublicKey(byte... keyData) throws IOException, GeneralSecurityException;
+
PUB decodePublicKey(byte[] keyData, int offset, int length) throws IOException, GeneralSecurityException;
+
PUB decodePublicKey(InputStream keyData) throws IOException, GeneralSecurityException;
-
+
/**
* Encodes the {@link PublicKey} using the {@code OpenSSH} format - same
* one used by the {@code decodePublicKey} method(s)
- * @param s The {@link OutputStream} to write the data to
+ *
+ * @param s The {@link OutputStream} to write the data to
* @param key The {@link PublicKey} - may not be {@code null}
* @return The key type value - one of the {@link #getSupportedTypeNames()}
* @throws IOException If failed to generate the encoding
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/config/keys/RSAPublicKeyDecoder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/RSAPublicKeyDecoder.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/RSAPublicKeyDecoder.java
index 05349dc..22f3a05 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/RSAPublicKeyDecoder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/RSAPublicKeyDecoder.java
@@ -36,14 +36,13 @@ import java.security.spec.RSAPublicKeySpec;
import java.util.Collections;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.ValidateUtils;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class RSAPublicKeyDecoder extends AbstractPublicKeyEntryDecoder<RSAPublicKey,RSAPrivateKey> {
+public class RSAPublicKeyDecoder extends AbstractPublicKeyEntryDecoder<RSAPublicKey, RSAPrivateKey> {
public static final RSAPublicKeyDecoder INSTANCE = new RSAPublicKeyDecoder();
public RSAPublicKeyDecoder() {
@@ -56,19 +55,19 @@ public class RSAPublicKeyDecoder extends AbstractPublicKeyEntryDecoder<RSAPublic
throw new InvalidKeySpecException("Unepected key type: " + keyType);
}
- BigInteger e=decodeBigInt(keyData);
- BigInteger n=decodeBigInt(keyData);
+ BigInteger e = decodeBigInt(keyData);
+ BigInteger n = decodeBigInt(keyData);
return generatePublicKey(new RSAPublicKeySpec(n, e));
}
-
+
@Override
public String encodePublicKey(OutputStream s, RSAPublicKey key) throws IOException {
ValidateUtils.checkNotNull(key, "No public key provided");
encodeString(s, KeyPairProvider.SSH_RSA);
encodeBigInt(s, key.getPublicExponent());
encodeBigInt(s, key.getModulus());
-
+
return KeyPairProvider.SSH_RSA;
}
@@ -86,7 +85,7 @@ public class RSAPublicKeyDecoder extends AbstractPublicKeyEntryDecoder<RSAPublic
if (key == null) {
return null;
}
-
+
if (!(key instanceof RSAPrivateCrtKey)) {
throw new InvalidKeyException("Cannot clone a non-RSAPrivateCrtKey: " + key.getClass().getSimpleName());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/digest/BaseDigest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/BaseDigest.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/BaseDigest.java
index 5d10d88..910baf8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/digest/BaseDigest.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/BaseDigest.java
@@ -33,7 +33,8 @@ import org.apache.sshd.common.util.ValidateUtils;
public class BaseDigest implements Digest {
private final String algorithm;
- private final int bsize, h;
+ private final int bsize;
+ private final int h;
private final String s;
private MessageDigest md;
@@ -43,7 +44,7 @@ public class BaseDigest implements Digest {
* object will be done in the {@link #init()} method.
*
* @param algorithm the JCE algorithm to use for this digest
- * @param bsize the block size of this digest
+ * @param bsize the block size of this digest
*/
public BaseDigest(String algorithm, int bsize) {
this.algorithm = ValidateUtils.checkNotNullAndNotEmpty(algorithm, "No algorithm");
@@ -91,18 +92,20 @@ public class BaseDigest implements Digest {
@Override
public int compareTo(Digest that) {
if (that == null) {
- return (-1); // push null(s) to end
+ return -1; // push null(s) to end
} else if (this == that) {
return 0;
}
- String thisAlg = getAlgorithm(), thatAlg = that.getAlgorithm();
+ String thisAlg = getAlgorithm();
+ String thatAlg = that.getAlgorithm();
int nRes = GenericUtils.safeCompare(thisAlg, thatAlg, false);
if (nRes != 0) {
return nRes; // debug breakpoint
}
-
- if ((nRes = Integer.compare(this.getBlockSize(), that.getBlockSize())) != 0) {
+
+ nRes = Integer.compare(this.getBlockSize(), that.getBlockSize());
+ if (nRes != 0) {
return nRes; // debug breakpoint
}
@@ -120,13 +123,9 @@ public class BaseDigest implements Digest {
if (getClass() != obj.getClass()) {
return false;
}
-
+
int nRes = compareTo((Digest) obj);
- if (nRes == 0) {
- return true;
- } else {
- return false;
- }
+ return nRes == 0;
}
@Override
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
index bce8b3a..9829d9e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
@@ -39,10 +39,19 @@ public enum BuiltinDigests implements DigestInformation, DigestFactory {
sha384(Constants.SHA384, "SHA-384", 48),
sha512(Constants.SHA512, "SHA-512", 64);
+ public static final Set<BuiltinDigests> VALUES =
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinDigests.class));
+
private final String algorithm;
private final int blockSize;
private final String factoryName;
+ BuiltinDigests(String factoryName, String algorithm, int blockSize) {
+ this.factoryName = factoryName;
+ this.algorithm = algorithm;
+ this.blockSize = blockSize;
+ }
+
@Override
public final String getName() {
return factoryName;
@@ -68,15 +77,6 @@ public enum BuiltinDigests implements DigestInformation, DigestFactory {
return new BaseDigest(getAlgorithm(), getBlockSize());
}
- BuiltinDigests(String factoryName, String algorithm, int blockSize) {
- this.factoryName = factoryName;
- this.algorithm = algorithm;
- this.blockSize = blockSize;
- }
-
- public static final Set<BuiltinDigests> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinDigests.class));
-
/**
* @param s The {@link Enum}'s name - ignored if {@code null}/empty
* @return The matching {@link org.apache.sshd.common.digest.BuiltinDigests} whose {@link Enum#name()} matches
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/digest/Digest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/Digest.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/Digest.java
index 128274d..ff282f8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/digest/Digest.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/Digest.java
@@ -22,6 +22,7 @@ package org.apache.sshd.common.digest;
* Interface used to compute digests, based on algorithms such as MD5 or SHA1.
* The digest implementation are compared first by the algorithm name (case
* <U>insensitive</U> and second according to the block size
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface Digest extends DigestInformation, Comparable<Digest> {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
index 0dd7d85..218cf82 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestFactory.java
@@ -20,18 +20,11 @@
package org.apache.sshd.common.digest;
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 DigestFactory extends NamedFactory<Digest> {
- // required because of generics issues
- Transformer<DigestFactory,NamedFactory<Digest>> FAC2NAMED=new Transformer<DigestFactory,NamedFactory<Digest>>() {
- @Override
- public NamedFactory<Digest> transform(DigestFactory input) {
- return input;
- }
- };
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestUtils.java
index 4665a37..9a2b2b8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/digest/DigestUtils.java
@@ -37,7 +37,7 @@ public final class DigestUtils {
/**
* @param f The {@link Factory} to create the {@link Digest} to use
* @param s The {@link String} to digest - ignored if {@code null}/empty,
- * otherwise its UTF-8 representation is used as input for the fingerprint
+ * otherwise its UTF-8 representation is used as input for the fingerprint
* @return The fingerprint - {@code null} if {@code null}/empty input
* @throws Exception If failed to calculate the digest
* @see #getFingerPrint(Digest, String, Charset)
@@ -47,10 +47,10 @@ public final class DigestUtils {
}
/**
- * @param f The {@link Factory} to create the {@link Digest} to use
- * @param s The {@link String} to digest - ignored if {@code null}/empty
+ * @param f The {@link Factory} to create the {@link Digest} to use
+ * @param s The {@link String} to digest - ignored if {@code null}/empty
* @param charset The {@link Charset} to use in order to convert the
- * string to its byte representation to use as input for the fingerprint
+ * string to its byte representation to use as input for the fingerprint
* @return The fingerprint - {@code null} if {@code null}/empty input
* @throws Exception If failed to calculate the digest
*/
@@ -61,7 +61,7 @@ public final class DigestUtils {
/**
* @param d The {@link Digest} to use
* @param s The {@link String} to digest - ignored if {@code null}/empty,
- * otherwise its UTF-8 representation is used as input for the fingerprint
+ * otherwise its UTF-8 representation is used as input for the fingerprint
* @return The fingerprint - {@code null} if {@code null}/empty input
* @throws Exception If failed to calculate the digest
* @see #getFingerPrint(Digest, String, Charset)
@@ -71,10 +71,10 @@ public final class DigestUtils {
}
/**
- * @param d The {@link Digest} to use
- * @param s The {@link String} to digest - ignored if {@code null}/empty
+ * @param d The {@link Digest} to use
+ * @param s The {@link String} to digest - ignored if {@code null}/empty
* @param charset The {@link Charset} to use in order to convert the
- * string to its byte representation to use as input for the fingerprint
+ * string to its byte representation to use as input for the fingerprint
* @return The fingerprint - {@code null} if {@code null}/empty input
* @throws Exception If failed to calculate the digest
*/
@@ -87,21 +87,21 @@ public final class DigestUtils {
}
/**
- * @param f The {@link Factory} to create the {@link Digest} to use
+ * @param f The {@link Factory} to create the {@link Digest} to use
* @param buf The data buffer to be fingerprint-ed
* @return The fingerprint - {@code null} if empty data buffer
* @throws Exception If failed to calculate the fingerprint
* @see #getFingerPrint(Factory, byte[], int, int)
*/
- public static String getFingerPrint(Factory<? extends Digest> f, byte ... buf) throws Exception {
+ public static String getFingerPrint(Factory<? extends Digest> f, byte... buf) throws Exception {
return getFingerPrint(f, buf, 0, GenericUtils.length(buf));
}
/**
- * @param f The {@link Factory} to create the {@link Digest} to use
- * @param buf The data buffer to be fingerprint-ed
+ * @param f The {@link Factory} to create the {@link Digest} to use
+ * @param buf The data buffer to be fingerprint-ed
* @param offset The offset of the data in the buffer
- * @param len The length of data - ignored if non-positive
+ * @param len The length of data - ignored if non-positive
* @return The fingerprint - {@code null} if non-positive length
* @throws Exception If failed to calculate the fingerprint
*/
@@ -110,21 +110,21 @@ public final class DigestUtils {
}
/**
- * @param d The {@link Digest} to use
+ * @param d The {@link Digest} to use
* @param buf The data buffer to be fingerprint-ed
* @return The fingerprint - {@code null} if empty data buffer
* @throws Exception If failed to calculate the fingerprint
* @see #getFingerPrint(Digest, byte[], int, int)
*/
- public static String getFingerPrint(Digest d, byte ... buf) throws Exception {
+ public static String getFingerPrint(Digest d, byte... buf) throws Exception {
return getFingerPrint(d, buf, 0, GenericUtils.length(buf));
}
-
+
/**
- * @param d The {@link Digest} to use
- * @param buf The data buffer to be fingerprint-ed
+ * @param d The {@link Digest} to use
+ * @param buf The data buffer to be fingerprint-ed
* @param offset The offset of the data in the buffer
- * @param len The length of data - ignored if non-positive
+ * @param len The length of data - ignored if non-positive
* @return The fingerprint - {@code null} if non-positive length
* @throws Exception If failed to calculate the fingerprint
*/
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemFactory.java
index bab4dda..6564466 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemFactory.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -33,6 +33,7 @@ public interface FileSystemFactory {
/**
* Create user specific file system.
+ *
* @param session The session created for the user
* @return The current {@link FileSystem} for the provided session
* @throws java.io.IOException when the filesystem can not be created
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeFileSystemFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeFileSystemFactory.java
index 53ae321..65ece51 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeFileSystemFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/nativefs/NativeFileSystemFactory.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -40,13 +40,14 @@ public class NativeFileSystemFactory extends AbstractLoggingBean implements File
public NativeFileSystemFactory() {
this(false);
}
-
+
public NativeFileSystemFactory(boolean createHome) {
this.createHome = createHome;
}
/**
* Should the home directories be created automatically
+ *
* @return true if the file system will create the home directory if not available
*/
public boolean isCreateHome() {
@@ -55,6 +56,7 @@ public class NativeFileSystemFactory extends AbstractLoggingBean implements File
/**
* Set if the home directories be created automatically
+ *
* @param createHome true if the file system will create the home directory if not available
*/
public void setCreateHome(boolean createHome) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
index 1d07cef..057e112 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
@@ -32,7 +32,6 @@ import java.nio.file.DirectoryStream;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemAlreadyExistsException;
-import java.nio.file.FileSystemException;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
@@ -49,7 +48,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
@@ -88,7 +86,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
protected FileSystem newFileSystem(Object src, Path path, Map<String, ?> env) throws IOException {
Path root = ensureDirectory(path).toRealPath();
- RootedFileSystem rootedFs=null;
+ RootedFileSystem rootedFs = null;
synchronized (fileSystems) {
if (!this.fileSystems.containsKey(root)) {
rootedFs = new RootedFileSystem(this, path, env);
@@ -105,7 +103,8 @@ public class RootedFileSystemProvider extends FileSystemProvider {
}
protected Path uriToPath(URI uri) {
- String scheme = uri.getScheme(), expected = getScheme();
+ String scheme = uri.getScheme();
+ String expected = getScheme();
if ((scheme == null) || (!scheme.equalsIgnoreCase(expected))) {
throw new IllegalArgumentException("URI scheme (" + scheme + ") is not '" + expected + "'");
}
@@ -162,7 +161,8 @@ public class RootedFileSystemProvider extends FileSystemProvider {
}
@Override
- public AsynchronousFileChannel newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs) throws IOException {
+ public AsynchronousFileChannel newAsynchronousFileChannel(Path path, Set<? extends OpenOption> options,
+ ExecutorService executor, FileAttribute<?>... attrs) throws IOException {
Path r = unroot(path);
FileSystemProvider p = provider(r);
return p.newAsynchronousFileChannel(r, options, executor, attrs);
@@ -269,17 +269,17 @@ public class RootedFileSystemProvider extends FileSystemProvider {
Path rootInstance = null;
RootedFileSystem fsInstance = null;
synchronized (fileSystems) {
- for (Map.Entry<Path,RootedFileSystem> fse : fileSystems.entrySet()) {
+ for (Map.Entry<Path, RootedFileSystem> fse : fileSystems.entrySet()) {
Path root = fse.getKey();
RootedFileSystem fs = fse.getValue();
if (real.equals(root)) {
return fs; // we were lucky to have the root
}
-
+
if (!real.startsWith(root)) {
continue;
}
-
+
// if already have a candidate prefer the longer match since both are prefixes of the real path
if ((rootInstance == null) || (rootInstance.getNameCount() < root.getNameCount())) {
rootInstance = root;
@@ -291,7 +291,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
if (fsInstance == null) {
throw new FileSystemNotFoundException(path.toString());
}
-
+
return fsInstance;
}
@@ -335,7 +335,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
return fs.provider();
}
- private static Path root(FileSystem fs, Path nat) {
+ private static Path root(FileSystem fs, Path nat) {
RootedFileSystem rfs = (RootedFileSystem) fs;
if (nat.isAbsolute()) {
Path root = rfs.getRoot();
@@ -354,7 +354,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
ValidateUtils.checkNotNull(path, "No path to unroot");
if (!(path instanceof RootedPath)) {
throw new ProviderMismatchException("unroot(" + path + ") is not a " + RootedPath.class.getSimpleName()
- + " but rather a " + path.getClass().getSimpleName());
+ + " but rather a " + path.getClass().getSimpleName());
}
RootedPath p = (RootedPath) path;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
index c6bd7df..386df6f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -75,7 +75,7 @@ public abstract class BaseFileSystem<T extends Path> extends FileSystem {
if (!GenericUtils.isEmpty(first)) {
appendDedupSep(sb, first.replace('\\', '/')); // in case we are running on Windows
}
-
+
if (GenericUtils.length(more) > 0) {
for (String segment : more) {
if ((sb.length() > 0) && (sb.charAt(sb.length() - 1) != '/')) {
@@ -90,13 +90,14 @@ public abstract class BaseFileSystem<T extends Path> extends FileSystem {
sb.setLength(sb.length() - 1);
}
- String path = sb.toString(), root = null;
+ String path = sb.toString();
+ String root = null;
if (path.startsWith("/")) {
root = "/";
path = path.substring(1);
}
- String[] names=GenericUtils.split(path, '/');
+ String[] names = GenericUtils.split(path, '/');
return create(root, names);
}
@@ -128,7 +129,7 @@ public abstract class BaseFileSystem<T extends Path> extends FileSystem {
break;
default:
throw new UnsupportedOperationException("Unsupported path matcher syntax: \'" + syntax + "\'");
- }
+ }
final Pattern regex = Pattern.compile(expr);
return new PathMatcher() {
@Override
@@ -148,81 +149,72 @@ public abstract class BaseFileSystem<T extends Path> extends FileSystem {
for (int i = 0; i < arr.length; i++) {
char ch = arr[i];
switch (ch) {
- case '\\':
- if (++i >= arr.length) {
- sb.append('\\');
- } else {
- char next = arr[i];
- switch (next) {
- case ',':
- // escape not needed
- break;
- case 'Q':
- case 'E':
- // extra escape needed
+ case '\\':
+ if (++i >= arr.length) {
sb.append('\\');
- default:
+ } else {
+ char next = arr[i];
+ switch (next) {
+ case ',':
+ // escape not needed
+ break;
+ case 'Q':
+ case 'E':
+ // extra escape needed
+ sb.append("\\\\");
+ break;
+ default:
+ sb.append('\\');
+ break;
+ }
+ sb.append(next);
+ }
+ break;
+ case '*':
+ sb.append(inClass == 0 ? ".*" : "*");
+ break;
+ case '?':
+ sb.append(inClass == 0 ? '.' : '?');
+ break;
+ case '[':
+ inClass++;
+ firstIndexInClass = i + 1;
+ sb.append('[');
+ break;
+ case ']':
+ inClass--;
+ sb.append(']');
+ break;
+ case '.':
+ case '(':
+ case ')':
+ case '+':
+ case '|':
+ case '^':
+ case '$':
+ case '@':
+ case '%':
+ if (inClass == 0 || (firstIndexInClass == i && ch == '^')) {
sb.append('\\');
}
- sb.append(next);
- }
- break;
- case '*':
- if (inClass == 0)
- sb.append(".*");
- else
- sb.append('*');
- break;
- case '?':
- if (inClass == 0)
- sb.append('.');
- else
- sb.append('?');
- break;
- case '[':
- inClass++;
- firstIndexInClass = i+1;
- sb.append('[');
- break;
- case ']':
- inClass--;
- sb.append(']');
- break;
- case '.':
- case '(':
- case ')':
- case '+':
- case '|':
- case '^':
- case '$':
- case '@':
- case '%':
- if (inClass == 0 || (firstIndexInClass == i && ch == '^'))
- sb.append('\\');
- sb.append(ch);
- break;
- case '!':
- if (firstIndexInClass == i)
- sb.append('^');
- else
- sb.append('!');
- break;
- case '{':
- inGroup++;
- sb.append('(');
- break;
- case '}':
- inGroup--;
- sb.append(')');
- break;
- case ',':
- if (inGroup > 0)
- sb.append('|');
- else
- sb.append(',');
- break;
- default:
- sb.append(ch);
+ sb.append(ch);
+ break;
+ case '!':
+ sb.append(firstIndexInClass == i ? '^' : '!');
+ break;
+ case '{':
+ inGroup++;
+ sb.append('(');
+ break;
+ case '}':
+ inGroup--;
+ sb.append(')');
+ break;
+ case ',':
+ sb.append(inGroup > 0 ? '|' : ',');
+ break;
+ default:
+ sb.append(ch);
}
}
return sb.toString();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
index 80ed9fe..3a795da 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
@@ -42,7 +42,7 @@ import org.apache.sshd.common.util.ValidateUtils;
public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSystem<T>> implements Path {
- private final FS fileSystem;
+ protected final FS fileSystem;
protected final String root;
protected final ImmutableList<String> names;
@@ -135,8 +135,8 @@ public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSys
T p1 = asT();
T p2 = checkPath(other);
return Objects.equals(p1.getFileSystem(), p2.getFileSystem())
- && Objects.equals(p1.root, p2.root)
- && startsWith(p1.names, p2.names);
+ && Objects.equals(p1.root, p2.root)
+ && startsWith(p1.names, p2.names);
}
@Override
@@ -361,7 +361,7 @@ public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSys
throw new ProviderMismatchException("Path is not of this class: " + paramPath + "[" + paramPath.getClass().getSimpleName() + "]");
}
T t = (T) paramPath;
-
+
FileSystem fs = t.getFileSystem();
if (fs.provider() != this.fileSystem.provider()) {
throw new ProviderMismatchException("Mismatched providers for " + t);
@@ -393,7 +393,7 @@ public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSys
sb.append(root);
}
for (String name : names) {
- if (sb.length() > 0 && sb.charAt(sb.length() - 1) != '/') {
+ if (sb.length() > 0 && sb.charAt(sb.length() - 1) != '/') {
sb.append(fileSystem.getSeparator());
}
sb.append(name);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java
index 4193fa0..123bbf2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -22,6 +22,7 @@ import java.util.AbstractList;
/**
* Simple immutable array list
+ *
* @param <T>
*/
public class ImmutableList<T> extends AbstractList<T> {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/file/virtualfs/VirtualFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/virtualfs/VirtualFileSystemFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/file/virtualfs/VirtualFileSystemFactory.java
index 2809787..b0c7e45 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/virtualfs/VirtualFileSystemFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/virtualfs/VirtualFileSystemFactory.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -74,7 +74,7 @@ public class VirtualFileSystemFactory implements FileSystemFactory {
@Override
public FileSystem createFileSystem(Session session) throws IOException {
String dir = computeRootDir(session.getUsername());
- return new RootedFileSystemProvider().newFileSystem(Paths.get(dir), Collections.<String,Object>emptyMap());
+ return new RootedFileSystemProvider().newFileSystem(Paths.get(dir), Collections.<String, Object>emptyMap());
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
index aad59eb..299af5d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
@@ -60,23 +60,23 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
private final ConnectionService service;
private final IoHandlerFactory socksProxyIoHandlerFactory = new IoHandlerFactory() {
- @Override
- public IoHandler create() {
- return new SocksProxy(getConnectionService());
- }
- };
+ @Override
+ public IoHandler create() {
+ return new SocksProxy(getConnectionService());
+ }
+ };
private final Session session;
private final Map<Integer, SshdSocketAddress> localToRemote = new HashMap<>();
private final Map<Integer, SshdSocketAddress> remoteToLocal = new HashMap<>();
private final Map<Integer, SocksProxy> dynamicLocal = new HashMap<>();
private final Set<LocalForwardingEntry> localForwards = new HashSet<>();
private final IoHandlerFactory staticIoHandlerFactory = new IoHandlerFactory() {
- @Override
- public IoHandler create() {
- return new StaticIoHandler();
- }
- };
- protected IoAcceptor acceptor;
+ @Override
+ public IoHandler create() {
+ return new StaticIoHandler();
+ }
+ };
+ private IoAcceptor acceptor;
public DefaultTcpipForwarder(ConnectionService service) {
this.service = ValidateUtils.checkNotNull(service, "No connection service");
@@ -107,10 +107,10 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
InetSocketAddress bound = doBind(local, staticIoHandlerFactory);
int port = bound.getPort();
SshdSocketAddress prev;
- synchronized(localToRemote) {
+ synchronized (localToRemote) {
prev = localToRemote.put(port, remote);
}
-
+
if (prev != null) {
throw new IOException("Multiple local port forwarding bindings on port=" + port + ": current=" + remote + ", previous=" + prev);
}
@@ -127,7 +127,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
ValidateUtils.checkNotNull(local, "Local address is null");
SshdSocketAddress bound;
- synchronized(localToRemote) {
+ synchronized (localToRemote) {
bound = localToRemote.remove(local.getPort());
}
@@ -160,10 +160,10 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
int port = (remote.getPort() == 0) ? result.getInt() : remote.getPort();
// TODO: Is it really safe to only store the local address after the request ?
SshdSocketAddress prev;
- synchronized(remoteToLocal) {
+ synchronized (remoteToLocal) {
prev = remoteToLocal.put(port, local);
}
-
+
if (prev != null) {
throw new IOException("Multiple remote port forwarding bindings on port=" + port + ": current=" + remote + ", previous=" + prev);
}
@@ -179,7 +179,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
@Override
public synchronized void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException {
SshdSocketAddress bound;
- synchronized(remoteToLocal) {
+ synchronized (remoteToLocal) {
bound = remoteToLocal.remove(remote.getPort());
}
@@ -213,13 +213,14 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
throw new IllegalStateException("TcpipForwarder is closing");
}
- SocksProxy socksProxy = new SocksProxy(service), prev;
+ SocksProxy socksProxy = new SocksProxy(service);
+ SocksProxy prev;
InetSocketAddress bound = doBind(local, socksProxyIoHandlerFactory);
int port = bound.getPort();
- synchronized(dynamicLocal) {
+ synchronized (dynamicLocal) {
prev = dynamicLocal.put(port, socksProxy);
}
-
+
if (prev != null) {
throw new IOException("Multiple dynamic port mappings found for port=" + port + ": current=" + socksProxy + ", previous=" + prev);
}
@@ -228,14 +229,14 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
if (log.isDebugEnabled()) {
log.debug("startDynamicPortForwarding(" + local + "): " + result);
}
-
+
return result;
}
@Override
public synchronized void stopDynamicPortForwarding(SshdSocketAddress local) throws IOException {
Closeable obj;
- synchronized(dynamicLocal) {
+ synchronized (dynamicLocal) {
obj = dynamicLocal.remove(local.getPort());
}
@@ -254,7 +255,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
@Override
public synchronized SshdSocketAddress getForwardedPort(int remotePort) {
- synchronized(remoteToLocal) {
+ synchronized (remoteToLocal) {
return remoteToLocal.get(remotePort);
}
}
@@ -263,7 +264,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
public synchronized SshdSocketAddress localPortForwardingRequested(SshdSocketAddress local) throws IOException {
ValidateUtils.checkNotNull(local, "Local address is null");
ValidateUtils.checkTrue(local.getPort() >= 0, "Invalid local port: %s", local);
-
+
FactoryManager manager = session.getFactoryManager();
ForwardingFilter filter = manager.getTcpipForwardingFilter();
if ((filter == null) || (!filter.canListen(local, session))) {
@@ -279,11 +280,11 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
}
boolean added;
- synchronized(localForwards) {
+ synchronized (localForwards) {
// NOTE !!! it is crucial to use the bound address host name first
added = localForwards.add(new LocalForwardingEntry(result.getHostName(), local.getHostName(), result.getPort()));
}
-
+
if (!added) {
throw new IOException("Failed to add local port forwarding entry for " + local + " -> " + result);
}
@@ -293,8 +294,9 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
@Override
public synchronized void localPortForwardingCancelled(SshdSocketAddress local) throws IOException {
LocalForwardingEntry entry;
- synchronized(localForwards) {
- if ((entry=LocalForwardingEntry.findMatchingEntry(local.getHostName(), local.getPort(), localForwards)) != null) {
+ synchronized (localForwards) {
+ entry = LocalForwardingEntry.findMatchingEntry(local.getHostName(), local.getPort(), localForwards);
+ if (entry != null) {
localForwards.remove(entry);
}
}
@@ -317,7 +319,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
}
/**
- * @param address The request bind address
+ * @param address The request bind address
* @param handlerFactory A {@link Factory} to create an {@link IoHandler} if necessary
* @return The {@link InetSocketAddress} to which the binding occurred
* @throws IOException If failed to bind
@@ -333,7 +335,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
// TODO find a better way to determine the resulting bind address - what if multi-threaded calls...
Set<SocketAddress> before = acceptor.getBoundAddresses();
try {
- InetSocketAddress bindAddress = address.toInetSocketAddress();
+ InetSocketAddress bindAddress = address.toInetSocketAddress();
acceptor.bind(bindAddress);
Set<SocketAddress> after = acceptor.getBoundAddresses();
@@ -374,7 +376,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
@SuppressWarnings("synthetic-access")
@Override
public void sessionCreated(final IoSession session) throws Exception {
- InetSocketAddress local = (InetSocketAddress) session.getLocalAddress();
+ InetSocketAddress local = (InetSocketAddress) session.getLocalAddress();
int localPort = local.getPort();
SshdSocketAddress remote = localToRemote.get(localPort);
final TcpipClientChannel channel;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarderFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarderFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarderFactory.java
index b05f84c..d9837ec 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarderFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarderFactory.java
@@ -23,8 +23,8 @@ import org.apache.sshd.common.session.ConnectionService;
/**
* The default {@link TcpipForwarderFactory} implementation.
*
- * @see {@link DefaultTcpipForwarder}
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ * @see {@link DefaultTcpipForwarder}
*/
public class DefaultTcpipForwarderFactory implements TcpipForwarderFactory {
public static final DefaultTcpipForwarderFactory INSTANCE = new DefaultTcpipForwarderFactory();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
index b1872ba..610936a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
@@ -63,12 +63,12 @@ public class LocalForwardingEntry extends SshdSocketAddress {
public String toString() {
return super.toString() + " - " + getAlias();
}
-
+
/**
- * @param host The host - ignored if {@code null}/empty - i.e., no match reported
- * @param port The port - ignored if non-positive - i.e., no match reported
+ * @param host The host - ignored if {@code null}/empty - i.e., no match reported
+ * @param port The port - ignored if non-positive - i.e., no match reported
* @param entries The {@link Collection} of {@link LocalForwardingEntry} to check
- * - ignored if {@code null}/empty - i.e., no match reported
+ * - ignored if {@code null}/empty - i.e., no match reported
* @return The <U>first</U> entry whose host or alias matches the host name - case
* <U>sensitive</U> <B>and</B> has a matching port - {@code null} if no match found
*/
@@ -76,13 +76,13 @@ public class LocalForwardingEntry extends SshdSocketAddress {
if (GenericUtils.isEmpty(host) || (port <= 0) || (GenericUtils.isEmpty(entries))) {
return null;
}
-
+
for (LocalForwardingEntry e : entries) {
if ((port == e.getPort()) && (host.equals(e.getHostName()) || host.equals(e.getAlias()))) {
return e;
}
}
-
+
return null; // no match found
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
index c0d6a7c..b09242a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
@@ -36,6 +36,7 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
/**
* SOCKS proxy server, supporting simple socks4/5 protocols.
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
* @see <A HREF="https://en.wikipedia.org/wiki/SOCKS">SOCKS Wikipedia</A>
*/
@@ -85,9 +86,9 @@ public class SocksProxy extends CloseableUtils.AbstractCloseable implements IoHa
}
@Override
- public void exceptionCaught(IoSession ioSession, Throwable cause) throws Exception {
+ public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
log.warn("Exception caught, closing socks proxy", cause);
- ioSession.close(false);
+ session.close(false);
}
public abstract class Proxy implements Closeable {
@@ -138,9 +139,9 @@ public class SocksProxy extends CloseableUtils.AbstractCloseable implements IoHa
}
int port = getUShort(buffer);
String host = Integer.toString(getUByte(buffer)) + "."
- + Integer.toString(getUByte(buffer)) + "."
- + Integer.toString(getUByte(buffer)) + "."
- + Integer.toString(getUByte(buffer));
+ + Integer.toString(getUByte(buffer)) + "."
+ + Integer.toString(getUByte(buffer)) + "."
+ + Integer.toString(getUByte(buffer));
String userId = getNTString(buffer);
// Socks4a
if (host.startsWith("0.0.0.")) {
@@ -246,20 +247,20 @@ public class SocksProxy extends CloseableUtils.AbstractCloseable implements IoHa
String host;
if (type == 0x01) {
host = Integer.toString(getUByte(buffer)) + "."
- + Integer.toString(getUByte(buffer)) + "."
- + Integer.toString(getUByte(buffer)) + "."
- + Integer.toString(getUByte(buffer));
+ + Integer.toString(getUByte(buffer)) + "."
+ + Integer.toString(getUByte(buffer)) + "."
+ + Integer.toString(getUByte(buffer));
} else if (type == 0x03) {
host = getBLString(buffer);
} else if (type == 0x04) {
host = Integer.toHexString(getUShort(buffer)) + ":"
- + Integer.toHexString(getUShort(buffer)) + ":"
- + Integer.toHexString(getUShort(buffer)) + ":"
- + Integer.toHexString(getUShort(buffer)) + ":"
- + Integer.toHexString(getUShort(buffer)) + ":"
- + Integer.toHexString(getUShort(buffer)) + ":"
- + Integer.toHexString(getUShort(buffer)) + ":"
- + Integer.toHexString(getUShort(buffer));
+ + Integer.toHexString(getUShort(buffer)) + ":"
+ + Integer.toHexString(getUShort(buffer)) + ":"
+ + Integer.toHexString(getUShort(buffer)) + ":"
+ + Integer.toHexString(getUShort(buffer)) + ":"
+ + Integer.toHexString(getUShort(buffer)) + ":"
+ + Integer.toHexString(getUShort(buffer)) + ":"
+ + Integer.toHexString(getUShort(buffer));
} else {
throw new IllegalStateException("Unsupported address type: " + type);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
index 0f4d89a..8d8a729 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
@@ -63,7 +63,8 @@ public class TcpipClientChannel extends AbstractClientChannel {
@Override
public synchronized OpenFuture open() throws IOException {
- final InetSocketAddress src, dst;
+ final InetSocketAddress src;
+ final InetSocketAddress dst;
switch (typeEnum) {
case Direct:
src = (InetSocketAddress) serverSession.getRemoteAddress();
@@ -100,7 +101,8 @@ public class TcpipClientChannel extends AbstractClientChannel {
if (streaming == Streaming.Async) {
throw new IllegalArgumentException("Asynchronous streaming isn't supported yet on this channel");
}
- invertedIn = out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
+ out = new ChannelOutputStream(this, remoteWindow, log, SshConstants.SSH_MSG_CHANNEL_DATA);
+ invertedIn = out;
}
@Override
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
index 16e9a1f..a278ab0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
@@ -28,14 +28,16 @@ public interface TcpipForwarder extends Closeable {
/**
* Start forwarding the given local address on the client to the given address on the server.
+ *
* @param remote The remote address
- * @param local The local address
+ * @param local The local address
* @throws IOException If failed to handle request
*/
SshdSocketAddress startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws IOException;
/**
* Stop forwarding the given local address.
+ *
* @param local The local address
* @throws IOException If failed to handle request
*/
@@ -44,26 +46,28 @@ public interface TcpipForwarder extends Closeable {
/**
* Start forwarding tcpip from the given remote address to the
* given local address.
- *
+ * <p/>
* The remote host name is the address to bind to on the server:
* <ul>
- * <li>"" means that connections are to be accepted on all protocol families
- * supported by the SSH implementation</li>
- * <li>"0.0.0.0" means to listen on all IPv4 addresses</li>
- * <li>"::" means to listen on all IPv6 addresses</li>
- * <li>"localhost" means to listen on all protocol families supported by the SSH
- * implementation on loopback addresses only, [RFC3330] and RFC3513]</li>
- * <li>"127.0.0.1" and "::1" indicate listening on the loopback interfaces for
- * IPv4 and IPv6 respectively</li>
+ * <li>"" means that connections are to be accepted on all protocol families
+ * supported by the SSH implementation</li>
+ * <li>"0.0.0.0" means to listen on all IPv4 addresses</li>
+ * <li>"::" means to listen on all IPv6 addresses</li>
+ * <li>"localhost" means to listen on all protocol families supported by the SSH
+ * implementation on loopback addresses only, [RFC3330] and RFC3513]</li>
+ * <li>"127.0.0.1" and "::1" indicate listening on the loopback interfaces for
+ * IPv4 and IPv6 respectively</li>
* </ul>
+ *
* @param remote The remote address
- * @param local The local address
+ * @param local The local address
* @throws IOException If failed to handle request
*/
SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException;
/**
* Stop forwarding of the given remote address.
+ *
* @param remote The remote {@link SshdSocketAddress}
* @throws IOException If failed to handle request
*/
@@ -77,6 +81,7 @@ public interface TcpipForwarder extends Closeable {
/**
* Called when the other side requested a remote port forward.
+ *
* @param local The request address
* @return The bound local addresses
* @throws IOException If failed to handle request
@@ -85,6 +90,7 @@ public interface TcpipForwarder extends Closeable {
/**
* Called when the other side cancelled a remote port forward.
+ *
* @param local The local {@link SshdSocketAddress}
* @throws IOException If failed to handle request
*/
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
index 3b95064..973f226 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultSshFuture.java
@@ -35,12 +35,18 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean implements SshFuture<T> {
- /** A default value to indicate the future has been canceled */
+ /**
+ * A default value to indicate the future has been canceled
+ */
private static final Object CANCELED = new Object();
- /** A value indicating a null */
+ /**
+ * A value indicating a null
+ */
private static final Object NULL = new Object();
- /** A lock used by the wait() method */
+ /**
+ * A lock used by the wait() method
+ */
private final Object lock;
private Object listeners;
private Object result;
@@ -100,31 +106,32 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
* <P>Waits (interruptible) for the specified timeout (msec.) and then checks
* the result:</P><BR/>
* <UL>
- * <LI>
- * If result is {@code null} then timeout is assumed to have expired - throw
- * an appropriate {@link IOException}
- * </LI>
- *
- * <LI>
- * If the result is of the expected type, then cast and return it
- * </LI>
- *
- * <LI>
- * If the result is an {@link IOException} then re-throw it
- * </LI>
- *
- * <LI>
- * If the result is a {@link Throwable} then throw an {@link IOException}
- * whose cause is the original exception
- * </LI>
- *
- * <LI>
- * Otherwise (should never happen), throw a {@link StreamCorruptedException}
- * with the name of the result type
- * </LI>
+ * <LI>
+ * If result is {@code null} then timeout is assumed to have expired - throw
+ * an appropriate {@link IOException}
+ * </LI>
+ * <p/>
+ * <LI>
+ * If the result is of the expected type, then cast and return it
+ * </LI>
+ * <p/>
+ * <LI>
+ * If the result is an {@link IOException} then re-throw it
+ * </LI>
+ * <p/>
+ * <LI>
+ * If the result is a {@link Throwable} then throw an {@link IOException}
+ * whose cause is the original exception
+ * </LI>
+ * <p/>
+ * <LI>
+ * Otherwise (should never happen), throw a {@link StreamCorruptedException}
+ * with the name of the result type
+ * </LI>
* </UL>
+ *
* @param expectedType The expected result type
- * @param timeout The timeout (millis) to wait for a result
+ * @param timeout The timeout (millis) to wait for a result
* @return The (never {@code null}) result
* @throws IOException If failed to retrieve the expected result on time
*/
@@ -133,7 +140,7 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
if (value == null) {
throw new SshException("Failed to get operation result within specified timeout: " + timeout);
}
-
+
Class<?> actualType = value.getClass();
if (expectedType.isAssignableFrom(actualType)) {
return expectedType.cast(value);
@@ -150,18 +157,20 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
/**
* Wait for the Future to be ready. If the requested delay is 0 or
* negative, this method immediately returns.
+ *
* @param timeoutMillis The delay we will wait for the Future to be ready
* @param interruptable Tells if the wait can be interrupted or not.
- * If {@code true} and the thread is interrupted then an {@link InterruptedIOException}
- * is thrown.
+ * If {@code true} and the thread is interrupted then an {@link InterruptedIOException}
+ * is thrown.
* @return The non-{@code null} result object if the Future is ready,
* {@code null} if the timeout expired and no result was received
* @throws InterruptedIOException If the thread has been interrupted
- * when it's not allowed.
+ * when it's not allowed.
*/
protected Object await0(long timeoutMillis, boolean interruptable) throws InterruptedIOException {
ValidateUtils.checkTrue(timeoutMillis >= 0L, "Negative timeout N/A: %d", timeoutMillis);
- long startTime = System.currentTimeMillis(), curTime = startTime;
+ long startTime = System.currentTimeMillis();
+ long curTime = startTime;
long endTime = ((Long.MAX_VALUE - timeoutMillis) < curTime) ? Long.MAX_VALUE : (curTime + timeoutMillis);
synchronized (lock) {
@@ -231,7 +240,7 @@ public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean i
if (listeners == null) {
listeners = listener;
} else if (listeners instanceof SshFutureListener) {
- listeners = new Object[] { listeners, listener };
+ listeners = new Object[]{listeners, listener};
} else {
Object[] ol = (Object[]) listeners;
int l = ol.length;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
index ecb5d07..8963aae 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFuture.java
@@ -34,25 +34,28 @@ public interface SshFuture<T extends SshFuture> {
* Wait for the asynchronous operation to complete.
* The attached listeners will be notified when the operation is
* completed.
+ *
* @return The {@code this} instance
* @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
- * if waiting was interrupted
+ * if waiting was interrupted
*/
T await() throws IOException;
/**
* Wait for the asynchronous operation to complete with the specified timeout.
+ *
* @return {@code true} if the operation is completed.
* @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
- * if waiting was interrupted
+ * if waiting was interrupted
*/
boolean await(long timeout, TimeUnit unit) throws IOException;
/**
* Wait for the asynchronous operation to complete with the specified timeout.
+ *
* @return {@code true} if the operation is completed.
* @throws IOException if failed - specifically {@link java.io.InterruptedIOException}
- * if waiting was interrupted
+ * if waiting was interrupted
*/
boolean await(long timeoutMillis) throws IOException;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
index 7681899..7422ed9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/SshFutureListener.java
@@ -32,8 +32,8 @@ public interface SshFutureListener<T extends SshFuture> extends EventListener {
* Invoked when the operation associated with the {@link SshFuture}
* has been completed even if you add the listener after the completion.
*
- * @param future The source {@link SshFuture} which called this
- * callback.
+ * @param future The source {@link SshFuture} which called this
+ * callback.
*/
void operationComplete(T future);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactoryFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactoryFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactoryFactory.java
index 9d9b312..6510439 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactoryFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoServiceFactoryFactory.java
@@ -28,8 +28,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 AbstractIoServiceFactoryFactory
- extends AbstractLoggingBean
- implements IoServiceFactoryFactory, ExecutorServiceConfigurer {
+ extends AbstractLoggingBean
+ implements IoServiceFactoryFactory, ExecutorServiceConfigurer {
private ExecutorService executorService;
private boolean shutdownExecutor;
@@ -56,7 +56,7 @@ public abstract class AbstractIoServiceFactoryFactory
@Override
public void setExecutorService(ExecutorService service) {
executorService = service;
-
+
}
@Override
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
index da71b02..187b6a1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
@@ -35,26 +35,30 @@ public enum BuiltinIoServiceFactoryFactories implements NamedFactory<IoServiceFa
NIO2(Nio2ServiceFactoryFactory.class),
NMINA(MinaServiceFactoryFactory.class);
+ public static final Set<BuiltinIoServiceFactoryFactories> VALUES =
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinIoServiceFactoryFactories.class));
+
private final Class<? extends IoServiceFactoryFactory> factoryClass;
- public final Class<? extends IoServiceFactoryFactory> getFactoryClass() {
- return factoryClass;
- }
BuiltinIoServiceFactoryFactories(Class<? extends IoServiceFactoryFactory> clazz) {
factoryClass = clazz;
}
+ public final Class<? extends IoServiceFactoryFactory> getFactoryClass() {
+ return factoryClass;
+ }
+
@Override
public final String getName() {
return name().toLowerCase();
}
-
+
@Override
public final IoServiceFactoryFactory create() {
- Class<? extends IoServiceFactoryFactory> clazz=getFactoryClass();
+ Class<? extends IoServiceFactoryFactory> clazz = getFactoryClass();
try {
return clazz.newInstance();
- } catch(Exception e) {
+ } catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
@@ -62,25 +66,22 @@ public enum BuiltinIoServiceFactoryFactories implements NamedFactory<IoServiceFa
}
}
}
-
- public static final Set<BuiltinIoServiceFactoryFactories> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinIoServiceFactoryFactories.class));
public static BuiltinIoServiceFactoryFactories fromFactoryName(String name) {
return NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, VALUES);
}
-
+
public static BuiltinIoServiceFactoryFactories fromFactoryClass(Class<?> clazz) {
if ((clazz == null) || (!IoServiceFactoryFactory.class.isAssignableFrom(clazz))) {
return null;
}
-
+
for (BuiltinIoServiceFactoryFactories f : VALUES) {
if (clazz.isAssignableFrom(f.getFactoryClass())) {
return f;
}
}
-
+
return null;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
index 0dcb30d..1ee6697 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactory.java
@@ -39,7 +39,7 @@ public class DefaultIoServiceFactoryFactory extends AbstractIoServiceFactoryFact
public DefaultIoServiceFactoryFactory() {
this(null, true);
}
-
+
protected DefaultIoServiceFactoryFactory(ExecutorService executors, boolean shutdownOnExit) {
super(executors, shutdownOnExit);
}
@@ -54,7 +54,7 @@ public class DefaultIoServiceFactoryFactory extends AbstractIoServiceFactoryFact
if (factory == null) {
factory = newInstance(IoServiceFactoryFactory.class);
if (factory instanceof ExecutorServiceConfigurer) {
- ExecutorServiceConfigurer configurer=(ExecutorServiceConfigurer) factory;
+ ExecutorServiceConfigurer configurer = (ExecutorServiceConfigurer) factory;
configurer.setExecutorService(getExecutorService());
configurer.setShutdownOnExit(isShutdownOnExit());
}
@@ -102,7 +102,7 @@ public class DefaultIoServiceFactoryFactory extends AbstractIoServiceFactoryFact
}
public static <T extends IoServiceFactoryFactory> T newInstance(Class<T> clazz, String factory) {
- BuiltinIoServiceFactoryFactories builtin = BuiltinIoServiceFactoryFactories.fromFactoryName(factory);
+ BuiltinIoServiceFactoryFactories builtin = BuiltinIoServiceFactoryFactories.fromFactoryName(factory);
if (builtin != null) {
return clazz.cast(builtin.create());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/io/IoConnectFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoConnectFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoConnectFuture.java
index 351e5e7..50b2053 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoConnectFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoConnectFuture.java
@@ -28,7 +28,7 @@ public interface IoConnectFuture extends SshFuture<IoConnectFuture> {
* Returns the cause of the connection failure.
*
* @return <tt>null</tt> if the connect operation is not finished yet,
- * or if the connection attempt is successful.
+ * or if the connection attempt is successful.
*/
Throwable getException();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandler.java
index 1d877e4..b0db68a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandler.java
@@ -28,7 +28,7 @@ public interface IoHandler {
void sessionClosed(IoSession session) throws Exception;
- void exceptionCaught(IoSession ioSession, Throwable cause) throws Exception;
+ void exceptionCaught(IoSession session, Throwable cause) throws Exception;
void messageReceived(IoSession session, Readable message) throws Exception;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
index 168df15..35c133f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoHandlerFactory.java
@@ -20,18 +20,11 @@
package org.apache.sshd.common.io;
import org.apache.sshd.common.Factory;
-import org.apache.sshd.common.util.Transformer;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
+// CHECKSTYLE:OFF
public interface IoHandlerFactory extends Factory<IoHandler> {
- // may be required due to generics reasons
- Transformer<IoHandlerFactory,Factory<IoHandler>> FAC2FAC =
- new Transformer<IoHandlerFactory, Factory<IoHandler>>() {
- @Override
- public Factory<IoHandler> transform(IoHandlerFactory input) {
- return input;
- }
- };
+
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
index a857d1c..d9232a3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/IoReadFuture.java
@@ -27,10 +27,13 @@ import org.apache.sshd.common.util.buffer.Buffer;
public interface IoReadFuture extends SshFuture<IoReadFuture> {
/**
* Wait and verify that the read succeeded.
+ *
* @throws IOException if the action failed for any reason
*/
void verify() throws IOException;
+
void verify(long timeout, TimeUnit unit) throws IOException;
+
void verify(long timeoutMillis) throws IOException;
Buffer getBuffer();