use of org.eclipse.jetty.util.security.Constraint in project jena by apache.
the class JettyLib method addPathConstraint.
public static void addPathConstraint(ConstraintSecurityHandler securityHandler, String pathSpec, String role) {
Objects.requireNonNull(securityHandler);
Objects.requireNonNull(pathSpec);
ConstraintMapping mapping = new ConstraintMapping();
Constraint constraint = new Constraint();
String[] roles = new String[] { role };
constraint.setRoles(roles);
constraint.setName(securityHandler.getAuthenticator().getAuthMethod());
constraint.setAuthenticate(true);
mapping.setConstraint(constraint);
mapping.setPathSpec(pathSpec);
securityHandler.addConstraintMapping(mapping);
}
use of org.eclipse.jetty.util.security.Constraint 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.util.security.Constraint 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.util.security.Constraint 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.util.security.Constraint 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