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

Commit ad69aec

Browse files
committed
feat: upgrade to spring boot 3 and spring shell 3
1 parent 2beb16e commit ad69aec

37 files changed

+283
-286
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
uses: actions/checkout@v3
3030
with:
3131
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
32-
- name: Set up JDK 11
32+
- name: Set up JDK 17
3333
uses: actions/setup-java@v3.9.0
3434
with:
35-
java-version: 11
35+
java-version: 17
3636
distribution: temurin
3737
cache: maven
3838
- name: Import GPG key

.github/workflows/reusable-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
- uses: actions/checkout@v3
2828
with:
2929
ref: ${{ inputs.ref }}
30-
- name: Set up JDK 11
30+
- name: Set up JDK 17
3131
uses: actions/setup-java@v3.9.0
3232
with:
33-
java-version: 11
33+
java-version: 17
3434
distribution: temurin
3535
cache: maven
3636

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,12 @@ public class ApplicationTest {
797797

798798
## Release notes
799799

800+
### 3.0.0
801+
802+
* Bump spring-boot.version 2.7.5 to 3.0.2
803+
* Bump spring-shell-starter 2.1.5 to 3.0.0
804+
* Java 17 minimum is required
805+
800806
### 2.0.3
801807

802808
* Bump spring-boot.version from 2.7.3 to 2.7.5

pom.xml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<groupId>com.github.fonimus</groupId>
2222
<artifactId>ssh-shell-spring-boot-parent</artifactId>
23-
<version>2.0.4-SNAPSHOT</version>
23+
<version>3.0.0-SNAPSHOT</version>
2424

2525
<packaging>pom</packaging>
2626

@@ -51,12 +51,12 @@
5151
</licenses>
5252

5353
<properties>
54-
<maven.compiler.source>1.8</maven.compiler.source>
55-
<maven.compiler.target>1.8</maven.compiler.target>
54+
<maven.compiler.source>17</maven.compiler.source>
55+
<maven.compiler.target>17</maven.compiler.target>
5656
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5757
<!--dependencies-->
58-
<spring-boot.version>2.7.5</spring-boot.version>
59-
<spring-shell.version>2.1.5</spring-shell.version>
58+
<spring-boot.version>3.0.2</spring-boot.version>
59+
<spring-shell.version>3.0.0</spring-shell.version>
6060
<sshd.version>2.9.2</sshd.version>
6161
<junit-jupiter.version>5.9.2</junit-jupiter.version>
6262
<!--sonar-->
@@ -202,6 +202,9 @@
202202
<artifactId>maven-compiler-plugin</artifactId>
203203
<version>3.10.1</version>
204204
<configuration>
205+
<compilerArgs>
206+
<arg>-parameters</arg>
207+
</compilerArgs>
205208
<forceJavacCompilerUse>true</forceJavacCompilerUse>
206209
</configuration>
207210
</plugin>

samples/basic/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>ssh-shell-spring-boot-parent</artifactId>
2121
<groupId>com.github.fonimus</groupId>
22-
<version>2.0.4-SNAPSHOT</version>
22+
<version>3.0.0-SNAPSHOT</version>
2323
<relativePath>../../pom.xml</relativePath>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>

samples/complete/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>ssh-shell-spring-boot-parent</artifactId>
2121
<groupId>com.github.fonimus</groupId>
22-
<version>2.0.4-SNAPSHOT</version>
22+
<version>3.0.0-SNAPSHOT</version>
2323
<relativePath>../../pom.xml</relativePath>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>

samples/complete/src/main/java/com/github/fonimus/ssh/shell/complete/DemoConfiguration.java renamed to samples/complete/src/main/java/com/github/fonimus/ssh/shell/complete/CompleteConfiguration.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.github.fonimus.ssh.shell.listeners.SshShellListener;
2121
import com.github.fonimus.ssh.shell.postprocess.PostProcessor;
2222
import lombok.extern.slf4j.Slf4j;
23+
import org.springframework.boot.actuate.web.exchanges.HttpExchangeRepository;
24+
import org.springframework.boot.actuate.web.exchanges.InMemoryHttpExchangeRepository;
2325
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
2426
import org.springframework.boot.context.properties.ConfigurationProperties;
2527
import org.springframework.context.annotation.Bean;
@@ -41,17 +43,17 @@
4143
*/
4244
@Slf4j
4345
@Configuration
44-
public class DemoConfiguration implements SchedulingConfigurer {
46+
public class CompleteConfiguration implements SchedulingConfigurer {
4547

4648
private final TasksCommand tasksCommand;
4749

48-
public DemoConfiguration(TasksCommand tasksCommand) {
50+
public CompleteConfiguration(TasksCommand tasksCommand) {
4951
this.tasksCommand = tasksCommand;
5052
}
5153

5254
@Bean
5355
public PostProcessor<String, String> quotePostProcessor() {
54-
return new PostProcessor<String, String>() {
56+
return new PostProcessor<>() {
5557

5658
@Override
5759
public String getName() {
@@ -72,7 +74,7 @@ public String process(String input, List<String> parameters) {
7274

7375
@Bean
7476
public PostProcessor<String, ZonedDateTime> datePostProcessor() {
75-
return new PostProcessor<String, ZonedDateTime>() {
77+
return new PostProcessor<>() {
7678

7779
@Override
7880
public String getName() {
@@ -93,7 +95,7 @@ public ZonedDateTime process(String input, List<String> parameters) {
9395

9496
@Bean
9597
public PostProcessor<ZonedDateTime, ZonedDateTime> uctPostProcessor() {
96-
return new PostProcessor<ZonedDateTime, ZonedDateTime>() {
98+
return new PostProcessor<>() {
9799

98100
@Override
99101
public String getName() {
@@ -166,6 +168,11 @@ public TaskScheduler threadPoolTaskExecutor2() {
166168
return threadPoolTaskScheduler;
167169
}
168170

171+
@Bean
172+
public HttpExchangeRepository httpTraceRepository() {
173+
return new InMemoryHttpExchangeRepository();
174+
}
175+
169176
@Override
170177
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
171178
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();

samples/complete/src/main/java/com/github/fonimus/ssh/shell/complete/DemoPromptProvider.java renamed to samples/complete/src/main/java/com/github/fonimus/ssh/shell/complete/CompletePromptProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import static org.jline.utils.AttributedStyle.DEFAULT;
2525

2626
@Component
27-
public class DemoPromptProvider implements PromptProvider {
27+
public class CompletePromptProvider implements PromptProvider {
2828

2929
@Override
3030
public AttributedString getPrompt() {

samples/complete/src/main/java/com/github/fonimus/ssh/shell/complete/DemoSecurity.java renamed to samples/complete/src/main/java/com/github/fonimus/ssh/shell/complete/CompleteSecurity.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,30 @@
2020
import org.springframework.context.annotation.Bean;
2121
import org.springframework.context.annotation.Configuration;
2222
import org.springframework.security.authentication.AuthenticationManager;
23-
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
23+
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
24+
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
2425
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
2526
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
26-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
27-
import org.springframework.security.core.userdetails.User;
28-
import org.springframework.security.core.userdetails.UserDetailsService;
2927
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
3028
import org.springframework.security.crypto.password.PasswordEncoder;
31-
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
29+
import org.springframework.security.web.SecurityFilterChain;
3230

3331
/**
3432
* Security configuration
3533
*/
3634
@Configuration
3735
@EnableWebSecurity
38-
@EnableGlobalMethodSecurity(prePostEnabled = true)
39-
public class DemoSecurity
40-
extends WebSecurityConfigurerAdapter {
36+
@EnableMethodSecurity
37+
public class CompleteSecurity {
4138

42-
@Override
43-
protected void configure(HttpSecurity http) throws Exception {
44-
http
45-
.authorizeRequests()
39+
@Bean
40+
public SecurityFilterChain filterChain(HttpSecurity http, AuthenticationManager authManager) throws Exception {
41+
http.authorizeHttpRequests()
42+
.requestMatchers("/ping").permitAll()
4643
.requestMatchers(EndpointRequest.to("info")).permitAll()
47-
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ACTUATOR");
48-
}
49-
50-
@Bean("customAuthManager")
51-
@Override
52-
public AuthenticationManager authenticationManager() throws Exception {
53-
return super.authenticationManager();
44+
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ACTUATOR")
45+
.and().authenticationManager(authManager);
46+
return http.build();
5447
}
5548

5649
@Bean
@@ -59,14 +52,21 @@ public PasswordEncoder passwordEncoder() {
5952
}
6053

6154
@Bean
62-
public UserDetailsService userDetailsService() {
63-
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
64-
PasswordEncoder encoder = passwordEncoder();
65-
manager.createUser(User.withUsername("user").password(encoder.encode("password")).roles("USER").build());
66-
manager.createUser(User.withUsername("actuator").password(encoder.encode("password")).roles("ACTUATOR").build
67-
());
68-
manager.createUser(User.withUsername("admin").password(encoder.encode("admin")).roles("ADMIN", "ACTUATOR")
69-
.build());
70-
return manager;
55+
public AuthenticationManager authManager(HttpSecurity http) throws Exception {
56+
AuthenticationManagerBuilder authenticationManagerBuilder =
57+
http.getSharedObject(AuthenticationManagerBuilder.class);
58+
authenticationManagerBuilder.inMemoryAuthentication()
59+
.withUser("user")
60+
.password(passwordEncoder().encode("password"))
61+
.roles("USER")
62+
.and()
63+
.withUser("actuator")
64+
.password(passwordEncoder().encode("password"))
65+
.roles("ACTUATOR")
66+
.and()
67+
.withUser("admin")
68+
.password(passwordEncoder().encode("admin"))
69+
.roles("ADMIN", "ACTUATOR");
70+
return authenticationManagerBuilder.build();
7171
}
7272
}

samples/complete/src/main/resources/application.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ spring:
55
url: jdbc:h2:mem:testdb
66
second-datasource:
77
url: jdbc:h2:mem:testdb2
8-
shell.interactive.enabled: true
98
main.lazy-initialization: true
109

1110
ssh:
1211
shell:
1312
authentication: security
14-
auth-provider-bean-name: customAuthManager
1513
authorized-public-keys: classpath:.ssh/authorized.keys
1614
commands:
1715
actuator:
@@ -37,8 +35,6 @@ management:
3735
endpoint:
3836
shutdown:
3937
enabled: true
40-
threaddump:
41-
enabled: false
4238
health:
4339
group:
4440
nocommands:

starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>ssh-shell-spring-boot-parent</artifactId>
2121
<groupId>com.github.fonimus</groupId>
22-
<version>2.0.4-SNAPSHOT</version>
22+
<version>3.0.0-SNAPSHOT</version>
2323
<relativePath>../pom.xml</relativePath>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616

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

19-
import lombok.Data;
19+
import lombok.Getter;
20+
import lombok.Setter;
2021
import org.springframework.shell.CompletionProposal;
2122

2223
/**
2324
* Extended completion proposal to be able to set complete attribute of proposal
2425
*/
25-
@Data
2626
public class ExtendedCompletionProposal extends CompletionProposal {
2727

2828
/**
2929
* If should add space after proposed proposal
3030
*/
31+
@Getter
32+
@Setter
3133
private boolean complete;
3234

3335
/**

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public class ExtendedShell extends Shell {
5858
* @param exitCodeMappings exit code mappipngs
5959
* @param postProcessors post processors
6060
*/
61-
public ExtendedShell(
61+
protected ExtendedShell(
6262
ResultHandlerService resultHandlerService, CommandCatalog commandRegistry,
6363
Terminal terminal, ShellContext shellContext, ExitCodeMappings exitCodeMappings,
6464
List<PostProcessor<?, ?>> postProcessors
6565
) {
6666
super(resultHandlerService, commandRegistry, terminal, shellContext, exitCodeMappings);
6767
this.resultHandlerService = resultHandlerService;
6868
if (postProcessors != null) {
69-
this.postProcessorNames.addAll(postProcessors.stream().map(PostProcessor::getName).collect(Collectors.toList()));
69+
this.postProcessorNames.addAll(postProcessors.stream().map(PostProcessor::getName).toList());
7070
}
7171
}
7272

@@ -118,7 +118,7 @@ public Object evaluate(Input input) {
118118
}
119119
if (isKeyCharInList(words)) {
120120
List<Integer> indexes =
121-
IntStream.range(0, words.size()).filter(i -> KEY_CHARS.contains(words.get(i))).boxed().collect(Collectors.toList());
121+
IntStream.range(0, words.size()).filter(i -> KEY_CHARS.contains(words.get(i))).boxed().toList();
122122
for (Integer index : indexes) {
123123
if (words.size() > index + 1) {
124124
String keyChar = words.get(index);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"org.springframework.boot.actuate.autoconfigure.metrics.MetricsEndpointAutoConfiguration",
8989
"org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksEndpointAutoConfiguration",
9090
"org.springframework.boot.actuate.autoconfigure.session.SessionsEndpointAutoConfiguration",
91-
"org.springframework.boot.actuate.autoconfigure.trace.http.HttpTraceEndpointAutoConfiguration",
91+
"org.springframework.boot.actuate.autoconfigure.web.exchanges.HttpExchangesAutoConfiguration",
9292
"org.springframework.boot.actuate.autoconfigure.web.mappings.MappingsEndpointAutoConfiguration"
9393
})
9494
@ComponentScan(basePackages = {"com.github.fonimus.ssh.shell"})

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void run() {
104104
terminalBuilder.type(sshEnv.getEnv().get(SSH_ENV_TERM));
105105
}
106106
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
107-
PrintStream ps = new PrintStream(baos, true, StandardCharsets.UTF_8.name());
107+
PrintStream ps = new PrintStream(baos, true, StandardCharsets.UTF_8);
108108
Terminal terminal = terminalBuilder.build()
109109
) {
110110

@@ -127,7 +127,7 @@ public void run() {
127127
}
128128

129129
DefaultResultHandler resultHandler = new DefaultResultHandler(terminal);
130-
resultHandler.handleResult(new String(baos.toByteArray(), StandardCharsets.UTF_8));
130+
resultHandler.handleResult(baos.toString(StandardCharsets.UTF_8));
131131
resultHandler.handleResult("Please type `help` to see available commands");
132132

133133
LineReader reader = LineReaderBuilder.builder()

0 commit comments

Comments
 (0)