首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jetty +可编程SPNEGO配置

Jetty +可编程SPNEGO配置
EN

Stack Overflow用户
提问于 2014-09-09 20:56:07
回答 1查看 1.2K关注 0票数 5

我正在尝试配置一个嵌入式Jetty xml服务器,以编程方式使用SPNEGO (没有xml)。

我正在尝试将这个:http://www.eclipse.org/jetty/documentation/current/spnego-support.html转换为非基于xml的配置。这是我的尝试:

代码语言:javascript
复制
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);

但是,当我访问服务器时,它试图使用基本身份验证(Base64)。

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2014-09-09 23:03:44

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25745228

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档