internal VirtualMachineData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, ComputePlan plan, IReadOnlyList <VirtualMachineExtensionData> resources, ManagedServiceIdentity identity, IList <string> zones, Models.ExtendedLocation extendedLocation, HardwareProfile hardwareProfile, StorageProfile storageProfile, AdditionalCapabilities additionalCapabilities, OSProfile osProfile, NetworkProfile networkProfile, SecurityProfile securityProfile, DiagnosticsProfile diagnosticsProfile, WritableSubResource availabilitySet, WritableSubResource virtualMachineScaleSet, WritableSubResource proximityPlacementGroup, VirtualMachinePriorityTypes?priority, VirtualMachineEvictionPolicyTypes?evictionPolicy, BillingProfile billingProfile, WritableSubResource host, WritableSubResource hostGroup, string provisioningState, VirtualMachineInstanceView instanceView, string licenseType, string vmId, string extensionsTimeBudget, int?platformFaultDomain, ScheduledEventsProfile scheduledEventsProfile, string userData, CapacityReservationProfile capacityReservation, ApplicationProfile applicationProfile) : base(id, name, resourceType, systemData, tags, location) { Plan = plan; Resources = resources; Identity = identity; Zones = zones; ExtendedLocation = extendedLocation; HardwareProfile = hardwareProfile; StorageProfile = storageProfile; AdditionalCapabilities = additionalCapabilities; OSProfile = osProfile; NetworkProfile = networkProfile; SecurityProfile = securityProfile; DiagnosticsProfile = diagnosticsProfile; AvailabilitySet = availabilitySet; VirtualMachineScaleSet = virtualMachineScaleSet; ProximityPlacementGroup = proximityPlacementGroup; Priority = priority; EvictionPolicy = evictionPolicy; BillingProfile = billingProfile; Host = host; HostGroup = hostGroup; ProvisioningState = provisioningState; InstanceView = instanceView; LicenseType = licenseType; VmId = vmId; ExtensionsTimeBudget = extensionsTimeBudget; PlatformFaultDomain = platformFaultDomain; ScheduledEventsProfile = scheduledEventsProfile; UserData = userData; CapacityReservation = capacityReservation; ApplicationProfile = applicationProfile; }
internal VirtualMachineScaleSetVmData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string instanceId, Models.Sku sku, Models.Plan plan, IReadOnlyList <VirtualMachineExtensionData> resources, IReadOnlyList <string> zones, bool?latestModelApplied, string vmId, VirtualMachineScaleSetVmInstanceView instanceView, HardwareProfile hardwareProfile, StorageProfile storageProfile, AdditionalCapabilities additionalCapabilities, OSProfile osProfile, SecurityProfile securityProfile, NetworkProfile networkProfile, VirtualMachineScaleSetVmNetworkProfileConfiguration networkProfileConfiguration, DiagnosticsProfile diagnosticsProfile, WritableSubResource availabilitySet, string provisioningState, string licenseType, string modelDefinitionApplied, VirtualMachineScaleSetVmProtectionPolicy protectionPolicy, string userData) : base(id, name, type, systemData, tags, location) { InstanceId = instanceId; Sku = sku; Plan = plan; Resources = resources; Zones = zones; LatestModelApplied = latestModelApplied; VmId = vmId; InstanceView = instanceView; HardwareProfile = hardwareProfile; StorageProfile = storageProfile; AdditionalCapabilities = additionalCapabilities; OSProfile = osProfile; SecurityProfile = securityProfile; NetworkProfile = networkProfile; NetworkProfileConfiguration = networkProfileConfiguration; DiagnosticsProfile = diagnosticsProfile; AvailabilitySet = availabilitySet; ProvisioningState = provisioningState; LicenseType = licenseType; ModelDefinitionApplied = modelDefinitionApplied; ProtectionPolicy = protectionPolicy; UserData = userData; }
public void List_of_strings() { var data = new SecurityProfile(); data.AddSecurityId("t1"); var sut = new ShadowCopier(); var result = sut.Copy(data); Assert.IsTrue(new Comparer().AreEqual(data, result)); }
public void Hydrate_slightly_complex_object() { var data = new SecurityProfile(); data.AddSecurityId("t1"); using (var session = Database.CreateSession()) { session.Add(data); session.Commit(); } SecurityProfile actual; using (var session = Database.CreateSession()) { actual = session.GetById <SecurityProfile>(data.Id); } Assert.IsTrue(data.SecruityIds.All(x => actual.SecruityIds.Contains(x))); }
public async override Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(actionContext.Request.Headers.Authorization?.Scheme) || string.IsNullOrEmpty(actionContext.Request.Headers.Authorization.Parameter) || !actionContext.Request.Headers.Authorization.Scheme.Equals("Bearer") || !await SecurityCache.IsValid(actionContext.Request.Headers.Authorization.Parameter)) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); return; } SecurityProfile securityProfile = SecurityCache.Get(actionContext.Request.Headers.Authorization.Parameter); if (securityProfile == null || !RequiredPermissions.All(permission => securityProfile.Permissions.Contains(permission))) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Forbidden); } actionContext.Request.Properties.Add("SecurityProfile", securityProfile); }
protected override bool PostSave(ITransaction transaction) { if (IsInsert && RevokeTime == null) // Is insert, not revoking { SecurityProfile securityProfile = new SecurityProfile(); securityProfile.AccessToken = AccessToken.ToString(); securityProfile.Expiration = Expiration.Value; securityProfile.UserID = UserID.Value; User user = DataObject.GetReadOnlyByPrimaryKey <User>(UserID, transaction, new string[] { "UserPermissions.Permission.Key" }); securityProfile.Permissions.AddRange(user.UserPermissions.Select(up => up.Permission.Key)); SecurityCache.AddSecurityProfile(securityProfile); } if (IsFieldDirty("RevokeTime") && RevokeTime != null) { SecurityCache.Revoke(AccessToken.ToString()); } return(base.PostSave(transaction)); }
public void ApplyConfiguration(SecurityProfile profileConfiguration) { if (profileConfiguration == null) throw new ArgumentNullException("profileConfiguration"); var profileType = profileConfiguration.GetType(); if (_profiles.Any(pi => pi.Type == profileType)) return; var profileImport = new ProfileImport(profileType); _profiles.Add(profileImport); profileConfiguration.Initialize(this); profileConfiguration.Configure(); profileImport.MarkCompleted(); }
/// <summary> /// Creates a new policy object. /// </summary> private static Opc.Ua.Security.SecurityProfile CreateProfile(string profileUri) { Opc.Ua.Security.SecurityProfile policy = new SecurityProfile(); policy.ProfileUri = profileUri; policy.Enabled = false; return policy; }