public async Task <IActionResult> DeleteAsync(DeleteConfigurationViewModel model)
        {
            if (model == null || model.UID == Guid.Empty)
            {
                return(Json(new { error = $"{GlobalConstants.ERROR_ACTION_PREFIX} delete {ENTITY_NAME}." }));
            }

            ConfigurationResponse _ConfigurationResponse = await __ConfigurationManager.GetByUIDAsync(model.UID);

            if (!_ConfigurationResponse.Success)
            {
                return(Json(new { error = $"{GlobalConstants.ERROR_ACTION_PREFIX} delete {ENTITY_NAME}." }));
            }
            else if (model.VerificationName != _ConfigurationResponse.Name)
            {
                ModelState.AddModelError("Error", "Incorrectly entered configuration name.");
                return(PartialView("_DeleteModal", model));
            }

            BaseResponse _DeleteResponse = await __ConfigurationManager.DeleteAsync(model.UID);

            if (!_DeleteResponse.Success)
            {
                return(Json(new { error = $"{GlobalConstants.ERROR_ACTION_PREFIX} delete {ENTITY_NAME}." }));
            }

            return(Json(new { success = $"{GlobalConstants.SUCCESS_ACTION_PREFIX} deleted {ENTITY_NAME}." }));
        }
		protected override void OnCreate (Bundle savedInstanceState) {
			base.OnCreate (savedInstanceState);

			// Set our view from the "main" layout resource
			this.SetContentView (Resource.Layout.movie_detail);

			// Create your application here
			var strConfig = this.Intent.Extras.GetString ("Configuration");
			var strSelectedMovie = this.Intent.Extras.GetString ("SelectedMovie");
			this.configuration = JsonConvert.DeserializeObject<ConfigurationResponse> (strConfig);
			this.movieDetail = JsonConvert.DeserializeObject<Movie> (strSelectedMovie);

			this.btnPlay = this.FindViewById<Button> (Resource.Id.movie_detail_btnPlay);
			this.btnPlay.Click += this.btnPlay_Click;
			this.btnFavorite = this.FindViewById<Button> (Resource.Id.movie_detail_btnFavorite);
			this.btnFavorite.Click += this.btnFavorite_Click;
			this.btnClose = this.FindViewById<ImageButton> (Resource.Id.movie_detail_close);
			this.btnClose.Click += this.btnClose_Click;
			this.txtTitle = this.FindViewById<TextView> (Resource.Id.movie_detail_txtTitle);
			this.txtReleaseDate = this.FindViewById<TextView> (Resource.Id.movie_detail_txtReleaseDate);
			this.ratingBar = this.FindViewById<RatingBar> (Resource.Id.movie_detail_ratingBar);
			this.txtVoteCount = this.FindViewById<TextView> (Resource.Id.movie_detail_txtVoteCount);
			this.txtOverview = this.FindViewById<TextView> (Resource.Id.movie_detail_txtOverview);
			this.imgPoster = this.FindViewById<ImageView> (Resource.Id.movie_detail_imgPoster);
			this.vwSimilarMovies = this.FindViewById<RelativeLayout> (Resource.Id.movie_detail_vwSimilarMovies);
			this.movieList = this.FindViewById<RecyclerView>(Resource.Id.movie_detail_lstSimilarMovies);
			this.movieLayoutManager = new LinearLayoutManager (this, LinearLayoutManager.Horizontal, false);
			this.movieList.SetLayoutManager (this.movieLayoutManager);

			this.updateLayout ();
		}
		public void Bind (MovieCategory data, ConfigurationResponse configuration, Action<Movie> selectionAction) {
			this.category = data;
			this.configuration = configuration;
			this.selectionAction = selectionAction;

			this.lblCategoryName.Text = this.category.CategoryName;
			this.collectionViewSource = new MovieCollectionViewSource (this.category.Movies, this.configuration);
			this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected;
			Data.Current.FavoriteChanged += this.favoriteChanged;
			this.longPressRecognizer = new UILongPressGestureRecognizer (() => {
				if (this.longPressRecognizer.NumberOfTouches > 0) {
					var point = this.longPressRecognizer.LocationOfTouch (0, this.cvMovies);
					var indexPath = this.cvMovies.IndexPathForItemAtPoint (point);
					if (indexPath != null) {
						var cell = this.cvMovies.CellForItem (indexPath) as MovieCollectionViewCell;
						if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) {
							cell.SetHighlighted (true, true);
						} else if (this.longPressRecognizer.State == UIGestureRecognizerState.Ended) {
							cell.SetHighlighted (false, true, () => {
								var movie = this.category.Movies [indexPath.Row];
								Data.Current.ToggleFavorite (movie);
							});
						}
					} else {
						foreach (MovieCollectionViewCell cell in this.cvMovies.VisibleCells)
							cell.SetHighlighted (false, false);
					}
				} 
			});
			this.cvMovies.AddGestureRecognizer (this.longPressRecognizer);
			this.cvMovies.Source = this.collectionViewSource;
			this.cvMovies.ReloadData ();
		}
        /// <summary>
        /// Registers a tunnel, meaning creating a request to localtunnel to open up a subdomain and port to bridge to.
        /// </summary>
        private void RegisterTunnel()
        {
            string url = string.Format("http://{0}/", ServiceHost);

            try
            {
                _config = Web.DoPost <ConfigurationResponse>(url, new Dictionary <string, string>()
                {
                    { "key", PublicKey }
                });

                if (!string.IsNullOrEmpty(_config.error))
                {
                    throw new ServiceException(_config.error);
                }
            }
            catch (ArgumentException ae)
            {
                throw new ServiceException("Invalid server response: " + ae.Message);
            }

            Created = DateTime.Now;

            // Record the usage of the port.
            Port.AddUsage(LocalHost, LocalPort, ServiceHost);
        }
