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;
}
Aggregations