code:     protected synchronized void authenticatorConfig() {
  
          // Always need an authenticator to support @ServletSecurity annotations
          LoginConfig loginConfig = context.getLoginConfig();
          if (loginConfig == null) {
              loginConfig = DUMMY_LOGIN_CONFIG;
              context.setLoginConfig(loginConfig);
          }
  
          // Has an authenticator been configured already?
          if (context.getAuthenticator() != null)
              return;
          
          if (!(context instanceof ContainerBase)) {
              return;     // Cannot install a Valve even if it would be needed
          }
  
          // Has a Realm been configured for us to authenticate against?
          if (context.getRealm() == null) {
              log.error(sm.getString("contextConfig.missingRealm"));
              ok = false;
              return;
          }
  
          /*
           * First check to see if there is a custom mapping for the login
           * method. If so, use it. Otherwise, check if there is a mapping in
           * org/apache/catalina/startup/Authenticators.properties.
           */
          Valve authenticator = null;
          if (customAuthenticators != null) {
              authenticator = (Valve)
                  customAuthenticators.get(loginConfig.getAuthMethod());
          }
          if (authenticator == null) {
              // Load our mapping properties if necessary
              if (authenticators == null) {
                  try {
                      InputStream is=this.getClass().getClassLoader().getResourceAsStream("org/apache/catalina/startup/Authenticators.properties");
                      if( is!=null ) {
                          authenticators = new Properties();
                          authenticators.load(is);
                      } else {
                          log.error(sm.getString(
                                  "contextConfig.authenticatorResources"));
                          ok=false;
                          return;
                      }
                  } catch (IOException e) {
                      log.error(sm.getString(
                                  "contextConfig.authenticatorResources"), e);
                      ok = false;
                      return;
                  }
              }
  
              // Identify the class name of the Valve we should configure
              String authenticatorName = null;
              authenticatorName =
                      authenticators.getProperty(loginConfig.getAuthMethod());
              if (authenticatorName == null) {
                  log.error(sm.getString("contextConfig.authenticatorMissing",
                                   loginConfig.getAuthMethod()));
                  ok = false;
                  return;
              }
  
              // Instantiate and install an Authenticator of the requested class
              try {
                  Class<?> authenticatorClass = Class.forName(authenticatorName);
                  authenticator = (Valve) authenticatorClass.newInstance();
              } catch (Throwable t) {
                  ExceptionUtils.handleThrowable(t);
                  log.error(sm.getString(
                                      "contextConfig.authenticatorInstantiate",
                                      authenticatorName),
                            t);
                  ok = false;
              }
          }
  
          if (authenticator != null && context instanceof ContainerBase) {
              Pipeline pipeline = ((ContainerBase) context).getPipeline();
              if (pipeline != null) {
                  ((ContainerBase) context).getPipeline().addValve(authenticator);
                  if (log.isDebugEnabled()) {
                      log.debug(sm.getString(
                                      "contextConfig.authenticatorConfigured",
                                      loginConfig.getAuthMethod()));
                  }
              }
          }
  
      }
  
  
      /**
       * Create (if necessary) and return a Digester configured to process the
       * web application deployment descriptor (web.xml).
       */
  