Exemple #5
0
        public async Task <IActionResult> StartLoanJobAsync()
        {
            IJobDetail _Job = JobBuilder.Create <LoanJob>()
                              .WithIdentity("loan", "elmsJobs")
                              .Build();

            if (await __Scheduler.CheckExists(_Job.Key))
            {
                return(RedirectToAction("Index", "Job", new { Area = "Admin", errorMessage = $"Already triggered Loan job scheduler." }));
            }

            ConfigurationResponse _IntervalResponse = await __ConfigurationManager.GetByNormalizedNameAsync(__Configuration.GetValue <string>("Configuration:General:SCHEDULED_EMAIL_INTERVAL"));

            if (int.TryParse(_IntervalResponse.Value, out int _IntervalHours))
            {
                ITrigger _Trigger = TriggerBuilder.Create()
                                    .WithIdentity("loanTrigger", "elmsJobs")
                                    .StartNow()
                                    .WithSimpleSchedule(x => x.WithIntervalInHours(_IntervalHours).RepeatForever())
                                    .Build();
                await __Scheduler.ScheduleJob(_Job, _Trigger);
            }
            else
            {
                ITrigger _Trigger = TriggerBuilder.Create()
                                    .WithIdentity("loanTrigger", "elmsJobs")
                                    .StartNow()
                                    .WithSimpleSchedule(x => x.WithIntervalInHours(DEFAULT_INTERVAL_HOURS).RepeatForever())
                                    .Build();
                await __Scheduler.ScheduleJob(_Job, _Trigger);
            }

            return(RedirectToAction("Index", "Job", new { Area = "Admin", successMessage = $"Successfully triggered Loan job scheduler." }));
        }
		public MovieRecyclerViewAdapter(Activity context, List<Movie> items, ConfigurationResponse configuration, bool isFavorites) : base() {
			this.isFavorites = isFavorites;
			this.context = context;
			this.configuration = configuration;
			this.movies = items;

		}
        private string ConfigureBaseUrlImage(ConfigurationResponse configuration)
        {
            string url = string.Empty;

            if (configuration.Images == null)
            {
                return(url);
            }

            url = configuration.Images.BaseUrl;
            string imageQuality = string.Empty;

            foreach (var quality in configuration.Images.BackdropSizes)
            {
                if (quality == Constans.DesiredQuality)
                {
                    imageQuality = quality;
                    break;
                }
            }

            if (imageQuality == string.Empty)
            {
                imageQuality = "original";
            }

            url += imageQuality;

            return(url);
        }
