private static async Task SaveAuthToken(AuthState authState, OAuthResult authResult)
        {
            using (var db = new AddInContext())
            {
                var existingToken =
                    await
                    db.SessionTokens.FirstOrDefaultAsync(
                        t => t.Provider == Settings.GoogleAuthority && t.Id == authState.stateKey);

                if (existingToken != null)
                {
                    db.SessionTokens.Remove(existingToken);
                }
                string username   = null;
                var    jwt        = SessionToken.ParseJwtToken(authResult.id_token);
                var    emailClaim = jwt.Claims.FirstOrDefault(c => c.Type == "email");
                if (emailClaim != null)
                {
                    username = emailClaim.Value;
                }

                var token = new SessionToken()
                {
                    Id          = authState.stateKey,
                    CreatedOn   = DateTime.Now,
                    AccessToken = authResult.access_token,
                    Provider    = Settings.GoogleAuthority,
                    Username    = username,
                };
                db.SessionTokens.Add(token);
                await db.SaveChangesAsync();
            }
        }
        private static async Task SaveAuthToken(AuthState authState, OAuthResult authResult, FacebookUserProfile userProfile)
        {
            using (var db = new AddInContext())
            {
                var existingToken =
                    await
                    db.SessionTokens.FirstOrDefaultAsync(
                        t => t.Provider == Settings.FacebookAuthority && t.Id == authState.stateKey);

                if (existingToken != null)
                {
                    db.SessionTokens.Remove(existingToken);
                }

                var token = new SessionToken()
                {
                    Id          = authState.stateKey,
                    CreatedOn   = DateTime.Now,
                    AccessToken = authResult.access_token,
                    Provider    = Settings.FacebookAuthority,
                    Username    = userProfile.id,
                };
                db.SessionTokens.Add(token);
                await db.SaveChangesAsync();
            }
        }
        private static async Task SaveAuthToken(AuthState authState, AuthenticationResult authResult)
        {
            var    idToken       = SessionToken.ParseJwtToken(authResult.IdToken);
            string username      = null;
            var    userNameClaim = idToken.Claims.FirstOrDefault(x => x.Type == "upn");

            if (userNameClaim != null)
            {
                username = userNameClaim.Value;
            }

            using (var db = new AddInContext())
            {
                var existingToken =
                    await
                    db.SessionTokens.FirstOrDefaultAsync(
                        t => t.Provider == Settings.AzureADAuthority && t.Id == authState.stateKey);

                if (existingToken != null)
                {
                    db.SessionTokens.Remove(existingToken);
                }
                var token = new SessionToken()
                {
                    Id          = authState.stateKey,
                    CreatedOn   = DateTime.Now,
                    AccessToken = authResult.AccessToken,
                    Provider    = Settings.AzureADAuthority,
                    Username    = username
                };
                db.SessionTokens.Add(token);
                await db.SaveChangesAsync();
            }
        }
Exemple #4
0
        public void TestMainMenuClick()
        {
            var assertableMenuAction = new AssertableMenuAction();
            var menuManager          = new MenuManager();

            menuManager.AddMenu(MenuLocation.MainMenu
                                + ("menu"
                                   + assertableMenuAction.Named("action1")
                                   + assertableMenuAction.Named("action2")
                                   + MenuItem.Separator
                                   + ("sub-menu"
                                      + assertableMenuAction.Named("sub-menu-action1")
                                      + assertableMenuAction.Named("sub-menu-action2")
                                      )
                                   + assertableMenuAction.Named("action3")));
            AddInContext context = CreateMainMenuContext();

            menuManager.GetMenuItems(context, null);
            menuManager.MenuClick(context, "-menu", "action1");
            menuManager.MenuClick(context, "-menu", "action2");
            menuManager.MenuClick(context, "-sub-menu", "sub-menu-action1");
            menuManager.MenuClick(context, "-sub-menu", "sub-menu-action2");
            menuManager.MenuClick(context, "-menu", "action3");
            Assert.AreEqual(new[] { "action1", "action2", "sub-menu-action1", "sub-menu-action2", "action3" }, assertableMenuAction.ExecutedActions);
        }
 private static void ShowForm(AddInContext context, string scope)
 {
     if (String.IsNullOrEmpty(scope))
     {
         scope = DetermineValidationScope(context.EARepository, context.MenuLocation);
     }
     if (scope == "")
     {
         //TO DO - add additional routines here which i.e. try to determine
         //a UPCC validation scope
         MessageBox.Show("Unable to determine a validator for the selected diagram, element or package.");
     }
     else
     {
         if (form == null || form.IsDisposed)
         {
             form = new ValidatorForm(context.EARepository, scope);
             form.Show();
         }
         else
         {
             form.resetValidatorForm(scope);
             form.Select();
             form.Focus();
             form.Show();
         }
     }
 }
        /// <summary>
        /// The constructor of the wizard initializes the form. Furthermore,
        /// the constructor is private since he is called by the method "ShowForm"
        /// which is part of the same class.
        /// </summary>
        public UpccModelCreator(AddInContext context)
        {
            InitializeComponent();

            repository     = context.EARepository;
            cctsRepository = context.CctsRepository;

            InitializeWindow();
        }
Exemple #7
0
        /// <summary>
        /// Gets the user session token from the database.
        /// </summary>
        /// <param name="userAuthSessionId"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static SessionToken GetUserSessionToken(string userAuthSessionId, string provider)
        {
            SessionToken st = null;

            using (var db = new AddInContext())
            {
                st = db.SessionTokens.FirstOrDefault(t => t.Id == userAuthSessionId && t.Provider == provider);
            }
            return(st);
        }
