Thank you very much Jan ...
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
HashLoginService loginService = new HashLoginService("MyRealm");
loginService.putUser("username1", new Password("password1"), new String[]{"user"});
loginService.putUser("username2", new Password("password2"), new String[]{"user"});
loginService.putUser("username3", new Password("password3"), new String[]{"user"});
server.addBean(loginService);
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
server.setHandler(security);
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setAuthenticate(true);
constraint.setRoles(new String[]{"user", "admin"});
ConstraintMapping mapping = new ConstraintMapping();
mapping.setPathSpec("/*");
mapping.setConstraint(constraint);
security.setConstraintMappings(Collections.singletonList(mapping));
security.setAuthenticator(new BasicAuthenticator());
security.setLoginService(loginService);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setResourceBase("./target");
ContextHandler contextHandler = new ContextHandler();
contextHandler.setContextPath("/test");
contextHandler.setHandler(resourceHandler);
server.setHandler(security);
security.setHandler(contextHandler);
server.start();
}