public void Remove_MultipleOccurences()
        {
            EncryptionPropertyCollection encPropertyCollection = new EncryptionPropertyCollection();

            for (int i = 0; i < 2; i++)
            {
                encPropertyCollection.Add(new EncryptionProperty());
            }
            EncryptionProperty multiple = new EncryptionProperty();

            for (int i = 0; i < 2; i++)
            {
                encPropertyCollection.Add(multiple);
            }
            encPropertyCollection.Remove(multiple);
            // Only the first occurence will be removed.
            Assert.Equal(3, encPropertyCollection.Count);
        }
        public void RemoveAt(int collectionSize, int removeIdx)
        {
            EncryptionPropertyCollection encPropertyCollection = new EncryptionPropertyCollection();
            EncryptionProperty           toRemove = null;

            for (int i = 0; i < collectionSize; i++)
            {
                EncryptionProperty property = new EncryptionProperty();
                encPropertyCollection.Add(property);

                if (i == removeIdx)
                {
                    toRemove = property;
                }
            }

            encPropertyCollection.RemoveAt(removeIdx);
            Assert.Equal(-1, encPropertyCollection.IndexOf(toRemove));
            Assert.Equal(collectionSize - 1, encPropertyCollection.Count);
        }
示例#3
0
        static void Main(string[] args)
        {
//<SNIPPET2>
            // Create a new CipherData object.
            CipherData cd = new CipherData();

            // Assign a byte array to be the CipherValue. This is a byte array representing encrypted data.
            cd.CipherValue = new byte[8];
//</SNIPPET2>
//<SNIPPET3>
            // Create a new EncryptedData object.
            EncryptedData ed = new EncryptedData();

//</SNIPPET3>
            //Add an encryption method to the object.
            ed.Id = "ED";
            ed.EncryptionMethod = new EncryptionMethod("http://www.w3.org/2001/04/xmlenc#aes128-cbc");
            ed.CipherData       = cd;

            //Add key information to the object.
            KeyInfo ki = new KeyInfo();

            ki.AddClause(new KeyInfoRetrievalMethod("#EK", "http://www.w3.org/2001/04/xmlenc#EncryptedKey"));
            ed.KeyInfo = ki;

            // Create new XML document and put encrypted data into it.
            XmlDocument        doc = new XmlDocument();
            XmlElement         encryptionPropertyElement = (XmlElement)doc.CreateElement("EncryptionProperty", EncryptedXml.XmlEncNamespaceUrl);
            EncryptionProperty ep = new EncryptionProperty(encryptionPropertyElement);

            ed.AddProperty(ep);

            // Output the resulting XML information into a file.
            string path = @"c:\test\MyTest.xml";

            File.WriteAllText(path, ed.GetXml().OuterXml);
            //Console.WriteLine(ed.GetXml().OuterXml);
        }
示例#4
0
        static void Main(string[] args)
        {
//<SNIPPET3>
//<SNIPPET1>
            // Create a new CipherData object using a byte array to represent encrypted data.
            Byte[]     sampledata = new byte[8];
            CipherData cd         = new CipherData(sampledata);
//</SNIPPET1>
            // Create a new EncryptedData object.
            EncryptedData ed = new EncryptedData();

            //Add an encryption method to the object.
            ed.Id = "ED";
            ed.EncryptionMethod = new EncryptionMethod("http://www.w3.org/2001/04/xmlenc#aes128-cbc");
            ed.CipherData       = cd;
//</SNIPPET3>
//<SNIPPET2>
            //Add key information to the object.
            KeyInfo ki = new KeyInfo();

            ki.AddClause(new KeyInfoRetrievalMethod("#EK", "http://www.w3.org/2001/04/xmlenc#EncryptedKey"));
            ed.KeyInfo = ki;
//</SNIPPET2>
            // Create new XML document and put encrypted data into it.
            XmlDocument        doc = new XmlDocument();
            XmlElement         encryptionPropertyElement = (XmlElement)doc.CreateElement("EncryptionProperty", EncryptedXml.XmlEncNamespaceUrl);
            EncryptionProperty ep = new EncryptionProperty(encryptionPropertyElement);

            ed.AddProperty(ep);

            // Output the resulting XML information into a file. Change the path variable to point to a directory where
            // the XML file should be written.
            string path = @"c:\test\MyTest.xml";

            File.WriteAllText(path, ed.GetXml().OuterXml);
        }
	public void AddProperty(EncryptionProperty ep) {}
