// final HashLoginService loginService = new HashLoginService("MyRealm",
// "META-INF/realm.properties");
final JPALoginService loginService = new JPALoginService();
// server.addBean(loginService);
final ConstraintSecurityHandler security = new ConstraintSecurityHandler();
final Constraint constraint = new Constraint();
constraint.setName(Constraint.__FORM_AUTH);
constraint.setAuthenticate(true);
constraint.setRoles(RoleType.names());
final ConstraintMapping cm = new ConstraintMapping();
cm.setPathSpec("/*");
cm.setConstraint(constraint);
security.setConstraintMappings(Arrays
.asList(new ConstraintMapping[] { cm }));
final FormAuthenticator fa = new FormAuthenticator(
WebApplication.ControllerResource.LOGIN.path(),
WebApplication.ControllerResource.ERROR.path(), false);
security.setAuthenticator(fa);
// security.setAuthenticator(new DigestAuthenticator());
security.setLoginService(loginService);
context.setSecurityHandler(security);
server.setHandler(context);
}