Exemple #8
0
        public void ShouldLaunchAndPopulateUpccModelCreatorForm()
        {
            AddInContext context = new AddInContext(new EARepositoryModelCreator(), MenuLocation.MainMenu.ToString());

            var t = new Thread(() => new Application().Run(new UpccModelCreator(context)));

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            t.Join();
        }
        public static SessionToken GetUserSessionTokenAny(string userAuthSessionId)
        {
            SessionToken st = null;

            using (var db = new AddInContext())
            {
                st = db.SessionTokens.FirstOrDefault(t => t.Id == userAuthSessionId);
            }
            return(st);
        }
 public static void ShowGeneratorWizard(AddInContext context)
 {
     try
     {
         new GeneratorWizardForm(context.CctsRepository).Show();
     }
     catch (CacheException ce)
     {
         MessageBox.Show(ce.Message, "VIENNA Add-In Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #11
0
 public static void DeleteUserSessionToken(string userAuthSessionId, string provider)
 {
     using (var db = new AddInContext())
     {
         var st = db.SessionTokens.Where(t => t.Id == userAuthSessionId && t.Provider == provider);
         if (st.Any())
         {
             db.SessionTokens.RemoveRange(st);
             db.SaveChanges();
         }
     }
 }
        public static void ShowForm(AddInContext context)
        {
            //clear the cache
            context.reloadRepository();
            //start
            var exporterForm     = new ExporterForm(context.CctsRepository, context.SelectedPackage);
            var mainWindowHandle = context.GetmainWindowHandle();

            if (mainWindowHandle != IntPtr.Zero)
            {
                WindowInteropHelper wih = new WindowInteropHelper(exporterForm);
                wih.Owner = context.GetmainWindowHandle();
            }
            exporterForm.Show();
        }
 public static void ShowForm(AddInContext context)
 {
     if (synchStereotypesForm == null || synchStereotypesForm.IsDisposed)
     {
         synchStereotypesForm = new SynchStereotypesForm(context.EARepository);
     }
     else
     {
         synchStereotypesForm.missingList.Items.Clear();
         synchStereotypesForm.Select();
         synchStereotypesForm.Focus();
     }
     synchStereotypesForm.CloseButton.Enabled = false;
     synchStereotypesForm.Show();
 }
Exemple #14
0
        public static void ShowForm(AddInContext context)
        {
            //clear the cache
            context.reloadRepository();
            //start
            var exporterForm = new ExportXSDSchemaForm(context.CctsRepository, context.SelectedPackage, context.settings);
            var mainWindow   = context.GetMainEAWindow();

            if (mainWindow != null)
            {
                exporterForm.ShowDialog(mainWindow);
            }
            else
            {
                exporterForm.ShowDialog();
            }
        }
 /// <summary>
 /// EA - get menu items
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="menuLocation"></param>
 /// <param name="menuName"></param>
 /// <returns></returns>
 public string[] EA_GetMenuItems(Repository repository, string menuLocation, string menuName)
 {
     try
     {
         if (string.IsNullOrEmpty(menuName))
         {
             // this is the first (top-level) invocation of this method for the current mouse click
             context = new AddInContext(repository, menuLocation);
         }
         return(menuManager.GetMenuItems(context, menuName));
     }
     catch (Exception e)
     {
         new ErrorReporterForm(e + "\n" + e.Message + "\n" + e.StackTrace, Repo.LibraryVersion);
         if (menuLocation == AddInSettings.AddInName)
         {
             return(new string[0]);
         }
         return(new[] { AddInSettings.AddInName });
     }
 }
Exemple #16
0
 private static void ToggleUmm2ModelState(AddInContext context)
 {
     context.EARepository.ToggleUmm2ModelState();
 }
 public static void ShowForm(AddInContext context)
 {
     new AboutWindow().Show();
 }
Exemple #18
0
 public static void ShowImporterWizard(AddInContext context)
 {
     new ImporterWizardFormOld(context.CctsRepository).Show();
 }
 public static void ShowForm(AddInContext context)
 {
     new UmmInitialPackageStructureCreator(context.EARepository).Show();
 }
 public static void ShowCreateDialog(AddInContext context)
 {
     new UmlClassCustomizer(context.CctsRepository).ShowDialog();
 }
 public static void ShowUpdateDialog(AddInContext context)
 {
     new UmlClassCustomizer(context.CctsRepository, ((Element)context.SelectedItem).ElementID).ShowDialog();
 }
Exemple #22
0
 public static void ShowForm(AddInContext context)
 {
     new WSDLGenerator(context.EARepository).Show();
 }
 ///<summary>
 /// The method is called from the menu manager of the VIENNAAddIn and
 /// creates creates as well as launches a new instance of the wizard.
 ///</summary>
 ///<param name="context">
 /// Specifies the context of the VIENNA Add-In containing items such as
 /// the current CC Repository.
 ///</param>
 public static void ShowForm(AddInContext context)
 {
     new UpccModelCreator(context).ShowDialog();
 }
Exemple #24
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            var addinContext = new AddInContext(this.repo, "TreeView", settings);

            ExportXSDSchemaForm.ShowForm(addinContext);
        }
Exemple #25
0
 public static void ShowForm(AddInContext context)
 {
     new StandardLibraryImporter(context.EARepository).ShowDialog();
 }
 public static void ShowForm(AddInContext context)
 {
     new SchemaAnalyzer().ShowDialog();
 }
Exemple #27
0
 public static void ShowForm(AddInContext context)
 {
     new XsltGeneratorForm(context.CctsRepository).ShowDialog();
 }
 public static void ShowForm(AddInContext context)
 {
     new SubSettingWizard(context.CctsRepository).Show();
 }
 public static void ShowCreateDialog(AddInContext context)
 {
     new SubSettingWizard(context.CctsRepository).ShowDialog();
 }
Exemple #30
0
 private static bool Never(AddInContext context)
 {
     return(false);
 }