login-config does exist in web.xml, but is set to FORM_LOGIN
login-config does NOT exist in the app, but is set to BASIC
the mpJwt feature is NOT enabled
We should use FORM_LOGIN

@throws Exception
555144
@Test
    public void MPJwtNoMpJwtConfig_formLoginInWebXML_basicInApp() throws Exception {

        genericLoginConfigFormLoginVariationTest(
                                                 MpJwtFatConstants.LOGINCONFIG_FORM_LOGIN_IN_WEB_XML_SERVLET_BASIC_IN_APP_ROOT_CONTEXT,
                                                 MpJwtFatConstants.LOGINCONFIG_FORM_LOGIN_IN_WEB_XML_SERVLET_BASIC_IN_APP,
                                                 MpJwtFatConstants.MPJWT_APP_CLASS_LOGIN_CONFIG_FORMLOGININWEBXML_BASICINAPP,
                                                 UseJWTToken.NO);

    }
387378
private function checkConfig()
    {
        if (empty($this->config['api_key'])) {
            throw new Exception("`api_key' must be configured");
        }

        if (empty($this->config['host'])) {
            throw new Exception("`host' must be configured");
        }

        if (empty($this->config['port'])) {
            $this->config['port'] = !empty($this->config['secure']) ? 443 : 80;
        }

        if (!isset($this->config['secure'])) {
            $this->config['secure'] = ($this->config['port'] == 443);
        }

        if (empty($this->config['hostname'])) {
            $this->config['hostname'] = gethostname() ? gethostname() : '<unknown>';
        }

        if (empty($this->config['project_root'])) {
            $this->config['project_root'] = dirname(__FILE__);
        }

        if (empty($this->config['environment_name'])) {
            $this->config['environment_name'] = 'development';
        }

        if (!isset($this->config['params_filters'])) {
            $this->config['params_filters'] = array('/password/');
        }

        if (!isset($this->config['connect_timeout'])) {
            $this->config['connect_timeout'] = 3;
        }

        if (!isset($this->config['write_timeout'])) {
            $this->config['write_timeout'] = 3;
        }

        if (!isset($this->config['backtrace_filters'])) {
            $this->config['backtrace_filters'] = array(
                sprintf('/^%s/', preg_quote($this->config['project_root'], '/')) => '[PROJECT_ROOT]'
            );
        }

        if (!isset($this->config['skipped_exceptions'])) {
            $this->config['skipped_exceptions'] = array();
        }

        if (!isset($this->config['default_writer'])) {
            $this->config['default_writer'] = 'Errbit\Writer\SocketWriter';
        }

        if (!isset($this->config['agent'])) {
            $this->config['agent'] = 'errbitPHP';
        }
        if (!isset($this->config['async'])) {
            $this->config['async'] = false;
        }
        if (!isset($this->config['ignore_user_agent'])) {
            $this->config['ignore_user_agent'] = array();
        }
    }
784809
public void init(ServletConfig servletConfig) throws ServletException
    {
        super.init(servletConfig);
        ServletTask.initServlet(this, BasicServlet.SERVLET_TYPE.XML);
        Enumeration<?> paramNames = this.getInitParameterNames();
        while (paramNames.hasMoreElements())
        {
            String strProperty = (String)paramNames.nextElement();
            String strValue = this.getInitParameter(strProperty);
            m_initProperties.put(strProperty, strValue);
        }
    }
1355185
protected void initLoginConfig(XmlParser.Node node)
    {
        XmlParser.Node method=node.get("auth-method");
        FormAuthenticator _formAuthenticator=null;
        if(method!=null)
        {
            Authenticator authenticator=null;
            String m=method.toString(false,true);
            if(SecurityConstraint.__FORM_AUTH.equals(m))
                authenticator=_formAuthenticator=new FormAuthenticator();
            else if(SecurityConstraint.__BASIC_AUTH.equals(m))
                authenticator=new BasicAuthenticator();
            else if(SecurityConstraint.__DIGEST_AUTH.equals(m))
                authenticator=new DigestAuthenticator();
            else if(SecurityConstraint.__CERT_AUTH.equals(m))
                authenticator=new ClientCertAuthenticator();
            else if(SecurityConstraint.__CERT_AUTH2.equals(m))
                authenticator=new ClientCertAuthenticator();
            else
                log.warn("UNKNOWN AUTH METHOD: "+m);
            getWebApplicationContext().setAuthenticator(authenticator);
        }
        XmlParser.Node name=node.get("realm-name");
        if(name!=null)
            getWebApplicationContext().setRealmName(name.toString(false,true));
        XmlParser.Node formConfig=node.get("form-login-config");
        if(formConfig!=null)
        {
            if(_formAuthenticator==null)
                log.warn("FORM Authentication miss-configured");
            else
            {
                XmlParser.Node loginPage=formConfig.get("form-login-page");
                if(loginPage!=null)
                    _formAuthenticator.setLoginPage(loginPage.toString(false,true));
                XmlParser.Node errorPage=formConfig.get("form-error-page");
                if(errorPage!=null)
                {
                    String ep=errorPage.toString(false,true);
                    _formAuthenticator.setErrorPage(ep);
                }
            }
        }
    }
