Exemplo n.º 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;

            return(rootNode);
        }
		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);
		}
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private void GetSymmetricCryptoProviderDataCollection()
        {
            SymmetricCryptoProviderCollectionNode symmetricCryptoProviderCollectionNode = Hierarchy.FindNodeByType(typeof(SymmetricCryptoProviderCollectionNode)) as SymmetricCryptoProviderCollectionNode;

            if (symmetricCryptoProviderCollectionNode == null)
            {
                return;
            }
            if (Object.ReferenceEquals(cryptographySettings.SymmetricCryptoProviders, symmetricCryptoProviderCollectionNode.SymmetricCryptoProviderDataCollection))
            {
                return;
            }

            cryptographySettings.SymmetricCryptoProviders.Clear();
            foreach (SymmetricAlgorithmProviderData symmetricAlgorithmProviderData in symmetricCryptoProviderCollectionNode.SymmetricCryptoProviderDataCollection)
            {
                cryptographySettings.SymmetricCryptoProviders[symmetricAlgorithmProviderData.Name] = symmetricAlgorithmProviderData;
            }
        }
		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;

			return rootNode;
		}