本文整理汇总了Java中org.eclipse.jetty.servlet.ServletContextHandler.setSecurityHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContextHandler.setSecurityHandler方法的具体用法?Java ServletContextHandler.setSecurityHandler怎么用?Java ServletContextHandler.setSecurityHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.ServletContextHandler
的用法示例。
在下文中一共展示了ServletContextHandler.setSecurityHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void startServer() {
server = new Server(PORT);
port = PORT;
ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContext.setSecurityHandler(basicAuth("camel", "camelPass", "Private!"));
servletContext.setContextPath("/");
server.setHandler(servletContext);
servletContext.addServlet(new ServletHolder(new MyHttpServlet()), "/*");
try {
server.start();
} catch (Exception ex) {
LOG.error("Could not start Server!", ex);
fail(ex.getLocalizedMessage());
}
}
示例2: startup
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void startup() throws Exception {
server = new Server(PORT);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/");
if (!Config.RPCUsername.equals("") && !Config.RPCPassword.equals("")) {
context.setSecurityHandler(basicAuth(Config.RPCUsername, Config.RPCPassword, Config.appName));
}
server.setHandler(context);
context.addServlet(JsonRpcServlet.class, "/"+Config.appName.toLowerCase());
server.start();
}
示例3: proxyHandler
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private ServletContextHandler proxyHandler() {
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setServletHandler(newServletHandler());
contextHandler.setSecurityHandler(basicAuth(PROXY_USER, PROXY_PASSWORD, "Private!"));
return contextHandler;
}