use of org.eclipse.jetty.servlet.ServletHolder in project jetty.project by eclipse.
the class RunAsAnnotationHandler method doHandle.
public void doHandle(Class clazz) {
if (!Servlet.class.isAssignableFrom(clazz))
return;
javax.annotation.security.RunAs runAs = (javax.annotation.security.RunAs) clazz.getAnnotation(javax.annotation.security.RunAs.class);
if (runAs != null) {
String role = runAs.value();
if (role != null) {
ServletHolder holder = getServletHolderForClass(clazz);
if (holder != null) {
MetaData metaData = _context.getMetaData();
Descriptor d = metaData.getOriginDescriptor(holder.getName() + ".servlet.run-as");
//let the annotation override it
if (d == null) {
metaData.setOrigin(holder.getName() + ".servlet.run-as", runAs, clazz);
org.eclipse.jetty.plus.annotation.RunAs ra = new org.eclipse.jetty.plus.annotation.RunAs();
ra.setTargetClassName(clazz.getCanonicalName());
ra.setRoleName(role);
RunAsCollection raCollection = (RunAsCollection) _context.getAttribute(RunAsCollection.RUNAS_COLLECTION);
if (raCollection == null) {
raCollection = new RunAsCollection();
_context.setAttribute(RunAsCollection.RUNAS_COLLECTION, raCollection);
}
raCollection.add(ra);
}
}
} else
LOG.warn("Bad value for @RunAs annotation on class " + clazz.getName());
}
}
use of org.eclipse.jetty.servlet.ServletHolder in project jetty.project by eclipse.
the class ProxyServletTest method startServer.
private void startServer(HttpServlet servlet) throws Exception {
QueuedThreadPool serverPool = new QueuedThreadPool();
serverPool.setName("server");
server = new Server(serverPool);
serverConnector = new ServerConnector(server);
server.addConnector(serverConnector);
ServletContextHandler appCtx = new ServletContextHandler(server, "/", true, false);
ServletHolder appServletHolder = new ServletHolder(servlet);
appCtx.addServlet(appServletHolder, "/*");
server.start();
}
use of org.eclipse.jetty.servlet.ServletHolder in project jetty.project by eclipse.
the class ReverseProxyTest method startServer.
private void startServer(HttpServlet servlet) throws Exception {
server = new Server();
serverConnector = new ServerConnector(server);
server.addConnector(serverConnector);
ServletContextHandler appCtx = new ServletContextHandler(server, "/", true, false);
ServletHolder appServletHolder = new ServletHolder(servlet);
appCtx.addServlet(appServletHolder, "/*");
server.start();
}
use of org.eclipse.jetty.servlet.ServletHolder in project jetty.project by eclipse.
the class ProxyServletTest method startProxy.
private void startProxy(Map<String, String> initParams) throws Exception {
QueuedThreadPool proxyPool = new QueuedThreadPool();
proxyPool.setName("proxy");
proxy = new Server(proxyPool);
HttpConfiguration configuration = new HttpConfiguration();
configuration.setSendDateHeader(false);
configuration.setSendServerVersion(false);
String value = initParams.get("outputBufferSize");
if (value != null)
configuration.setOutputBufferSize(Integer.valueOf(value));
proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration));
proxy.addConnector(proxyConnector);
proxyContext = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
proxyServletHolder.setInitParameters(initParams);
proxyContext.addServlet(proxyServletHolder, "/*");
proxy.start();
}
use of org.eclipse.jetty.servlet.ServletHolder in project jetty.project by eclipse.
the class ProxyServletFailureTest method prepareProxy.
private void prepareProxy(Map<String, String> initParams) throws Exception {
QueuedThreadPool executor = new QueuedThreadPool();
executor.setName("proxy");
proxy = new Server(executor);
proxyConnector = new ServerConnector(proxy);
proxy.addConnector(proxyConnector);
proxyConnector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchUntilContent(false);
ServletContextHandler proxyCtx = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
proxyServletHolder.setInitParameters(initParams);
proxyCtx.addServlet(proxyServletHolder, "/*");
proxy.start();
client = prepareClient();
}
Aggregations