use of org.eclipse.jetty.security.ConstraintMapping 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;
}
use of org.eclipse.jetty.security.ConstraintMapping in project alluxio by Alluxio.
the class WebServer method disableMethod.
/**
* @param method to disable
*/
private void disableMethod(String method) {
Constraint constraint = new Constraint();
constraint.setAuthenticate(true);
constraint.setName("Disable " + method);
ConstraintMapping disableMapping = new ConstraintMapping();
disableMapping.setConstraint(constraint);
disableMapping.setMethod(method.toUpperCase());
disableMapping.setPathSpec("/");
mSecurityHandler.addConstraintMapping(disableMapping);
}
use of org.eclipse.jetty.security.ConstraintMapping in project calcite-avatica by apache.
the class HttpServer method configureCommonAuthentication.
protected ConstraintSecurityHandler configureCommonAuthentication(String constraintName, String[] allowedRoles, Authenticator authenticator, String realm, LoginService loginService) {
Constraint constraint = new Constraint();
constraint.setName(constraintName);
constraint.setRoles(allowedRoles);
// This is telling Jetty to not allow unauthenticated requests through (very important!)
constraint.setAuthenticate(true);
ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint(constraint);
cm.setPathSpec("/*");
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setAuthenticator(authenticator);
securityHandler.setLoginService(loginService);
securityHandler.setConstraintMappings(new ConstraintMapping[] { cm });
return securityHandler;
}
use of org.eclipse.jetty.security.ConstraintMapping in project zookeeper by apache.
the class JettyAdminServer method constrainTraceMethod.
/**
* Add constraint to a given context to disallow TRACE method
* @param ctxHandler the context to modify
*/
private void constrainTraceMethod(ServletContextHandler ctxHandler) {
Constraint c = new Constraint();
c.setAuthenticate(true);
ConstraintMapping cmt = new ConstraintMapping();
cmt.setConstraint(c);
cmt.setMethod("TRACE");
cmt.setPathSpec("/*");
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setConstraintMappings(new ConstraintMapping[] { cmt });
ctxHandler.setSecurityHandler(securityHandler);
}
Aggregations