public override async ValueTask <SecurityTokenValidationResult> ValidateTokenAsync(XmlReader securityToken, TokenValidationParameters validationParameters) { if (!CanValidateToken) { return(null); } var token = ReadUsernameToken(securityToken); try { var user = await _validator.ValidatePasswordAsync(token.UserName, token.Password); if (user == null) { throw new SecurityException("Could not validate userName and/or password."); } return(new SecurityTokenValidationResult { Token = token, User = user, Success = true }); } catch (Exception ex) { return(new SecurityTokenValidationResult { Error = ex }); } }