Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jul 26, 2024
1 parent 3b835fd commit d816783
Show file tree
Hide file tree
Showing 29 changed files with 116 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected void appendDedupSep(StringBuilder sb, CharSequence s) {

/**
* In case we are running on Windows, accept "\\" as a file separator. Ignore in *nix as "\\" is a valid filename
*
*
* @param name the name to fix the separator for if running on Windows
* @return the fixed name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public static String appendPathComponent(String prefix, String component) {

StringBuilder sb = new StringBuilder(
prefix.length() + component.length() + File.separator.length())
.append(prefix);
.append(prefix);

if (sb.charAt(prefix.length() - 1) == File.separatorChar) {
if (component.charAt(0) == File.separatorChar) {
Expand Down Expand Up @@ -743,7 +743,7 @@ private static List<String> removeExtraCdUps(Path toResolve) {

/**
* Build a path from the list of path parts
*
*
* @param root the root path
* @param fs the filesystem
* @param namesList the parts of the path to build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/**
* Exposes direct access to the underlying buffer
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
public class ExposedBufferByteArrayOutputStream extends ByteArrayOutputStream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/**
* Various events used by {@link ClientChannel#waitFor(java.util.Collection, long)}
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
public enum ClientChannelEvent {
Expand All @@ -42,13 +42,13 @@ public enum ClientChannelEvent {
EOF,
/**
* Received exit status from remote peer
*
*
* @see ClientChannel#getExitStatus()
**/
EXIT_STATUS,
/**
* Received exit signal from remote peer
*
*
* @see ClientChannel#getExitSignal()
*/
EXIT_SIGNAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public synchronized void write(byte[] buf, int s, int l) throws IOException {
} catch (InterruptedException e) {
throw (IOException) new InterruptedIOException(
"Interrupted while waiting for remote space on write len=" + l + " to " + this)
.initCause(e);
.initCause(e);
}
session.resetIdleTimeout();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static Result fromName(String name) {
/**
* Process an SSH request. If an exception is thrown, the ConnectionService will send a failure message if needed
* and the request will be considered handled.
*
*
* @param t The input parameter
* @param request The request string
* @param wantReply Whether a reply is requested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/**
* A factory for creating forwarder objects for client port forwarding
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static byte[] readOakleyGroupPrimeValue(Reader r) throws IOException {
* <LI>Remaining lines are appended to one big string assumed to contain the HEX-encoded value</LI>
* </P>
* </UL>
*
*
* @param br The {@link BufferedReader} to read the data from
* @return The prime value bytes suitable for building a {@code BigInteger}
* @throws IOException If invalid data or no encoded value found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

/**
* Holds KEX negotiation stage configuration
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
public interface KexFactoryManager extends SignatureFactoriesManager, KexExtensionHandlerManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

/**
* Holds providers and helpers related to the server side authentication process
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
public interface ServerAuthenticationManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* Invoked when &quot;hostbased&quot; authentication is used
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
* @see <A HREF="https://tools.ietf.org/html/rfc4252#section-9">RFC 4252 - section 9</A>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public interface CommandLifecycle {
/**
* Starts the command execution. All streams must have been set <U>before</U> calling this method. The command
* should implement {@link java.lang.Runnable}, and this method should spawn a new thread like:
*
*
* <pre>
* {@code Thread(this).start(); }
* {@code
* Thread(this).start();
* }
* </pre>
*
* @param channel The {@link ChannelSession} through which the command has been received
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public interface ServerSession
* <LI>Sends the {@code SSH_MSG_USERAUTH_SUCCESS} message.</LI>
* </P>
* </UL>
*
*
* @param username The authenticated username
* @param authService The service to start
* @param buffer Any extra data received to use to start the service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ public class HostBoundPubKeyAuthTest extends BaseTestSupport {
.run("mkdir -p /home/bob/.ssh") // Create the SSH config directory
.entryPoint("/entrypoint.sh") // Sets bob as owner of anything under /home/bob and launches sshd
.build())) //
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_KEYS + "/user01_authorized_keys"),
"/home/bob/.ssh/authorized_keys")
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_RESOURCES + "/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
.waitingFor(Wait.forLogMessage(".*Server listening on :: port 22.*\\n", 1))
.withExposedPorts(22) //
.withLogConsumer(new Slf4jLogConsumer(LOG));
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_KEYS + "/user01_authorized_keys"),
"/home/bob/.ssh/authorized_keys")
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_RESOURCES + "/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
.waitingFor(Wait.forLogMessage(".*Server listening on :: port 22.*\\n", 1))
.withExposedPorts(22) //
.withLogConsumer(new Slf4jLogConsumer(LOG));

private final String privateKeyName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,46 @@ public class ClientOpenSSHCertificatesTest extends BaseTestSupport {
.run("echo 'user02:password02' | chpasswd") // ...both users
.entryPoint("/entrypoint.sh") // Sets up supervisor to run sshd
.build())) //
.withCopyFileToContainer(MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/docker/sshd_config"), "/etc/ssh/sshd_config")
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/docker/supervisord.conf"),
"/etc/supervisor/supervisord.conf")
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/user/user01_authorized_keys"),
"/keys/user/user01/authorized_keys")
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/user/user02_authorized_keys"),
"/keys/user/user02/authorized_keys")
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host01"),
"/keys/host/host01")
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host01"
+ PublicKeyEntry.PUBKEY_FILE_SUFFIX),
"/keys/host/host01" + PublicKeyEntry.PUBKEY_FILE_SUFFIX)
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host02"),
"/keys/host/host02")
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host02"
+ PublicKeyEntry.PUBKEY_FILE_SUFFIX),
"/keys/host/host02" + PublicKeyEntry.PUBKEY_FILE_SUFFIX)
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/ca/ca" + PublicKeyEntry.PUBKEY_FILE_SUFFIX),
"/ca" + PublicKeyEntry.PUBKEY_FILE_SUFFIX)
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/docker/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
// must be set to "/keys/host/host01" or "/keys/host/host02"
.withEnv("SSH_HOST_KEY", "/keys/host/host01") //
.withExposedPorts(22);
.withCopyFileToContainer(MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/docker/sshd_config"), "/etc/ssh/sshd_config")
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/docker/supervisord.conf"),
"/etc/supervisor/supervisord.conf")
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/user/user01_authorized_keys"),
"/keys/user/user01/authorized_keys")
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/user/user02_authorized_keys"),
"/keys/user/user02/authorized_keys")
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host01"),
"/keys/host/host01")
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host01"
+ PublicKeyEntry.PUBKEY_FILE_SUFFIX),
"/keys/host/host01" + PublicKeyEntry.PUBKEY_FILE_SUFFIX)
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host02"),
"/keys/host/host02")
.withCopyFileToContainer(
MountableFile.forClasspathResource("org/apache/sshd/client/opensshcerts/host/host02"
+ PublicKeyEntry.PUBKEY_FILE_SUFFIX),
"/keys/host/host02" + PublicKeyEntry.PUBKEY_FILE_SUFFIX)
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/ca/ca" + PublicKeyEntry.PUBKEY_FILE_SUFFIX),
"/ca" + PublicKeyEntry.PUBKEY_FILE_SUFFIX)
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(
"org/apache/sshd/client/opensshcerts/docker/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
// must be set to "/keys/host/host01" or "/keys/host/host02"
.withEnv("SSH_HOST_KEY", "/keys/host/host01") //
.withExposedPorts(22);

private static final String USER_KEY_PATH = "org/apache/sshd/client/opensshcerts/user/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ public class OpenSshCipherTest extends BaseTestSupport {
.run("mkdir -p /home/bob/.ssh") // Create the SSH config directory
.entryPoint("/entrypoint.sh") // Sets bob as owner of anything under /home/bob and launches sshd
.build())) //
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_RESOURCES + "/bob_key.pub"),
"/home/bob/.ssh/authorized_keys")
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_RESOURCES + "/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
.waitingFor(Wait.forLogMessage(".*Server listening on :: port 22.*\\n", 1)).withExposedPorts(22) //
.withLogConsumer(new Slf4jLogConsumer(LOG));
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_RESOURCES + "/bob_key.pub"),
"/home/bob/.ssh/authorized_keys")
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_RESOURCES + "/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
.waitingFor(Wait.forLogMessage(".*Server listening on :: port 22.*\\n", 1)).withExposedPorts(22) //
.withLogConsumer(new Slf4jLogConsumer(LOG));

private final String providerName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ public void forwardingWithConnectionClose() throws Exception {
.run("mkdir -p /root/.ssh") // Create the SSH config directory
.entryPoint("/entrypoint.sh") //
.build())) //
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_KEYS + "/user01_ed25519"),
"/root/.ssh/id_ed25519")
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_KEYS + "/user01_ed25519.pub"),
"/root/.ssh/id_ed25519.pub")
// Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(MountableFile.forHostPath(entryPoint.getPath(), 0x1ff),
"/entrypoint.sh")
.withAccessToHost(true) //
.waitingFor(Wait.forLogMessage(".*forwarding_success.*\n", 1))
.withLogConsumer(new Slf4jLogConsumer(LOG));
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_KEYS + "/user01_ed25519"),
"/root/.ssh/id_ed25519")
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_KEYS + "/user01_ed25519.pub"),
"/root/.ssh/id_ed25519.pub")
// Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(MountableFile.forHostPath(entryPoint.getPath(), 0x1ff),
"/entrypoint.sh")
.withAccessToHost(true) //
.waitingFor(Wait.forLogMessage(".*forwarding_success.*\n", 1))
.withLogConsumer(new Slf4jLogConsumer(LOG));
try {
Testcontainers.exposeHostPorts(sshPort, gRpcPort);
sshdContainer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ private void testStrictKex(boolean withStrictKex) throws Exception {
.run("mkdir -p /home/bob/.ssh") // Create the SSH config directory
.entryPoint("/entrypoint.sh") //
.build())) //
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_RESOURCES + "/bob_key.pub"),
"/home/bob/.ssh/authorized_keys")
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_RESOURCES + "/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
.waitingFor(Wait.forLogMessage(".*Server listening on :: port 22.*\\n", 1)) //
.withExposedPorts(22) //
.withLogConsumer(new Slf4jLogConsumer(LOG));
.withCopyFileToContainer(MountableFile.forClasspathResource(TEST_RESOURCES + "/bob_key.pub"),
"/home/bob/.ssh/authorized_keys")
// entrypoint must be executable. Spotbugs doesn't like 0777, so use hex
.withCopyFileToContainer(
MountableFile.forClasspathResource(TEST_RESOURCES + "/entrypoint.sh", 0x1ff),
"/entrypoint.sh")
.waitingFor(Wait.forLogMessage(".*Server listening on :: port 22.*\\n", 1)) //
.withExposedPorts(22) //
.withLogConsumer(new Slf4jLogConsumer(LOG));
sshdContainer.start();
try {
FileKeyPairProvider keyPairProvider = CommonTestSupportUtils.createTestKeyPairProvider(TEST_RESOURCES + "/bob_key");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class LdapNetworkConnector<C> extends NetworkConnector {
public static final String DEFAULT_LDAP_BIND_PASSWORD_PATTERN = "{1}";
/**
* A list of known binary attributes
*
*
* @see <A HREF="http://docs.oracle.com/javase/jndi/tutorial/ldap/misc/attrs.html">LDAP Attributes</A>
*/
public static final String DEFAULT_BINARY_ATTRIBUTES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* <code>&quot;{0}@my.domain.com&quot;</code>.</LI>
* </P>
* </OL>
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
public class LdapPasswordAuthenticator extends LdapAuthenticator implements PasswordAuthenticator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Collection<KeyPair> extractKeyPairs(
int numLines = GenericUtils.size(lines);
StringBuilder sb = new StringBuilder(
beginMarker.length() + endMarker.length() + 4 + numLines * 80)
.append(beginMarker);
.append(beginMarker);
if (numLines > 0) {
for (String l : lines) {
sb.append(eol).append(l);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

/**
* Helper class for {@code Putty} key files decoders
*
*
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a>
*/
public class PuttyKeyReader implements Closeable {
Expand Down
Loading

0 comments on commit d816783

Please sign in to comment.