示例#6
0
 public void AddProperty(EncryptionProperty ep)
 {
 }
	public bool Contains(EncryptionProperty value) {}
        public void LoadXml_Null()
        {
            EncryptionProperty encryptionProperty = new EncryptionProperty();

            Assert.Throws <ArgumentNullException>(() => encryptionProperty.LoadXml(null));
        }
示例#9
0
 public bool Contains(EncryptionProperty value)
 {
 }
示例#10
0
 public int Add(EncryptionProperty value)
 {
 }
	public int Add(EncryptionProperty value) {}
	public void CopyTo(EncryptionProperty[] array, int index) {}
	public void Remove(EncryptionProperty value) {}
	public void Insert(int index, EncryptionProperty value) {}
	public int IndexOf(EncryptionProperty value) {}
示例#16
0
 internal MachineLearningWorkspaceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagedServiceIdentity identity, AzureLocation?location, IDictionary <string, string> tags, MachineLearningSku sku, string workspaceId, string description, string friendlyName, string keyVault, string applicationInsights, string containerRegistry, string storageAccount, Uri discoveryUri, ProvisioningState?provisioningState, EncryptionProperty encryption, bool?hbiWorkspace, string serviceProvisionedResourceGroup, int?privateLinkCount, string imageBuildCompute, bool?allowPublicAccessWhenBehindVnet, PublicNetworkAccess?publicNetworkAccess, IReadOnlyList <MachineLearningPrivateEndpointConnectionData> privateEndpointConnections, IList <SharedPrivateLinkResource> sharedPrivateLinkResources, NotebookResourceInfo notebookInfo, ServiceManagedResourcesSettings serviceManagedResourcesSettings, string primaryUserAssignedIdentity, Guid?tenantId, bool?storageHnsEnabled, Uri mlFlowTrackingUri) : base(id, name, resourceType, systemData)
 {
     Identity                        = identity;
     Location                        = location;
     Tags                            = tags;
     Sku                             = sku;
     WorkspaceId                     = workspaceId;
     Description                     = description;
     FriendlyName                    = friendlyName;
     KeyVault                        = keyVault;
     ApplicationInsights             = applicationInsights;
     ContainerRegistry               = containerRegistry;
     StorageAccount                  = storageAccount;
     DiscoveryUri                    = discoveryUri;
     ProvisioningState               = provisioningState;
     Encryption                      = encryption;
     HbiWorkspace                    = hbiWorkspace;
     ServiceProvisionedResourceGroup = serviceProvisionedResourceGroup;
     PrivateLinkCount                = privateLinkCount;
     ImageBuildCompute               = imageBuildCompute;
     AllowPublicAccessWhenBehindVnet = allowPublicAccessWhenBehindVnet;
     PublicNetworkAccess             = publicNetworkAccess;
     PrivateEndpointConnections      = privateEndpointConnections;
     SharedPrivateLinkResources      = sharedPrivateLinkResources;
     NotebookInfo                    = notebookInfo;
     ServiceManagedResourcesSettings = serviceManagedResourcesSettings;
     PrimaryUserAssignedIdentity     = primaryUserAssignedIdentity;
     TenantId                        = tenantId;
     StorageHnsEnabled               = storageHnsEnabled;
     MlFlowTrackingUri               = mlFlowTrackingUri;
 }
示例#17
0
        public void PropertyElement_Set_Null()
        {
            EncryptionProperty encryptionProperty = new EncryptionProperty();

            Assert.Throws <ArgumentNullException>(() => encryptionProperty.PropertyElement = null);
        }
示例#18
0
 public int IndexOf(EncryptionProperty value)
 {
 }