410944
public base_response login() throws Exception
	{
		login login = new login(this.user_name, this.password, this.timeout);
		base_response result = login.perform_operation(this);
		if (result.errorcode == 0 || result.errorcode == 1034)
			this.sessionid = result.sessionid;

		return result;
	}
734331
public void bootstrap() throws ConfigurationException {

    XMLConfigurator configurator = new XMLConfigurator();

    for (String config : configs) {
      log.debug("Loading XMLTooling configuration " + config);
      configurator.load(Configuration.class.getResourceAsStream(config));
    }
  }
1351307
@Override
  public boolean login() throws LoginException {
    Callback[] callbacks = new Callback[1];
    callbacks[0] = new NameCallback("user name: ");
    try {
      mCallbackHandler.handle(callbacks);
    } catch (IOException | UnsupportedCallbackException e) {
      throw new LoginException(e.getMessage());
    }

    String userName = ((NameCallback) callbacks[0]).getName();
    if (!userName.isEmpty()) {
      mUser = new User(userName);
      return true;
    }
    return false;
  }
362983
public Login login(String username, String password, String domain)
      throws Exception {
    // login is a two step process
    // first we get a token
    TokenResult token = prepareLogin(username);
    // and then with the token we login using the password
    Login login = login(token, username, password, domain);
    return login;
  }
1313459
void init() throws MpJwtProcessingException {
        String methodName = "init";
        if (tc.isDebugEnabled()) {
            Tr.entry(tc, methodName);
        }
        setUpJsseHelper();
        if (this.jsseHelper == null) {
            if (tc.isDebugEnabled()) {
                Tr.exit(tc, methodName);
            }
            return;
        }
        Properties sslProps = null;
        try {
            sslProps = getSslPropertiesFromJsseHelper();
        } catch (Exception e) {
            String msg = Tr.formatMessage(tc, "ERROR_LOADING_SSL_PROPS", new Object[] { e.getLocalizedMessage() });
            Tr.error(tc, msg);
            throw new MpJwtProcessingException(msg, e);
        }
        setKeystoreAndTruststoreNames(sslProps);
        if (tc.isDebugEnabled()) {
            Tr.exit(tc, methodName);
        }
    }
780048
public TokenResult prepareLogin(String username) throws Exception {
    username = encode(username);
    Api apiResult = null;
    TokenResult token = new TokenResult();
    token.tokenName = "lgtoken";
    token.tokenMode = TokenMode.token1_19;
    // see https://github.com/WolfgangFahl/Mediawiki-Japi/issues/31
    if (this.isVersion128()) {
      apiResult = this.getQueryResult("&meta=tokens&type=login");
      super.handleError(apiResult);
      token.token = apiResult.getQuery().getTokens().getLogintoken();
    } else {
      apiResult = getActionResult("login", "&lgname=" + username, null, null);
      super.handleError(apiResult);
      Login login = apiResult.getLogin();
      token.token = login.getToken();
    }
    return token;
  }
134631
public void configureDefaults() throws Exception
    {
        //cannot configure if the context is already started
        if (_context.isStarted())
        {
            if (log.isDebugEnabled()){log.debug("Cannot configure webapp after it is started");};
            return;
        }
        
        getWebApplicationContext().setWelcomeFiles(null);
        
        String defaultsDescriptor=getWebApplicationContext().getDefaultsDescriptor();
        if(defaultsDescriptor!=null&&defaultsDescriptor.length()>0)
        {
            Resource dftResource=Resource.newSystemResource(defaultsDescriptor);
            if(dftResource==null)
                dftResource=Resource.newResource(defaultsDescriptor);
            XmlParser.Node defaultConfig=xmlParser.parse(dftResource.getURL());
            initialize(defaultConfig);
        }
    }
