You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gg...@apache.org on 2023/07/16 13:52:06 UTC
[mina-sshd] branch master updated (0263a7355 -> 441ca31c9)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
from 0263a7355 Bump Bouncy Castle from 1.73 to 1.75
new d459158b8 Use stock JRE Charset instead of magic string
new 441ca31c9 No need to nest
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../config/keys/loader/openssh/kdf/BCrypt.java | 11 +++---
.../apache/sshd/common/util/io/FileSnapshot.java | 26 +++++++-------
.../sshd/common/util/threads/ThreadUtils.java | 41 ++++++++++------------
.../apache/sshd/common/channel/LocalWindow.java | 2 +-
4 files changed, 37 insertions(+), 43 deletions(-)
[mina-sshd] 02/02: No need to nest
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit 441ca31c9c5bf8c0b71aa9602b3e570e32be0703
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 16 09:51:44 2023 -0400
No need to nest
---
.../sshd/common/util/threads/ThreadUtils.java | 29 ++++++++++------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
index 90780abad..d5e84d05b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
@@ -62,13 +62,12 @@ public final class ThreadUtils {
public static <V> V runAsInternal(Callable<V> code) throws Exception {
if (isInternalThread()) {
return code.call();
- } else {
- try {
- IS_INTERNAL_THREAD.set(Boolean.TRUE);
- return code.call();
- } finally {
- IS_INTERNAL_THREAD.remove();
- }
+ }
+ try {
+ IS_INTERNAL_THREAD.set(Boolean.TRUE);
+ return code.call();
+ } finally {
+ IS_INTERNAL_THREAD.remove();
}
}
@@ -87,13 +86,12 @@ public final class ThreadUtils {
public static <T, V> V runAsInternal(T param, IOFunction<? super T, V> code) throws IOException {
if (isInternalThread()) {
return code.apply(param);
- } else {
- try {
- IS_INTERNAL_THREAD.set(Boolean.TRUE);
- return code.apply(param);
- } finally {
- IS_INTERNAL_THREAD.remove();
- }
+ }
+ try {
+ IS_INTERNAL_THREAD.set(Boolean.TRUE);
+ return code.apply(param);
+ } finally {
+ IS_INTERNAL_THREAD.remove();
}
}
@@ -122,9 +120,8 @@ public final class ThreadUtils {
CloseableExecutorService executorService, boolean shutdownOnExit) {
if (executorService == null || shutdownOnExit || executorService instanceof NoCloseExecutor) {
return executorService;
- } else {
- return new NoCloseExecutor(executorService);
}
+ return new NoCloseExecutor(executorService);
}
public static CloseableExecutorService noClose(CloseableExecutorService executorService) {
[mina-sshd] 01/02: Use stock JRE Charset instead of magic string
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit d459158b89cfe8dc9818a9256a461802c9a77692
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 16 09:51:08 2023 -0400
Use stock JRE Charset instead of magic string
Clean up exceptions on non-public methods
---
.../config/keys/loader/openssh/kdf/BCrypt.java | 11 ++++-----
.../apache/sshd/common/util/io/FileSnapshot.java | 26 +++++++++++-----------
.../sshd/common/util/threads/ThreadUtils.java | 12 +++++-----
.../apache/sshd/common/channel/LocalWindow.java | 2 +-
4 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
index 84b546ed2..0a78aa8c8 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/kdf/BCrypt.java
@@ -21,6 +21,7 @@ package org.apache.sshd.common.config.keys.loader.openssh.kdf;
// It's available on maven as artifact org.connectbot.jbcrypt:jbcrypt:1.0.0. pbkdf method added 2016 by Kenny Root.
// Modifications for Apache MINA sshd: this comment, plus changed the package from org.mindrot.jbcrypt to avoid conflicts.
import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.security.DigestException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -862,13 +863,9 @@ public class BCrypt {
public static boolean checkpw(String plaintext, String hashed) {
byte hashed_bytes[];
byte try_bytes[];
- try {
- String try_pw = hashpw(plaintext, hashed);
- hashed_bytes = hashed.getBytes("UTF-8");
- try_bytes = try_pw.getBytes("UTF-8");
- } catch (UnsupportedEncodingException uee) {
- return false;
- }
+ String try_pw = hashpw(plaintext, hashed);
+ hashed_bytes = hashed.getBytes(StandardCharsets.UTF_8);
+ try_bytes = try_pw.getBytes(StandardCharsets.UTF_8);
if (hashed_bytes.length != try_bytes.length)
return false;
byte ret = 0;
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/io/FileSnapshot.java b/sshd-common/src/main/java/org/apache/sshd/common/util/io/FileSnapshot.java
index 29ec35d32..4911d80ef 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/io/FileSnapshot.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/io/FileSnapshot.java
@@ -82,10 +82,10 @@ public class FileSnapshot {
/**
* Creates a new {@link FileSnapshot} instance.
*
- * @param snapTime the {@link Instant} the snapshot was taken
- * @param lastModified the "last modified" {@link FileTime}
- * @param size the file size
- * @param fileKey the file key
+ * @param snapTime the {@link Instant} the snapshot was taken
+ * @param lastModified the "last modified" {@link FileTime}
+ * @param size the file size
+ * @param fileKey the file key
*/
protected FileSnapshot(Instant snapTime, FileTime lastModified, long size, Object fileKey) {
this.snapTime = Objects.requireNonNull(snapTime);
@@ -133,10 +133,10 @@ public class FileSnapshot {
/**
* Creates a new {@link FileSnapshot} for the given path.
*
- * @param file to take the snapshot of
- * @param options {@link LinkOption}s to use
- * @return the {@link FileSnapshot}, never {@code null}
- * @throws IOException if an I/O error occurs
+ * @param file to take the snapshot of
+ * @param options {@link LinkOption}s to use
+ * @return the {@link FileSnapshot}, never {@code null}
+ * @throws IOException if an I/O error occurs
*/
public static FileSnapshot save(Path file, LinkOption... options) throws IOException {
BasicFileAttributes attributes = null;
@@ -155,11 +155,11 @@ public class FileSnapshot {
/**
* Reload the {@link FileSnapshot} for the given file.
*
- * @param file to take the snapshot of
- * @param options {@link LinkOption}s to use
- * @return a {@link FileSnapshot}, never {@code null}; if {@code == this}, the file may be assumed
- * unmodified
- * @throws IOException if an I/O error occurs
+ * @param file to take the snapshot of
+ * @param options {@link LinkOption}s to use
+ * @return a {@link FileSnapshot}, never {@code null}; if {@code == this}, the file may be assumed
+ * unmodified
+ * @throws IOException if an I/O error occurs
*/
public FileSnapshot reload(Path file, LinkOption... options) throws IOException {
FileSnapshot newSnapshot = save(file, options);
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
index a94ff9cce..90780abad 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/threads/ThreadUtils.java
@@ -76,13 +76,13 @@ public final class ThreadUtils {
* Runs an {@link IOFunction} with a flag set indicating that the executing thread is an Apache MINA sshd
* framework-internal thread.
*
- * @param <T> parameter type
- * @param <V> return type
- * @param param parameter for the function
- * @param code function to run
- * @return the result of {@code code}
+ * @param <T> parameter type
+ * @param <V> return type
+ * @param param parameter for the function
+ * @param code function to run
+ * @return the result of {@code code}
* @throws IOException propagated from {@code code.apply()}
- * @see #isInternalThread()
+ * @see #isInternalThread()
*/
public static <T, V> V runAsInternal(T param, IOFunction<? super T, V> code) throws IOException {
if (isInternalThread()) {
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/LocalWindow.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/LocalWindow.java
index 8e52bb633..ff46a2a03 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/LocalWindow.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/LocalWindow.java
@@ -56,7 +56,7 @@ public class LocalWindow extends Window {
/**
* Initializes the {@link LocalWindow} with the packet and window sizes from the {@code resolver}.
*
- * @param resolver {@PropertyResolver} to access properties
+ * @param resolver {@PropertyResolver} to access properties
*/
public void init(PropertyResolver resolver) {
init(CoreModuleProperties.WINDOW_SIZE.getRequired(resolver),