Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 23d45a8

Browse files
committed
Fix some issues
1 parent d79ed49 commit 23d45a8

25 files changed

+168
-40
lines changed

samples/complete/src/main/java/com/github/fonimus/ssh/shell/complete/DemoCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@
4444

4545
import java.io.File;
4646
import java.security.SecureRandom;
47-
import java.util.*;
47+
import java.util.ArrayList;
48+
import java.util.Arrays;
49+
import java.util.Collections;
50+
import java.util.Date;
51+
import java.util.List;
52+
import java.util.Map;
4853
import java.util.stream.Collectors;
4954

5055
/**

samples/complete/src/test/java/com/github/fonimus/ssh/shell/complete/DemoCommandTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
package com.github.fonimus.ssh.shell.complete;
1818

19-
import com.github.fonimus.ssh.shell.*;
19+
import com.github.fonimus.ssh.shell.SshContext;
20+
import com.github.fonimus.ssh.shell.SshShellCommandFactory;
21+
import com.github.fonimus.ssh.shell.SshShellHelper;
22+
import com.github.fonimus.ssh.shell.SshShellProperties;
23+
import com.github.fonimus.ssh.shell.SshShellRunnable;
2024
import com.github.fonimus.ssh.shell.auth.SshAuthentication;
2125
import org.jline.reader.LineReader;
2226
import org.jline.reader.ParsedLine;

starter/src/main/java/com/github/fonimus/ssh/shell/ExtendedCompleterAdapter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ private static boolean isComplete(CompletionProposal p) {
7070
* line continuations, <em>etc.</em>)
7171
* See @{@link org.springframework.shell.jline.JLineShellAutoConfiguration}
7272
*/
73-
static List<String> sanitizeInput(List<String> words) {
74-
words = words.stream()
73+
private static List<String> sanitizeInput(List<String> words) {
74+
return words.stream()
7575
// CR at beginning/end of line introduced by backslash
7676
.map(s -> s.replaceAll("^\\n+|\\n+$", ""))
7777
// CR in middle of word introduced by return inside a quoted string
7878
.map(s -> s.replaceAll("\\n+", " "))
7979
.collect(Collectors.toList());
80-
return words;
8180
}
8281
}

starter/src/main/java/com/github/fonimus/ssh/shell/ExtendedShell.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@
2020
import com.github.fonimus.ssh.shell.postprocess.PostProcessorObject;
2121
import com.github.fonimus.ssh.shell.postprocess.provided.SavePostProcessor;
2222
import lombok.extern.slf4j.Slf4j;
23-
import org.springframework.shell.*;
23+
import org.springframework.shell.CompletionContext;
24+
import org.springframework.shell.CompletionProposal;
25+
import org.springframework.shell.Input;
26+
import org.springframework.shell.ResultHandler;
27+
import org.springframework.shell.Shell;
2428

2529
import java.util.ArrayList;
2630
import java.util.Collections;
2731
import java.util.List;
2832
import java.util.stream.Collectors;
2933
import java.util.stream.IntStream;
3034

31-
import static com.github.fonimus.ssh.shell.ExtendedInput.*;
35+
import static com.github.fonimus.ssh.shell.ExtendedInput.ARROW;
36+
import static com.github.fonimus.ssh.shell.ExtendedInput.KEY_CHARS;
37+
import static com.github.fonimus.ssh.shell.ExtendedInput.PIPE;
3238
import static com.github.fonimus.ssh.shell.SshShellCommandFactory.SSH_THREAD_CONTEXT;
3339

