public AddOrderCommand(OrderClientViewModel orderClientViewModel, UnitOfWorkFactory unitOfWorkFactory, AuthenticationStore authenticationStore)
 {
     _orderClientViewModel  = orderClientViewModel;
     _unitOfWorkFactory     = unitOfWorkFactory;
     _authentificationStore = authenticationStore;
     //_user = _orderClientViewModel.User;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Decrypt the document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HandleDecryptDocument(object sender, EventArgs e)
        {
            var    authenticateStore = AuthenticationStore.Instance();
            var    activeDocument    = Globals.ThisAddIn.Application.ActiveDocument;
            string sidDocumentIdValue;

            if (!activeDocument.TryGetVariable(Constants.VariableName, out sidDocumentIdValue))
            {
                return;
            }

            var range  = activeDocument.Range();
            var shapes = range.InlineShapes;

            foreach (InlineShape shape in shapes)
            {
                if (shape.Type != WdInlineShapeType.wdInlineShapePicture || string.IsNullOrWhiteSpace(shape.AlternativeText))
                {
                    continue;
                }

                // DECRYPT
                var b64Encoded = shape.AlternativeText;
                var xml        = DecryptOfficeDocument(sidDocumentIdValue, authenticateStore.IdentityToken, b64Encoded);
                if (string.IsNullOrWhiteSpace(xml))
                {
                    return;
                }

                shape.Range.InsertXML(xml);
                SetEncrypted(activeDocument, "false");
                activeDocument.Save();
            }
        }
 public ContactsViewModel(NavigationStore navigationStore, AuthenticationStore authenticationStore, UnitOfWorkFactory unitOfWorkFactory)
 {
     NavigateToRepairCommand       = new NavigateCommand <RepairClientViewModel>(navigationStore, () => new RepairClientViewModel(navigationStore, authenticationStore, unitOfWorkFactory));
     NavigateToStoreClientCommand  = new NavigateCommand <StoreClientViewModel>(navigationStore, () => new StoreClientViewModel(navigationStore, authenticationStore, unitOfWorkFactory));
     NavigateToOrdersClientCommand = new NavigateCommand <OrdersClientViewModel>(navigationStore, () => new OrdersClientViewModel(navigationStore, authenticationStore, unitOfWorkFactory));
     NavigateToExitCommand         = new NavigateCommand <LogInViewModel>(navigationStore, () => new LogInViewModel(navigationStore, authenticationStore, unitOfWorkFactory));
 }
Exemplo n.º 4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            UnitOfWorkFactory   unitOfWorkFactory   = new UnitOfWorkFactory();
            AuthenticationStore authenticationStore = new AuthenticationStore(new AuthenticationService(unitOfWorkFactory));
            NavigationStore     navigationStore     = new NavigationStore();

            //using (var context = new MyContext())
            //{
            //    context.Database.EnsureDeleted();
            //    context.Database.EnsureCreated();

            //    authenticationStore.Register("admin", "admin", "admin", "*****@*****.**", UserType.Admin);

            //    context.SaveChanges();
            //}

            navigationStore.CurrentViewModel = new LogInViewModel(navigationStore, authenticationStore, unitOfWorkFactory);
            MainWindow mainWindow = new MainWindow()
            {
                DataContext = new MainViewModel(navigationStore)
            };

            mainWindow.Show();
            base.OnStartup(e);
        }
 public ProfileUserController()
 {
     ViewModel = new ProfileUserViewModel();
     ViewModel.WindowLoaded += HandleWindowLoaded;
     _store = AuthenticationStore.Instance();
     _store.Authenticated += HandleAuthenticate;
 }
 private void HandleRibbonLoad(object sender, RibbonUIEventArgs e)
 {
     DisplayLogin(true);
     _authenticationStore = AuthenticationStore.Instance();
     _officeDocumentStore = OfficeDocumentStore.Instance();
     _authenticationStore.Authenticated += HandleAuthenticate;
     AuthenticationStore.Instance().Restore();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Encrypt the document.
        /// </summary>
        /// <param name="Doc"></param>
        /// <param name="Cancel"></param>
        private void HandleDocumentBeforeClose(Document Doc, ref bool Cancel)
        {
            string sidDocumentIdValue;

            if (!Doc.TryGetVariable(Constants.VariableName, out sidDocumentIdValue))
            {
                return;
            }

            string isEncryptedStr;
            bool   isEncrypted = false;

            if (Doc.TryGetVariable(Constants.IsEncryptedVariableName, out isEncryptedStr))
            {
                bool.TryParse(isEncryptedStr, out isEncrypted);
            }

            if (isEncrypted)
            {
                return;
            }

            // Encrypt the content.
            var encryptionHelper = new EncryptionHelper();
            var encryptedResult  = encryptionHelper.Encrypt(Doc, sidDocumentIdValue).Result;

            if (!string.IsNullOrWhiteSpace(AuthenticationStore.Instance().IdentityToken))
            {
                var officeDocumentStore = OfficeDocumentStore.Instance();
                officeDocumentStore.StoreDecryption(sidDocumentIdValue, new DecryptedResponse
                {
                    Password = encryptedResult.Password,
                    Salt     = encryptedResult.Salt
                });
            }

            // Insert the image.
            var range    = Doc.Range();
            var image    = ResourceHelper.GetImage("WordAccessManagementAddin.Resources.lock.png");
            var filePath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png";
            var bm       = SteganographyHelper.CreateNonIndexedImage(image);

            bm.Save(filePath);
            range.Text = string.Empty;
            var shape = range.InlineShapes.AddPicture(filePath, false, true);

            shape.AlternativeText = encryptedResult.Content;
            File.Delete(filePath);
            SetEncrypted(Doc, "true");
            Doc.Save();
        }
Exemplo n.º 8
0
 public ProtectUserController(Window window)
 {
     _window = window;
     _documentManagementFactory      = new DocumentManagementFactory();
     _identityServerUmaClientFactory = new IdentityServerUmaClientFactory();
     _identityServerClientFactory    = new IdentityServerClientFactory();
     _authenticationStore            = AuthenticationStore.Instance();
     _officeDocumentStore            = OfficeDocumentStore.Instance();
     ViewModel = new ProtectUserViewModel();
     Init();
     ViewModel.DocumentProtected         += HandleProtectDocument;
     ViewModel.SharedLinkAdded           += HandleAddSharedLink;
     ViewModel.SelectedSharedLinkRemoved += HandleRemoveSharedLink;
 }
Exemplo n.º 9
0
 public async Task <bool> TryLoginAsync(string user, string password)
 {
     IsBusy = true;
     try
     {
         await AuthenticationStore.NewLogin(user, password);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
     finally
     {
         IsBusy = false;
     }
     return(true);
 }
Exemplo n.º 10
0
        async Task <RocketChatClientAuthentication> AuthenticateAsyncImpl(string baseUrl, string username, string password)
        {
            var cacheKey = RocketChatClientAuthentication.CalculateCacheKey(baseUrl, username);

            if (tokenCache.ContainsKey(cacheKey))
            {
                return(tokenCache[cacheKey]);
            }

            using (var client = HttpClientFactory.CreateClient("RocketChat"))
            {
                client.BaseAddress = new Uri(baseUrl.EnsureEndsWith('/'));

                var jsonPayload = new
                {
                    user     = username,
                    password = password
                };

                var response = await client.PostAsJsonAsync("api/v1/login", jsonPayload);

                if (response.IsSuccessStatusCode)
                {
                    var authenticationResponse = await response.Content.ReadFromJsonAsync <AuthenticationResponse>();

                    var authResult = new RocketChatClientAuthentication
                    {
                        BaseUrl   = baseUrl,
                        Username  = username,
                        UserId    = authenticationResponse.Data.UserId,
                        AuthToken = authenticationResponse.Data.AuthToken
                    };
                    tokenCache[cacheKey] = authResult;

                    await PresenceService.SetUserPresenceAsync(authResult, "online", "serving your DevOps notifications");

                    AuthenticationStore.AddTokenRegistration(authResult);
                    return(authResult);
                }
                else
                {
                    var message = string.Format("Failed to authenticate `{0}` @ `{1}`", username, baseUrl);
                    throw new ApplicationException(message);
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Handle the "navigated" event of the webrowser.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HandleNavigated(object sender, NavigationEventArgs e)
        {
            HideScriptErrors(webBrowser, true);
            DisplaySpinner(false);
            if (e.Uri == null || !e.Uri.AbsoluteUri.StartsWith(Constants.CallbackUrl))
            {
                return;
            }

            var query = e.Uri.Query;

            query = query.Replace("?", "");
            var parameters = query.Split('&').Select(r =>
            {
                var splittedParameter = r.Split('=');
                return(new KeyValuePair <string, string>(splittedParameter[0], splittedParameter[1]));
            });

            AuthenticationStore.Instance().Authenticate(parameters);
            Close();
        }
Exemplo n.º 12
0
 public LogInCommand(AuthenticationStore authenticationStore, LogInViewModel logInViewModel)
 {
     _authenticationStore = authenticationStore;
     _logInViewModel      = logInViewModel;
 }
Exemplo n.º 13
0
 public ResetPasswordRequest(AuthenticationStore auth, APIConnection connection)
 {
     Auth       = auth;
     Connection = connection;
     UserID     = auth.UserID;
 }
 public GetInstanceRequest(AuthenticationStore auth, APIConnection connection)
 {
     Auth       = auth;
     Connection = connection;
     UserID     = auth.UserID;
 }
Exemplo n.º 15
0
 public AddRepairOrderCommand(RepairClientViewModel repairClientViewModel, UnitOfWorkFactory unitOfWorkFactory, AuthenticationStore authenticationStore)
 {
     _repairClientViewModel = repairClientViewModel;
     _unitOfWorkFactory     = unitOfWorkFactory;
     _authentificationStore = authenticationStore;
 }
Exemplo n.º 16
0
        //private readonly ICommand _navigateToUsers;

        public RegisterCommand(AuthenticationStore authenticationStore, RegisteryViewModel registeryViewModel /*, ICommand navigateToUsers*/)
        {
            _authenticationStore = authenticationStore;
            _registeryViewModel  = registeryViewModel;
            //_navigateToUsers = navigateToUsers;
        }
Exemplo n.º 17
0
 public CreateUserRequest(AuthenticationStore auth, APIConnection connection)
 {
     Auth       = auth;
     Connection = connection;
     UserID     = auth.UserID;
 }
Exemplo n.º 18
0
 public SendFriendRequestRequest(AuthenticationStore auth, APIConnection connection)
 {
     Auth       = auth;
     Connection = connection;
     UserID     = auth.UserID;
 }
 public UpdateStatusRequest(AuthenticationStore auth, APIConnection connection)
 {
     Auth       = auth;
     Connection = connection;
     UserID     = auth.UserID;
 }
 public GetHUDRequest(AuthenticationStore auth, APIConnection connection)
 {
     Auth       = auth;
     Connection = connection;
 }
Exemplo n.º 21
0
 public GetCurrentHUDRequest(AuthenticationStore auth, APIConnection connection)
 {
     Auth       = auth;
     Connection = connection;
     UserID     = auth.UserID;
 }
Exemplo n.º 22
0
 private void InternalStartup()
 {
     Application.DocumentBeforeClose += HandleDocumentBeforeClose;
     OfficeDocumentStore.Instance().Decrypted    += HandleDecryptDocument;
     AuthenticationStore.Instance().Disconnected += HandleDisconnect;
 }