jetty9.4.x及之前版本存在安全漏洞,需要升级jetty10,研究了下,最终勉强升级了,但是jaas认证没有找到设置的方式.过程如下:
一、研究jetty6升级jetty10的差异。
Mortbay的jetty在最开始的版本,1998年发布Mortbay1.0的jetty,标准为RFC1945,到1999年开始Sourceforge开始接手jetty,2006年Codehaus开始接受jetty,到2008年Eclipse基于jdk1.5开始重写谢jetty,直到现在11.x系列的jetty。jetty6的时候包还是org.mortbay.jetty,从2008年后的jetty8开始包变为org.eclipse.jetty了, 而且api也变了,变化很大。
jetty10需要jdk11及以上
二、下载jetty10获取升级所需jar,官网地址https://www.eclipse.org/jetty/download.php。
将其中所有jar包括lib下的jar全部都加入build bath,删除所有jetty6的jar
如果是maven项目可以参考这个https://www.cnblogs.com/xiaoqi/p/6293422.html
三、修改jetty类引用及api使用方式,参考官网文档https://www.eclipse.org/jetty/documentation/jetty-10/programming_guide.php里的例子
也可以参考这几个
https://www.iteye.com/blog/zyn010101-1679798
https://www.cnblogs.com/xiaoqi/p/6293422.html
https://www.eclipse.org/jetty/javadoc/jetty-10/index.html
SocketConnector改成ServerConnector connector = new ServerConnector(server,new HttpConnectionFactory());
Content改为ServletContextHandler
private ServletContextHandler createContextHandler(String contextPath, HttpServlet httpServlet)
{
ServletContextHandler sch = new ServletContextHandler(ServletContextHandler.SESSIONS);
sch.setContextPath(contextPath);
sch.addServlet(new ServletHolder(httpServlet), "/*");
return sch;
}
List<Handler> handlers = new ArrayList<Handler>();
Handler handler = createContextHandler(GetStatusServlet.CONTEXT_PATH, new GetStatusServlet(transformationMap, jobMap));
handlers.add(handler);
handler = createContextHandler(GetTransStatusServlet.CONTEXT_PATH, new GetTransStatusServlet(transformationMap));
handlers.add(handler);
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
server.setHandler(contexts);
server.start();