상속: System.Collections.ICollection, System.Collections.IEnumerable
예제 #1
0
        public CryptographicAttributeObject(Oid oid, AsnEncodedDataCollection?values)
        {
            _oid = oid.CopyOid();

            if (values == null)
            {
                Values = new AsnEncodedDataCollection();
            }
            else
            {
                foreach (AsnEncodedData asn in values)
                {
                    if (asn.Oid is null)
                    {
                        throw new ArgumentException(SR.Argument_InvalidOidValue, nameof(values));
                    }

                    if (!string.Equals(asn.Oid.Value, oid.Value, StringComparison.Ordinal))
                    {
                        throw new InvalidOperationException(SR.Format(SR.InvalidOperation_WrongOidInAsnCollection, oid.Value, asn.Oid.Value));
                    }
                }
                Values = values;
            }
        }
		// methods

		public int Add (AsnEncodedData asnEncodedData)
		{
			if (asnEncodedData == null)
				throw new ArgumentNullException ("asnEncodedData");

			AsnEncodedDataCollection coll = new AsnEncodedDataCollection (asnEncodedData);
			return Add (new CryptographicAttributeObject (asnEncodedData.Oid, coll));
		}
예제 #3
0
		// constructors

		public CryptographicAttributeObject (Oid oid) 
		{
			if (oid == null)
				throw new ArgumentNullException ("oid");

			_oid = new Oid (oid);
			_list = new AsnEncodedDataCollection ();
		}
예제 #4
0
        // constructors

        public CryptographicAttributeObject(Oid oid)
        {
            if (oid == null)
            {
                throw new ArgumentNullException("oid");
            }

            _oid  = new Oid(oid);
            _list = new AsnEncodedDataCollection();
        }
예제 #5
0
		public void ConstructorOidCollection () 
		{
			Oid o = new Oid (defaultOid);
			AsnEncodedDataCollection coll = new AsnEncodedDataCollection ();
			CryptographicAttributeObject ca = new CryptographicAttributeObject (o, coll);
			Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
			Assert.AreEqual (0, ca.Values.Count, "Values - 0");
			coll.Add (new AsnEncodedData (new byte [0]));
			Assert.AreEqual (1, ca.Values.Count, "Values - 1");
		}
        // methods

        public int Add(AsnEncodedData asnEncodedData)
        {
            if (asnEncodedData == null)
            {
                throw new ArgumentNullException("asnEncodedData");
            }

            AsnEncodedDataCollection coll = new AsnEncodedDataCollection(asnEncodedData);

            return(Add(new CryptographicAttributeObject(asnEncodedData.Oid, coll)));
        }
예제 #7
0
		public CryptographicAttributeObject (Oid oid,	AsnEncodedDataCollection values)
		{
			if (oid == null)
				throw new ArgumentNullException ("oid");

			_oid = new Oid (oid);
			if (values == null)
				_list = new AsnEncodedDataCollection ();
			else
				_list = values;
		}
 public CryptographicAttributeObject (Oid oid, AsnEncodedDataCollection values) {
     m_oid = new Oid(oid);
     if (values == null)
         m_values = new AsnEncodedDataCollection();
     else {
         foreach (AsnEncodedData asn in values) {
             if (0 != String.Compare(asn.Oid.Value, oid.Value, StringComparison.Ordinal))
                 throw new InvalidOperationException(SecurityResources.GetResourceString("InvalidOperation_DuplicateItemNotAllowed"));
         }
         m_values = values;
     }
 }
예제 #9
0
        public CryptographicAttributeObject(Oid oid, AsnEncodedDataCollection values)
        {
            if (oid == null)
            {
                throw new ArgumentNullException("oid");
            }

            _oid = new Oid(oid);
            if (values == null)
            {
                _list = new AsnEncodedDataCollection();
            }
            else
            {
                _list = values;
            }
        }
