Search in sources :

Example 1 with ShutdownHandler

use of org.eclipse.jetty.server.handler.ShutdownHandler in project Manga by herrlock.

the class JettyServer method createShutdownHandler.

private Handler createShutdownHandler() {
    String pwConfig = new File("conf/jetty-users.dsc").getAbsolutePath();
    HashLoginService loginService = new HashLoginService("MangaDownloader-Realm", pwConfig);
    this.server.addBean(loginService, true);
    ConstraintSecurityHandler secHandler = new ConstraintSecurityHandler();
    secHandler.setAuthenticator(new BasicAuthenticator());
    ConstraintMapping cm = new ConstraintMapping();
    final Constraint userConstraint = new Constraint(Constraint.__BASIC_AUTH, "**");
    userConstraint.setAuthenticate(true);
    cm.setConstraint(userConstraint);
    cm.setPathSpec("/shutdown/*");
    secHandler.setConstraintMappings(Arrays.asList(cm));
    secHandler.setHandler(new ShutdownHandler(SUPER_SECRET_MAGIC_TOKEN_FOR_SHUTDOWN, false, true));
    secHandler.setLoginService(loginService);
    return secHandler;
}
Also used : HashLoginService(org.eclipse.jetty.security.HashLoginService) ConstraintMapping(org.eclipse.jetty.security.ConstraintMapping) BasicAuthenticator(org.eclipse.jetty.security.authentication.BasicAuthenticator) ShutdownHandler(org.eclipse.jetty.server.handler.ShutdownHandler) Constraint(org.eclipse.jetty.util.security.Constraint) ConstraintSecurityHandler(org.eclipse.jetty.security.ConstraintSecurityHandler) File(java.io.File)

Aggregations

File (java.io.File)1 ConstraintMapping (org.eclipse.jetty.security.ConstraintMapping)1 ConstraintSecurityHandler (org.eclipse.jetty.security.ConstraintSecurityHandler)1 HashLoginService (org.eclipse.jetty.security.HashLoginService)1 BasicAuthenticator (org.eclipse.jetty.security.authentication.BasicAuthenticator)1 ShutdownHandler (org.eclipse.jetty.server.handler.ShutdownHandler)1 Constraint (org.eclipse.jetty.util.security.Constraint)1