Example #1
0
        /// <summary>
        /// Get the authenticator object for the authenticator name.
        /// </summary>
        /// <param name="authenticatorName">A string containing the name of the desired authenticator.</param>
        /// <returns>Returns the requested authenticator if it is found, and null otherwise.</returns>
        public static Authenticator GetAuthenticator(string authenticatorName)
        {
            const string methodName = "GetAuthenticator()";
            const string bwsApiName = "bwsUtilService.getAuthenticators()";

            logMessage("Entering {0}", methodName);
            Authenticator returnValue = null;

            GetAuthenticatorsRequest request = new GetAuthenticatorsRequest();

            request.metadata = Metadata;

            GetAuthenticatorsResponse response = null;

            try
            {
                logRequest(bwsApiName);
                response = bwsUtilService.getAuthenticators(request);
                logResponse(bwsApiName, response.returnStatus.code, response.metadata);
            }
            catch (WebException e)
            {
                // Log and re-throw exception.
                logMessage("Exiting {0} with exception \"{1}\"", methodName, e.Message);
                throw e;
            }

            if (response.returnStatus.code.Equals("SUCCESS"))
            {
                if (response.authenticators != null && response.authenticators.Length > 0)
                {
                    foreach (Authenticator authenticator in response.authenticators)
                    {
                        if (authenticator.name.Equals(authenticatorName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            returnValue = authenticator;
                            break;
                        }
                    }

                    if (returnValue == null)
                    {
                        logMessage("Could not find \"{0}\" in GetAuthenticatorsResponse",
                                   authenticatorName);
                    }
                }
                else
                {
                    logMessage("No authenticators in GetAuthenticatorsResponse");
                }
            }
            else
            {
                logMessage("Error Message: \"{0}\"", response.returnStatus.message);
            }

            logMessage("Exiting {0} with {1}", methodName, returnValue == null ? "\"null\"" :
                       "Authenticator object (Name \"" + returnValue.name + "\")");
            return(returnValue);
        }
        /// <summary>
        /// Get the authenticator object for the authenticator name.
        /// </summary>
        /// <param name="authenticatorName">A string containing the name of the desired authenticator.</param>
        /// <returns>Returns the requested authenticator if it is found, and null otherwise.</returns>
        public static Authenticator GetAuthenticator(string authenticatorName)
        {
            const string methodName = "GetAuthenticator()";
            const string bwsApiName = "bwsUtilService.getAuthenticators()";
            logMessage("Entering {0}", methodName);
            Authenticator returnValue = null;

            GetAuthenticatorsRequest request = new GetAuthenticatorsRequest();
            request.metadata = Metadata;

            GetAuthenticatorsResponse response = null;

            try
            {
                logRequest(bwsApiName);
                response = bwsUtilService.getAuthenticators(request);
                logResponse(bwsApiName, response.returnStatus.code, response.metadata);
            }
            catch (WebException e)
            {
                // Log and re-throw exception.
                logMessage("Exiting {0} with exception \"{1}\"", methodName, e.Message);
                throw e;
            }

            if (response.returnStatus.code.Equals("SUCCESS"))
            {
                if (response.authenticators != null && response.authenticators.Length > 0)
                {
                    foreach (Authenticator authenticator in response.authenticators)
                    {
                        if (authenticator.name.Equals(authenticatorName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            returnValue = authenticator;
                            break;
                        }
                    }

                    if (returnValue == null)
                    {
                        logMessage("Could not find \"{0}\" in GetAuthenticatorsResponse",
                            authenticatorName);
                    }
                }
                else
                {
                    logMessage("No authenticators in GetAuthenticatorsResponse");
                }
            }
            else
            {
                logMessage("Error Message: \"{0}\"", response.returnStatus.message);
            }

            logMessage("Exiting {0} with {1}", methodName, returnValue == null ? "\"null\"" :
                "Authenticator object (Name \"" + returnValue.name + "\")");
            return returnValue;
        }
        /// <summary>
        /// Get the authenticator object for the authenticator name.
        /// </summary>
        /// <param name="authenticatorName">A string containing the name of the desired authenticator.</param>
        /// <returns>Returns the requested authenticator if it is found, and null otherwise.</returns>
        public static Authenticator GetAuthenticator(string authenticatorName)
        {
            const string methodName = "GetAuthenticator()";
            const string bwsApiName = "bwsUtilService.getAuthenticators()";
            Console.Error.WriteLine("Entering {0}", methodName);
            Authenticator returnValue = null;

            GetAuthenticatorsRequest request = new GetAuthenticatorsRequest();
            request.metadata = Metadata;

            Console.Error.WriteLine("Calling {0}...", bwsApiName);
            GetAuthenticatorsResponse response = bwsUtilService.getAuthenticators(request);
            Console.Error.WriteLine("...{0} returned \"{1}\"", bwsApiName, response.returnStatus.code);

            if (response.returnStatus.code.Equals("SUCCESS"))
            {
                if (response.authenticators != null && response.authenticators.Length > 0)
                {
                    foreach (Authenticator authenticator in response.authenticators)
                    {
                        if (authenticator.name.Equals(authenticatorName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            returnValue = authenticator;
                            break;
                        }
                    }

                    if (returnValue == null)
                    {
                        Console.Error.WriteLine("Could not find \"{0}\" in GetAuthenticatorsResponse",
                            authenticatorName);
                    }
                }
                else
                {
                    Console.Error.WriteLine("No authenticators in GetAuthenticatorsResponse");
                }
            }
            else
            {
                Console.Error.WriteLine("Error: Code: \"{0}\", Message: \"{1}\"", response.returnStatus.code,
                    response.returnStatus.message);
            }

            Console.Error.WriteLine("Exiting {0} with {1}", methodName, returnValue == null ? "\"null\"" :
                "Authenticator object (Name \"" + returnValue.name + "\")");
            return returnValue;
        }