예제 #10
0
 public CryptographicAttributeObject(Oid oid, AsnEncodedDataCollection values)
 {
     _oid = new Oid(oid);
     if (values == null)
     {
         Values = new AsnEncodedDataCollection();
     }
     else
     {
         foreach (AsnEncodedData asn in values)
         {
             if (!string.Equals(asn.Oid.Value, oid.Value, StringComparison.Ordinal))
                 throw new InvalidOperationException(SR.Format(SR.InvalidOperation_WrongOidInAsnCollection, oid.Value, asn.Oid.Value));
         }
         Values = values;
     }
 }
예제 #11
0
 public CryptographicAttributeObject(Oid oid, AsnEncodedDataCollection values)
 {
     m_oid = new Oid(oid);
     if (values == null)
     {
         m_values = new AsnEncodedDataCollection();
     }
     else
     {
         foreach (AsnEncodedData asn in values)
         {
             if (0 != String.Compare(asn.Oid.Value, oid.Value, StringComparison.Ordinal))
             {
                 throw new InvalidOperationException(SecurityResources.GetResourceString("InvalidOperation_DuplicateItemNotAllowed"));
             }
         }
         m_values = values;
     }
 }
 public CryptographicAttributeObject(System.Security.Cryptography.Oid oid, AsnEncodedDataCollection values)
 {
     this.m_oid = new System.Security.Cryptography.Oid(oid);
     if (values == null)
     {
         this.m_values = new AsnEncodedDataCollection();
     }
     else
     {
         AsnEncodedDataEnumerator enumerator = values.GetEnumerator();
         while (enumerator.MoveNext())
         {
             if (string.Compare(enumerator.Current.Oid.Value, oid.Value, StringComparison.Ordinal) != 0)
             {
                 throw new InvalidOperationException(SecurityResources.GetResourceString("InvalidOperation_DuplicateItemNotAllowed"));
             }
         }
         this.m_values = values;
     }
 }
예제 #13
0
 public CryptographicAttributeObject(System.Security.Cryptography.Oid oid, AsnEncodedDataCollection values)
 {
     this.m_oid = new System.Security.Cryptography.Oid(oid);
     if (values == null)
     {
         this.m_values = new AsnEncodedDataCollection();
     }
     else
     {
         AsnEncodedDataEnumerator enumerator = values.GetEnumerator();
         while (enumerator.MoveNext())
         {
             if (string.Compare(enumerator.Current.Oid.Value, oid.Value, StringComparison.Ordinal) != 0)
             {
                 throw new InvalidOperationException(SecurityResources.GetResourceString("InvalidOperation_DuplicateItemNotAllowed"));
             }
         }
         this.m_values = values;
     }
 }
 internal static AsnEncodedDataCollection GetAsnEncodedDataCollection(System.Security.Cryptography.CAPI.CRYPT_ATTRIBUTE cryptAttribute)
 {
     AsnEncodedDataCollection datas = new AsnEncodedDataCollection();
     Oid oid = new Oid(cryptAttribute.pszObjId);
     string name = oid.Value;
     for (uint i = 0; i < cryptAttribute.cValue; i++)
     {
         IntPtr pBlob = new IntPtr(((long) cryptAttribute.rgValue) + (i * Marshal.SizeOf(typeof(System.Security.Cryptography.CAPI.CRYPTOAPI_BLOB))));
         Pkcs9AttributeObject asnEncodedData = new Pkcs9AttributeObject(oid, System.Security.Cryptography.CAPI.BlobToByteArray(pBlob));
         Pkcs9AttributeObject obj3 = CryptoConfig.CreateFromName(name) as Pkcs9AttributeObject;
         if (obj3 != null)
         {
             obj3.CopyFrom(asnEncodedData);
             asnEncodedData = obj3;
         }
         datas.Add(asnEncodedData);
     }
     return datas;
 }