3440
/**

starter/src/main/java/com/github/fonimus/ssh/shell/SshShellAutoConfiguration.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
import com.github.fonimus.ssh.shell.listeners.SshShellListenerService;
2424
import com.github.fonimus.ssh.shell.postprocess.PostProcessor;
2525
import com.github.fonimus.ssh.shell.postprocess.TypePostProcessorResultHandler;
26-
import com.github.fonimus.ssh.shell.postprocess.provided.*;
26+
import com.github.fonimus.ssh.shell.postprocess.provided.GrepPostProcessor;
27+
import com.github.fonimus.ssh.shell.postprocess.provided.HighlightPostProcessor;
28+
import com.github.fonimus.ssh.shell.postprocess.provided.JsonPointerPostProcessor;
29+
import com.github.fonimus.ssh.shell.postprocess.provided.PrettyJsonPostProcessor;
30+
import com.github.fonimus.ssh.shell.postprocess.provided.SavePostProcessor;
2731
import com.github.fonimus.ssh.shell.providers.ExtendedFileValueProvider;
2832
import lombok.extern.slf4j.Slf4j;
2933
import org.apache.sshd.server.SshServer;

starter/src/main/java/com/github/fonimus/ssh/shell/SshShellHelper.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,30 @@
3333
import org.jline.terminal.Size;
3434
import org.jline.terminal.Terminal;
3535
import org.jline.terminal.impl.AbstractPosixTerminal;
36-
import org.jline.utils.*;
37-
import org.springframework.shell.table.*;
36+
import org.jline.utils.AttributedString;
37+
import org.jline.utils.AttributedStringBuilder;
38+
import org.jline.utils.AttributedStyle;
39+
import org.jline.utils.Display;
40+
import org.jline.utils.InfoCmp;
41+
import org.jline.utils.NonBlockingReader;
42+
import org.springframework.shell.table.Aligner;
43+
import org.springframework.shell.table.ArrayTableModel;
44+
import org.springframework.shell.table.CellMatcher;
45+
import org.springframework.shell.table.SimpleHorizontalAligner;
46+
import org.springframework.shell.table.SimpleVerticalAligner;
47+
import org.springframework.shell.table.Table;
48+
import org.springframework.shell.table.TableBuilder;
49+
import org.springframework.shell.table.TableModel;
3850

3951
import java.io.PrintWriter;
40-
import java.util.*;
52+
import java.util.ArrayList;
53+
import java.util.Arrays;
54+
import java.util.HashMap;
55+
import java.util.HashSet;
56+
import java.util.List;
57+
import java.util.Map;
58+
import java.util.Set;
59+
import java.util.UUID;
4160

4261
/**
4362
* Ssh shell helper for user interactions and authorities check

starter/src/main/java/com/github/fonimus/ssh/shell/SshShellRunnable.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848
import org.springframework.shell.jline.PromptProvider;
4949
import org.springframework.shell.result.DefaultResultHandler;
5050

51-
import java.io.*;
51+
import java.io.ByteArrayOutputStream;
52+
import java.io.File;
53+
import java.io.IOException;
54+
import java.io.InputStream;
55+
import java.io.OutputStream;
56+
import java.io.PrintStream;
5257
import java.nio.charset.StandardCharsets;
5358

5459
import static com.github.fonimus.ssh.shell.SshShellCommandFactory.SSH_THREAD_CONTEXT;

starter/src/main/java/com/github/fonimus/ssh/shell/SshShellTerminalDelegate.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
package com.github.fonimus.ssh.shell;
1818

19-
import org.jline.terminal.*;
19+
import org.jline.terminal.Attributes;
20+
import org.jline.terminal.Cursor;
21+
import org.jline.terminal.MouseEvent;
22+
import org.jline.terminal.Size;
23+
import org.jline.terminal.Terminal;
2024
import org.jline.utils.InfoCmp;
2125
import org.jline.utils.NonBlockingReader;
2226

starter/src/main/java/com/github/fonimus/ssh/shell/commands/DatasourceCommand.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,27 @@
2727
import org.springframework.shell.Availability;
2828
import org.springframework.shell.CompletionContext;
2929
import org.springframework.shell.CompletionProposal;
30-
import org.springframework.shell.standard.*;
30+
import org.springframework.shell.standard.ShellCommandGroup;
31+
import org.springframework.shell.standard.ShellMethod;
32+
import org.springframework.shell.standard.ShellMethodAvailability;
33+
import org.springframework.shell.standard.ShellOption;
34+
import org.springframework.shell.standard.ValueProviderSupport;
3135
import org.springframework.stereotype.Component;
3236

3337
import javax.sql.DataSource;
3438
import java.beans.IntrospectionException;
3539
import java.beans.PropertyDescriptor;
3640
import java.lang.reflect.InvocationTargetException;
37-
import java.sql.*;
38-
import java.util.*;
41+
import java.sql.Connection;
42+
import java.sql.DatabaseMetaData;
43+
import java.sql.ResultSet;
44+
import java.sql.SQLException;
45+
import java.sql.Statement;
46+
import java.util.ArrayList;
47+
import java.util.Arrays;
48+
import java.util.HashMap;
49+
import java.util.List;
50+
import java.util.Map;
3951
import java.util.function.Function;
4052
import java.util.stream.Collectors;
4153
import java.util.stream.IntStream;

starter/src/main/java/com/github/fonimus/ssh/shell/commands/JmxCommand.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,31 @@
2424
import org.springframework.shell.Availability;
2525
import org.springframework.shell.CompletionContext;
2626
import org.springframework.shell.CompletionProposal;
27-
import org.springframework.shell.standard.*;
27+
import org.springframework.shell.standard.ShellCommandGroup;
28+
import org.springframework.shell.standard.ShellMethod;
29+
import org.springframework.shell.standard.ShellMethodAvailability;
30+
import org.springframework.shell.standard.ShellOption;
31+
import org.springframework.shell.standard.ValueProviderSupport;
2832
import org.springframework.stereotype.Component;
2933

30-
import javax.management.*;
34+
import javax.management.InstanceNotFoundException;
35+
import javax.management.JMException;
36+
import javax.management.MBeanAttributeInfo;
37+
import javax.management.MBeanFeatureInfo;
38+
import javax.management.MBeanInfo;
39+
import javax.management.MBeanOperationInfo;
40+
import javax.management.MBeanParameterInfo;
41+
import javax.management.MBeanServer;
42+
import javax.management.MalformedObjectNameException;
43+
import javax.management.ObjectInstance;
44+
import javax.management.ObjectName;
3145
import java.lang.management.ManagementFactory;
32-
import java.util.*;
46+
import java.util.ArrayList;
47+
import java.util.Arrays;
48+
import java.util.Collections;
49+
import java.util.Comparator;
50+
import java.util.List;
51+
import java.util.Set;
3352
import java.util.stream.Collectors;
3453

3554
/**

starter/src/main/java/com/github/fonimus/ssh/shell/commands/SshShellComponent.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2020
import org.springframework.shell.standard.ShellComponent;
2121

22-
import java.lang.annotation.*;
22+
import java.lang.annotation.Documented;
23+
import java.lang.annotation.ElementType;
24+
import java.lang.annotation.Retention;
25+
import java.lang.annotation.RetentionPolicy;
26+
import java.lang.annotation.Target;
2327

2428
import static com.github.fonimus.ssh.shell.SshShellProperties.SSH_SHELL_ENABLE;
2529

starter/src/main/java/com/github/fonimus/ssh/shell/commands/actuator/ActuatorCommand.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ public class ActuatorCommand extends AbstractCommand {
7171

7272
private final Environment environment;
7373

74-
private final SshShellProperties properties;
75-
7674
private final SshShellHelper helper;
7775

7876
private final AuditEventsEndpoint audit;
@@ -122,7 +120,6 @@ public ActuatorCommand(ApplicationContext applicationContext, Environment enviro
122120
super(helper, properties, properties.getCommands().getActuator());
123121
this.applicationContext = applicationContext;
124122
this.environment = environment;
125-
this.properties = properties;
126123
this.helper = helper;
127124
this.audit = audit;
128125
this.beans = beans;

starter/src/main/java/com/github/fonimus/ssh/shell/commands/system/JvmCommand.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
import org.springframework.shell.standard.ShellCommandGroup;
2525
import org.springframework.shell.standard.ShellMethod;
2626
import org.springframework.shell.standard.ShellMethodAvailability;
27-
import org.springframework.shell.table.*;
27+
import org.springframework.shell.table.ArrayTableModel;
28+
import org.springframework.shell.table.BorderStyle;
29+
import org.springframework.shell.table.SimpleHorizontalAligner;
30+
import org.springframework.shell.table.SimpleVerticalAligner;
31+
import org.springframework.shell.table.SizeConstraints;
32+
import org.springframework.shell.table.Table;
33+
import org.springframework.shell.table.TableBuilder;
34+
import org.springframework.shell.table.TableModel;
2835

2936
import java.util.Map;
3037
import java.util.TreeMap;

starter/src/main/java/com/github/fonimus/ssh/shell/commands/system/ThreadCommand.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@
3939

4040
import java.time.LocalDateTime;
4141
import java.time.format.DateTimeFormatter;
42-
import java.util.*;
43-
44-
import static com.github.fonimus.ssh.shell.SshShellHelper.*;
42+
import java.util.ArrayList;
43+
import java.util.Comparator;
44+
import java.util.HashMap;
45+
import java.util.List;
46+
import java.util.Map;
47+
48+
import static com.github.fonimus.ssh.shell.SshShellHelper.INTERACTIVE_LONG_MESSAGE;
49+
import static com.github.fonimus.ssh.shell.SshShellHelper.INTERACTIVE_SHORT_MESSAGE;
50+
import static com.github.fonimus.ssh.shell.SshShellHelper.at;
4551

4652
/**
4753
* Thread command

starter/src/test/java/com/github/fonimus/ssh/shell/AbstractCommandTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@
3131
import java.io.PrintWriter;
3232
import java.util.Collections;
3333

34-
import static com.github.fonimus.ssh.shell.SshHelperTest.*;
34+
import static com.github.fonimus.ssh.shell.SshHelperTest.call;
35+
import static com.github.fonimus.ssh.shell.SshHelperTest.verifyResponse;
36+
import static com.github.fonimus.ssh.shell.SshHelperTest.write;
3537
import static com.github.fonimus.ssh.shell.SshShellCommandFactory.SSH_THREAD_CONTEXT;
36-
import static org.junit.jupiter.api.Assertions.*;
38+
import static org.junit.jupiter.api.Assertions.assertAll;
39+
import static org.junit.jupiter.api.Assertions.assertEquals;
40+
import static org.junit.jupiter.api.Assertions.assertFalse;
41+
import static org.junit.jupiter.api.Assertions.assertThrows;
42+
import static org.junit.jupiter.api.Assertions.assertTrue;
3743
import static org.mockito.Mockito.mock;
3844
import static org.mockito.Mockito.when;
3945

starter/src/test/java/com/github/fonimus/ssh/shell/ExtendedShellTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
import java.util.List;
2626

2727
import static com.github.fonimus.ssh.shell.SshShellCommandFactory.SSH_THREAD_CONTEXT;
28-
import static org.junit.jupiter.api.Assertions.*;
28+
import static org.junit.jupiter.api.Assertions.assertEquals;
29+
import static org.junit.jupiter.api.Assertions.assertNotNull;
30+
import static org.junit.jupiter.api.Assertions.assertNull;
31+
import static org.junit.jupiter.api.Assertions.fail;
2932

3033
class ExtendedShellTest {
3134

starter/src/test/java/com/github/fonimus/ssh/shell/SshHelperTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
import org.slf4j.Logger;
2424
import org.slf4j.LoggerFactory;
2525

26-
import java.io.*;
26+
import java.io.IOException;
27+
import java.io.InputStream;
28+
import java.io.OutputStream;
29+
import java.io.PipedInputStream;
30+
import java.io.PipedOutputStream;
2731
import java.nio.charset.StandardCharsets;
2832
import java.time.Duration;
2933
import java.util.Properties;

starter/src/test/java/com/github/fonimus/ssh/shell/SshShellApplicationCustomAuthenticatorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import org.springframework.test.annotation.DirtiesContext;
2525
import org.springframework.test.context.junit.jupiter.SpringExtension;
2626

27-
import static com.github.fonimus.ssh.shell.SshHelperTest.*;
27+
import static com.github.fonimus.ssh.shell.SshHelperTest.call;
28+
import static com.github.fonimus.ssh.shell.SshHelperTest.verifyResponse;
29+
import static com.github.fonimus.ssh.shell.SshHelperTest.write;
2830

2931
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
3032
classes = {SshShellApplicationCustomAuthenticatorTest.class, SshShellPasswordConfigurationTest.class},

starter/src/test/java/com/github/fonimus/ssh/shell/SshShellApplicationSecurityTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import org.springframework.test.annotation.DirtiesContext;
2525
import org.springframework.test.context.junit.jupiter.SpringExtension;
2626

27-
import static com.github.fonimus.ssh.shell.SshHelperTest.*;
27+
import static com.github.fonimus.ssh.shell.SshHelperTest.call;
28+
import static com.github.fonimus.ssh.shell.SshHelperTest.verifyResponse;
29+
import static com.github.fonimus.ssh.shell.SshHelperTest.write;
2830

2931
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
3032
classes = {SshShellApplicationSecurityTest.class, SshShellSecurityConfigurationTest.class},

starter/src/test/java/com/github/fonimus/ssh/shell/SshShellApplicationWebTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828

2929
import static com.github.fonimus.ssh.shell.SshHelperTest.call;
3030
import static com.github.fonimus.ssh.shell.SshHelperTest.write;
31-
import static org.junit.jupiter.api.Assertions.*;
31+
import static org.junit.jupiter.api.Assertions.assertAll;
32+
import static org.junit.jupiter.api.Assertions.assertFalse;
33+
import static org.junit.jupiter.api.Assertions.assertNotNull;
34+
import static org.junit.jupiter.api.Assertions.assertTrue;
3235

3336
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
3437
classes = {SshShellApplicationWebTest.class, SshShellSessionConfigurationTest.class},

starter/src/test/java/com/github/fonimus/ssh/shell/SshShellHelperTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@
2828
import java.util.Arrays;
2929
import java.util.Collections;
3030

31-
import static org.junit.jupiter.api.Assertions.*;
31+
import static org.junit.jupiter.api.Assertions.assertEquals;
32+
import static org.junit.jupiter.api.Assertions.assertFalse;
33+
import static org.junit.jupiter.api.Assertions.assertNotNull;
34+
import static org.junit.jupiter.api.Assertions.assertTrue;
3235
import static org.mockito.ArgumentMatchers.anyString;
33-
import static org.mockito.Mockito.*;
36+
import static org.mockito.Mockito.reset;
37+
import static org.mockito.Mockito.times;
38+
import static org.mockito.Mockito.verify;
39+
import static org.mockito.Mockito.when;
3440

3541
class SshShellHelperTest extends AbstractShellHelperTest {
3642

starter/src/test/java/com/github/fonimus/ssh/shell/auth/SshShellSecurityAuthenticationProviderTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
import java.util.Map;
3535

3636
import static com.github.fonimus.ssh.shell.auth.SshShellSecurityAuthenticationProvider.AUTHENTICATION_ATTRIBUTE;
37-
import static org.junit.jupiter.api.Assertions.*;
37+
import static org.junit.jupiter.api.Assertions.assertEquals;
38+
import static org.junit.jupiter.api.Assertions.assertFalse;
39+
import static org.junit.jupiter.api.Assertions.assertNull;
40+
import static org.junit.jupiter.api.Assertions.assertThrows;
41+
import static org.junit.jupiter.api.Assertions.assertTrue;
3842
import static org.mockito.ArgumentMatchers.any;
3943
import static org.mockito.ArgumentMatchers.eq;
4044

starter/src/test/java/com/github/fonimus/ssh/shell/commands/HistoryCommandTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import java.io.IOException;
2727
import java.util.List;
2828

29-
import static org.junit.jupiter.api.Assertions.*;
29+
import static org.junit.jupiter.api.Assertions.assertEquals;
30+
import static org.junit.jupiter.api.Assertions.assertNotNull;
31+
import static org.junit.jupiter.api.Assertions.assertTrue;
3032
import static org.mockito.Mockito.mock;
3133
import static org.mockito.Mockito.when;
3234

0 commit comments

Comments
 (0)