Example #1
0
        public ProfileViewModel(IJsonServiceClient serviceClient)
        {
            _serviceClient = serviceClient;

            //Показать/скрыть панель профиля
            OpenProfilePanelCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var user = Locator.Current.GetService <ICurrentUser>();
                await Open(user?.Id);
            });

            //Сохранить изменения Name профиля
            ApplyProfileNameCommand = ReactiveCommand.CreateFromTask(SetProfile);

            //Сохранить изменения AboutMe профиля
            ApplyProfileAboutMeCommand = ReactiveCommand.CreateFromTask(SetProfile);

            //Скрытие окна
            LayoutUpdatedWindow = ReactiveCommand.Create <object>(obj =>
            {
                if (obj is IHaveWidth window)
                {
                    ProfileViewModel.WindowWidth = window.Width;
                    IsShowChat = !IsOpened || window.Width > 650;
                }
            });

            //Показать/скрыть редактирование профиля
            SetEditNameProfileCommand    = ReactiveCommand.Create(() => ResetEditMode(UserProfileEditMode.DisplayName));
            SetEditAboutMeProfileCommand = ReactiveCommand.Create(() => ResetEditMode(UserProfileEditMode.AboutMe));

            //Показать/скрыть ContextMenu
            ContextMenuProfile = ReactiveCommand.Create <object>(obj => { IsActiveContextMenu = !IsActiveContextMenu; });
        }
 /// <summary>
 /// create a JSON clientrequest object
 /// post the request
 /// and parse the result
 /// </summary>
 /// <param name="url">basic url of rest service</param>
 /// <param name="request">specific request parameter of the API</param>
 public cJSON(string url, string request)
 {
     this._url     = url;
     this._request = request;
     client        = new JsonServiceClient(url);
     this._rss     = JObject.Parse(client.Get <String>(this._request));
 }
 public EncryptedServiceClient(IJsonServiceClient client, RSAParameters publicKey)
 {
     Client = client;
     Client.ClearCookies();
     PublicKey          = publicKey;
     ServerPublicKeyXml = publicKey.ToPublicKeyXml();
 }
Example #4
0
        private static async Task AssertDoesGetAccessTokenUsingRefreshTokenCookie(IJsonServiceClient client)
        {
            var authResponse = await client.PostAsync(new Authenticate {
                provider = "credentials",
                UserName = "******",
                Password = "******",
            });

            var initialAccessToken  = client.GetTokenCookie();
            var initialRefreshToken = client.GetRefreshTokenCookie();

            Assert.That(initialAccessToken, Is.Not.Null);
            Assert.That(initialRefreshToken, Is.Not.Null);

            var request = new Secured {
                Name = "test"
            };
            var response = await client.SendAsync(request);

            Assert.That(response.Result, Is.EqualTo(request.Name));

            client.Post(new InvalidateLastAccessToken());
            // JwtAuthProvider.PrintDump(initialAccessToken);
            // JwtAuthProvider.PrintDump(initialRefreshToken);

            response = await client.SendAsync(request);

            Assert.That(response.Result, Is.EqualTo(request.Name));
            var latestAccessToken = client.GetTokenCookie();

            Assert.That(latestAccessToken, Is.Not.EqualTo(initialAccessToken));
        }
    private static void AssertDoesGetAccessTokenUsingRefreshTokenCookie(IJsonServiceClient client)
    {
        var authResponse = client.Post(new Authenticate {
            provider = "credentials",
            UserName = Username,
            Password = Password
        });

        var initialAccessToken  = client.GetTokenCookie();
        var initialRefreshToken = client.GetRefreshTokenCookie();

        Assert.That(initialAccessToken, Is.Not.Null);
        Assert.That(initialRefreshToken, Is.Not.Null);

        var request = new Secured {
            Name = "test"
        };
        var response = client.Send(request);

        Assert.That(response.Result, Is.EqualTo(request.Name));

        var jwtAuthProvider = AuthenticateService.GetRequiredJwtAuthProvider();

        jwtAuthProvider.InvalidateJwtIds.Add(jwtAuthProvider.LastJwtId());
        // JwtAuthProvider.PrintDump(initialAccessToken);
        // JwtAuthProvider.PrintDump(initialRefreshToken);

        response = client.Send(request);
        Assert.That(response.Result, Is.EqualTo(request.Name));
        var latestAccessToken = client.GetTokenCookie();

        Assert.That(latestAccessToken, Is.Not.EqualTo(initialAccessToken));
    }
        public static void Main(string[] args)
        {
            client = new JsonServiceClient(BASE_URL);
            credentials = client.Post(new Authenticate { UserName = USERNAME, Password = PASSWORD, RememberMe = true });

            getInstallationDetails();

            uploadSensorValues();

            uploadSensorStatuses();

            getSensorValues();

            getSensorStatuses();

            getSensorsForInstallation();

            getNotificationsByType();

            uploadPicture();

            downloadPicture();

            createCustomNotification();

            Console.ReadKey();
        }
