Exemple #1
0
        private async void AuthenticationComplete(
            Session session,
            INavigation navigation,
            IAuthenticationProcess authenticationProcess,
            PushNotification notification)
        {
            if (Environment.CurrentManagedThreadId != this.hostThreadId)
            {
                this.InvokeOnMainThread(() => this.AuthenticationComplete(session, navigation, authenticationProcess, notification));
                return;
            }

            this.ApplicationInstance = this.applicationInstanceFactory.Create(this, session);
            ServiceResult result = await this.ApplicationInstance.InitializeUserSession();

            if (result.ResultCode == ServiceResultCode.Success)
            {
                this.ApplicationInstance.SignedOut +=
                    () =>
                {
                    this.ApplicationInstance = null;
                    authenticationProcess.LaunchFromSignOut(navigation);
                };

                this.ApplicationInstance.Launch(navigation, notification);
            }
            else
            {
                this.ApplicationInstance = null;
                this.HandleFailedApplicationInitialization(navigation, result);
            }
        }
Exemple #2
0
        /// <summary>
        /// Launches the initial view for the application.
        /// </summary>
        /// <param name="authenticationProcess">An optional authentication process.</param>
        /// <param name="notification">An optional push notification if the application was launched due to the user acknowledging a notification on their device.</param>
        public void Launch(IAuthenticationProcess authenticationProcess, PushNotification notification = null)
        {
            if (this.ApplicationInstance != null)
            {
                throw new InvalidOperationException("An application instance has already been launched.");
            }

            this.hostThreadId = Environment.CurrentManagedThreadId;
            INavigation navigation = this.CreateNavigation();

            if (authenticationProcess != null)
            {
                authenticationProcess.Completed +=
                    session =>
                    this.AuthenticationComplete(
                        session,
                        navigation,
                        authenticationProcess,
                        notification);

                authenticationProcess.Launch(navigation);
            }
            else
            {
                this.LaunchApplicationInstance(Session.Anonymous, navigation, notification);
            }
        }
        public void Fail_logon_without_license_guid()
        {
            var factory    = _container.Resolve <IUnitOfWorkScopeFactory>();
            var rep        = _container.Resolve <IRepository <Account> >();
            var accountRep = _container.Resolve <IRepository <Account> >();
            var licenseRep = _container.Resolve <IRepository <License> >();
            var logonRep   = _container.Resolve <IRepository <LogonHistory> >();

            IAuthenticationProcess process = null;
            LogonHistory           logon   = null;

            using (var scope = factory.Create())
            {
                //Создаем УЗ
                var account = new Account()
                {
                    CreateDate = DateTime.Now, Email = "*****@*****.**", Guid = Guid.NewGuid()
                };
                var license1 = new License()
                {
                    TypeId = 1, Guid = Guid.NewGuid(), CreateDate = DateTime.Now, ChangeDate = DateTime.Now, Access = true, Count = 1, ApplicationId = 1, Account = account
                };
                var license2 = new License()
                {
                    TypeId = 2, Guid = Guid.NewGuid(), CreateDate = DateTime.Now, ChangeDate = DateTime.Now, Access = true, Count = 1, ApplicationId = 1, Account = account
                };
                var license3 = new License()
                {
                    TypeId = 3, Guid = Guid.NewGuid(), CreateDate = DateTime.Now, ChangeDate = DateTime.Now, Access = true, Count = 1, ApplicationId = 1, Account = account
                };

                accountRep.Add(account); licenseRep.Add(license1); licenseRep.Add(license2); licenseRep.Add(license3);
                scope.Flush();

                //Проверяем доступ
                process = BG.Domain.Authentication.Bootstrap.Configuration.Configure(_container, true);
                process.Logon(null, new LogonHistory()
                {
                    CSDBuildNumber = "123"
                });
                scope.Flush();

                logon = logonRep.FirstOrDefault();
            }

            Assert.IsTrue(process != null, "Не удалось создать процесс");
            Assert.IsTrue(!process.IsValid, process.ErrorMessage ?? "Ошибка");
            Assert.IsTrue(logon != null, "Не создался логон");
            Assert.IsTrue(!logon.AccountId.HasValue || logon.AccountId.Value <= 0, "УЗ должна отсутствовать");
        }
Exemple #4
0
 /// <summary>
 /// Launches the initial view for the application asynchronously.
 /// </summary>
 /// <param name="authenticationProcess">An optional authentication process.</param>
 /// <param name="launchOptions">
 /// The launch options for an iOS application containing the data for a notification if the app was launched from the user responding to a notification alert.
 /// The dicationary will be ignored if it is empty or null.
 /// </param>
 /// <param name="ignoreInvalidNotification">True if an invalid notification should be ignored while launching, otherwise false if an exception should be thrown.</param>
 public void Launch(IAuthenticationProcess authenticationProcess, NSDictionary launchOptions, bool ignoreInvalidNotification = true)
 {
     this.Launch(authenticationProcess, iOSPushNotificationConverter.FromLaunchOptions(launchOptions), ignoreInvalidNotification);
 }
Exemple #5
0
 public TokenAuthController(IAuthenticationProcess authenticationProcess)
 {
     this._authenticationProcess = authenticationProcess;
 }
Exemple #6
0
 /// <summary>
 /// Launches the initial view for the application.
 /// </summary>
 /// <param name="authenticationProcess">An optional authentication process.</param>
 /// <param name="notification">An optional dictionary containing the values for a push notification if the application was launched due to the user acknowledging a notification on their device.</param>
 /// <param name="ignoreInvalidNotification">True if an invalid notification should be ignored while launching, otherwise false if an exception should be thrown.</param>
 protected void Launch(IAuthenticationProcess authenticationProcess, IDictionary <string, string> notification = null, bool ignoreInvalidNotification = true)
 {
     this.Launch(authenticationProcess, this.ParseNotification(notification, ignoreInvalidNotification));
 }