예제 #1
0
        /// <summary>
        /// Perform Login operation asynchronously
        /// </summary>
        /// <param name="mediaType">MediaType, enumeration defining the media type of the http operation</param>
        /// <param name="username">string, containing the username</param>
        /// <param name="password">string, containing the password</param>
        /// <returns>string, containing the complete text of the HTTP response/returns>
        public async Task <string> LoginAsync(string username, string password, string twoFactorPassword, bool enableValidation)
        {
            string responseText = await this.SECURE_API_Async(
                Properties.Resources.MediaType_XML,
                HTTP.PUT,
                new string[] { "Authentication", "Login" },
                null,
                new StringContent(
                    TestController.SerializeXML(new AuthenticationDetail()
            {
                UserName = username,
                Password = password,
                TwoFactorPassword = twoFactorPassword
            })));

            if (this.Last_HTTPstatus == (int)HttpStatusCode.OK ||
                this.Last_HTTPstatus == (int)HttpStatusCode.Accepted)
            {
                this.Session = TestController.DeserializeXML <SessionDetail>(responseText, enableValidation);
            }
            return(responseText);
        }
예제 #2
0
 /// <summary>
 /// Serialize the XSD generated SECURE code to XML in string format.
 /// </summary>
 /// <param name="o">The System.Object to serialize.</param>
 /// <returns>a UTF-8 encoded XML string</returns>
 public static string SerializeXML(object o)
 {
     return(TestController.SerializeXML(o, true));
 }