Exemplo n.º 1
0
 private void Login(PasswordBox password)
 {
     try
     {
         Password = ((PasswordBox)password).Password;
         if (!String.IsNullOrWhiteSpace(Email) && !String.IsNullOrWhiteSpace(Password))
         {
             LoginRequested?.Invoke();
         }
         else if (String.IsNullOrWhiteSpace(Email) && !String.IsNullOrWhiteSpace(Password))
         {
             throw new InvalidOperationException(Properties.Resources.ErrorLoginEnterEmail);
         }
         else if (!String.IsNullOrWhiteSpace(Email) && String.IsNullOrWhiteSpace(Password))
         {
             throw new InvalidOperationException(Properties.Resources.ErrorLoginEnterPassword);
         }
         else
         {
             throw new InvalidOperationException(Properties.Resources.ErrorLoginEnterEmailAndPassword);
         }
     }
     catch (InvalidOperationException e)
     {
         ErrorHandler.ThrowError(0, e.Message);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemplo n.º 2
0
 private void Monitor_CardInserted(object sender, CardStatusEventArgs e)
 {
     if (HorekaNFCReader.connectCard())
     {
         NFCUID = HorekaNFCReader.GetCardUID();
         LoginRequested?.Invoke();
     }
 }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ddlAction.SelectedIndex < 1)
            {
                MessageBox.Show(this, LocRm.GetString("SelectAnActionToAdd"));
                return;
            }
            var oa = (ListItem)ddlAction.SelectedItem;

            if (!MainForm.Conf.Subscribed && oa.Restricted)
            {
                LoginRequested?.Invoke(this, EventArgs.Empty);
                return;
            }
            bool cancel;

            string[] config = GetConfig("", "", "", "", oa.Value, out cancel);
            if (cancel)
            {
                return;
            }


            var oae = new objectsActionsEntry
            {
                mode         = Mode,
                objectid     = Oid,
                objecttypeid = Otid,
                type         = oa.Value,
                param1       = config[0],
                param2       = config[1],
                param3       = config[2],
                param4       = config[3],

                ident = Guid.NewGuid().ToString()
            };

            MainForm.Actions.Add(oae);
            RenderEventList();
        }
Exemplo n.º 4
0
 static void Application_LoginRequested(object sender, EventArgs e)
 {
     LoginRequested?.Invoke(null, e);
 }
Exemplo n.º 5
0
        internal async Task StartAsync(string configContent, RegistrationKind regKind)
        {
            Logger.LogInfo("Framework starting...");

            // Load and validate configuration data
            var config = new Configuration();

            config.Load(configContent);
            _config = config;

            var clientId = config.DefaultClientId;

            Organization        = config.OAuth.Client.Organization;
            Name                = config.OAuth.Client.ClientName;
            DetailedDescription = config.OAuth.Client.Description;

            Identifier    = config.DefaultClientId.Id;
            Environment   = config.DefaultClientId.Environment;
            RegisteredBy  = config.DefaultClientId.RegisteredBy;
            Scope         = new List <string>(config.DefaultClientId.Scope.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s))).AsReadOnly();
            ScopeAsString = config.DefaultClientId.Scope;
            Status        = config.DefaultClientId.Status;

            RedirectUri = config.DefaultClientId.RedirectUri;

            // Load device and any previous registration info.
            await MASDevice.InitializeAsync(config);

            // Authorization providers not supported yet
            //var response = await MAGRequests.GetAuthorizationProviders(_config, Device);

            // Load client access if client registration is requested
            if (MAS.RegistrationKind == RegistrationKind.Client)
            {
                Client = await MASUser.InitializeAsync(config, MASDevice.Current, true);
            }

            // Load user and any previous access token or idtoken info
            await MASUser.InitializeAsync(config, MASDevice.Current, false);

            if (!MASDevice.Current.IsRegistered)
            {
                switch (regKind)
                {
                case RegistrationKind.Client:
                    if (!config.HasScope(ScopeNames.MssoClientRegister))
                    {
                        ErrorFactory.ThrowError(ErrorCode.DeviceRegistrationAttemptedWithUnregisteredScope);
                    }

                    await MASDevice.Current.RegisterWithClientAsync();

                    // Create a device anonymous user
                    var clientUser = new MASUser(_config, MASDevice.Current);
                    await clientUser.LoginAnonymouslyAsync();

                    Client = clientUser;

                    break;

                case RegistrationKind.User:
                    // Ask for login with user device registration
                    LoginRequested?.Invoke(null, EventArgs.Empty);
                    break;

                default:
                    ErrorFactory.ThrowError(ErrorCode.DeviceRegistrationAttemptedWithUnregisteredScope);
                    break;
                }
            }

            Logger.LogInfo("Framework started");
        }