use of org.eclipse.jetty.server.LocalConnector in project elasticsearch-jetty by sonian.
the class RestConstraintSecurityHandlerTests method createServer.
@BeforeMethod
public void createServer() {
server = new Server();
connector = new LocalConnector();
server.addConnector(connector);
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class JaspiTest method before.
@Before
public void before() throws Exception {
System.setProperty("org.apache.geronimo.jaspic.configurationFile", "src/test/resources/jaspi.xml");
_server = new Server();
_connector = new LocalConnector(_server);
_server.addConnector(_connector);
ContextHandlerCollection contexts = new ContextHandlerCollection();
_server.setHandler(contexts);
TestLoginService loginService = new TestLoginService("TestRealm");
loginService.putUser("user", new Password("password"), new String[] { "users" });
loginService.putUser("admin", new Password("secret"), new String[] { "users", "admins" });
_server.addBean(loginService);
ContextHandler context = new ContextHandler();
contexts.addHandler(context);
context.setContextPath("/ctx");
JaspiAuthenticatorFactory jaspiAuthFactory = new JaspiAuthenticatorFactory();
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
context.setHandler(security);
security.setAuthenticatorFactory(jaspiAuthFactory);
// security.setAuthenticator(new BasicAuthenticator());
Constraint constraint = new Constraint("All", "users");
constraint.setAuthenticate(true);
ConstraintMapping mapping = new ConstraintMapping();
mapping.setPathSpec("/jaspi/*");
mapping.setConstraint(constraint);
security.addConstraintMapping(mapping);
TestHandler handler = new TestHandler();
security.setHandler(handler);
ContextHandler other = new ContextHandler();
contexts.addHandler(other);
other.setContextPath("/other");
ConstraintSecurityHandler securityOther = new ConstraintSecurityHandler();
other.setHandler(securityOther);
securityOther.setAuthenticatorFactory(jaspiAuthFactory);
securityOther.addConstraintMapping(mapping);
securityOther.setHandler(new TestHandler());
_server.start();
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class AllowSymLinkAliasCheckerTest method setupServer.
private void setupServer() throws Exception {
// Setup server
server = new Server();
localConnector = new LocalConnector(server);
server.addConnector(localConnector);
ResourceHandler fileResourceHandler = new ResourceHandler();
fileResourceHandler.setDirectoriesListed(true);
fileResourceHandler.setWelcomeFiles(new String[] { "index.html" });
fileResourceHandler.setEtags(true);
ContextHandler fileResourceContext = new ContextHandler();
fileResourceContext.setContextPath("/");
fileResourceContext.setAllowNullPathInfo(true);
fileResourceContext.setHandler(fileResourceHandler);
fileResourceContext.setBaseResource(new PathResource(rootPath));
fileResourceContext.clearAliasChecks();
fileResourceContext.addAliasCheck(new AllowSymLinkAliasChecker());
server.setHandler(fileResourceContext);
server.start();
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class BufferedResponseHandlerTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
_server = new Server();
_config = new HttpConfiguration();
_config.setOutputBufferSize(1024);
_config.setOutputAggregationSize(256);
_local = new LocalConnector(_server, new HttpConnectionFactory(_config));
_server.addConnector(_local);
_bufferedHandler = new BufferedResponseHandler();
_bufferedHandler.getPathIncludeExclude().include("/include/*");
_bufferedHandler.getPathIncludeExclude().exclude("*.exclude");
_bufferedHandler.getMimeIncludeExclude().exclude("text/excluded");
_bufferedHandler.setHandler(_test = new TestHandler());
_contextHandler = new ContextHandler("/ctx");
_contextHandler.setHandler(_bufferedHandler);
_server.setHandler(_contextHandler);
_server.start();
// BufferedResponseHandler.LOG.setDebugEnabled(true);
}
use of org.eclipse.jetty.server.LocalConnector in project jetty.project by eclipse.
the class ContextHandlerCollectionTest method testVirtualHostWildcard.
@Test
public void testVirtualHostWildcard() throws Exception {
Server server = new Server();
LocalConnector connector = new LocalConnector(server);
server.setConnectors(new Connector[] { connector });
ContextHandler context = new ContextHandler("/");
IsHandledHandler handler = new IsHandledHandler("H");
context.setHandler(handler);
ContextHandlerCollection c = new ContextHandlerCollection();
c.addHandler(context);
server.setHandler(c);
try {
server.start();
checkWildcardHost(true, server, null, new String[] { "example.com", ".example.com", "vhost.example.com" });
checkWildcardHost(false, server, new String[] { null }, new String[] { "example.com", ".example.com", "vhost.example.com" });
checkWildcardHost(true, server, new String[] { "example.com", "*.example.com" }, new String[] { "example.com", ".example.com", "vhost.example.com" });
checkWildcardHost(false, server, new String[] { "example.com", "*.example.com" }, new String[] { "badexample.com", ".badexample.com", "vhost.badexample.com" });
checkWildcardHost(false, server, new String[] { "*." }, new String[] { "anything.anything" });
checkWildcardHost(true, server, new String[] { "*.example.com" }, new String[] { "vhost.example.com", ".example.com" });
checkWildcardHost(false, server, new String[] { "*.example.com" }, new String[] { "vhost.www.example.com", "example.com", "www.vhost.example.com" });
checkWildcardHost(true, server, new String[] { "*.sub.example.com" }, new String[] { "vhost.sub.example.com", ".sub.example.com" });
checkWildcardHost(false, server, new String[] { "*.sub.example.com" }, new String[] { ".example.com", "sub.example.com", "vhost.example.com" });
checkWildcardHost(false, server, new String[] { "example.*.com", "example.com.*" }, new String[] { "example.vhost.com", "example.com.vhost", "example.com" });
} finally {
server.stop();
}
}
Aggregations