Example #1
0
        /// <summary>
        /// Download EncryptedEmail Message
        /// </summary>
        /// <param name="url"></param>
        /// <param name="aliasId"></param>
        /// <param name="redirect"></param>
        /// <returns>
        /// File if redirect=true, DownloadSpecification object otherwise
        /// </returns>
        public IQuery <System.IO.Stream> Message(Uri url, string aliasId = null, bool redirect = true)
        {
            var sfApiQuery = new ShareFile.Api.Client.Requests.Query <System.IO.Stream>(Client);

            sfApiQuery.Action("Message");
            sfApiQuery.Uri(url);
            sfApiQuery.QueryString("aliasId", aliasId);
            sfApiQuery.QueryString("redirect", redirect);
            sfApiQuery.HttpMethod = "GET";
            return(sfApiQuery);
        }
Example #2
0
        /// <summary>
        /// Shows preview of the folder user email
        /// </summary>
        /// <param name="folderUrl"></param>
        /// <param name="notifyUsersParams"></param>
        public IQuery <System.IO.Stream> NotifyUsersPreview(Uri folderUrl, NotifyUsersParams notifyUsersParams)
        {
            var sfApiQuery = new ShareFile.Api.Client.Requests.Query <System.IO.Stream>(Client);

            sfApiQuery.Action("AccessControls");
            sfApiQuery.Uri(folderUrl);
            sfApiQuery.SubAction("NotifyUsersPreview");
            sfApiQuery.Body       = notifyUsersParams;
            sfApiQuery.HttpMethod = "POST";
            return(sfApiQuery);
        }
        /// <summary>
        /// Callback method for Redirection events received by the ShareFile Client SDK
        /// </summary>
        /// <param name="requestMessage"></param>
        /// <param name="redirection"></param>
        /// <returns></returns>
        private EventHandlerResponse OnDomainChange(HttpRequestMessage requestMessage, Redirection redirection)
        {
            // Check if we already have a session on the target
            bool hasSession = true;

            if (redirection.SessionCheck)
            {
                hasSession = false;
                try
                {
                    var query = new ShareFile.Api.Client.Requests.Query <Session>(Client);
                    query.Uri(new Uri(redirection.SessionUri.ToString() + "?root=" + redirection.Root));
                    var session = query.Execute();
                    hasSession = true;
                }
                catch (Exception)
                { }
            }
            // If we're not authenticated, we have to authenticate now using Forms
            if (!hasSession && redirection.FormsUri != null)
            {
                var authDomain = new AuthenticationDomain()
                {
                    Uri = redirection.SessionUri.ToString()
                };
                authDomain = this.AuthenticateForms(authDomain,
                                                    new Uri(string.Format("{0}?root={1}&redirect_url={2}", redirection.FormsUri, redirection.Root, Uri.EscapeUriString(Resources.RedirectURL))),
                                                    redirection.TokenUri,
                                                    redirection.Root);
                if (authDomain.OAuthToken == null)
                {
                    return(new EventHandlerResponse()
                    {
                        Action = EventHandlerResponseAction.Throw
                    });
                }
            }
            return(new EventHandlerResponse()
            {
                Action = EventHandlerResponseAction.Redirect, Redirection = redirection
            });
        }
 /// <summary>
 /// Callback method for Redirection events received by the ShareFile Client SDK
 /// </summary>
 /// <param name="requestMessage"></param>
 /// <param name="redirection"></param>
 /// <returns></returns>
 private EventHandlerResponse OnDomainChange(HttpRequestMessage requestMessage, Redirection redirection)
 {
     // Check if we already have a session on the target 
     bool hasSession = true;
     if (redirection.SessionCheck)
     {
         hasSession = false;
         try
         {
             var query = new ShareFile.Api.Client.Requests.Query<Session>(Client);
             query.Uri(new Uri(redirection.SessionUri.ToString() + "?root=" + redirection.Root));
             var session = query.Execute();
             hasSession = true;
         }
         catch (Exception)
         { }
     }
     // If we're not authenticated, we have to authenticate now using Forms
     if (!hasSession && redirection.FormsUri != null)
     {
         var authDomain = new AuthenticationDomain() { Uri = redirection.SessionUri.ToString() };
         authDomain = this.AuthenticateForms(authDomain,
             new Uri(string.Format("{0}?root={1}&redirect_url={2}", redirection.FormsUri, redirection.Root, Uri.EscapeUriString(Resources.RedirectURL))),
             redirection.TokenUri,
             redirection.Root);
         if (authDomain.OAuthToken == null)
         {
             return new EventHandlerResponse() { Action = EventHandlerResponseAction.Throw };
         }
     }
     return new EventHandlerResponse() { Action = EventHandlerResponseAction.Redirect, Redirection = redirection };
 }