/// <summary>Checks possibility to open list data with provided settings. </summary>
 /// <param name="serverSettings">The server settings.</param>
 /// <exception cref="ArgumentNullException">If <paramref name="serverSettings"/> is null. </exception>
 /// <exception cref="ITHit.WebDAV.Client.Exceptions.UnauthorizedException">Incorrect credentials provided or insufficient permissions to access the requested item.</exception>
 /// <exception cref="ITHit.WebDAV.Client.Exceptions.NotFoundException">The requested folder doesn't exist on the server.</exception>
 /// <exception cref="ITHit.WebDAV.Client.Exceptions.ForbiddenException">The server refused to fulfill the request.</exception>
 /// <exception cref="ITHit.WebDAV.Client.Exceptions.WebDavException">Unexpected error occurred.</exception>
 /// <returns>The <see cref="Task"/>.</returns>
 public static async Task CheckConnectionAsync(ServerSettings serverSettings)
 {
     if (serverSettings == null)
     {
         throw new ArgumentNullException(nameof(serverSettings));
     }
     WebDavSessionAsync session = Create(serverSettings);
     await session.OpenItemAsync(serverSettings.ServerUri).ConfigureAwait(false);
 }
        /// <summary>
        /// Creates instance of this class.
        /// </summary>
        /// <param name="url">URL to navigate to. This URL must redirect to a log-in page.</param>
        public WebBrowserLogin(Uri url, IWebRequestAsync request, WebDavSessionAsync davClient, ILog log)
        {
            this.url       = url;
            this.request   = request;
            this.davClient = davClient;
            this.log       = log;
            InitializeComponent();

            this.webView = new Microsoft.Web.WebView2.Wpf.WebView2();
            this.Loaded += WebBrowserLogin_Load;
            this.panel.Children.Add(this.webView);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates and configures WebDAV client to access the remote storage;
        /// </summary>
        private static void ConfigureWebDAVClient()
        {
            DavClient = new WebDavSessionAsync(Program.Settings.WebDAVClientLicense);

            // Set authentication credentials if needed. Supports Basic, Digest, NTLM, Kerberos.
            // DavClient.Credentials = new System.Net.NetworkCredential("User1", "pwd");

            // Disable automatic redirect processing so we can process the
            // 302 login redirect inside the error event handler.
            DavClient.AllowAutoRedirect = false;
            DavClient.WebDavError      += DavClient_WebDavError;

            ITHit.WebDAV.Client.Logger.FileLogger.LogFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), "WebDAVLog.txt");
            ITHit.WebDAV.Client.Logger.FileLogger.Level   = ITHit.WebDAV.Client.Logger.LogLevel.All;
        }
        /// <summary>Creates and configure session. </summary>
        /// <param name="serverSettings">The server settings.</param>
        /// <returns>The configured <see cref="ITHit.WebDAV.Client.WebDavSessionAsync"/>.</returns>
        /// <exception cref="ArgumentNullException"> If <paramref name="serverSettings"/> is null. </exception>
        /// <exception cref="ITHit.WebDAV.Client.Exceptions.InvalidLicenseException"> The license is invalid. </exception>
        public static WebDavSessionAsync Create(ServerSettings serverSettings)
        {
            if (serverSettings == null)
            {
                throw new ArgumentNullException(nameof(serverSettings));
            }
#if !DEBUG
            FileLogger.Level = LogLevel.Off;
#endif

            // Disables ssl certificate validity check.
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
            var session = new WebDavSessionAsync(LicenseContent);
            if (serverSettings.HasCredential)
            {
                session.Credentials = new NetworkCredential(serverSettings.UserName, serverSettings.Password);
            }

            return(session);
        }
 /// <summary>Initializes a new instance of the <see cref="StorageManager"/> class.</summary>
 /// <param name="locationMapper">The location mapper.</param>
 /// <param name="session">The session.</param>
 /// <param name="localStorage">The local storage.</param>
 public StorageManager(LocationMapper locationMapper, WebDavSessionAsync session, LocalStorage localStorage)
 {
     this.LocationMapper = locationMapper;
     this.session        = session;
     this.LocalStorage   = localStorage;
 }