Skip to content

Commit 54a5dad

Browse files
committed
Doing work
1 parent 949d237 commit 54a5dad

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

hello-client/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies {
1414
implementation 'org.springframework.boot:spring-boot-starter-security'
1515
implementation 'org.springframework.security:spring-security-messaging'
1616
implementation 'org.springframework.security:spring-security-rsocket'
17+
implementation 'info.picocli:picocli:4.1.2'
1718
}
1819

1920
task buildImage(type: DockerBuildImage, dependsOn: build) {

hello-client/src/main/java/example/client/hello/HelloClientApplication.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
package example.client.hello;
22

3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
35
import org.springframework.boot.CommandLineRunner;
46
import org.springframework.boot.SpringApplication;
57
import org.springframework.boot.autoconfigure.SpringBootApplication;
68
import org.springframework.stereotype.Component;
79

10+
import static picocli.CommandLine.Option;
11+
import static picocli.CommandLine.Parameters;
12+
import static picocli.CommandLine.populateCommand;
13+
814
@SpringBootApplication
915
public class HelloClientApplication {
16+
private static final Logger LOG = LoggerFactory.getLogger(HelloClientApplication.class);
1017

1118
public static void main(String... args) {
1219
SpringApplication.run(HelloClientApplication.class, args);
@@ -17,7 +24,35 @@ public class Runner implements CommandLineRunner {
1724

1825
@Override
1926
public void run(String... args) throws Exception {
27+
ClientArguments params = populateCommand(new ClientArguments(), args);
2028

29+
LOG.debug("token: {}", params.token);
30+
LOG.debug("method: {}", params.method);
31+
LOG.debug("name: {}", params.name);
2132
}
2233
}
34+
35+
/**
36+
* Hello client command line arguments.
37+
*/
38+
public static class ClientArguments {
39+
40+
/**
41+
* Basic auth username
42+
*/
43+
@Option(names = "--token", description = "jwt token")
44+
public String token;
45+
46+
/**
47+
* RSocket method name
48+
*/
49+
@Parameters(index = "0", arity = "1", description = "the method to call")
50+
public String method;
51+
52+
/**
53+
* "name" argument to send to the method
54+
*/
55+
@Parameters(index = "1", arity = "1", defaultValue = "name argument for method")
56+
public String name;
57+
}
2358
}

hello-service/src/main/java/example/service/hello/config/RSocketSecurityConfiguration.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@
1717
@EnableRSocketSecurity
1818
public class RSocketSecurityConfiguration {
1919

20+
@Bean
21+
public ReactiveUserDetailsService userDetailsService() {
22+
UserDetails admin = User.withDefaultPasswordEncoder()
23+
.username("admin")
24+
.password("password")
25+
.roles("ADMIN")
26+
.build();
27+
28+
UserDetails user = User.withDefaultPasswordEncoder()
29+
.username("user")
30+
.password("password")
31+
.roles("USER")
32+
.build();
33+
34+
return new MapReactiveUserDetailsService(admin, user);
35+
}
36+
2037
@Bean
2138
public PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
2239
rsocket.authorizePayload(authorize ->

0 commit comments

Comments
 (0)