jettyServer.setStopAtShutdown( true );
Connector connector = ( isSSL ? getSSLConnector() : getDefaultConnector() );
jettyServer.setConnectors( new Connector[] { connector } );
WebAppContext webapp = new WebAppContext();
webapp.setContextPath( "/" );
webapp.setResourceBase( getBasedir() + "/target/classes/" );
webapp.setServer( jettyServer );
if ( withAuth )
{
Constraint constraint = new Constraint();
constraint.setName( Constraint.__BASIC_AUTH );
constraint.setRoles( new String[] { "user", "admin" } );
constraint.setAuthenticate( true );
ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint( constraint );
cm.setPathSpec( "/*" );
SecurityHandler sh = new SecurityHandler();
sh.setUserRealm( new HashUserRealm( "MyRealm", getBasedir() + "/src/test/resources/realm.properties" ) );
sh.setConstraintMappings( new ConstraintMapping[] { cm } );
webapp.addHandler( sh );
}
DefaultHandler defaultHandler = new DefaultHandler();
defaultHandler.setServer( jettyServer );