示例#19
0
    public static void Encrypt(XmlDocument Doc, string ElementToEncrypt, RSA Alg, string KeyName)
    {
        // Check the arguments.
        if (Doc == null)
        {
            throw new ArgumentNullException("Doc");
        }
        if (ElementToEncrypt == null)
        {
            throw new ArgumentNullException("ElementToEncrypt");
        }
        if (Alg == null)
        {
            throw new ArgumentNullException("Alg");
        }

        ////////////////////////////////////////////////
        // Find the specified element in the XmlDocument
        // object and create a new XmlElemnt object.
        ////////////////////////////////////////////////

        XmlElement elementToEncrypt = Doc.GetElementsByTagName(ElementToEncrypt)[0] as XmlElement;

        // Throw an XmlException if the element was not found.
        if (elementToEncrypt == null)
        {
            throw new XmlException("The specified element was not found");
        }

        //////////////////////////////////////////////////
        // Create a new instance of the EncryptedXml class
        // and use it to encrypt the XmlElement with the
        // a new random symmetric key.
        //////////////////////////////////////////////////

        // Create a 256 bit Rijndael key.
        RijndaelManaged sessionKey = new RijndaelManaged();

        sessionKey.KeySize = 256;

        EncryptedXml eXml = new EncryptedXml();

        byte[] encryptedElement = eXml.EncryptData(elementToEncrypt, sessionKey, false);

        ////////////////////////////////////////////////
        // Construct an EncryptedData object and populate
        // it with the desired encryption information.
        ////////////////////////////////////////////////


        EncryptedData edElement = new EncryptedData();

        edElement.Type = EncryptedXml.XmlEncElementUrl;

        // Create an EncryptionMethod element so that the
        // receiver knows which algorithm to use for decryption.

        edElement.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncAES256Url);

        // Encrypt the session key and add it to an EncryptedKey element.
        EncryptedKey ek = new EncryptedKey();

        byte[] encryptedKey = EncryptedXml.EncryptKey(sessionKey.Key, Alg, false);

        ek.CipherData = new CipherData(encryptedKey);

        ek.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncRSA15Url);

        // Save some more information about the key using
        // the EncryptionProperty element.  In this example,
        // we will save the value "LibVersion1".  You can save
        // anything you want here.

        // Create a new "EncryptionProperty" XmlElement object.
        XmlElement element = new XmlDocument().CreateElement("EncryptionProperty", EncryptedXml.XmlEncNamespaceUrl);

        // Set the value of the EncryptionProperty" XmlElement object.
        element.InnerText = "LibVersion1";

        // Create the EncryptionProperty object using the XmlElement object.
        EncryptionProperty encProp = new EncryptionProperty(element);

        // Add the EncryptionProperty object to the EncryptedData object.
        edElement.AddProperty(encProp);

        // Set the KeyInfo element to specify the
        // name of the RSA key.

        // Create a new KeyInfo element.
        edElement.KeyInfo = new KeyInfo();

        // Create a new KeyInfoName element.
        KeyInfoName kin = new KeyInfoName();

        // Specify a name for the key.
        kin.Value = KeyName;

        // Add the KeyInfoName element to the
        // EncryptedKey object.
        ek.KeyInfo.AddClause(kin);

        // Add the encrypted key to the
        // EncryptedData object.

        edElement.KeyInfo.AddClause(new KeyInfoEncryptedKey(ek));

        // Add the encrypted element data to the
        // EncryptedData object.
        edElement.CipherData.CipherValue = encryptedElement;

        ////////////////////////////////////////////////////
        // Replace the element from the original XmlDocument
        // object with the EncryptedData element.
        ////////////////////////////////////////////////////

        EncryptedXml.ReplaceElement(elementToEncrypt, edElement, false);
    }
示例#20
0
 public void Insert(int index, EncryptionProperty value)
 {
 }
示例#21
0
 public void Remove(EncryptionProperty value)
 {
 }
