예제 #1
0
        private void LoginClick(object sender, EventArgs e)
        {
            try
            {
                //Inizialize Authentication api (Authentication api not require authentication token)
                var authApi = new IO.Swagger.Api.AuthenticationApi(_apiUrl);
                //Login to obtain a valid token (and a refresh token)
                var resultToken = authApi.AuthenticationGetToken(new AuthenticationTokenRequestDTO(userTxt.Text, passwordTxt.Text, _appId, _secret));

                _authToken    = resultToken.AccessToken;
                _refreshToken = resultToken.RefreshToken;

                tokenLabel.Text      = "Token presente";
                tokenLabel.ForeColor = Color.Green;
                tokenValue.Text      = string.Empty;
                //Print token information
                foreach (var propertyInfo in resultToken.GetType().GetProperties())
                {
                    tokenValue.Text += string.Format("{0}: {1}{2}", propertyInfo.Name, propertyInfo.GetValue(resultToken), Environment.NewLine);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
예제 #2
0
 private void refreshToken(object sender, EventArgs e)
 {
     try
     {
         //Inizialize Authentication api (Authentication api not require authentication token)
         var authApi = new IO.Swagger.Api.AuthenticationApi(_apiUrl);
         //Try to obtain a new token with the refresh token provided durin login procedure
         var resultToken = authApi.AuthenticationRefresh(new RefreshTokenRequestDTO(_appId, _secret, _refreshToken));
         _authToken           = resultToken.AccessToken;
         _refreshToken        = resultToken.RefreshToken;
         tokenLabel.Text      = "Token presente";
         tokenLabel.ForeColor = Color.Green;
         tokenValue.Text      = string.Empty;
         //Print token information
         foreach (var propertyInfo in resultToken.GetType().GetProperties())
         {
             tokenValue.Text += string.Format("{0}: {1}{2}", propertyInfo.Name, propertyInfo.GetValue(resultToken), Environment.NewLine);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         throw;
     }
 }
예제 #3
0
        private void ReLogin()
        {
            IO.Swagger.Model.AuthenticationTokenRequestDTO arxLogonRequest = new IO.Swagger.Model.AuthenticationTokenRequestDTO(_username, _password, _clientId, _clientSecret);
            var authApi     = new IO.Swagger.Api.AuthenticationApi(_url);
            var resultToken = authApi.AuthenticationGetToken(arxLogonRequest);

            _expireDateTime = DateTime.Now.AddSeconds(resultToken.ExpiresIn == null ? 60 * 10 : resultToken.ExpiresIn.Value).AddMinutes(-10);
            _authToken      = resultToken.AccessToken;
            _refreshToken   = resultToken.RefreshToken;
        }
예제 #4
0
        private void button14_Click(object sender, EventArgs e)
        {
            var authApi = new IO.Swagger.Api.AuthenticationApi(Configuration);
            var ticket  = authApi.AuthenticationInsertLogonTicket(new LogonTicketRequestDto(2, "", null, DateTime.Now.AddDays(10), Settings.ExampleSettings.AppName, Settings.ExampleSettings.AppSecret, null, null, null));

            labelLogonToken.Text = "Ottenuto un logo token per l'utente 2 valido per 10 giorni, Token: " + ticket.LogonTicket;

            var url = "http://NEXTYEAR2020/ARXivarNextWebPortal/Account/LogonTicket/" + ticket.LogonTicket;

            logonTicketUrl.Text     = url;
            logonTicketUrlFull.Text = url + "?lang=EN&ReturnUrl=%2FARXivarNextWebPortal%2F#!/tasklistrepeater?showTask=1";
        }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //Inizialize Authentication api (Authentication api not require authentication token)
                var authApi = new IO.Swagger.Api.AuthenticationApi(_apiUrl);
                //Login to obtain a valid token (and a refresh token)

                /*
                 *
                 *
                 *
                 *      In the login procedure for the management API it is necessary to specify the additional scope ArxManagement to obtain a token enabled for management API
                 *
                 *
                 *
                 */


                var resultToken = authApi.AuthenticationGetToken(new AuthenticationTokenRequestDTO(userTxt.Text, passwordTxt.Text, _appId, _secret, null, null, null, null, null, null, null, new List <string> {
                    "ArxManagement"
                }));

                _authToken    = resultToken.AccessToken;
                _refreshToken = resultToken.RefreshToken;

                tokenLabel.Text      = "Token presente";
                tokenLabel.ForeColor = Color.Green;
                tokenValue.Text      = string.Empty;
                //Print token information
                foreach (var propertyInfo in resultToken.GetType().GetProperties())
                {
                    tokenValue.Text += string.Format("{0}: {1}{2}", propertyInfo.Name, propertyInfo.GetValue(resultToken), Environment.NewLine);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
예제 #6
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                //Inizialize Authentication api (Authentication api not require authentication token)
                var authApi = new IO.Swagger.Api.AuthenticationApi(ApiUrl);
                //Login to obtain a valid token (and a refresh token)
                var reqdto = new AuthenticationTokenRequestDTO(
                    textBoxUsername.Text, // Username
                    textBoxPassword.Text, // Password
                    AppName,              // Application name
                    AppSecret);           // Application secret
                AuthenticationTokenDTO resultToken = authApi.AuthenticationGetToken(reqdto);

                _authToken    = resultToken.AccessToken;
                _refreshToken = resultToken.RefreshToken;

                MessageBox.Show("Succes login!", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #7
0
        private Task TaskWebApi()
        {
            var task = new Task(() =>
            {
                DispatcherHelper.UIDispatcher.Invoke(() => IsBusy = true);

                var listTaskTest = new List <Task>();

                DispatcherHelper.UIDispatcher.BeginInvoke((Action)(() => { _logger.Info("Execute login test"); }));


                try
                {
                    var authApi = new IO.Swagger.Api.AuthenticationApi(Url);

                    var tokenRequestDto = new AuthenticationTokenRequestDTO(Username, Password, CLIENTID, CLIENTSECRET, null, null, null, null, null, null, null);
                    var tokenResponse   = authApi.AuthenticationGetToken(tokenRequestDto);

                    var configuration = new IO.Swagger.Client.Configuration()
                    {
                        ApiKey = new Dictionary <string, string>()
                        {
                            { "Authorization", tokenResponse.AccessToken }
                        },
                        ApiKeyPrefix = new Dictionary <string, string>()
                        {
                            { "Authorization", "Bearer" }
                        },
                        BasePath = Url
                    };

                    for (int i = 0; i < ThreadCount; i++)
                    {
                        DispatcherHelper.UIDispatcher.BeginInvoke((Action)(() => { _logger.Info(string.Format(" - Create procedure connection {0} of {1}", (i + 1), ThreadCount)); }));

                        var taskClient = new Task(() => TestProcedureApi(configuration, string.Format("Thread{0}", i + 1)), TaskCreationOptions.LongRunning);

                        taskClient.Start();
                        listTaskTest.Add(taskClient);

                        Thread.Sleep(1000);
                    }

                    listTaskTest.ForEach(x => x.Wait());

                    DispatcherHelper.UIDispatcher.BeginInvoke((Action)(() =>
                    {
                        _logger.Info(string.Format("REPORT\r\nMASK\r\n{0}\r\nSTORE\r\n{1}\r\nSEARCH\r\n{2}\r\nF2\r\n{3}\r\nCycle\r\n{4}",
                                                   TimeCalculator.EvaluateTime(_timeMask.ToArray()).ToString(),
                                                   TimeCalculator.EvaluateTime(_timeStore.ToArray()).ToString(),
                                                   TimeCalculator.EvaluateTime(_timeSearch.ToArray()).ToString(),
                                                   TimeCalculator.EvaluateTime(_timeF2.ToArray()).ToString(),
                                                   TimeCalculator.EvaluateTime(_timeTestProcedure.ToArray()).ToString()
                                                   ));
                    }));

                    MessageBox.Show("Test procedure completed", "Execute completed", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception exception)
                {
                    DispatcherHelper.UIDispatcher.BeginInvoke((Action)(() =>
                    {
                        _logger.Error(exception.Message);
                    }));

                    MessageBox.Show(exception.Message, "Execute error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    DispatcherHelper.UIDispatcher.Invoke(() => IsBusy = false);
                }
            }
                                );

            return(task);
        }