public byte[] CallApiOther(string component, string operationType, string operationName, Dictionary <string, string> parameters) { Uri requestUrl = PrepareZapRequest(this.otherFormat, component, operationType, operationName, parameters); byte[] response = webClient.DownloadData(requestUrl); return(response); }
internal static string Get(string url, string token, IWebClient webClient) { // Set headers webClient.Headers[HttpRequestHeader.Authorization] = string.Format("Zoho-authtoken {0}", token); webClient.Headers[HttpRequestHeader.UserAgent] = "ZohoVault/2.5.1 (Android 4.4.4; LGE/Nexus 5/19/2.5.1"; webClient.Headers["requestFrom"] = "vaultmobilenative"; try { // GET return(webClient.DownloadData(url).ToUtf8()); } catch (WebException e) { throw MakeNetworkError(e); } }
public void SetFacets_SameAvatar_ShouldReturnFalse(IWebClient webClient, Contact xdbContact, IXdbContext xdbContext, string url, string mimeType, byte[] picture) { // Arrange var userProfile = Substitute.For <Sitecore.Security.UserProfile>(); userProfile[Accounts.Constants.UserProfile.Fields.PictureUrl] = url; userProfile[Accounts.Constants.UserProfile.Fields.PictureMimeType] = mimeType; Sitecore.XConnect.Serialization.DeserializationHelpers.SetFacet(xdbContact, Avatar.DefaultFacetKey, new Avatar(mimeType, picture)); webClient.DownloadData(url).Returns(picture); var facetUpdater = new AvatarFacetUpdater(webClient); // Act var changed = facetUpdater.SetFacets(userProfile, xdbContact, xdbContext); // Assert changed.Should().BeFalse(); xdbContext.DidNotReceiveWithAnyArgs().RegisterOperation(Arg.Any <IXdbOperation>()); }
public static void Logout(Session session, IWebClient webClient) { webClient.Headers.Add(HttpRequestHeader.Cookie, string.Format("_pwdbox_session={0}", session.Id)); try { var response = webClient.DownloadData("https://api0.passwordbox.com/api/0/api_logout.json"); var parsedResponse = ParseLogoutResponseJson(response.ToUtf8()); if (parsedResponse.Message != "Good bye") { throw new LogoutException(LogoutException.FailureReason.InvalidResponse, "Logout failed"); } } catch (WebException e) { throw new LogoutException(LogoutException.FailureReason.Unknown, "Logout failed", e); } }
public void SetFacets_NoAvatar_ShouldSetFacet(IWebClient webClient, Contact xdbContact, IXdbContext xdbContext, string url, string mimeType, byte[] picture) { // Arrange var userProfile = Substitute.For <Sitecore.Security.UserProfile>(); userProfile[Accounts.Constants.UserProfile.Fields.PictureUrl] = url; userProfile[Accounts.Constants.UserProfile.Fields.PictureMimeType] = mimeType; webClient.DownloadData(url).Returns(picture); var facetUpdater = new AvatarFacetUpdater(webClient); // Act var changed = facetUpdater.SetFacets(userProfile, xdbContact, xdbContext); // Assert changed.Should().BeTrue(); xdbContext.Received(1).RegisterOperation(Arg.Is <SetFacetOperation>(x => x.FacetReference.FacetKey == Avatar.DefaultFacetKey && ((Avatar)x.Facet).Picture == picture && ((Avatar)x.Facet).MimeType == mimeType)); }
public static Account[] Fetch(Session session, IWebClient webClient) { // TODO: Figure out url-escaping. It seems the cookie already comes escaped. webClient.Headers.Add(HttpRequestHeader.Cookie, string.Format("_pwdbox_session={0}", session.Id)); try { var response = webClient.DownloadData("https://api0.passwordbox.com/api/0/assets"); var encryptedAccounts = ParseFetchResponseJson(response.ToUtf8()); return(DecryptAccounts(encryptedAccounts, session.Key)); } catch (WebException e) { throw new FetchException(FetchException.FailureReason.Network, "Network error", e); } catch (SerializationException e) { throw new FetchException(FetchException.FailureReason.InvalidResponse, "Invalid response, failed to parse JSON", e); } }
public static Blob Fetch(Session session, IWebClient webClient) { webClient.Headers.Add("Cookie", string.Format("PHPSESSID={0}", Uri.EscapeDataString(session.Id))); byte[] response; try { response = webClient.DownloadData("https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=android"); } catch (WebException e) { throw new FetchException(FetchException.FailureReason.WebException, "WebException occured", e); } try { return new Blob(response.ToUtf8().Decode64(), session.KeyIterationCount); } catch (FormatException e) { throw new FetchException(FetchException.FailureReason.InvalidResponse, "Invalid base64 in response", e); } }
private byte[] GetUpdateScriptsFromRemote(VersionInfo versionInfo) { if (versionInfo.Resolved.IsNullOrEmpty()) { return(null); } string packageUrl = $"{availableSource}/{versionInfo.Resolved}"; _logger.LogInformation("Getting update scripts for version {0} from {1}", versionInfo.Version, packageUrl); byte[] packageByte = _webClient.DownloadData(packageUrl); try { string file = Path.Combine(PluginBase.GetPath <UpdaterPlug>(), "DbScripts", $"package.{versionInfo.Version}.zip"); File.WriteAllBytes(file, packageByte); } catch (Exception ex) { _logger.LogError(ex, ex.Message); } return(packageByte); }
public static Blob Fetch(Session session, IWebClient webClient) { webClient.Headers.Add("Cookie", string.Format("PHPSESSID={0}", Uri.EscapeDataString(session.Id))); byte[] response; try { response = webClient.DownloadData("https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=android"); } catch (WebException e) { throw new FetchException(FetchException.FailureReason.WebException, "WebException occured", e); } try { return(new Blob(response.ToUtf8().Decode64(), session.KeyIterationCount)); } catch (FormatException e) { throw new FetchException(FetchException.FailureReason.InvalidResponse, "Invalid base64 in response", e); } }
public static Blob Fetch(Session session, IWebClient webClient) { byte[] response; try { SetSessionCookies(webClient, session); response = webClient.DownloadData(GetFetchUrl(session.Platform)); } catch (WebException e) { throw new FetchException(FetchException.FailureReason.WebException, "WebException occurred", e); } try { return(new Blob(response.ToUtf8().Decode64(), session.KeyIterationCount, session.EncryptedPrivateKey)); } catch (FormatException e) { throw new FetchException(FetchException.FailureReason.InvalidResponse, "Invalid base64 in response", e); } }
public virtual Stream GetFileStream() { var data = _webClient.DownloadData(new Uri(_appServiceSettings.VstsAssessmentOrgsUrl), _appServiceSettings.GitAccessToken); return(new MemoryStream(data)); }