示例#22
0
        internal static MachineLearningWorkspaceData DeserializeMachineLearningWorkspaceData(JsonElement element)
        {
            Optional <ManagedServiceIdentity>        identity = default;
            Optional <AzureLocation>                 location = default;
            Optional <IDictionary <string, string> > tags     = default;
            Optional <MachineLearningSku>            sku      = default;
            ResourceIdentifier             id                              = default;
            string                         name                            = default;
            ResourceType                   type                            = default;
            SystemData                     systemData                      = default;
            Optional <string>              workspaceId                     = default;
            Optional <string>              description                     = default;
            Optional <string>              friendlyName                    = default;
            Optional <string>              keyVault                        = default;
            Optional <string>              applicationInsights             = default;
            Optional <string>              containerRegistry               = default;
            Optional <string>              storageAccount                  = default;
            Optional <Uri>                 discoveryUrl                    = default;
            Optional <ProvisioningState>   provisioningState               = default;
            Optional <EncryptionProperty>  encryption                      = default;
            Optional <bool>                hbiWorkspace                    = default;
            Optional <string>              serviceProvisionedResourceGroup = default;
            Optional <int>                 privateLinkCount                = default;
            Optional <string>              imageBuildCompute               = default;
            Optional <bool>                allowPublicAccessWhenBehindVnet = default;
            Optional <PublicNetworkAccess> publicNetworkAccess             = default;
            Optional <IReadOnlyList <MachineLearningPrivateEndpointConnectionData> > privateEndpointConnections = default;
            Optional <IList <SharedPrivateLinkResource> > sharedPrivateLinkResources = default;
            Optional <NotebookResourceInfo>            notebookInfo = default;
            Optional <ServiceManagedResourcesSettings> serviceManagedResourcesSettings = default;
            Optional <string> primaryUserAssignedIdentity = default;
            Optional <Guid>   tenantId          = default;
            Optional <bool>   storageHnsEnabled = default;
            Optional <Uri>    mlFlowTrackingUri = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    var serializeOptions = new JsonSerializerOptions {
                        Converters = { new ManagedServiceIdentityTypeV3Converter() }
                    };
                    identity = JsonSerializer.Deserialize <ManagedServiceIdentity>(property.Value.ToString(), serializeOptions);
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = MachineLearningSku.DeserializeMachineLearningSku(property.Value);
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("workspaceId"))
                        {
                            workspaceId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("description"))
                        {
                            description = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("friendlyName"))
                        {
                            friendlyName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("keyVault"))
                        {
                            keyVault = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("applicationInsights"))
                        {
                            applicationInsights = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("containerRegistry"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                containerRegistry = null;
                                continue;
                            }
                            containerRegistry = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("storageAccount"))
                        {
                            storageAccount = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("discoveryUrl"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                discoveryUrl = null;
                                continue;
                            }
                            discoveryUrl = new Uri(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("encryption"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            encryption = EncryptionProperty.DeserializeEncryptionProperty(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("hbiWorkspace"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hbiWorkspace = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("serviceProvisionedResourceGroup"))
                        {
                            serviceProvisionedResourceGroup = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("privateLinkCount"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateLinkCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("imageBuildCompute"))
                        {
                            imageBuildCompute = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("allowPublicAccessWhenBehindVnet"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            allowPublicAccessWhenBehindVnet = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("publicNetworkAccess"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            publicNetworkAccess = new PublicNetworkAccess(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("privateEndpointConnections"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <MachineLearningPrivateEndpointConnectionData> array = new List <MachineLearningPrivateEndpointConnectionData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(MachineLearningPrivateEndpointConnectionData.DeserializeMachineLearningPrivateEndpointConnectionData(item));
                            }
                            privateEndpointConnections = array;
                            continue;
                        }
                        if (property0.NameEquals("sharedPrivateLinkResources"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <SharedPrivateLinkResource> array = new List <SharedPrivateLinkResource>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(SharedPrivateLinkResource.DeserializeSharedPrivateLinkResource(item));
                            }
                            sharedPrivateLinkResources = array;
                            continue;
                        }
                        if (property0.NameEquals("notebookInfo"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            notebookInfo = NotebookResourceInfo.DeserializeNotebookResourceInfo(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("serviceManagedResourcesSettings"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            serviceManagedResourcesSettings = ServiceManagedResourcesSettings.DeserializeServiceManagedResourcesSettings(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("primaryUserAssignedIdentity"))
                        {
                            primaryUserAssignedIdentity = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("tenantId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            tenantId = property0.Value.GetGuid();
                            continue;
                        }
                        if (property0.NameEquals("storageHnsEnabled"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            storageHnsEnabled = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("mlFlowTrackingUri"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                mlFlowTrackingUri = null;
                                continue;
                            }
                            mlFlowTrackingUri = new Uri(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new MachineLearningWorkspaceData(id, name, type, systemData, identity, Optional.ToNullable(location), Optional.ToDictionary(tags), sku.Value, workspaceId.Value, description.Value, friendlyName.Value, keyVault.Value, applicationInsights.Value, containerRegistry.Value, storageAccount.Value, discoveryUrl.Value, Optional.ToNullable(provisioningState), encryption.Value, Optional.ToNullable(hbiWorkspace), serviceProvisionedResourceGroup.Value, Optional.ToNullable(privateLinkCount), imageBuildCompute.Value, Optional.ToNullable(allowPublicAccessWhenBehindVnet), Optional.ToNullable(publicNetworkAccess), Optional.ToList(privateEndpointConnections), Optional.ToList(sharedPrivateLinkResources), notebookInfo.Value, serviceManagedResourcesSettings.Value, primaryUserAssignedIdentity.Value, Optional.ToNullable(tenantId), Optional.ToNullable(storageHnsEnabled), mlFlowTrackingUri.Value));
        }