Example #7
0
 public EncryptedServiceClient(IJsonServiceClient client, RSAParameters publicKey)
 {
     Client = client;
     Client.ClearCookies();
     PublicKey          = publicKey;
     ServerPublicKeyXml = publicKey.ToPublicKeyXml();
     KeyId = Convert.ToBase64String(publicKey.Modulus).Substring(0, 7);
 }
        public SendAttachmentsViewModel(IJsonServiceClient serviceClient)
        {
            IsOpen      = false;
            MessageText = string.Empty;

            _serviceClient = serviceClient;
            _mapper        = Locator.Current.GetService <IMapper>();
        }
 public SearchService(IUrlBuilder urlBuilder,
                      IJsonServiceClient serviceClient,
                      ILogFactory logFactory)
 {
     _urlBuilder    = urlBuilder;
     _serviceClient = serviceClient;
     _logFactory    = logFactory;
 }
Example #10
0
        public static IEncryptedClient GetEncryptedClient(this IJsonServiceClient client, string serverPublicKeyXml)
        {
            if (string.IsNullOrEmpty(serverPublicKeyXml))
            {
                throw new ArgumentNullException(nameof(serverPublicKeyXml));
            }

            return(new EncryptedServiceClient(client, serverPublicKeyXml));
        }
Example #11
0
 public IntrinioClient(string username, string password)
 {
     _username   = username;
     _password   = password;
     _jsonClient = new JsonServiceClient(_apiBaseUrl)
     {
         AlwaysSendBasicAuthHeader = true, UserName = _username, Password = _password
     };
 }
Example #12
0
 public void InitializeTestData()
 {
     Console.WriteLine("--AppSettings--");
     foreach (string key in ConfigurationManager.AppSettings.AllKeys)
     {
         Console.WriteLine($"{key}: '{ConfigurationManager.AppSettings[key]}'");
     }
     Console.WriteLine("--End AppSettings--");
     _jsonClient = new JsonServiceClient(ConfigurationManager.AppSettings["ServiceUrl"]);
 }
 public cJSON(string url, string request, string username, string password)
 {
     this._url     = url;
     this._request = request;
     client        = new JsonServiceClient(url)
     {
         UserName = username,
         Password = password,
     };
     this._rss = JObject.Parse(client.Get <String>(this._request));
 }
Example #14
0
        public LoginRegisterForm(IJsonServiceClient authClient)
        {
            //_SSEventClient = sSEventClient;
            //check auth here??
            InitializeComponent();
            tabLogin.PageVisible                           = false;
            tabRegister.PageVisible                        = false;
            tabAutoLogin.PageVisible                       = true;
            tabResetPassword.PageVisible                   = false;
            ctrl_LayoutUserEmail.ContentVisible            = false;
            ctrl_LayoutPassword.ContentVisible             = false;
            ctrl_LayoutSwithToResetPassword.ContentVisible = false;
            tabCtrlLoginRegister.SelectedTabPage           = tabAutoLogin;
            tabCtrlLoginRegister.ShowTabHeader             = DevExpress.Utils.DefaultBoolean.False;
            DialogResult   = DialogResult.Abort;
            Text           = "JaRS - Sign in";
            _AppSettings   = new AppSettings();
            _Authenticator = new Authenticator(authClient);
            cbEditRememberLogin.Checked = _Authenticator.LastRememberMe;

            //add custom validators
            CustomEmailValidationRule emRule = new CustomEmailValidationRule
            {
                ErrorText = "please provide a valid email",
                ErrorType = ErrorType.Default
            };

            CustomPasswordValidationRule pwRule = new CustomPasswordValidationRule
            {
                ErrorText = "Please make sure the password meets the required criteria.",
                ErrorType = ErrorType.Default
            };

            dxRegisterValidationProvider.SetValidationRule(txtRegisterEmail, emRule);
            dxRegisterValidationProvider.SetValidationRule(txtRegisterPassword1, pwRule);
        }
