JAVA-22211 Upgrade dependencies versions for helidon-se module (#14389)
* JAVA-22211 Upgrade dependencies versions for helidon-se module * JAVA-22211 Add properties for each version --------- Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
parent
8553d79655
commit
ad46c3d204
@ -28,13 +28,13 @@
|
||||
<dependency>
|
||||
<groupId>io.helidon.webserver</groupId>
|
||||
<artifactId>helidon-webserver-netty</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
<version>${helidon-webserver-netty.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.webserver</groupId>
|
||||
<artifactId>helidon-webserver-json</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
<version>${helidon-webserver-json.version}</version>
|
||||
</dependency>
|
||||
<!--Security -->
|
||||
<dependency>
|
||||
@ -43,19 +43,26 @@
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.security</groupId>
|
||||
<artifactId>helidon-security-provider-http-auth</artifactId>
|
||||
<groupId>io.helidon.security.providers</groupId>
|
||||
<artifactId>helidon-security-providers-http-auth</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.security</groupId>
|
||||
<groupId>io.helidon.security.integration</groupId>
|
||||
<artifactId>helidon-security-integration-webserver</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.webserver</groupId>
|
||||
<artifactId>helidon-webserver-http2</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<helidon.version>0.10.4</helidon.version>
|
||||
<helidon.version>3.2.2</helidon.version>
|
||||
<helidon-webserver-netty.version>0.10.6</helidon-webserver-netty.version>
|
||||
<helidon-webserver-json.version>0.11.0</helidon-webserver-json.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -6,7 +6,7 @@ import io.helidon.config.spi.ConfigSource;
|
||||
|
||||
public class ConfigApplication {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
public static void main(String... args) {
|
||||
|
||||
ConfigSource configSource = ConfigSources.classpath("application.yaml").build();
|
||||
Config config = Config.builder()
|
||||
@ -15,10 +15,10 @@ public class ConfigApplication {
|
||||
.sources(configSource)
|
||||
.build();
|
||||
|
||||
int port = config.get("server.port").asInt();
|
||||
int pageSize = config.get("web.page-size").asInt();
|
||||
boolean debug = config.get("web.debug").asBoolean();
|
||||
String userHome = config.get("user.home").asString();
|
||||
int port = config.get("server.port").asInt().get();
|
||||
int pageSize = config.get("web.page-size").asInt().get();
|
||||
boolean debug = config.get("web.debug").asBoolean().get();
|
||||
String userHome = config.get("user.home").asString().get();
|
||||
|
||||
System.out.println("port: " + port);
|
||||
System.out.println("pageSize: " + pageSize);
|
||||
|
@ -50,9 +50,7 @@ public class BookResource implements Service {
|
||||
|
||||
private JsonArray from(List<Book> books) {
|
||||
JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder();
|
||||
books.forEach(book -> {
|
||||
jsonArrayBuilder.add(from(book));
|
||||
});
|
||||
books.forEach(book -> jsonArrayBuilder.add(from(book)));
|
||||
return jsonArrayBuilder.build();
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package com.baeldung.helidon.se.routing;
|
||||
|
||||
import io.helidon.webserver.Routing;
|
||||
import io.helidon.webserver.ServerConfiguration;
|
||||
import io.helidon.webserver.WebServer;
|
||||
import io.helidon.webserver.json.JsonSupport;
|
||||
|
||||
public class WebApplicationRouting {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
|
||||
ServerConfiguration serverConfig = ServerConfiguration.builder()
|
||||
.port(9080)
|
||||
.build();
|
||||
public static void main(String... args) {
|
||||
|
||||
Routing routing = Routing.builder()
|
||||
.register(JsonSupport.get())
|
||||
.register(JsonSupport.create())
|
||||
.register("/books", new BookResource())
|
||||
.get("/greet", (request, response) -> response.send("Hello World !"))
|
||||
.build();
|
||||
|
||||
WebServer.create(serverConfig, routing)
|
||||
WebServer.builder().port(9080).addRouting(routing)
|
||||
.build()
|
||||
.start()
|
||||
.thenAccept(ws ->
|
||||
System.out.println("Server started at: http://localhost:" + ws.port())
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.baeldung.helidon.se.security;
|
||||
|
||||
import io.helidon.security.provider.httpauth.UserStore;
|
||||
import io.helidon.security.providers.httpauth.SecureUserStore;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public class MyUser implements UserStore.User {
|
||||
public class MyUser implements SecureUserStore.User {
|
||||
|
||||
private String login;
|
||||
private char[] password;
|
||||
@ -17,17 +18,17 @@ public class MyUser implements UserStore.User {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLogin() {
|
||||
public String login() {
|
||||
return login;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getPassword() {
|
||||
return password;
|
||||
public boolean isPasswordValid(char[] chars) {
|
||||
return Arrays.equals(chars, password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getRoles() {
|
||||
public Collection<String> roles() {
|
||||
return roles;
|
||||
}
|
||||
}
|
||||
|
@ -3,30 +3,28 @@ package com.baeldung.helidon.se.security;
|
||||
import io.helidon.config.Config;
|
||||
import io.helidon.security.Security;
|
||||
import io.helidon.security.SubjectType;
|
||||
import io.helidon.security.provider.httpauth.HttpBasicAuthProvider;
|
||||
import io.helidon.security.provider.httpauth.UserStore;
|
||||
import io.helidon.security.webserver.WebSecurity;
|
||||
import io.helidon.security.integration.webserver.WebSecurity;
|
||||
import io.helidon.security.providers.httpauth.HttpBasicAuthProvider;
|
||||
import io.helidon.security.providers.httpauth.SecureUserStore;
|
||||
import io.helidon.webserver.Routing;
|
||||
import io.helidon.webserver.ServerConfiguration;
|
||||
import io.helidon.webserver.WebServer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class WebApplicationSecurity {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
public static void main(String... args) {
|
||||
|
||||
Config config = Config.create();
|
||||
ServerConfiguration serverConfig =
|
||||
ServerConfiguration.fromConfig(config.get("server"));
|
||||
|
||||
Map<String, MyUser> users = new HashMap<>();
|
||||
users.put("user", new MyUser("user", "user".toCharArray(), Arrays.asList("ROLE_USER")));
|
||||
users.put("user", new MyUser("user", "user".toCharArray(), Collections.singletonList("ROLE_USER")));
|
||||
users.put("admin", new MyUser("admin", "admin".toCharArray(), Arrays.asList("ROLE_USER", "ROLE_ADMIN")));
|
||||
UserStore store = user -> Optional.ofNullable(users.get(user));
|
||||
SecureUserStore store = user -> Optional.ofNullable(users.get(user));
|
||||
|
||||
HttpBasicAuthProvider httpBasicAuthProvider = HttpBasicAuthProvider.builder()
|
||||
.realm("myRealm")
|
||||
@ -38,13 +36,12 @@ public class WebApplicationSecurity {
|
||||
Security security = Security.builder()
|
||||
.addAuthenticationProvider(httpBasicAuthProvider)
|
||||
.build();
|
||||
//Security security = Security.fromConfig(config);
|
||||
//Security security = Security.create(config);
|
||||
|
||||
//2. WebSecurity from Security or from Config
|
||||
// WebSecurity webSecurity = WebSecurity.from(security)
|
||||
// .securityDefaults(WebSecurity.authenticate());
|
||||
// WebSecurity webSecurity = WebSecurity.create(security).securityDefaults(WebSecurity.authenticate());
|
||||
|
||||
WebSecurity webSecurity = WebSecurity.from(config);
|
||||
WebSecurity webSecurity = WebSecurity.create(config);
|
||||
|
||||
Routing routing = Routing.builder()
|
||||
.register(webSecurity)
|
||||
@ -52,7 +49,7 @@ public class WebApplicationSecurity {
|
||||
.get("/admin", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_ADMIN"))
|
||||
.build();
|
||||
|
||||
WebServer webServer = WebServer.create(serverConfig, routing);
|
||||
WebServer webServer = WebServer.create(routing, config.get("server"));
|
||||
|
||||
webServer.start().thenAccept(ws ->
|
||||
System.out.println("Server started at: http://localhost:" + ws.port())
|
||||
|
@ -1,22 +1,18 @@
|
||||
package com.baeldung.helidon.se.webserver;
|
||||
|
||||
import io.helidon.webserver.Routing;
|
||||
import io.helidon.webserver.ServerConfiguration;
|
||||
import io.helidon.webserver.WebServer;
|
||||
|
||||
public class SimpleWebApplication {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
|
||||
ServerConfiguration serverConfig = ServerConfiguration.builder()
|
||||
.port(9001)
|
||||
.build();
|
||||
public static void main(String... args) {
|
||||
|
||||
Routing routing = Routing.builder()
|
||||
.get("/greet", (request, response) -> response.send("Hello World !"))
|
||||
.build();
|
||||
|
||||
WebServer.create(serverConfig, routing)
|
||||
WebServer.builder(routing)
|
||||
.port(9001).addRouting(routing).build()
|
||||
.start()
|
||||
.thenAccept(ws ->
|
||||
System.out.println("Server started at: http://localhost:" + ws.port())
|
||||
|
Loading…
x
Reference in New Issue
Block a user