Exemple #8
0
        public async Task <ConfigurationResponse> Execute()
        {
            var absoluteUriWithVirtualPath = _hostingProvider.GetAbsoluteUriWithVirtualPath();
            var result = new ConfigurationResponse
            {
                Version = "1.0",
                Issuer  = absoluteUriWithVirtualPath,
                PatProfilesSupported        = _patsupportedProfiles,
                AatProfilesSupported        = _aatsupportedProfiles,
                RptProfilesSupported        = _bearerRptProfiles,
                PatGrantTypesSupported      = _patGrantTypesSupported,
                AatGrantTypesSupported      = _aatGrantTypesSupported,
                ClaimTokenProfilesSupported = new List <string>(),
                UmaProfilesSupported        = _umaProfilesSupported,
                DynamicClientEndPoint       = await _configurationService.GetRegisterOperation(),
                TokenEndPoint                   = await _configurationService.GetTokenOperation(),
                AuthorizationEndPoint           = await _configurationService.GetAuthorizationOperation(),
                RequestingPartyClaimsEndPoint   = string.Empty,
                IntrospectionEndPoint           = absoluteUriWithVirtualPath + IntrospectionApi,
                ResourceSetRegistrationEndPoint = absoluteUriWithVirtualPath + ResourceSetApi,
                PermissionRegistrationEndPoint  = absoluteUriWithVirtualPath + PermissionApi,
                RptEndPoint    = absoluteUriWithVirtualPath + RptApi,
                PolicyEndPoint = absoluteUriWithVirtualPath + PolicyApi,
                ScopeEndPoint  = absoluteUriWithVirtualPath + ScopeApi
            };

            return(result);
        }
 public static void AbandonSettings()
 {
     client       = null;
     config       = null;
     appSettings  = null;
     lastResponse = null;
     serverKey    = null;
     clientKey    = null;
 }
Exemple #10
0
        private static void AssertConfigSectionEqual(ConfigurationResponse expected, ConfigurationResponse actual)
        {
            actual.AdditionalFiles.Should().BeEquivalentTo(expected.AdditionalFiles, "Additional files differ");

            RuleSet expectedRuleSet = TestRuleSetHelper.XmlToRuleSet(expected.RuleSet.OuterXml);
            RuleSet actualRuleSet   = TestRuleSetHelper.XmlToRuleSet(actual.RuleSet.OuterXml);

            RuleSetAssert.AreEqual(expectedRuleSet, actualRuleSet, "Rule sets differ");
        }
 public static void AbandonSettings()
 {
     client = null;
     config = null;
     appSettings = null;
     lastResponse = null;
     serverKey = null;
     clientKey = null;
 }
        public async Task <ConfigurationResponse> GetConfigAsync(string fileName)
        {
            var result = new ConfigurationResponse();

            using (FileStream fs = File.OpenRead(GlobalConfig.AppFile(fileName)))
            {
                result.SolBotConfig = await JsonSerializer.DeserializeAsync <Solbot>(fs, _options);
            }

            return(result);
        }
