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); }
private async Task <UserAssertion> FetchAssertionFromWsTrustAsync() { if (AuthenticationRequestParameters.Authority.AuthorityType == Instance.AuthorityType.Adfs) { return(null); } var userRealmResponse = await _commonNonInteractiveHandler .QueryUserRealmDataAsync(AuthenticationRequestParameters.Authority.UserRealmUriPrefix) .ConfigureAwait(false); if (userRealmResponse.IsFederated) { var wsTrustResponse = await _commonNonInteractiveHandler.PerformWsTrustMexExchangeAsync( userRealmResponse.FederationMetadataUrl, userRealmResponse.CloudAudienceUrn, UserAuthType.UsernamePassword).ConfigureAwait(false); // We assume that if the response token type is not SAML 1.1, it is SAML 2 return(new UserAssertion( wsTrustResponse.Token, wsTrustResponse.TokenType == WsTrustResponse.Saml1Assertion ? OAuth2GrantType.Saml11Bearer : OAuth2GrantType.Saml20Bearer)); } if (userRealmResponse.IsManaged) { // handle grant flow if (!_usernamePasswordInput.HasPassword()) { throw new MsalClientException(MsalError.PasswordRequiredForManagedUserError); } return(null); } throw new MsalClientException( MsalError.UnknownUserType, string.Format( CultureInfo.CurrentCulture, MsalErrorMessage.UnsupportedUserType, userRealmResponse.AccountType)); }