示例#1
0
        /// <summary>
        /// Decides if the given attribute certificate should be selected.
        /// </summary>
        /// <param name="obj">The attribute certificate to be checked.</param>
        /// <returns><code>true</code> if the object matches this selector.</returns>
        public bool Match(
            object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            IX509AttributeCertificate attrCert = obj as IX509AttributeCertificate;

            if (attrCert == null)
            {
                return(false);
            }

            if (this.attributeCert != null && !this.attributeCert.Equals(attrCert))
            {
                return(false);
            }

            if (serialNumber != null && !attrCert.SerialNumber.Equals(serialNumber))
            {
                return(false);
            }

            if (holder != null && !attrCert.Holder.Equals(holder))
            {
                return(false);
            }

            if (issuer != null && !attrCert.Issuer.Equals(issuer))
            {
                return(false);
            }

            if (attributeCertificateValid != null && !attrCert.IsValid(attributeCertificateValid.Value))
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Decides if the given attribute certificate should be selected.
        /// </summary>
        /// <param name="obj">The attribute certificate to be checked.</param>
        /// <returns><code>true</code> if the object matches this selector.</returns>
        public bool Match(
            object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            IX509AttributeCertificate attrCert = obj as IX509AttributeCertificate;

            if (attrCert == null)
            {
                return(false);
            }

            if (this.attributeCert != null && !this.attributeCert.Equals(attrCert))
            {
                return(false);
            }

            if (serialNumber != null && !attrCert.SerialNumber.Equals(serialNumber))
            {
                return(false);
            }

            if (holder != null && !attrCert.Holder.Equals(holder))
            {
                return(false);
            }

            if (issuer != null && !attrCert.Issuer.Equals(issuer))
            {
                return(false);
            }

            if (attributeCertificateValid != null && !attrCert.IsValid(attributeCertificateValid.Value))
            {
                return(false);
            }

            if (targetNames.Count > 0 || targetGroups.Count > 0)
            {
                Asn1OctetString targetInfoExt = attrCert.GetExtensionValue(
                    X509Extensions.TargetInformation);

                if (targetInfoExt != null)
                {
                    TargetInformation targetinfo;
                    try
                    {
                        targetinfo = TargetInformation.GetInstance(
                            X509ExtensionUtilities.FromExtensionValue(targetInfoExt));
                    }
                    catch (Exception)
                    {
                        return(false);
                    }

                    Targets[] targetss = targetinfo.GetTargetsObjects();

                    if (targetNames.Count > 0)
                    {
                        bool found = false;

                        for (int i = 0; i < targetss.Length && !found; i++)
                        {
                            Target[] targets = targetss[i].GetTargets();

                            for (int j = 0; j < targets.Length; j++)
                            {
                                GeneralName targetName = targets[j].TargetName;

                                if (targetName != null && targetNames.Contains(targetName))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                        if (!found)
                        {
                            return(false);
                        }
                    }

                    if (targetGroups.Count > 0)
                    {
                        bool found = false;

                        for (int i = 0; i < targetss.Length && !found; i++)
                        {
                            Target[] targets = targetss[i].GetTargets();

                            for (int j = 0; j < targets.Length; j++)
                            {
                                GeneralName targetGroup = targets[j].TargetGroup;

                                if (targetGroup != null && targetGroups.Contains(targetGroup))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }

                        if (!found)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
示例#3
0
        public bool Match(object obj)
        {
            //IL_0008: Unknown result type (might be due to invalid IL or missing references)
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            IX509AttributeCertificate iX509AttributeCertificate = obj as IX509AttributeCertificate;

            if (iX509AttributeCertificate == null)
            {
                return(false);
            }
            if (attributeCert != null && !((object)attributeCert).Equals((object)iX509AttributeCertificate))
            {
                return(false);
            }
            if (serialNumber != null && !iX509AttributeCertificate.SerialNumber.Equals(serialNumber))
            {
                return(false);
            }
            if (holder != null && !iX509AttributeCertificate.Holder.Equals(holder))
            {
                return(false);
            }
            if (issuer != null && !iX509AttributeCertificate.Issuer.Equals(issuer))
            {
                return(false);
            }
            if (attributeCertificateValid != null && !iX509AttributeCertificate.IsValid(attributeCertificateValid.Value))
            {
                return(false);
            }
            if (((global::System.Collections.ICollection)targetNames).get_Count() > 0 || ((global::System.Collections.ICollection)targetGroups).get_Count() > 0)
            {
                Asn1OctetString extensionValue = iX509AttributeCertificate.GetExtensionValue(X509Extensions.TargetInformation);
                if (extensionValue != null)
                {
                    TargetInformation instance;
                    try
                    {
                        instance = TargetInformation.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue));
                    }
                    catch (global::System.Exception)
                    {
                        return(false);
                    }
                    Targets[] targetsObjects = instance.GetTargetsObjects();
                    if (((global::System.Collections.ICollection)targetNames).get_Count() > 0)
                    {
                        bool flag = false;
                        for (int i = 0; i < targetsObjects.Length; i++)
                        {
                            if (flag)
                            {
                                break;
                            }
                            Target[] targets = targetsObjects[i].GetTargets();
                            for (int j = 0; j < targets.Length; j++)
                            {
                                GeneralName targetName = targets[j].TargetName;
                                if (targetName != null && targetNames.Contains(targetName))
                                {
                                    flag = true;
                                    break;
                                }
                            }
                        }
                        if (!flag)
                        {
                            return(false);
                        }
                    }
                    if (((global::System.Collections.ICollection)targetGroups).get_Count() > 0)
                    {
                        bool flag2 = false;
                        for (int k = 0; k < targetsObjects.Length; k++)
                        {
                            if (flag2)
                            {
                                break;
                            }
                            Target[] targets2 = targetsObjects[k].GetTargets();
                            for (int l = 0; l < targets2.Length; l++)
                            {
                                GeneralName targetGroup = targets2[l].TargetGroup;
                                if (targetGroup != null && targetGroups.Contains(targetGroup))
                                {
                                    flag2 = true;
                                    break;
                                }
                            }
                        }
                        if (!flag2)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
    public bool Match(object obj)
    {
        if (obj == null)
        {
            throw new ArgumentNullException("obj");
        }
        IX509AttributeCertificate iX509AttributeCertificate = obj as IX509AttributeCertificate;

        if (iX509AttributeCertificate == null)
        {
            return(false);
        }
        if (attributeCert != null && !attributeCert.Equals(iX509AttributeCertificate))
        {
            return(false);
        }
        if (serialNumber != null && !iX509AttributeCertificate.SerialNumber.Equals(serialNumber))
        {
            return(false);
        }
        if (holder != null && !iX509AttributeCertificate.Holder.Equals(holder))
        {
            return(false);
        }
        if (issuer != null && !iX509AttributeCertificate.Issuer.Equals(issuer))
        {
            return(false);
        }
        if (attributeCertificateValid != null && !iX509AttributeCertificate.IsValid(attributeCertificateValid.Value))
        {
            return(false);
        }
        if (targetNames.Count > 0 || targetGroups.Count > 0)
        {
            Asn1OctetString extensionValue = iX509AttributeCertificate.GetExtensionValue(X509Extensions.TargetInformation);
            if (extensionValue != null)
            {
                TargetInformation instance;
                try
                {
                    instance = TargetInformation.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue));
                }
                catch (Exception)
                {
                    return(false);
                }
                Targets[] targetsObjects = instance.GetTargetsObjects();
                if (targetNames.Count > 0)
                {
                    bool flag = false;
                    for (int i = 0; i < targetsObjects.Length; i++)
                    {
                        if (flag)
                        {
                            break;
                        }
                        Target[] targets = targetsObjects[i].GetTargets();
                        for (int j = 0; j < targets.Length; j++)
                        {
                            GeneralName targetName = targets[j].TargetName;
                            if (targetName != null && targetNames.Contains(targetName))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (!flag)
                    {
                        return(false);
                    }
                }
                if (targetGroups.Count > 0)
                {
                    bool flag2 = false;
                    for (int k = 0; k < targetsObjects.Length; k++)
                    {
                        if (flag2)
                        {
                            break;
                        }
                        Target[] targets2 = targetsObjects[k].GetTargets();
                        for (int l = 0; l < targets2.Length; l++)
                        {
                            GeneralName targetGroup = targets2[l].TargetGroup;
                            if (targetGroup != null && targetGroups.Contains(targetGroup))
                            {
                                flag2 = true;
                                break;
                            }
                        }
                    }
                    if (!flag2)
                    {
                        return(false);
                    }
                }
            }
        }
        return(true);
    }
示例#5
0
        public bool Match(object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            IX509AttributeCertificate iX509AttributeCertificate = obj as IX509AttributeCertificate;

            if (iX509AttributeCertificate == null)
            {
                return(false);
            }
            if (this.attributeCert != null && !this.attributeCert.Equals(iX509AttributeCertificate))
            {
                return(false);
            }
            if (this.serialNumber != null && !iX509AttributeCertificate.SerialNumber.Equals(this.serialNumber))
            {
                return(false);
            }
            if (this.holder != null && !iX509AttributeCertificate.Holder.Equals(this.holder))
            {
                return(false);
            }
            if (this.issuer != null && !iX509AttributeCertificate.Issuer.Equals(this.issuer))
            {
                return(false);
            }
            if (this.attributeCertificateValid != null && !iX509AttributeCertificate.IsValid(this.attributeCertificateValid.Value))
            {
                return(false);
            }
            if (this.targetNames.Count > 0 || this.targetGroups.Count > 0)
            {
                Asn1OctetString extensionValue = iX509AttributeCertificate.GetExtensionValue(X509Extensions.TargetInformation);
                if (extensionValue != null)
                {
                    TargetInformation instance;
                    try
                    {
                        instance = TargetInformation.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue));
                    }
                    catch (Exception)
                    {
                        bool result = false;
                        return(result);
                    }
                    Targets[] targetsObjects = instance.GetTargetsObjects();
                    if (this.targetNames.Count > 0)
                    {
                        bool flag = false;
                        int  num  = 0;
                        while (num < targetsObjects.Length && !flag)
                        {
                            Target[] targets = targetsObjects[num].GetTargets();
                            for (int i = 0; i < targets.Length; i++)
                            {
                                GeneralName targetName = targets[i].TargetName;
                                if (targetName != null && this.targetNames.Contains(targetName))
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            num++;
                        }
                        if (!flag)
                        {
                            return(false);
                        }
                    }
                    if (this.targetGroups.Count <= 0)
                    {
                        return(true);
                    }
                    bool flag2 = false;
                    int  num2  = 0;
                    while (num2 < targetsObjects.Length && !flag2)
                    {
                        Target[] targets2 = targetsObjects[num2].GetTargets();
                        for (int j = 0; j < targets2.Length; j++)
                        {
                            GeneralName targetGroup = targets2[j].TargetGroup;
                            if (targetGroup != null && this.targetGroups.Contains(targetGroup))
                            {
                                flag2 = true;
                                break;
                            }
                        }
                        num2++;
                    }
                    if (!flag2)
                    {
                        return(false);
                    }
                    return(true);
                }
            }
            return(true);
        }