Exemple #1
0
        public CryptographySettingsNode Build()
        {
            CryptographySettingsNode rootNode = new CryptographySettingsNode();

            HashProviderCollectionNode hashProviderCollectionNode = new HashProviderCollectionNode();

            foreach (HashProviderData hashProviderData in cryptographySettings.HashProviders)
            {
                CreateHashProviderNode(hashProviderCollectionNode, hashProviderData);
            }

            SymmetricCryptoProviderCollectionNode symmetricCryptoProviderCollectionNode = new SymmetricCryptoProviderCollectionNode();

            foreach (SymmetricProviderData symmetricCryptoProviderData in cryptographySettings.SymmetricCryptoProviders)
            {
                CreateSymmetricCryptoProviderNode(symmetricCryptoProviderCollectionNode, symmetricCryptoProviderData);
            }

            rootNode.AddNode(hashProviderCollectionNode);
            rootNode.AddNode(symmetricCryptoProviderCollectionNode);

            rootNode.DefaultHashProvider            = defaultHashProviderNode;
            rootNode.DefaultSymmetricCryptoProvider = defaultSymmetricProviderNode;

            rootNode.RequirePermission = cryptographySettings.SectionInformation.RequirePermission;

            return(rootNode);
        }
Exemple #2
0
        private void CreateSymmetricCryptoProviderNode(SymmetricCryptoProviderCollectionNode symmetricCryptoProviderCollectionNode, object symmetricCryptoProviderData)
        {
            SymmetricCryptoProviderNode symmetricAlgorithmProviderNode = NodeCreationService.CreateNodeByDataType(symmetricCryptoProviderData.GetType(), new object[] { symmetricCryptoProviderData }) as SymmetricCryptoProviderNode;

            if (null == symmetricAlgorithmProviderNode)
            {
                LogNodeMapError(symmetricCryptoProviderCollectionNode, symmetricCryptoProviderData.GetType());
                return;
            }

            if (string.Compare(symmetricAlgorithmProviderNode.Name, cryptographySettings.DefaultSymmetricCryptoProviderName) == 0)
            {
                defaultSymmetricProviderNode = symmetricAlgorithmProviderNode;
            }

            symmetricCryptoProviderCollectionNode.AddNode(symmetricAlgorithmProviderNode);
        }