Пример #1
0
        /**
         * Gets the role authority as a <code>string[]</code> object.
         * @return the role authority of this RoleSyntax represented as a
         * <code>string[]</code> array.
         */
        public string[] GetRoleAuthorityAsString()
        {
            if (roleAuthority == null)
            {
                return(new string[0]);
            }

            GeneralName[] names       = roleAuthority.GetNames();
            string[]      namesString = new string[names.Length];
            for (int i = 0; i < names.Length; i++)
            {
                Asn1Encodable asn1Value = names[i].Name;
                if (asn1Value is IAsn1String)
                {
                    namesString[i] = ((IAsn1String)asn1Value).GetString();
                }
                else
                {
                    namesString[i] = asn1Value.ToString();
                }
            }

            return(namesString);
        }
		private X509Name[] GetPrincipals(
			GeneralNames names)
		{
			object[] p = this.GetNames(names.GetNames());

            int count = 0;

            for (int i = 0; i != p.Length; i++)
			{
				if (p[i] is X509Name)
				{
                    ++count;
				}
			}

            X509Name[] result = new X509Name[count];

            int pos = 0;
            for (int i = 0; i != p.Length; i++)
            {
                if (p[i] is X509Name)
                {
                    result[pos++] = (X509Name)p[i];
                }
            }

            return result;
        }
		private bool MatchesDN(
			X509Name		subject,
			GeneralNames	targets)
		{
			GeneralName[] names = targets.GetNames();

			for (int i = 0; i != names.Length; i++)
			{
				GeneralName gn = names[i];

				if (gn.TagNo == GeneralName.DirectoryName)
				{
					try
					{
						if (X509Name.GetInstance(gn.Name).Equivalent(subject))
						{
							return true;
						}
					}
					catch (Exception)
					{
					}
				}
			}

			return false;
		}