本文整理匯總了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;
}