【发布时间】:2016-04-15 11:16:00
【问题描述】:
【问题讨论】:
-
我同意,出于安全原因,这会很好。您应该始终运行最新版本,但最好将其隐藏起来,以防您落后几天。
【问题讨论】:
我认为摆脱 VAADIN 目录名称是不可能的,因为它在服务器端和客户端的某些框架类中是硬编码的。例如:com.vaadin.server.BootstrapHandler、com.vaadin.server.VaadinServlet 和 com.vaadin.client.ui.ui.UIConnector
【讨论】:
从技术上讲,可以隐藏 Vaadin 版本。您只需在 Servlet 会话开始时注册 BootstrapListener
public class ApplicationBootstrapListener implements BootstrapListener {
@Override
public void modifyBootstrapFragment(BootstrapFragmentResponse response) {
List<Node> nodes = response.getFragmentNodes();
for (Node node : nodes) {
if (node.toString()
.contains("js?v=")) {
String fakeVersion = node.attr("src")
.replace("7.5.8", "1.1.1");
node.attributes()
.put("src", fakeVersion);
}
}
}
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
}
}
//somewhere in servletInitialized()
getService().addSessionInitListener(event -> event.getSession()
.addBootstrapListener(
new ApplicationBootstrapListener()));
在这一步之后,应用程序应该会停止工作。这是因为 Vaadin 将无法找到 vaadinBootstrap.js,因为您已更改其名称。您可能需要复制此 JavaScript 的内容,将其放在公共文件夹中的某个位置,然后将其重命名为您想要的任何假名(在我的情况下,它是 vaadinBootstrap.js?v=1.1.1。
至于第二个问题,我也觉得不可能,至少没有逆向工程的帮助。
【讨论】:
基于 Kuki 的回答,这在 Vaadin 8.9.4 上对我有用,无需复制任何 js 文件。
@Override
public void modifyBootstrapFragment(BootstrapFragmentResponse bootstrapFragmentResponse) {
final List<Node> nodes = bootstrapFragmentResponse.getFragmentNodes();
final String oldVersion = "8.9.4";
final String fakeVersion = "x.y.z";
for (Node node : nodes) {
/* replacing the version in src-attributes */
if (node.attr("src").contains(oldVersion)) {
node.attributes().put("src", node.attr("src").replace(oldVersion, fakeVersion));
}
/* replacing the version in the child-DataNodes */
for (Node child : node.childNodes()) {
if (child instanceof DataNode) {
final DataNode dataNode = ((DataNode) child);
if (dataNode.getWholeData().contains(oldVersion)) {
dataNode.setWholeData(dataNode.getWholeData().replace(oldVersion, fakeVersion));
}
}
}
}
}
【讨论】: