use of org.eclipse.jetty.util.security.Constraint 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.util.security.Constraint 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);
}
use of org.eclipse.jetty.util.security.Constraint in project jetty-bootstrap by teknux-org.
the class JettyConstraintUtil method getConstraintSecurityHandlerConfidential.
/**
* Create constraint which redirect to Secure Port
*
* @return ConstraintSecurityHandler
*/
public static ConstraintSecurityHandler getConstraintSecurityHandlerConfidential() {
Constraint constraint = new Constraint();
constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");
ConstraintSecurityHandler constraintSecurityHandler = new ConstraintSecurityHandler();
constraintSecurityHandler.addConstraintMapping(constraintMapping);
return constraintSecurityHandler;
}
Aggregations