我想要将一个嵌入式Jetty web服务器通过编程方式配置成使用SPNEGO(不使用xml)。
我正在尝试将这个网站转换成非基于xml的配置:http://www.eclipse.org/jetty/documentation/current/spnego-support.html。以下是我的尝试内容:
然而,当我访问服务器时,它试图使用基本认证(base 64)。
有任何想法吗?
我正在尝试将这个网站转换成非基于xml的配置:http://www.eclipse.org/jetty/documentation/current/spnego-support.html。以下是我的尝试内容:
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
// ...
String domainRealm = "MY.DOMAIN.COM";
Constraint constraint = new Constraint();
constraint.setName(Constraint.__SPNEGO_AUTH);
constraint.setRoles(new String[] { domainRealm });
constraint.setAuthenticate(true);
ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint(constraint);
cm.setPathSpec("/*");
SpnegoLoginService loginService = new SpnegoLoginService();
loginService.setConfig(System.getProperty("spnego.properties"));
loginService.setName(domainRealm);
ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
sh.setLoginService(loginService);
sh.setConstraintMappings(new ConstraintMapping[]{cm});
sh.setRealmName(domainRealm);
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setErrorHandler(new ErrorHandler() { }); // TODO
contextHandler.setContextPath(contextPath);
contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), "/*");
contextHandler.addEventListener(new ContextLoaderListener(context));
contextHandler.setSecurityHandler(sh);
Server server = new Server(port);
server.setHandler(contextHandler);
然而,当我访问服务器时,它试图使用基本认证(base 64)。
有任何想法吗?
AnnotationConfigWebApplicationContext
(Spring)进行编程。在代码片段中添加了一些额外的代码。(没有WAR文件) - Cheetah