예제 #15
0
 internal AsnEncodedDataEnumerator(AsnEncodedDataCollection asnEncodedDatas)
 {
     _asnEncodedDatas = asnEncodedDatas;
     _current = -1;
 }
예제 #16
0
 internal AsnEncodedDataEnumerator(AsnEncodedDataCollection asnEncodedDatas)
 {
     this.m_asnEncodedDatas = asnEncodedDatas;
     this.m_current         = -1;
 }
예제 #17
0
		public void ConstructorOidNullCollection ()
		{
			AsnEncodedDataCollection coll = new AsnEncodedDataCollection ();
			CryptographicAttributeObject ca = new CryptographicAttributeObject (null, coll);
		}
예제 #18
0
파일: PkcsUtils.cs 프로젝트: JianwenSun/cc
        internal static AsnEncodedDataCollection GetAsnEncodedDataCollection (CAPI.CRYPT_ATTRIBUTE cryptAttribute) {
            AsnEncodedDataCollection list = new AsnEncodedDataCollection();
            Oid oid = new Oid(cryptAttribute.pszObjId);
            string szOid = oid.Value;

            for (uint index = 0; index < cryptAttribute.cValue; index++) {
                checked {
                    IntPtr pAttributeBlob = new IntPtr((long)cryptAttribute.rgValue + (index * Marshal.SizeOf(typeof(CAPI.CRYPTOAPI_BLOB))));
                    Pkcs9AttributeObject attribute = new Pkcs9AttributeObject(oid, CAPI.BlobToByteArray(pAttributeBlob));
                    Pkcs9AttributeObject customAttribute = CryptoConfig.CreateFromName(szOid) as Pkcs9AttributeObject;
                    if (customAttribute != null) {
                        customAttribute.CopyFrom(attribute);
                        attribute = customAttribute;
                    }
                    list.Add(attribute);
                }
            }
            return list;
        }
예제 #19
0
 // note: couldn't reuse the IEnumerator from ArrayList because
 // it doesn't throw the same exceptions
 internal AsnEncodedDataEnumerator(AsnEncodedDataCollection collection)
 {
     _collection = collection;
     _position   = -1;
 }
예제 #20
0
파일: PkcsUtils.cs 프로젝트: JianwenSun/cc
 internal static AsnEncodedDataCollection GetAsnEncodedDataCollection (CAPI.CRYPT_ATTRIBUTE_TYPE_VALUE cryptAttribute) {
     AsnEncodedDataCollection list = new AsnEncodedDataCollection();
     list.Add(new Pkcs9AttributeObject(new Oid(cryptAttribute.pszObjId), CAPI.BlobToByteArray(cryptAttribute.Value)));
     return list;
 }
		// note: couldn't reuse the IEnumerator from ArrayList because 
		// it doesn't throw the same exceptions
		internal AsnEncodedDataEnumerator (AsnEncodedDataCollection collection) 
		{
			_collection = collection;
			_position = -1;
		}
예제 #22
0
        public static void CryptographicAttributeObjectMismatch()
        {
            Oid oid = new Oid(Oids.DocumentDescription);
            Oid wrongOid = new Oid(Oids.DocumentName);

            AsnEncodedDataCollection col = new AsnEncodedDataCollection();
            col.Add(new AsnEncodedData(oid, new byte[3]));

            object ignore;
            Assert.Throws<InvalidOperationException>(() => ignore = new CryptographicAttributeObject(wrongOid, col));
        }
 internal static AsnEncodedDataCollection GetAsnEncodedDataCollection(System.Security.Cryptography.CAPI.CRYPT_ATTRIBUTE_TYPE_VALUE cryptAttribute)
 {
     AsnEncodedDataCollection datas = new AsnEncodedDataCollection();
     datas.Add(new Pkcs9AttributeObject(new Oid(cryptAttribute.pszObjId), System.Security.Cryptography.CAPI.BlobToByteArray(cryptAttribute.Value)));
     return datas;
 }