Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2004-06-06 05:17:41 +0400
committerSebastien Pouliot <sebastien@ximian.com>2004-06-06 05:17:41 +0400
commitf3f5b554d8de75044d67144f43a807991b1a930f (patch)
tree20d90e912845fba511f6afdd3099e9b60ac82ced /mcs/class/System/System.Security.Cryptography.X509Certificates
parent8d8eeb9459597195838130438a0abbbf60493c63 (diff)
2004-06-05 Sebastien Pouliot <sebastien@ximian.com>
* X509CertificateCollection.cs: Fixed Contains which works by value (i.e. not by object reference). Fixed Remove for null and unexisting elements. svn path=/trunk/mcs/; revision=28896
Diffstat (limited to 'mcs/class/System/System.Security.Cryptography.X509Certificates')
-rw-r--r--mcs/class/System/System.Security.Cryptography.X509Certificates/ChangeLog6
-rw-r--r--mcs/class/System/System.Security.Cryptography.X509Certificates/X509CertificateCollection.cs43
2 files changed, 46 insertions, 3 deletions
diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/ChangeLog b/mcs/class/System/System.Security.Cryptography.X509Certificates/ChangeLog
index da3b0415be3..4965f14a9cc 100644
--- a/mcs/class/System/System.Security.Cryptography.X509Certificates/ChangeLog
+++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/ChangeLog
@@ -1,3 +1,9 @@
+2004-06-05 Sebastien Pouliot <sebastien@ximian.com>
+
+ * X509CertificateCollection.cs: Fixed Contains which works by value
+ (i.e. not by object reference). Fixed Remove for null and unexisting
+ elements.
+
2003-03-01 Sebastien Pouliot <spouliot@videotron.ca>
* X509CertificateCollection.cs: Fixed bugs in AddRange
diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509CertificateCollection.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509CertificateCollection.cs
index 3b5abccecd0..5e6c714f429 100644
--- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509CertificateCollection.cs
+++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509CertificateCollection.cs
@@ -5,9 +5,12 @@
// Lawrence Pit (loz@cable.a2000.nl)
// Sebastien Pouliot (spouliot@motus.com)
//
+// Copyright (C) 2004 Novell (http://www.novell.com)
+//
using System;
using System.Collections;
+using System.Globalization;
using System.Security.Cryptography;
namespace System.Security.Cryptography.X509Certificates {
@@ -15,7 +18,9 @@ namespace System.Security.Cryptography.X509Certificates {
[Serializable]
public class X509CertificateCollection : CollectionBase, IEnumerable {
- public X509CertificateCollection () {}
+ public X509CertificateCollection ()
+ {
+ }
public X509CertificateCollection (X509Certificate [] value)
{
@@ -64,9 +69,17 @@ public class X509CertificateCollection : CollectionBase, IEnumerable {
public bool Contains (X509Certificate value)
{
- return InnerList.Contains (value);
- }
+ if (value == null)
+ return false;
+ byte[] hash = value.GetCertHash ();
+ for (int i=0; i < InnerList.Count; i++) {
+ X509Certificate x509 = (X509Certificate) InnerList [i];
+ if (Compare (x509.GetCertHash (), hash))
+ return true;
+ }
+ return false;
+ }
public void CopyTo (X509Certificate[] array, int index)
{
@@ -100,9 +113,33 @@ public class X509CertificateCollection : CollectionBase, IEnumerable {
public void Remove (X509Certificate value)
{
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ if (IndexOf (value) == -1) {
+ throw new ArgumentException ("value",
+ Locale.GetText ("Not part of the collection."));
+ }
+
InnerList.Remove (value);
}
+ // private stuff
+
+ private bool Compare (byte[] array1, byte[] array2)
+ {
+ if ((array1 == null) && (array2 == null))
+ return true;
+ if ((array1 == null) || (array2 == null))
+ return false;
+ if (array1.Length != array2.Length)
+ return false;
+ for (int i=0; i < array1.Length; i++) {
+ if (array1 [i] != array2 [i])
+ return false;
+ }
+ return true;
+ }
+
// Inner Class
public class X509CertificateEnumerator : IEnumerator {