spark.Spark.secure()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.2k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中spark.Spark.secure()方法的一些代码示例,展示了Spark.secure()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spark.secure()方法的具体详情如下:
包路径:spark.Spark
类名称:Spark
方法名:secure

Spark.secure介绍

[英]Set the connection to be secure, using the specified keystore and truststore. This has to be called before any route mapping is done. You have to supply a keystore file, truststore file is optional (keystore will be reused). This method is only relevant when using embedded Jetty servers. It should not be used if you are using Servlets, where you will need to secure the connection in the servlet container
[中]使用指定的密钥库和信任库将连接设置为安全的。在完成任何路由映射之前,必须调用该函数。您必须提供密钥库文件,信任库文件是可选的(密钥库将被重用)。此方法仅适用于使用嵌入式Jetty服务器的情况。如果您使用的是servlet,则不应使用它,因为您需要在servlet容器中保护连接

代码示例

代码示例来源:origin: xjdr/xio

private static void setupSpark(int port, String name, boolean tls) throws Exception {
 if (tls) {
  Resource keystore = new ClassPathResource("snakeoil.jks");
  URL url = keystore.getURL();
  String path = url.toString();
  secure(path, "snakeoil", path, "snakeoil");
 }
 port(port);
 get("/", (req, res) -> setupSparkResponse(name, req, res));
 post("/", (req, res) -> setupSparkResponse(name, req, res));
}

代码示例来源:origin: lamarios/Homedash2

secure(Constants.KEY_STORE, Constants.KEY_STORE_PASS, null, null);

相关文章