// Retrieves a list of supported services from a hard coded list. // This is then return so ythe UI can be updated. // TODO: poss move to Device Helper class? public async Task <List <NamedGuid> > PopulateSupportedServices() { // Initalise empty collection of named Guid's List <NamedGuid> services = new List <NamedGuid>(); try { // Get current service using the current device id var service = await GetService(); // Itterate through the list of availible services checking the number of // possible characteristics, if there is more than 1, add it to the list to be returned. for (int i = 0; i < Utils.ServiceHandler.GetTotalGuid(); i++) { NamedGuid guid = Utils.ServiceHandler.GetGuid(i); var characteristic = service.GetCharacteristics(guid.Guid); if (characteristic.Count > 0) { services.Add(guid); } } } catch (Exception ex) { MessageHelper.DisplayBasicMessage(ex.Message); } // Return a list of Named Guid objects which have more then 0 characteristics return(services); }
// Return a list of Characteristics from a service, and return a list to be displayed on the UI. public async Task <List <GattCharacteristic> > GetCharacteristics(NamedGuid guid) { // Initalise empty collection of GattCharacteristic objects. List <GattCharacteristic> characteristics = new List <GattCharacteristic>(); // Set this selected service value to the value recieved from the UI so it can be used later. this.SelectedService = guid; try { // Get current service using the current device id var service = await GetService(); // Get a list of characteristics from the service and add them to the charateristics list. var characteristic = service.GetCharacteristics(guid.Guid); foreach (var item in characteristic) { characteristics.Add(item); } } catch (Exception e) { MessageHelper.DisplayBasicMessage(StringResources.CharacteristicsError + " : " + e.Message); } // return list to be displayed on the UI. return(characteristics); }
// Return a list of Characteristics from a service, and return a list to be displayed on the UI. public async Task<List<GattCharacteristic>> GetCharacteristics(NamedGuid guid) { // Initalise empty collection of GattCharacteristic objects. List<GattCharacteristic> characteristics = new List<GattCharacteristic>(); // Set this selected service value to the value recieved from the UI so it can be used later. this.SelectedService = guid; try { // Get current service using the current device id var service = await GetService(); // Get a list of characteristics from the service and add them to the charateristics list. var characteristic = service.GetCharacteristics(guid.Guid); foreach (var item in characteristic) { characteristics.Add(item); } } catch (Exception e) { MessageHelper.DisplayBasicMessage(StringResources.CharacteristicsError+ " : " + e.Message); } // return list to be displayed on the UI. return characteristics; }
// Handle the user selecting a service private void ServiceList_SelectionChanged(object sender, SelectionChangedEventArgs e) { NamedGuid selected = this.possibleServiceList.SelectedItem as NamedGuid; if (selected != null) { // Send reference of selected item to the viewmodel to be processed. this.viewmodel.HandleSelectedService(selected); } }
// Handle the event from the user selecting a service. internal async void HandleSelectedService(NamedGuid selected) { this.SelectedDeviceViewModel.CleanCharacteristics(); // Get a list of supported characteristics and updat the viewmodel with the results. this.SelectedDeviceViewModel.SupportedCharacteristics = await this.selectedDevice.GetCharacteristics(selected); // Let the UI know that data has changed.. this.RaisePropertyChanged("SelectedDeviceViewModel"); }
public static string Compute(long accountId, string userId) { var accountIdAsString = accountId.ToString(); var vwoNamespaceGuid = Identifiable.NamedGuid.Compute(NamedGuidAlgorithm.SHA1, UrlNamespace, VWO_NAMESPACE_URL); var accountIdGuid = NamedGuid.Compute(NamedGuidAlgorithm.SHA1, vwoNamespaceGuid, accountIdAsString); var userIdGuid = NamedGuid.Compute(NamedGuidAlgorithm.SHA1, accountIdGuid, userId); var uuid = userIdGuid.ToString(GUID_FORMAT).ToUpper(); LogDebugMessage.UuidForUser(file, userId, accountId, uuid); return(uuid); }
// Checks to make sure the selected device type cannot be a null value. public void SetSelectedDevice(NamedGuid selected) { // if the value has a relevent value, set the selectedDeviceType. If this is not the case display an error. if (selected != null) { this.selectedDeviceType = selected; } else { MessageHelper.DisplayBasicMessage(StringResources.InitialisationError); } }
// Handle the changed event of the supported device types. private void SupportedTypesList_SelectionChanged(object sender, SelectionChangedEventArgs e) { NamedGuid selected = this.DeviceSelector.SelectedItem as NamedGuid; if (selected != null) { // Send reference of selected item to the viewmodel to be processed. this.viewmodel.SetSelectedDevice(selected); } else { MessageHelper.DisplayBasicMessage(StringResources.DeviceUnAvailable); } }
public void SecurityServiceBase_Read_ReadPermissionsResultIsNotNull_PermissionsUpdated() { //------------Setup for test-------------------------- var perms1 = new List <WindowsGroupPermission> { new WindowsGroupPermission(), new WindowsGroupPermission() }; var perms2 = new List <WindowsGroupPermission> { new WindowsGroupPermission { ResourceName = "Permission1" }, new WindowsGroupPermission { ResourceName = "Permission2" }, new WindowsGroupPermission { ResourceName = "Permission3" }, }; var overrideResource = new NamedGuid { Name = "Workflow", Value = new Guid() }; var securityServiceBase = new TestSecurityServiceBase { ReadPermissionsResults = perms1, OverrideResource = overrideResource }; securityServiceBase.Read(); Assert.AreEqual(perms1.Count, securityServiceBase.Permissions.Count); securityServiceBase.ReadPermissionsResults = perms2; //------------Execute Test--------------------------- securityServiceBase.Read(); //------------Assert Results------------------------- Assert.AreEqual(perms2.Count, securityServiceBase.Permissions.Count); for (int i = 0; i < perms2.Count; i++) { Assert.AreEqual(perms2[i].ResourceName, securityServiceBase.Permissions[i].ResourceName); } }
private INamedGuid InitializeOverrideResource(INamedGuid securitySettingsOverrideResource) { if (securitySettingsOverrideResource != null) { var resource = new NamedGuid { Value = securitySettingsOverrideResource.Value, Name = securitySettingsOverrideResource.Name }; RegisterOverrideResourcePropertyChanged(resource); return(resource); } return(new NamedGuid { Name = "", Value = Guid.Empty }); }
//中島追加 public async void DeviceSetter() { try { //デバイスUUIDを取得 NamedGuid dHelperLightBlueBean = DeviceHelper.GetGuid("LightBlue Bean"); //該当するデバイスを列挙 dInfoLightBlueBean = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(dHelperLightBlueBean.Guid)); // Devices.Clear(); for (int cnt = 0; cnt < dInfoLightBlueBean.Count; cnt++) { Devices.Add(new DeviceMember(cnt, dInfoLightBlueBean[cnt].Name)); } this.RaisePropertyChanged("DeviceMember"); } catch { MessageHelper.DisplayBasicMessage("センサとペアリングされていますか?"); } }
public void JwtManager_GenerateToken_ValidateToken() { //------------Setup for test------------------------- if (File.Exists(EnvironmentVariables.ServerSecuritySettingsFile)) { File.Delete(EnvironmentVariables.ServerSecuritySettingsFile); } var resourceId = Guid.NewGuid(); var resourceName = @"Hello World"; var overrideResource = new NamedGuid { Name = "appAuth", Value = Guid.NewGuid() }; var permissions = new[] { new WindowsGroupPermission { IsServer = true, WindowsGroup = "Deploy Admins", View = false, Execute = false, Contribute = false, DeployTo = true, DeployFrom = true, Administrator = false }, new WindowsGroupPermission { ResourceID = resourceId, ResourceName = "Category1\\Workflow1", WindowsGroup = "Public", View = true, Execute = true, Contribute = false } }; var hmac = new HMACSHA256(); var secretKey = Convert.ToBase64String(hmac.Key); var securitySettingsTO = new SecuritySettingsTO(permissions, overrideResource, secretKey); SecurityWrite.Write(securitySettingsTO); var payload = "<DataList><UserGroups Description='' IsEditable='True' ColumnIODirection='Output'><Name Description='' IsEditable='True' ColumnIODirection='Output'>public</Name></UserGroups></DataList>"; var res = new Mock <IResource>(); res.Setup(a => a.ResourceName).Returns(resourceName); res.Setup(resource => resource.ResourceID).Returns(resourceId); var mockCatalog = new Mock <IResourceCatalog>(); mockCatalog.Setup(a => a.GetResource(It.IsAny <Guid>(), resourceId)).Returns(res.Object); mockCatalog.Setup(a => a.GetResourcePath(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns("bob\\dave"); CustomContainer.Register(mockCatalog.Object); var mockResourceNameProvider = new Mock <IResourceNameProvider>(); mockResourceNameProvider.Setup(a => a.GetResourceNameById(It.IsAny <Guid>())).Returns(resourceName); CustomContainer.Register(mockResourceNameProvider.Object); //------------Execute Test--------------------------- var securitySettings = new SecuritySettings(); var jwtManager = new JwtManager(securitySettings); var encryptedPayload = jwtManager.GenerateToken(payload); var response = jwtManager.ValidateToken(encryptedPayload); //------------Assert Results------------------------- Assert.IsNotNull(encryptedPayload); Assert.AreEqual(payload, response); }
public SecuritySettingsTO() { WindowsGroupPermissions = new List <WindowsGroupPermission>(); AuthenticationOverrideWorkflow = new NamedGuid(); SecretKey = ""; }