Esempio n. 1
0
 public DeviceRequest(string appId, IPlatformUtilsService platformUtilsService)
 {
     Type       = platformUtilsService.GetDevice();
     Name       = platformUtilsService.GetDeviceString();
     Identifier = appId;
     PushToken  = null; // TODO?
 }
Esempio n. 2
0
        public ApiService(
            ITokenService tokenService,
            IPlatformUtilsService platformUtilsService,
            Func <bool, Task> logoutCallbackAsync,
            string customUserAgent = null,
            bool?ignoreCertErrors  = null)
        {
            _tokenService         = tokenService;
            _platformUtilsService = platformUtilsService;
            _logoutCallbackAsync  = logoutCallbackAsync;
            var device = (int)_platformUtilsService.GetDevice();

            if (ignoreCertErrors ?? GlobalIgnoreCertErrors)
            {
                _httpClientHandler = new HttpClientHandler
                {
                    ServerCertificateCustomValidationCallback = (mg, ct, ch, er) => true,
                    //SslProtocols =
                    //    System.Security.Authentication.SslProtocols.Tls |
                    //    System.Security.Authentication.SslProtocols.Tls11 |
                    //    System.Security.Authentication.SslProtocols.Tls12,
                };
                _httpClient = new HttpClient(_httpClientHandler);
            }
            else
            {
                _httpClient = new HttpClient();
            }

            _httpClient.DefaultRequestHeaders.Add("Device-Type", device.ToString());
            if (!string.IsNullOrWhiteSpace(customUserAgent))
            {
                _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(customUserAgent);
            }
        }
Esempio n. 3
0
        public ApiService(
            ITokenService tokenService,
            IPlatformUtilsService platformUtilsService,
            Func <bool, Task> logoutCallbackAsync)
        {
            _tokenService         = tokenService;
            _platformUtilsService = platformUtilsService;
            _logoutCallbackAsync  = logoutCallbackAsync;
            var device = _platformUtilsService.GetDevice();

            _deviceType = device.ToString();
        }
Esempio n. 4
0
        public ApiService(
            ITokenService tokenService,
            IPlatformUtilsService platformUtilsService,
            Func <bool, Task> logoutCallbackAsync,
            string customUserAgent = null)
        {
            _tokenService         = tokenService;
            _platformUtilsService = platformUtilsService;
            _logoutCallbackAsync  = logoutCallbackAsync;
            var device = (int)_platformUtilsService.GetDevice();

            _httpClient.DefaultRequestHeaders.Add("Device-Type", device.ToString());
            if (!string.IsNullOrWhiteSpace(customUserAgent))
            {
                _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(customUserAgent);
            }
        }
Esempio n. 5
0
        public ApiService(
            ITokenService tokenService,
            IPlatformUtilsService platformUtilsService,
            Func <Tuple <string, bool, bool>, Task> logoutCallbackAsync,
            string customUserAgent = null)
        {
            _tokenService         = tokenService;
            _platformUtilsService = platformUtilsService;
            _logoutCallbackAsync  = logoutCallbackAsync;
            var device = (int)_platformUtilsService.GetDevice();

            _httpClient.DefaultRequestHeaders.Add("Device-Type", device.ToString());
            _httpClient.DefaultRequestHeaders.Add("Bitwarden-Client-Name", _platformUtilsService.GetClientType().GetString());
            _httpClient.DefaultRequestHeaders.Add("Bitwarden-Client-Version", _platformUtilsService.GetApplicationVersion());
            if (!string.IsNullOrWhiteSpace(customUserAgent))
            {
                _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(customUserAgent);
            }
        }
Esempio n. 6
0
        public ApiService(
            ITokenService tokenService,
            IPlatformUtilsService platformUtilsService,
            Func <bool, Task> logoutCallbackAsync,
            HttpMessageHandler httpMessageHandler = null)
        {
            _tokenService         = tokenService;
            _platformUtilsService = platformUtilsService;
            _logoutCallbackAsync  = logoutCallbackAsync;
            var device = _platformUtilsService.GetDevice();

            _deviceType = device.ToString();
            if (httpMessageHandler != null)
            {
                _httpClient = new HttpClient(httpMessageHandler);
            }
            else
            {
                _httpClient = new HttpClient();
            }
        }
Esempio n. 7
0
 public DeviceRequest(string appId, IPlatformUtilsService platformUtilsService)
 {
     Type       = platformUtilsService.GetDevice();
     Name       = platformUtilsService.GetDeviceString();
     Identifier = appId;
 }