1278093
protected void configureClassPath() throws Exception
    {
        //call each of the instances
        // first, configure the classpaths
        for (int i=0; i<_configurations.length;i++)
        {
            _configurations[i].setWebApplicationContext(this);
            _configurations[i].configureClassPath();
        }
    }
1246298
public void configureWebApp () throws Exception
    {
        //cannot configure if the _context is already started
        if (_context.isStarted())
        {
            if (log.isDebugEnabled()){log.debug("Cannot configure webapp after it is started");};
            return;
        }
        
        if(log.isDebugEnabled())
            log.debug("Configuring web-jetty.xml");
        
        Resource webInf=getWebApplicationContext().getWebInf();
        // handle any WEB-INF descriptors
        if(webInf!=null&&webInf.isDirectory())
        {
            // do jetty.xml file
            Resource jetty=webInf.addPath("web-jetty.xml");
            if(!jetty.exists())
                jetty=webInf.addPath("jetty-web.xml");
            if(!getWebApplicationContext().isIgnoreWebJetty()&&jetty.exists())
            {
                
                // Give permission to see Jetty classes
                String[] old_server_classes = _context.getServerClasses();
                String[] server_classes = new String[1+(old_server_classes==null?0:old_server_classes.length)];
                server_classes[0]="-org.browsermob.proxy.jetty.";
                if (server_classes!=null)
                    System.arraycopy(old_server_classes, 0, server_classes, 1, old_server_classes.length);
                
                try
                {
                    _context.setServerClasses(server_classes);
                    if(log.isDebugEnabled())
                        log.debug("Configure: "+jetty);
                    
                    XmlConfiguration jetty_config=new XmlConfiguration(jetty.getURL());
                    jetty_config.configure(getWebApplicationContext());
                }
                finally
                {
                    if (_context.getServerClasses()==server_classes)
                        _context.setServerClasses(old_server_classes);
                }
            }
        }
        
    }
919470
@Override
    public boolean login() throws LoginException {
        try{
            Object[] userPass= getCallBackAuth();
            if (null == userPass || userPass.length < 2) {
                setAuthenticated(false);
                throw new FailedLoginException();
            }
            String name = (String) userPass[0];
            Object pass = userPass[1];
            boolean authenticated = authenticate(name, pass);
            setAuthenticated(authenticated);

            if (!isAuthenticated()) {
                throw new FailedLoginException();
            }
            return isAuthenticated();
        } catch (UnsupportedCallbackException e) {
            throw new LoginException("Error obtaining callback information.");
        } catch (IOException e) {
            if (_debug) {
                e.printStackTrace();
            }
            throw new LoginException("IO Error performing login.");
        }
    }
572095
protected void configureEndpointAccessByFormLogin(final ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry requests) throws Exception {
        requests.and()
            .formLogin()
            .loginPage(ENDPOINT_URL_ADMIN_FORM_LOGIN)
            .permitAll();
    }
430613
@Override
  public boolean loginHandler(String target, HttpServletRequest request, HttpServletResponse response) throws IOException {
    if (! isLoginTarget(target)) {
      return false;
    }

    if (isPageRequest(request)) {
      sendLoginForm(request, response);
    } else {
      ServletUtils.sendResponseError(response, HttpServletResponse.SC_UNAUTHORIZED, "Access denied. Please login.");
    }
    return true;
  }
421872
public void init() throws Exception {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());

        if (!cfg.exists()) {

            ConfigurationManager manager = new ConfigurationManager(cfg, false, locateConfigurationProvider());

            try {

                manager.runProjectConfigurationInitializers();

                if (options.isVerbose()) {
                    log.info("CONFIGURATION FILE [" + cfg.getAbsolutePath() + "] CREATION COMPLETE");
                }

            } catch (IOException aux) {
                if (options.isVerbose()) {
                    log.error("The system can't create the file [ " + cfg.getAbsolutePath() + "]");
                }
                if (options.isThrowException()) {
                    System.setProperty("user.dir", userDir);
                    throw aux;
                }
            }

        } else {
            if (options.isVerbose()) {
                log.error("The configuration file [" + cfg.getAbsolutePath() + "] already exists");
            }
        }
        System.setProperty("user.dir", userDir);
    }