private Dictionary <string, string> GetAdditionalBodyParameters(UserAssertion userAssertion) { var dict = new Dictionary <string, string>(); if (userAssertion != null) { dict[OAuth2Parameter.GrantType] = userAssertion.AssertionType; dict[OAuth2Parameter.Assertion] = Convert.ToBase64String(Encoding.UTF8.GetBytes(userAssertion.Assertion)); } // This is hit if the account is managed, as no userAssertion is created for a managed account else { dict[OAuth2Parameter.GrantType] = OAuth2GrantType.Password; dict[OAuth2Parameter.Username] = _usernamePasswordInput.UserName; dict[OAuth2Parameter.Password] = new string(_usernamePasswordInput.PasswordToCharArray()); } ISet <string> unionScope = new HashSet <string>() { OAuth2Value.ScopeOpenId, OAuth2Value.ScopeOfflineAccess, OAuth2Value.ScopeProfile }; unionScope.UnionWith(AuthenticationRequestParameters.Scope); dict[OAuth2Parameter.Scope] = unionScope.AsSingleString(); return(dict); }
public void PlainTextPassword() { // Arrange UsernamePasswordInput input = new UsernamePasswordInput("user", "plain_text_password"); // Act char[] charPassword = input.PasswordToCharArray(); // Assert Assert.IsTrue(input.HasPassword()); CollectionAssert.AreEqual("plain_text_password".ToCharArray(), charPassword); }
public void SecureStringPassword() { // Arrange SecureString secureString = new SecureString(); "secure_string_password".ToCharArray().ToList().ForEach(c => secureString.AppendChar(c)); UsernamePasswordInput input = new UsernamePasswordInput("user", secureString); // Act char[] charPassword = input.PasswordToCharArray(); // Assert Assert.IsTrue(input.HasPassword()); CollectionAssert.AreEqual("secure_string_password".ToCharArray(), charPassword); }