use of org.eclipse.jetty.security.SecurityHandler in project blade by biezhi.
the class SessionAuthentication method readObject.
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
SecurityHandler security = SecurityHandler.getCurrentSecurityHandler();
if (security == null)
throw new IllegalStateException("!SecurityHandler");
LoginService login_service = security.getLoginService();
if (login_service == null)
throw new IllegalStateException("!LoginService");
_userIdentity = login_service.login(_name, _credentials, null);
LOG.debug("Deserialized and relogged in {}", this);
}
use of org.eclipse.jetty.security.SecurityHandler in project jena by apache.
the class TestFusekiTestAuth method ctlBeforeClass.
@BeforeClass
public static void ctlBeforeClass() {
SecurityHandler sh = FusekiTestAuth.makeSimpleSecurityHandler("/*", USER, PASSWORD);
FusekiTestAuth.setupServer(false, sh);
}
use of org.eclipse.jetty.security.SecurityHandler in project airlift by airlift.
the class HttpServer method createServletContext.
private static ServletContextHandler createServletContext(Servlet theServlet, Map<String, String> parameters, Set<Filter> filters, TraceTokenManager tokenManager, LoginService loginService, String... connectorNames) {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.addFilter(new FilterHolder(new TimingFilter()), "/*", null);
if (tokenManager != null) {
context.addFilter(new FilterHolder(new TraceTokenFilter(tokenManager)), "/*", null);
}
// -- security handler
if (loginService != null) {
SecurityHandler securityHandler = createSecurityHandler(loginService);
context.setSecurityHandler(securityHandler);
}
// -- user provided filters
for (Filter filter : filters) {
context.addFilter(new FilterHolder(filter), "/*", null);
}
// -- gzip handler
context.setGzipHandler(new GzipHandler());
// -- the servlet
ServletHolder servletHolder = new ServletHolder(theServlet);
servletHolder.setInitParameters(ImmutableMap.copyOf(parameters));
context.addServlet(servletHolder, "/*");
// Starting with Jetty 9 there is no way to specify connectors directly, but
// there is this wonky @ConnectorName virtual hosts automatically added
String[] virtualHosts = new String[connectorNames.length];
for (int i = 0; i < connectorNames.length; i++) {
virtualHosts[i] = "@" + connectorNames[i];
}
context.setVirtualHosts(virtualHosts);
return context;
}
use of org.eclipse.jetty.security.SecurityHandler in project jspwiki by apache.
the class TestContainer method addWebApp.
/**
* Configures a test web application
*
* @param context the name of the web m_context; must start with "/"
* @param path the file path for the WAR file, or expanded WAR directory
* @throws IOException
*/
public void addWebApp(String context, String path) throws IOException {
// Set the default users and roles for the realm (note that realm name *must* match web.xml <realm-name>
HashLoginService loginService = new HashLoginService("JSPWikiRealm");
loginService.putUser(Users.ADMIN, new Password(Users.ADMIN_PASS), new String[] { "Authenticated", "Admin" });
loginService.putUser(Users.JANNE, new Password(Users.JANNE_PASS), new String[] { "Authenticated" });
WebAppContext webAppContext = new WebAppContext(path, context);
// Add a security handler.
SecurityHandler csh = new ConstraintSecurityHandler();
csh.setLoginService(loginService);
webAppContext.setSecurityHandler(csh);
log.error("Adding webapp " + context + " for path " + path);
handlerCollection.addHandler(webAppContext);
}
use of org.eclipse.jetty.security.SecurityHandler in project crnk-framework by crnk-project.
the class SecurityModuleIntTest method getTestContainerFactory.
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
final TestContainerFactory testContainerFactory = super.getTestContainerFactory();
return new TestContainerFactory() {
@Override
public TestContainer create(URI baseUri, DeploymentContext deploymentContext) {
TestContainer container = testContainerFactory.create(baseUri, deploymentContext);
try {
Field field = container.getClass().getDeclaredField("server");
field.setAccessible(true);
Server server = (Server) field.get(container);
Handler handler = server.getHandler();
SecurityHandler securityHandler = identityManager.getSecurityHandler();
if (securityHandler.getHandler() == null) {
securityHandler.setHandler(handler);
}
server.setHandler(securityHandler);
} catch (Exception e) {
throw new IllegalStateException(e);
}
return container;
}
};
}
Aggregations