use of org.eclipse.jetty.security.ConstraintMapping in project elasticsearch-jetty by sonian.
the class RestConstraintSecurityHandlerTests method forbidden.
protected ConstraintMapping forbidden(String method, String url) {
ConstraintMapping constraintMapping = new ConstraintMapping();
Constraint constraint = new Constraint();
constraintMapping.setMethod(method);
constraintMapping.setPathSpec(url);
constraint.setAuthenticate(true);
constraintMapping.setConstraint(constraint);
return constraintMapping;
}
use of org.eclipse.jetty.security.ConstraintMapping in project hive by apache.
the class HttpServer method setupPam.
/**
* Secure the web server with PAM.
*/
void setupPam(Builder b, Handler handler) {
LoginService loginService = new PamLoginService();
webServer.addBean(loginService);
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
Constraint constraint = new PamConstraint();
ConstraintMapping mapping = new PamConstraintMapping(constraint);
security.setConstraintMappings(Collections.singletonList(mapping));
security.setAuthenticator(b.pamAuthenticator);
security.setLoginService(loginService);
security.setHandler(handler);
webServer.setHandler(security);
}
use of org.eclipse.jetty.security.ConstraintMapping in project hive by apache.
the class ThriftHttpCLIService method constrainHttpMethods.
public void constrainHttpMethods(ServletContextHandler ctxHandler, boolean allowOptionsMethod) {
Constraint c = new Constraint();
c.setAuthenticate(true);
ConstraintMapping cmt = new ConstraintMapping();
cmt.setConstraint(c);
cmt.setMethod("TRACE");
cmt.setPathSpec("/*");
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
if (!allowOptionsMethod) {
ConstraintMapping cmo = new ConstraintMapping();
cmo.setConstraint(c);
cmo.setMethod("OPTIONS");
cmo.setPathSpec("/*");
securityHandler.setConstraintMappings(new ConstraintMapping[] { cmt, cmo });
} else {
securityHandler.setConstraintMappings(new ConstraintMapping[] { cmt });
}
ctxHandler.setSecurityHandler(securityHandler);
}
use of org.eclipse.jetty.security.ConstraintMapping in project cayenne by apache.
the class Http2Server method basicAuth.
private static SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService loginService = new HashLoginService();
UserStore userStore = new UserStore();
userStore.addUser(username, Credential.getCredential(password), new String[] { "cayenne-service-user" });
loginService.setUserStore(userStore);
loginService.setName(realm);
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setRoles(new String[] { "cayenne-service-user" });
constraint.setAuthenticate(true);
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");
ConstraintSecurityHandler constraintSecurityHandler = new ConstraintSecurityHandler();
constraintSecurityHandler.setAuthenticator(new BasicAuthenticator());
constraintSecurityHandler.setRealmName(realm);
constraintSecurityHandler.addConstraintMapping(constraintMapping);
constraintSecurityHandler.setLoginService(loginService);
return constraintSecurityHandler;
}
use of org.eclipse.jetty.security.ConstraintMapping in project elastic-core-maven by OrdinaryDude.
the class API method disableHttpMethod.
private static void disableHttpMethod(ConstraintSecurityHandler securityHandler, String httpMethod) {
ConstraintMapping mapping = new ConstraintMapping();
Constraint constraint = new Constraint();
constraint.setName("Disable " + httpMethod);
constraint.setAuthenticate(true);
mapping.setConstraint(constraint);
mapping.setPathSpec("/");
mapping.setMethod(httpMethod);
securityHandler.addConstraintMapping(mapping);
}
Aggregations