更新时间:2023-10-21 19:10:58
此答案指出正确的方向。以编程方式,必须将 SecurityConstraint
添加到 Builder
并设置 ConfidentialPortManager
:
This answer pointed in the right direction. Programmatically, one has to add a SecurityConstraint
to Builder
and set ConfidentialPortManager
:
DeploymentInfo servletBuilder = Servlets.deployment();
servletBuilder.addSecurityConstraint(new SecurityConstraint()
.addWebResourceCollection(new WebResourceCollection()
.addUrlPattern("/*"))
.setTransportGuaranteeType(TransportGuaranteeType.CONFIDENTIAL)
.setEmptyRoleSemantic(EmptyRoleSemantic.PERMIT))
.setConfidentialPortManager(new ConfidentialPortManager() {
@Override
public int getConfidentialPort(HttpServerExchange exchange) {
return 443;
}
}
);