예제 #1
0
        /// <summary>
        /// Builds the HTTP Challenge Validator. It will also initialise them.
        /// </summary>
        /// <param name="standalone">true if we use the built-in webserver, false otherwise</param>
        /// <param name="webRoot">the full path to the web server root, when not using built-in</param>
        /// <returns>the HTTP challenge Validator</returns>
        public static IHTTPChallengeValidator GetHTTPChallengeValidator(bool standalone, int httpPort, string webRoot = null)
        {
            IHTTPChallengeValidator challengeValidator = null;

            if (standalone)
            {
                if (!CheckAvailableServerPort(httpPort))
                {
                    Program._logger.Warn("HTTP Standalone activation selected, but port {0} was not available. No HTTP session established", httpPort);
                    return(null);
                }
                challengeValidator = new HTTPChallengeWebServerValidator(httpPort);
                if (challengeValidator != null)
                {
                    Program._logger.Info("HTTP Challenge WebServer Validator established, listening on Port({0})", httpPort);
                }
            }
            else if (webRoot != null)
            {
                challengeValidator = new HTTPChallengeFileValidator(webRoot);
                if (challengeValidator != null)
                {
                    Program._logger.Info("HTTP Challenge File Validator established");
                }
            }
            else
            {
                Program._logger.Warn("HTTP Web Server Root path was not specified");
            }
            return(challengeValidator);
        }
        /// <summary>
        /// Builds the HTTP Challenge Validator. It will also initialise them.
        /// </summary>
        /// <param name="standalone">true if we use the built-in webserver, false otherwise</param>
        /// <param name="webRoot">the full path to the web server root, when not using built-in</param>
        /// <returns>the HTTP challenge Validator</returns>
        public static IHTTPChallengeValidator GetHTTPChallengeValidator(bool standalone, int httpPort, string webRoot = null)
        {
            IHTTPChallengeValidator challengeValidator = null;

            if (standalone)
            {
                if (!CheckAvailableServerPort(httpPort))
                {
                    return(null);
                }
                challengeValidator = new HTTPChallengeWebServerValidator(httpPort);
            }
            else if (webRoot != null)
            {
                challengeValidator = new HTTPChallengeFileValidator(webRoot);
            }
            return(challengeValidator);
        }