Exemple #13
0
        private static void EdgeConfigurationTests(WebClient webClient)
        {
            // Download the configuration.
            File.Delete("Config.tar.gz");
            ConfigurationDownloadPrepareResponse configurationDownloadResponse = webClient.ConfigurationDownloadPrepare();

            webClient.ConfigurationDownload("Config.tar.gz");

            // Restore the configuration.
            ConfigurationResponse configurationRestoreResponse = webClient.ConfigurationRestore("Config.tar.gz");
        }
        public IActionResult Index()
        {
            var issuer = Request.GetAbsoluteUriWithVirtualPath();
            var result = new ConfigurationResponse
            {
                ProjectsEndpoint   = $"{issuer}/{Constants.Routes.ProjectsController}",
                ConnectorsEndpoint = $"{issuer}/{Constants.Routes.ConnectorsController}"
            };

            return(new OkObjectResult(result));
        }
		private async void create () {
			this.configuration = await Data.Current.GetConfigurationAsync ();
			this.categories = await Data.Current.GetMoviesByCategoryAsync ();
//			this.spotlightMovies = await Data.Current.GetSpotlightMoviesAsync ();

			if (this.categoryList.GetLayoutManager () == null)
				this.categoryList.SetLayoutManager (new LinearLayoutManager (this, LinearLayoutManager.Vertical, false));
		
			if (this.categoryList.GetAdapter () == null) 
				this.categoryList.SetAdapter (new MovieCategoryRecyclerViewAdapter (this, this.categories, this.configuration));
		}
        public static string GetCurrentAppName()
        {
            if (!string.IsNullOrEmpty(currentAppName))
            {
                return(currentAppName);
            }

            Init();
            lastResponse   = client.GetApplicationName(serverKey.EncryptWithPublicKey(config.ApplicationHash));
            currentAppName = lastResponse.ApplicationName;
            return(currentAppName);
        }
        public ActionResult Get()
        {
            var issuer        = Request.GetAbsoluteUriWithVirtualPath();
            var configuration = new ConfigurationResponse
            {
                Version = "2.1",
                HierarchicalresourcesEdp = $"{issuer}/{Constants.RouteNames.HierarchicalResourcesController}",
                ElfinderEdp = $"{issuer}/{Constants.RouteNames.ElFinterController}"
            };

            return(new OkObjectResult(configuration));
        }
        public ActionResult Get()
        {
            var absoluteUrl = HttpContext.Request.GetAbsoluteUriWithVirtualPath().TrimEnd('/');
            var result      = new ConfigurationResponse
            {
                AuthProviderEndPoint   = absoluteUrl + '/' + Constants.RouteValues.AuthProvider,
                SettingEndPoint        = absoluteUrl + '/' + Constants.RouteValues.Setting,
                RepresentationEndPoint = absoluteUrl + "/" + Constants.RouteValues.Representations
            };

            return(new OkObjectResult(result));
        }
		public override void PrepareForReuse () {
			if (this.collectionViewSource != null)
				this.collectionViewSource.MovieSelected -= this.collectionViewSource_MovieSelected;
			Data.Current.FavoriteChanged -= this.favoriteChanged;
			this.collectionViewSource = null;
			this.category = null;
			this.configuration = null;
			this.selectionAction = null;
			this.cvMovies.RemoveGestureRecognizer (this.longPressRecognizer);
			this.longPressRecognizer = null;

			base.PrepareForReuse ();
		}
        public async Task <ConfigurationResponse> SetConfigAsync(string fileName, Solbot solbot)
        {
            var result = new ConfigurationResponse();

            using (FileStream fs = File.Create(GlobalConfig.AppFile(fileName)))
            {
                await JsonSerializer.SerializeAsync(fs, solbot, options : _options);
            }

            result.WriteSuccess = true;

            return(result);
        }
        public static ConfigurationResponse SetValue(string key, string value)
        {
            Init();
            //RSAKeyPair serverKey = GetServerKey();
            string masterEncryptedAppHash = serverKey.EncryptWithPublicKey(config.ApplicationHash);
            //RSAKeyPair tempKey = new RSAKeyPair();
            //RijndaelKeyVectorPair clientKey = GetClientKey(masterEncryptedAppHash, tempKey);

            string encryptedKey = RijndaelEncryptor.Encrypt(key, clientKey.Base64Key, clientKey.Base64InitializationVector);
            string newValue     = RijndaelEncryptor.Encrypt(value, clientKey.Base64Key, clientKey.Base64InitializationVector);

            lastResponse = client.SetValue(masterEncryptedAppHash, encryptedKey, newValue);
            return(lastResponse);
        }
