@Bean public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory( ConfigProvider<UndertowConfig> cfg) { int port = cfg.defaultReadConfig().findFirst().get().getPort(); UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(port); factory.addBuilderCustomizers((UndertowBuilderCustomizer) builder -> { // (*) builder.setServerOption(UndertowOptions.DECODE_URL, true); builder.setServerOption(UndertowOptions.URL_CHARSET, StandardCharsets.UTF_8.name()); }); factory.addDeploymentInfoCustomizers( (UndertowDeploymentInfoCustomizer) deployment -> { // (*) deployment.setDefaultEncoding(StandardCharsets.UTF_8.name()); }); return factory; }
private UndertowDeploymentInfoCustomizer enableAuthUDICustomizer() { return (DeploymentInfo di) -> { if(StringUtils.isEmpty(encodedPass)) { return; } SecurityConstraint sc = new SecurityConstraint(); sc.setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.AUTHENTICATE); // empty web resource interpret as default sc.addWebResourceCollection(new WebResourceCollection()); di.addSecurityConstraints(sc); di.setSecurityDisabled(false); di.setAuthenticationMode(AuthenticationMode.PRO_ACTIVE); di.setLoginConfig(new LoginConfig(HttpServletRequest.BASIC_AUTH, "Haven Agent")); di.setIdentityManager(new IdentityManagerImpl(encodedPass)); }; }
@Bean @Autowired public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory(List<UndertowDeploymentInfoCustomizer> customizers) { UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(); for (UndertowDeploymentInfoCustomizer customizer : customizers) { factory.addDeploymentInfoCustomizers(customizer); } return factory; }
@Bean public EmbeddedServletContainerFactory servletContainer() { UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(); factory.addDeploymentInfoCustomizers(new UndertowDeploymentInfoCustomizer() { @Override public void customize(DeploymentInfo deploymentInfo) { deploymentInfo.addInitialHandlerChainWrapper(new RootHandlerWrapper()); } }); factory.setPort(Integer.parseInt(environment.getProperty("shiny.proxy.port", "8080"))); return factory; }