code: private void configureSecurity(ServletContextHandler context, String realmName, String authMethod,
  								   String formLoginPage, String formErrorPage) {
  		final SecurityHandler securityHandler = context.getSecurityHandler();
  
  		Authenticator authenticator = null;
  		if (authMethod == null) {
  			LOG.warn("UNKNOWN AUTH METHOD: " + authMethod);
  		} else {
  			switch (authMethod) {
  				case Constraint.__FORM_AUTH:
  					authenticator = new FormAuthenticator();
  					securityHandler.setInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE, formLoginPage);
  					securityHandler.setInitParameter(FormAuthenticator.__FORM_ERROR_PAGE, formErrorPage);
  					break;
  				case Constraint.__BASIC_AUTH:
  					authenticator = new BasicAuthenticator();
  					break;
  				case Constraint.__DIGEST_AUTH:
  					authenticator = new DigestAuthenticator();
  					break;
  				case Constraint.__CERT_AUTH:
  					authenticator = new ClientCertAuthenticator();
  					break;
  				case Constraint.__CERT_AUTH2:
  					authenticator = new ClientCertAuthenticator();
  					break;
  				case Constraint.__SPNEGO_AUTH:
  					authenticator = new SpnegoAuthenticator();
  					break;
  				default:
  					authenticator = getAuthenticator(authMethod);
  					break;
  			}
  		}
  
  		securityHandler.setAuthenticator(authenticator);
  
  		securityHandler.setRealmName(realmName);
  
  	}
docs: Sets the security authentication method and the realm name on the
  security handler. This has to be done before the context is started.
  
  @param context
  @param realmName
  @param authMethod
  @param formLoginPage
  @param formErrorPage