Exemple #22
0
        public ActionResult Get()
        {
            var version    = this.config.GetValue <string>("AppVersion");
            var trackingId = this.config.GetValue <string>("AnalyticsTrackingId");

            var config = new ConfigurationResponse {
                AppVersion          = version,
                AnalyticsTrackingId = trackingId
            };

            var result = Json(config);

            return(result);
        }
 private static RijndaelKeyVectorPair GetClientKey(string masterEncryptedAppHash, RSAKeyPair tempKey)
 {
     if (clientKey == null)
     {
         ConfigurationResponse clientKeyResponse = client.GetClientKey(masterEncryptedAppHash, tempKey.PublicKeyXml);
         clientKey = clientKeyResponse.ClientKey;
         if (clientKey != null)
         {
             clientKey.Base64InitializationVector = tempKey.DecryptWithPrivateKey(clientKey.Base64InitializationVector);
             clientKey.Base64Key = tempKey.DecryptWithPrivateKey(clientKey.Base64Key);
         }
     }
     return(clientKey);
 }
        public async Task <IActionResult> EditViewAsync(Guid uid)
        {
            if (uid == Guid.Empty)
            {
                return(Json(new { message = $"{GlobalConstants.ERROR_ACTION_PREFIX} find {ENTITY_NAME}." }));
            }

            ConfigurationResponse _Response = await __ConfigurationManager.GetByUIDAsync(uid);

            if (!_Response.Success)
            {
                return(Json(new { message = $"{GlobalConstants.ERROR_ACTION_PREFIX} find {ENTITY_NAME}." }));
            }

            return(View("Edit", __Mapper.Map <UpdateConfigurationViewModel>(_Response)));
        }
        public IActionResult Get()
        {
            var issuer = Request.GetAbsoluteUriWithVirtualPath();
            var result = new ConfigurationResponse
            {
                ClaimsEndpoint         = issuer + Constants.EndPoints.Claims,
                ClientsEndpoint        = issuer + Constants.EndPoints.Clients,
                JweEndpoint            = issuer + Constants.EndPoints.Jwe,
                JwsEndpoint            = issuer + Constants.EndPoints.Jws,
                ManageEndpoint         = issuer + Constants.EndPoints.Manage,
                ResourceOwnersEndpoint = issuer + Constants.EndPoints.ResourceOwners,
                ScopesEndpoint         = issuer + Constants.EndPoints.Scopes
            };

            return(new OkObjectResult(result));
        }
        public async Task <IActionResult> CreateAsync(CreateConfigurationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewData["ErrorMessage"] = "Invalid form submission";
                return(PartialView("_CreateModal", model));
            }

            ConfigurationResponse _Response = await __ConfigurationManager.CreateAsync(__Mapper.Map <CreateConfigurationRequest>(model));

            if (!_Response.Success)
            {
                return(RedirectToAction("Index", "Configuration", new { area = "Admin", successMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} create {ENTITY_NAME}." }));
            }

            return(RedirectToAction("Index", "Configuration", new { area = "Admin", successMessage = $"{GlobalConstants.SUCCESS_ACTION_PREFIX} created {ENTITY_NAME}." }));
        }
        public void MustCorrectlyRetrieveConfiguration()
        {
            var response = new ConfigurationResponse
            {
                Configuration = new ClientConfiguration()
            };

            proxy.Setup(p => p.Send(It.Is <SimpleMessage>(m => m.Purport == SimpleMessagePurport.ConfigurationNeeded))).Returns(response);

            var communication = sut.GetConfiguration();
            var configuration = communication.Value.Configuration;

            proxy.Verify(p => p.Send(It.Is <SimpleMessage>(m => m.Purport == SimpleMessagePurport.ConfigurationNeeded)), Times.Once);

            Assert.IsTrue(communication.Success);
            Assert.IsInstanceOfType(configuration, typeof(ClientConfiguration));
        }
        private static RSAKeyPair GetServerKey()
        {
            if (serverKey == null)
            {
                serverKey = new RSAKeyPair();
                serverKey.PrivateKeyXml = string.Empty;
                ConfigurationResponse response = client.GetServerKey();
                if (response.Result == ConfigurationResult.Error)
                {
                    lastResponse = response;
                    return(null);
                }
                serverKey.PublicKeyXml = response.ServerKey;
            }

            return(serverKey);
        }
        public ConfigurationResponse GetConfiguration(string LookupType, string Login_Key, int UserId)
        {
            ConfigurationResponse objResponse = new ConfigurationResponse();

            if (!string.IsNullOrEmpty(Login_Key))
            {
                objResponse.configurations = db.Configurations.Where(x => x.Lookup_Type == LookupType && x.User_Id == UserId).ToList();
                objResponse.Message        = objResponse.configurations.Count + " Configuration setting found";
                objResponse.Status         = "1";
            }
            else
            {
                objResponse.configurations = null;
                objResponse.Message        = "Invalid login key";
                objResponse.Status         = "0";
            }
            return(objResponse);
        }
Exemple #30
0
        public void AddApplications(ConfigurationResponse configurationResponse)
        {
            appListBox.Items.Clear();

            foreach (Imi.Wms.Mobile.Server.Interface.Application app in configurationResponse.Applications)
            {
                appListBox.Items.Add(app.Name);
            }

            if (appListBox.Items.Count > 0)
            {
                appListBox.SelectedIndex = 0;
                startButton.Enabled      = true;
            }
            else
            {
                startButton.Enabled = false;
            }
        }
        public IActionResult GetConfiguration()
        {
            var issuer = Request.GetAbsoluteUriWithVirtualPath();
            var result = new ConfigurationResponse
            {
                ClaimTokenProfilesSupported  = new List <string>(),
                UmaProfilesSupported         = _umaProfilesSupported,
                ResourceRegistrationEndpoint = $"{issuer}{Constants.RouteValues.ResourceSet}",
                PermissionEndpoint           = $"{issuer}{Constants.RouteValues.Permission}",
                PoliciesEndpoint             = $"{issuer}{Constants.RouteValues.Policies}",
                Issuer = issuer,
                AuthorizationEndpoint = null,
                TokenEndpoint         = $"{issuer}{Constants.RouteValues.Token}",
                JwksUri = $"{issuer}{Constants.RouteValues.Jwks}",
                RegistrationEndpoint  = $"{issuer}{Constants.RouteValues.Registration}",
                IntrospectionEndpoint = $"{issuer}{Constants.RouteValues.Introspection}",
                RevocationEndpoint    = $"{issuer}{Constants.RouteValues.Token}/revoke",
                GrantTypesSupported   = new List <string>
                {
                    "authorization_code",
                    "implicit",
                    "refresh_token",
                    "client_credentials",
                    "password",
                    "uma_ticket"
                },
                TokenEndpointAuthSigningAlgValuesSupported = new List <string>
                {
                    "RS256"
                },
                TokenEndpointAuthMethodsSupported = new List <string>
                {
                    "client_secret_basic",
                    "client_secret_post",
                    "client_secret_jwt",
                    "private_key_jwt",
                    "tls_client_auth"
                }
            };

            return(new OkObjectResult(result));
        }
        private static void LoadLocalConfiguration()
        {
            if (!File.Exists(LocalConfigurationFile))
            {
                throw new NotFoundException(
                          "Local Configuration file not found: Object is null => " + ConfigurationResponse, "");
            }
            else
            {
                ConfigurationResponse =
                    JsonConvert.DeserializeObject <ConfigurationResponse>(File.ReadAllText(LocalConfigurationFile));

                if (ConfigurationResponse == null)
                {
                    throw new NotFoundException(
                              "Configuration Service: Object is null -- hint: check if local configuration file is deserializable => " +
                              ConfigurationResponse, "");
                }
            }
        }
        public async Task <IActionResult> DeleteModalAsync(Guid uid)
        {
            if (uid == Guid.Empty)
            {
                return(Json(new { message = $"{GlobalConstants.ERROR_ACTION_PREFIX} find {ENTITY_NAME}." }));
            }

            ConfigurationResponse _Response = await __ConfigurationManager.GetByUIDAsync(uid);

            if (!_Response.Success)
            {
                return(Json(new { message = $"{GlobalConstants.ERROR_ACTION_PREFIX} find {ENTITY_NAME}." }));
            }

            return(PartialView("_DeleteModal", new DeleteConfigurationViewModel
            {
                UID = uid,
                Name = _Response.Name,
                Value = _Response.Value
            }));
        }
Exemple #34
0
        public void MustCorrectlySetConfiguration()
        {
            var response = new ConfigurationResponse
            {
                Configuration = new ClientConfiguration
                {
                    AppConfig = new AppConfig(),
                    SessionId = Guid.NewGuid(),
                    Settings  = new Settings()
                }
            };

            runtime.Setup(r => r.GetConfiguration()).Returns(new CommunicationResult <ConfigurationResponse>(true, response));

            var result = sut.Perform();

            Assert.AreSame(configuration.AppConfig, response.Configuration.AppConfig);
            Assert.AreEqual(configuration.SessionId, response.Configuration.SessionId);
            Assert.AreSame(configuration.Settings, response.Configuration.Settings);
            Assert.AreEqual(OperationResult.Success, result);
        }
Exemple #35
0
        public void MustCorrectlyReceiveMessage()
        {
            var received              = false;
            var simpleReceived        = false;
            var message               = new ReconfigurationMessage(null, null);
            var configurationResponse = new ConfigurationResponse();

            sut.OnReceiveStub = (m) => { received = true; return(configurationResponse); };
            sut.OnReceiveSimpleMessageStub = (m) => { simpleReceived = true; return(null); };
            sut.OnConnectStub = (t) => { return(true); };
            sut.Connect();

            message.CommunicationToken = sut.GetCommunicationToken().Value;

            var response = sut.Send(message);

            Assert.IsTrue(received);
            Assert.IsFalse(simpleReceived);
            Assert.IsInstanceOfType(response, typeof(ConfigurationResponse));
            Assert.AreSame(configurationResponse, response);
        }
        public Task <ConfigurationResponse> Execute()
        {
            var absoluteUriWithVirtualPath = _hostingProvider.GetAbsoluteUriWithVirtualPath();
            var result = new ConfigurationResponse
            {
                ClaimTokenProfilesSupported  = new List <string>(),
                UmaProfilesSupported         = _umaProfilesSupported,
                ResourceRegistrationEndpoint = absoluteUriWithVirtualPath + ResourceSetApi,
                PermissionEndpoint           = absoluteUriWithVirtualPath + PermissionApi,
                PoliciesEndpoint             = absoluteUriWithVirtualPath + PolicyApi,
                // OAUTH2.0
                Issuer = absoluteUriWithVirtualPath,
                AuthorizationEndpoint = null,// absoluteUriWithVirtualPath + AuthorizationApi,
                TokenEndpoint         = absoluteUriWithVirtualPath + TokenApi,
                JwksUri = absoluteUriWithVirtualPath + JwksApi,
                RegistrationEndpoint  = absoluteUriWithVirtualPath + RegistrationApi,
                IntrospectionEndpoint = absoluteUriWithVirtualPath + IntrospectionApi,
                RevocationEndpoint    = absoluteUriWithVirtualPath + RevocationApi
            };

            return(Task.FromResult(result));
        }
        public static ConfigurationResponse SetValue(string key, string value)
        {
            Init();
            //RSAKeyPair serverKey = GetServerKey();
            string masterEncryptedAppHash = serverKey.EncryptWithPublicKey(config.ApplicationHash);
            //RSAKeyPair tempKey = new RSAKeyPair();
            //RijndaelKeyVectorPair clientKey = GetClientKey(masterEncryptedAppHash, tempKey);

            string encryptedKey = RijndaelEncryptor.Encrypt(key, clientKey.Base64Key, clientKey.Base64InitializationVector);
            string newValue = RijndaelEncryptor.Encrypt(value, clientKey.Base64Key, clientKey.Base64InitializationVector);

            lastResponse = client.SetValue(masterEncryptedAppHash, encryptedKey, newValue);
            return lastResponse;
        }
		private readonly int favoritesCategoryIndex = 4; // Wrong scope, put this somewhere else

		public MovieCategoryRecyclerViewAdapter(Activity context, List<MovieCategory> items, ConfigurationResponse configuration) : base() {
			this.context = context;
			this.configuration = configuration;
			this.categories = items;
		}
        public static string GetValue(string key, bool reload)
        {
            if (appSettings != null &&
                appSettings.ContainsKey(key) &&
                !reload)
            {
                return appSettings[key];
            }
            else
            {
                Init();

                string masterEncryptedAppHash = serverKey.EncryptWithPublicKey(config.ApplicationHash);
                //RSAKeyPair tempKey = new RSAKeyPair();
                //RijndaelKeyVectorPair clientKey = GetClientKey(masterEncryptedAppHash, tempKey);

                ConfigurationResponse valueResponse = client.GetValue(masterEncryptedAppHash, RijndaelEncryptor.Encrypt(key, clientKey.Base64Key, clientKey.Base64InitializationVector));

                string retVal = string.Empty;
                if( !string.IsNullOrEmpty(valueResponse.SettingValue) )
                    retVal = RijndaelEncryptor.Decrypt(valueResponse.SettingValue, clientKey.Base64Key, clientKey.Base64InitializationVector);

                if (appSettings.ContainsKey(key))
                {
                    appSettings[key] = retVal;
                }
                else
                {
                    appSettings.Add(key, retVal);
                }

                lastResponse = valueResponse;
                return retVal;
            }
        }
        private static RSAKeyPair GetServerKey()
        {
            if (serverKey == null)
            {
                serverKey = new RSAKeyPair();
                serverKey.PrivateKeyXml = string.Empty;
                ConfigurationResponse response = client.GetServerKey();
                if (response.Result == ConfigurationResult.Error)
                {
                    lastResponse = response;
                    return null;
                }
                serverKey.PublicKeyXml = response.ServerKey;
            }

            return serverKey;
        }
        /// <summary>
        /// Registers a tunnel, meaning creating a request to localtunnel to open up a subdomain and port to bridge to.
        /// </summary>
        private void RegisterTunnel()
        {
            string url = string.Format("http://{0}/", ServiceHost);

            try
            {
                _config = Web.DoPost<ConfigurationResponse>(url, new Dictionary<string, string>() { { "key", PublicKey } });

                if (!string.IsNullOrEmpty(_config.error))
                {
                    throw new ServiceException(_config.error);
                }
            }
            catch (ArgumentException ae)
            {
                throw new ServiceException("Invalid server response: " + ae.Message);
            }

            Created =  DateTime.Now;

            // Record the usage of the port.
            Port.AddUsage(LocalHost, LocalPort, ServiceHost);
        }
        public static string GetCurrentAppName()
        {
            if (!string.IsNullOrEmpty(currentAppName))
                return currentAppName;

            Init();
            lastResponse = client.GetApplicationName(serverKey.EncryptWithPublicKey(config.ApplicationHash));
            currentAppName = lastResponse.ApplicationName;
            return currentAppName;
        }