Ejemplo n.º 1
0
        /// <summary>
        /// Authenticate User and refresh token
        /// </summary>
        public void Authenticate()
        {
            try
            {
                //Authenticate with custom User and Password from config file...
                if (!string.IsNullOrEmpty(Properties.Settings.Default.UserPW))
                {
                    string sResponse = RZRestAPI.GetAuthToken(Properties.Settings.Default.UserKey, Decrypt(Properties.Settings.Default.UserPW, Environment.UserName));
                    try
                    {
                        Guid.Parse(sResponse);
                        sAuthToken = sResponse;
                        //tbURL.Text = Properties.Settings.Default.InternalURL;
                        //oInstPanel.sInternalURL = Properties.Settings.Default.InternalURL;
                        tbURL.IsEnabled    = true;
                        tbIPFSGW.IsEnabled = true;
                    }
                    catch { }
                }

                //Authenticate with dummy account
                if (string.IsNullOrEmpty(sAuthToken))
                {
                    sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken());
                }
            }
            catch { }
        }
Ejemplo n.º 2
0
        private void _addPackageSource(string name, string location, bool trusted, Request request)
        {
            Properties.Settings.Default.Location = location;

            //Set default URL if no loaction is specified
            if (!string.IsNullOrEmpty(location))
            {
                Properties.Settings.Default.Location = location;
                Properties.Settings.Default.Save();
            }

            //RZRestAPI.sURL = Properties.Settings.Default.Location;

            string       sUser = "******";
            SecureString sPW   = ToSecureString(GetTimeToken());


            if (request.OptionKeys.Contains("Username"))
            {
                Properties.Settings.Default.Username = request.GetOptionValue("Username");
                sUser = Properties.Settings.Default.Username;
            }
            else
            {
                Properties.Settings.Default.Username = "";
            }

            if (request.OptionKeys.Contains("Password"))
            {
                sPW = ToSecureString(request.GetOptionValue("Password"));
                Properties.Settings.Default.Password = EncryptString(sPW);
            }
            else
            {
                Properties.Settings.Default.Password = "";
            }

            if (request.OptionKeys.Contains("ContentURL"))
            {
                Properties.Settings.Default.ContentURL = request.GetOptionValue("ContentURL");
            }
            else
            {
                Properties.Settings.Default.ContentURL = "";
            }

            Properties.Settings.Default.Save();

            _AuthenticationToken = RZRestAPI.GetAuthToken(sUser, ToInsecureString(sPW));

            Guid gToken;

            if (!Guid.TryParse(_AuthenticationToken, out gToken))
            {
                request.Warning(_AuthenticationToken);
                dLastTokenRefresh = new DateTime();
                return;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Check if RuckZuck Token is still valid or request a new token if last refresh was mor than an hour
        /// </summary>
        /// <param name="request"></param>
        private void _reAuthenticate(Request request)
        {
            //Check if there is a token..
            Guid gToken;

            if (!Guid.TryParse(_AuthenticationToken, out gToken))
            {
                dLastTokenRefresh = new DateTime();
            }

            //Re-Authenticate after 30min
            if ((DateTime.Now - dLastTokenRefresh).TotalMinutes >= 30)
            {
                if (string.IsNullOrEmpty(Properties.Settings.Default.Location))
                {
                    //Properties.Settings.Default.Location = WebServiceURL;
                    //Properties.Settings.Default.Save();
                }

                //RZRestAPI.sURL = Properties.Settings.Default.Location;

                if (!string.IsNullOrEmpty(Properties.Settings.Default.Username))
                {
                    _AuthenticationToken = RZRestAPI.GetAuthToken(Properties.Settings.Default.Username, ToInsecureString(DecryptString(Properties.Settings.Default.Password)));
                    dLastTokenRefresh    = DateTime.Now;
                    request.Debug("RZ Account: " + Properties.Settings.Default.Username);
                }
                else
                {
                    _AuthenticationToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken());
                    dLastTokenRefresh    = DateTime.Now;
                    request.Debug("RZ Account: FreeRZ");
                }

                if (!Guid.TryParse(_AuthenticationToken, out gToken))
                {
                    dLastTokenRefresh = new DateTime();
                    request.Warning(_AuthenticationToken);
                    _AuthenticationToken = "";
                    return;
                }

                request.Debug("RZ Authentication Token:" + _AuthenticationToken);
            }
        }
Ejemplo n.º 4
0
        private void btSettingsSave_Click(object sender, RoutedEventArgs e)
        {
            string sResponse = RZRestAPI.GetAuthToken(tbUsername.Text, tbPassword.Password);

            try
            {
                //Check if GUID came back..
                Guid.Parse(sResponse);

                //Enable InternalURL
                //tbURL.IsEnabled = true;
                tbIPFSGW.IsEnabled = true;

                //Update and save new username and password
                Properties.Settings.Default.UserKey = tbUsername.Text;
                Properties.Settings.Default.UserPW  = Encrypt(tbPassword.Password, Environment.UserName);
                //Properties.Settings.Default.InternalURL = tbURL.Text;
                Properties.Settings.Default.IPFSGW = tbIPFSGW.Text;
                RuckZuck_WCF.RZRestAPI.ipfs_GW_URL = tbIPFSGW.Text;
                Properties.Settings.Default.Save();

                //oInstPanel.sInternalURL = tbURL.Text;

                //Back to Main
                //tabWizard.SelectedItem = tabMain;
                tbUsername.BorderBrush = Brushes.Green;

                oInstPanel.EnableFeedback = true;
                oInstPanel.EnableEdit     = true;
                oInstPanel.EnableSupport  = true;

                oSCAN.SoftwareRepository = new List <GetSoftware>();
                oSCAN.GetSWRepository().ConfigureAwait(false);
            }
            catch
            {
                //Username or Password are wrong !
                tbUsername.BorderBrush = Brushes.Red;
                tbPassword.BorderBrush = Brushes.Red;
                tbUsername.ToolTip     = sResponse;
                tbPassword.ToolTip     = sResponse;
                //oInstPanel.sInternalURL = "";
            }
        }
Ejemplo n.º 5
0
        private void PSCode_Load(object sender, EventArgs e)
        {
            string sCurrentDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                ToolStripMenuItem tsm = new ToolStripMenuItem();
                if (string.IsNullOrEmpty(sAuthToken))
                {
                    sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken());
                }

                RZRestAPI.Token = sAuthToken;


                lAllSoftware = RZRestAPI.SWResults("");

                dataGridView1.DataSource = lAllSoftware.ToList().OrderBy(t => t.Shortname).ToList();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
Ejemplo n.º 6
0
        //public event ChangedEventHandler onEdit;

        public InstallSwPanel()
        {
            InitializeComponent();
            tSearch.Elapsed  += TSearch_Elapsed;
            tSearch.Enabled   = false;
            tSearch.AutoReset = false;

            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                if (string.IsNullOrEmpty(sAuthToken))
                {
                    sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken());
                }

                RZRestAPI.Token = sAuthToken;

                RZScan oSCAN = new RZScan(false, false);

                Task.Run(() => oSCAN.GetSWRepository()).Wait();

                lAllSoftware = oSCAN.SoftwareRepository;

                List <GetSoftware>       oDBCat = new List <GetSoftware>();
                PropertyGroupDescription PGD    = new PropertyGroupDescription("", new ShortnameToCategory());

                foreach (GetSoftware oSW in oSCAN.SoftwareRepository)
                {
                    try
                    {
                        if (oSW.Categories.Count > 1)
                        {
                            foreach (string sCAT in oSW.Categories)
                            {
                                try
                                {
                                    //Check if SW is already installed
                                    if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName & t.ProductVersion == oSW.ProductVersion) != null)
                                    {
                                        GetSoftware oNew = new GetSoftware()
                                        {
                                            Categories = new List <string> {
                                                sCAT
                                            }, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = true
                                        };
                                        oDBCat.Add(oNew);
                                    }
                                    else
                                    {
                                        GetSoftware oNew = new GetSoftware()
                                        {
                                            Categories = new List <string> {
                                                sCAT
                                            }, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = false
                                        };
                                        oDBCat.Add(oNew);
                                    }
                                }
                                catch { }
                            }
                        }
                        else
                        {
                            //Check if SW is already installed
                            if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName & t.ProductVersion == oSW.ProductVersion) != null)
                            {
                                oDBCat.Add(new GetSoftware()
                                {
                                    Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = true
                                });
                            }
                            else
                            {
                                oDBCat.Add(new GetSoftware()
                                {
                                    Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = false
                                });
                            }
                        }
                    }
                    catch { }
                }

                ListCollectionView lcv = new ListCollectionView(oDBCat.ToList());

                foreach (var o in RZRestAPI.GetCategories(oSCAN.SoftwareRepository))
                {
                    PGD.GroupNames.Add(o);
                }

                lcv.GroupDescriptions.Add(PGD);

                lvSW.ItemsSource = lcv;
            }
            catch { }
            Mouse.OverrideCursor = null;
        }