Erweiterungen
This commit is contained in:
@@ -6,23 +6,24 @@ import com.vaadin.flow.theme.Theme;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import de.assecutor.emulatorstation.pojo.UserInfo;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@Push
|
@Push
|
||||||
@Theme("default")
|
@Theme("default")
|
||||||
public class Application implements AppShellConfigurator {
|
public class Application implements AppShellConfigurator {
|
||||||
public static final Map<String, String> users = Map.ofEntries(
|
public static final Map<String, UserInfo> users = Map.ofEntries(
|
||||||
Map.entry("admin", "ZY6X9X93Co8m"),
|
Map.entry("admin", new UserInfo("ZY6X9X93Co8m", null)),
|
||||||
Map.entry("GFL", "GFL123"),
|
Map.entry("GFL", new UserInfo("GFL123", "172.18.0.100")),
|
||||||
Map.entry("Berlin", "Berlin123"),
|
Map.entry("Berlin", new UserInfo("Berlin123", "172.18.0.101")),
|
||||||
Map.entry("Bremen", "Bremen123"),
|
Map.entry("Bremen", new UserInfo("Bremen123", "172.18.0.102")),
|
||||||
Map.entry("Hamburg", "Hamburg123"),
|
Map.entry("Hamburg", new UserInfo("Hamburg123", "172.18.0.103")),
|
||||||
Map.entry("Essen", "Essen123"),
|
Map.entry("Essen", new UserInfo("Essen123", "172.18.0.104")),
|
||||||
Map.entry("Leipzig", "Leipzig123"),
|
Map.entry("Leipzig", new UserInfo("Leipzig123", "172.18.0.105")),
|
||||||
Map.entry("Dresden", "Dresden123"),
|
Map.entry("Dresden", new UserInfo("Dresden123", "172.18.0.106")),
|
||||||
Map.entry("Hannover", "Hannover123"),
|
Map.entry("Hannover", new UserInfo("Hannover123", "172.18.0.107")),
|
||||||
Map.entry("Stuttgart", "Stuttgart123"),
|
Map.entry("Stuttgart", new UserInfo("Stuttgart123", "172.18.0.108")),
|
||||||
Map.entry("FrankfurtAmMain", "FrankfurtAmMain123")
|
Map.entry("FrankfurtAmMain", new UserInfo("FrankfurtAmMain123", "172.18.0.109"))
|
||||||
);
|
);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.vaadin.flow.router.Route;
|
|||||||
import com.vaadin.flow.server.auth.AnonymousAllowed;
|
import com.vaadin.flow.server.auth.AnonymousAllowed;
|
||||||
import com.vaadin.flow.theme.lumo.LumoUtility;
|
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||||
import de.assecutor.emulatorstation.pojo.ExecResponse;
|
import de.assecutor.emulatorstation.pojo.ExecResponse;
|
||||||
|
import de.assecutor.emulatorstation.Application;
|
||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
import util.Util;
|
import util.Util;
|
||||||
|
|
||||||
@@ -38,8 +39,6 @@ public final class MainView extends Main implements BeforeEnterObserver
|
|||||||
|
|
||||||
private final IFrame webView;
|
private final IFrame webView;
|
||||||
|
|
||||||
private UI ui;
|
|
||||||
|
|
||||||
private final ExecutorService executor = Executors.newSingleThreadExecutor();
|
private final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
MainView() {
|
MainView() {
|
||||||
@@ -97,7 +96,7 @@ public final class MainView extends Main implements BeforeEnterObserver
|
|||||||
add(webView);
|
add(webView);
|
||||||
|
|
||||||
addAttachListener(event -> {
|
addAttachListener(event -> {
|
||||||
ui = event.getUI();
|
event.getUI();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +144,7 @@ public final class MainView extends Main implements BeforeEnterObserver
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshWebView() {
|
private void refreshWebView() {
|
||||||
webView.setSrc("http://" + server + ":6080/?autoconnect=true");
|
webView.setSrc("http://" + Application.users.get(username).ip() + ":6080/?autoconnect=true");
|
||||||
webView.reload();
|
webView.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,11 +306,7 @@ public final class MainView extends Main implements BeforeEnterObserver
|
|||||||
"WEB_VNC=true"
|
"WEB_VNC=true"
|
||||||
],
|
],
|
||||||
"HostConfig": {
|
"HostConfig": {
|
||||||
"PortBindings": {
|
"NetworkMode": "votianBridge",
|
||||||
"6080/tcp": [
|
|
||||||
{ "HostPort": "6080" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Devices": [
|
"Devices": [
|
||||||
{
|
{
|
||||||
"PathOnHost": "/dev/kvm",
|
"PathOnHost": "/dev/kvm",
|
||||||
@@ -322,10 +317,20 @@ public final class MainView extends Main implements BeforeEnterObserver
|
|||||||
},
|
},
|
||||||
"ExposedPorts": {
|
"ExposedPorts": {
|
||||||
"6080/tcp": {}
|
"6080/tcp": {}
|
||||||
|
},
|
||||||
|
"NetworkingConfig": {
|
||||||
|
"EndpointsConfig": {
|
||||||
|
"votianBridge": {
|
||||||
|
"IPAMConfig": {
|
||||||
|
"IPv4Address": "%s"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""";
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""".formatted(Application.users.get(username).ip());
|
||||||
|
|
||||||
|
System.out.println(jsonPayload);
|
||||||
// HTTP-Request erstellen
|
// HTTP-Request erstellen
|
||||||
HttpRequest request = HttpRequest.newBuilder()
|
HttpRequest request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create("http://" + server + ":2375/containers/create?name=android-container-" + username))
|
.uri(URI.create("http://" + server + ":2375/containers/create?name=android-container-" + username))
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package de.assecutor.emulatorstation.base.ui.view;
|
|||||||
import com.vaadin.flow.router.BeforeEnterEvent;
|
import com.vaadin.flow.router.BeforeEnterEvent;
|
||||||
import com.vaadin.flow.router.BeforeEnterObserver;
|
import com.vaadin.flow.router.BeforeEnterObserver;
|
||||||
import com.vaadin.flow.router.Route;
|
import com.vaadin.flow.router.Route;
|
||||||
import com.vaadin.flow.server.VaadinService;
|
|
||||||
|
|
||||||
@Route("")
|
@Route("")
|
||||||
public class RootView implements BeforeEnterObserver {
|
public class RootView implements BeforeEnterObserver {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
|||||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||||
|
|
||||||
import de.assecutor.emulatorstation.Application;
|
import de.assecutor.emulatorstation.Application;
|
||||||
|
import de.assecutor.emulatorstation.pojo.UserInfo;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SecurityConfig extends VaadinWebSecurity {
|
public class SecurityConfig extends VaadinWebSecurity {
|
||||||
@@ -38,9 +39,9 @@ public class SecurityConfig extends VaadinWebSecurity {
|
|||||||
@Bean
|
@Bean
|
||||||
public UserDetailsService userDetailsService() {
|
public UserDetailsService userDetailsService() {
|
||||||
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
|
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
|
||||||
Application.users.forEach((username, rawPassword) ->
|
Application.users.forEach((username, info) ->
|
||||||
manager.createUser(User.withUsername(username)
|
manager.createUser(User.withUsername(username)
|
||||||
.password(rawPassword)
|
.password(info.password())
|
||||||
.roles("USER")
|
.roles("USER")
|
||||||
.build())
|
.build())
|
||||||
);
|
);
|
||||||
@@ -61,7 +62,8 @@ public class SecurityConfig extends VaadinWebSecurity {
|
|||||||
String username = authentication.getName();
|
String username = authentication.getName();
|
||||||
session.setAttribute("user", username);
|
session.setAttribute("user", username);
|
||||||
session.setAttribute("username", username);
|
session.setAttribute("username", username);
|
||||||
response.sendRedirect("/main");
|
String target = "admin".equalsIgnoreCase(username) ? "/admin" : "/main";
|
||||||
|
response.sendRedirect(target);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package de.assecutor.emulatorstation.pojo;
|
||||||
|
|
||||||
|
public record UserInfo(String password, String ip) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user