Example #15
0
 public static IEncryptedClient GetEncryptedClient(this IJsonServiceClient client, RSAParameters publicKey)
 {
     return(new EncryptedServiceClient(client, publicKey));
 }
Example #16
0
 /// <summary>
 /// Pass in the serviceClients to use for the global context,
 /// </summary>
 /// <param name="serviceClient"></param>
 /// <param name="authClient"></param>
 public GlobalContext(IJsonServiceClient serviceClient, IJsonServiceClient authClient)
 {
     _ServiceClient = serviceClient;
     _AuthClient    = authClient;
     _Instance      = this;
 }
Example #17
0
 public ChatMessageDataService(IJsonServiceClient jsonServiceClient)
 {
     _jsonServiceClient = jsonServiceClient;
 }
        public RetailProductRepository(IJsonServiceClient jsonServiceClient, IRedskyProductMapper redskyProductMapper)
        {
            _jsonServiceClient = jsonServiceClient;

            _redskyProductMapper = redskyProductMapper;
        }
Example #19
0
 public ChatRoomDataService(IJsonServiceClient jsonServiceClient)
 {
     _jsonServiceClient = jsonServiceClient;
 }
Example #20
0
 public Authenticator(IJsonServiceClient authClient)
 {
     AuthClient = authClient;
     LoadUserClientSettings();
 }
Example #21
0
		public UserAccountService(IJsonServiceClient jsonClient)
		{
			_jsonClient = jsonClient;
		}
Example #22
0
 public EncryptedServiceClient(IJsonServiceClient client, string publicKeyXml)
     : this(client, publicKeyXml.ToPublicRSAParameters())
 {
 }
Example #23
0
        public SettingsViewModel(IJsonServiceClient serviceClient)
        {
            ChatSettings = new UserChatSettings();

            LoginAuditCollection = new ObservableCollection <LoginAuditViewModel>();

            ContextMenuCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                IsContextMenu = !IsContextMenu;
                ContextMenuSettingsActiveEvent?.Invoke(IsContextMenu);
            });

            OpenSettingsCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                IsOpened = !IsOpened;
                CloseContextMenu();
                GetSettingsCommand.Execute(null);
                OpenSettingsActiveEvent?.Invoke(IsOpened);
            });

            GetSettingsCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                SetSelectedMenuItem(SelectedMenuItem.Settings);
                var settingsUser = await serviceClient.GetAsync(new GetMySettings());
                if (settingsUser.SendingMessageByEnterKey)
                {
                    TypeEnter = settingsUser.SendingMessageByEnterKey;
                    TypeEnterEvent?.Invoke(TypeEnter);
                }
            });

            SaveSettingsCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var settingsUser = await serviceClient.PostAsync(new SetSettings {
                    SendingMessageByEnterKey = TypeEnter
                });
                ChatSettings = settingsUser;
            });

            MorePointerPressedCommand = ReactiveCommand.Create <object>(obj => { IsContextMenu = false; });

            GetHistoryLoginAuditCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                SetSelectedMenuItem(SelectedMenuItem.Audit);
                LoginAuditCollection.Clear();
                LoginHistoryCollection = await serviceClient.GetAsync(new GetLoginAudit());
                foreach (var item in LoginHistoryCollection.History.Take(100))
                {
                    LoginAuditView = new LoginAuditViewModel
                    {
                        Id                = item.Id,
                        IpAddress         = item.IpAddress,
                        OperatingSystem   = item.OperatingSystem,
                        NameVersionClient = item.NameVersionClient,
                        DateOfEntry       = item.DateOfEntry.Date == DateTime.Now.Date
                            ? $"{item.DateOfEntry:HH:mm}"
                            : $"{item.DateOfEntry:dd.MM.yyyy HH:mm}",
                        IsActive = item.SessionId == LoginHistoryCollection.UniqueSessionUser ? "Активный" : ""
                    };
                    LoginAuditCollection.Add(LoginAuditView);
                }
            });
        }
 protected static void AssertAuthenticateResponse(IJsonServiceClient client, AuthenticateResponse authResponse)
 {
     Assert.That(authResponse.BearerToken, Is.Null);
     Assert.That(client.GetTokenCookie(), Is.Not.Null);
 }