use of org.eclipse.jetty.security.SecurityHandler in project jetty.project by eclipse.
the class ServletContextHandler method setSecurityHandler.
/* ------------------------------------------------------------ */
/**
* @param securityHandler The {@link SecurityHandler} to set on this context.
*/
public void setSecurityHandler(SecurityHandler securityHandler) {
if (isStarted())
throw new IllegalStateException("STARTED");
Handler next = null;
if (_securityHandler != null) {
next = _securityHandler.getHandler();
_securityHandler.setHandler(null);
replaceHandler(_securityHandler, securityHandler);
}
_securityHandler = securityHandler;
if (next != null && _securityHandler.getHandler() == null)
_securityHandler.setHandler(next);
relinkHandlers();
}
use of org.eclipse.jetty.security.SecurityHandler in project jetty.project by eclipse.
the class ServletHandler method doStart.
/* ----------------------------------------------------------------- */
@Override
protected synchronized void doStart() throws Exception {
ContextHandler.Context context = ContextHandler.getCurrentContext();
_servletContext = context == null ? new ContextHandler.StaticContext() : context;
_contextHandler = (ServletContextHandler) (context == null ? null : context.getContextHandler());
if (_contextHandler != null) {
SecurityHandler security_handler = _contextHandler.getChildHandlerByClass(SecurityHandler.class);
if (security_handler != null)
_identityService = security_handler.getIdentityService();
}
updateNameMappings();
updateMappings();
if (getServletMapping("/") == null && isEnsureDefaultServlet()) {
if (LOG.isDebugEnabled())
LOG.debug("Adding Default404Servlet to {}", this);
addServletWithMapping(Default404Servlet.class, "/");
updateMappings();
getServletMapping("/").setDefault(true);
}
if (isFilterChainsCached()) {
_chainCache[FilterMapping.REQUEST] = new ConcurrentHashMap<>();
_chainCache[FilterMapping.FORWARD] = new ConcurrentHashMap<>();
_chainCache[FilterMapping.INCLUDE] = new ConcurrentHashMap<>();
_chainCache[FilterMapping.ERROR] = new ConcurrentHashMap<>();
_chainCache[FilterMapping.ASYNC] = new ConcurrentHashMap<>();
_chainLRU[FilterMapping.REQUEST] = new ConcurrentLinkedQueue<>();
_chainLRU[FilterMapping.FORWARD] = new ConcurrentLinkedQueue<>();
_chainLRU[FilterMapping.INCLUDE] = new ConcurrentLinkedQueue<>();
_chainLRU[FilterMapping.ERROR] = new ConcurrentLinkedQueue<>();
_chainLRU[FilterMapping.ASYNC] = new ConcurrentLinkedQueue<>();
}
if (_contextHandler == null)
initialize();
super.doStart();
}
use of org.eclipse.jetty.security.SecurityHandler in project jetty.project by eclipse.
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 jetty.project by eclipse.
the class ServletContextHandlerTest method testFindContainer.
@Test
public void testFindContainer() throws Exception {
ContextHandlerCollection contexts = new ContextHandlerCollection();
_server.setHandler(contexts);
ServletContextHandler root = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS);
SessionHandler session = root.getSessionHandler();
ServletHandler servlet = root.getServletHandler();
SecurityHandler security = new ConstraintSecurityHandler();
root.setSecurityHandler(security);
_server.start();
assertEquals(root, AbstractHandlerContainer.findContainerOf(_server, ContextHandler.class, session));
assertEquals(root, AbstractHandlerContainer.findContainerOf(_server, ContextHandler.class, security));
assertEquals(root, AbstractHandlerContainer.findContainerOf(_server, ContextHandler.class, servlet));
}
use of org.eclipse.jetty.security.SecurityHandler in project dropwizard by dropwizard.
the class ServletEnvironmentTest method setsSecurityHandlers.
@Test
void setsSecurityHandlers() {
final SecurityHandler securityHandler = new ConstraintSecurityHandler();
environment.setSecurityHandler(securityHandler);
assertThat(handler.getSecurityHandler()).isEqualTo(securityHandler);
assertThat(handler.isSecurityEnabled()).isTrue();
}
Aggregations