public virtual void ValidateSubject(Subject subject)
        {
            if (subject == null) throw new ArgumentNullException("subject");

            bool validContentFound = false;

            if (subject.Items == null || subject.Items.Length == 0)
                throw new Saml20FormatException("Subject MUST contain either an identifier or a subject confirmation");

            foreach (object o in subject.Items)
            {
                if (o is NameID)
                {
                    validContentFound = true;
                    NameIdValidator.ValidateNameID((NameID)o);
                }
                else if (o is EncryptedElement)
                {
                    validContentFound = true;
                    NameIdValidator.ValidateEncryptedID((EncryptedElement)o);
                }
                else if (o is SubjectConfirmation)
                {
                    validContentFound = true;
                    SubjectConfirmationValidator.ValidateSubjectConfirmation((SubjectConfirmation)o);
                }
            }

            if (!validContentFound)
                throw new Saml20FormatException("Subject must have either NameID, EncryptedID or SubjectConfirmation subelement.");
        }
        public void ValidateSubject(Subject subject)
        {
            if (subject.Items == null || subject.Items.Length == 0)
                throw new DKSaml20FormatException("The DK-SAML 2.0 Profile requires at least one \"SubjectConfirmation\" element within the \"Subject\" element.");

            bool subjectConfirmationPresent = false;
            foreach (object item in subject.Items)
            {
                if (item is SubjectConfirmation)
                {
                    SubjectConfirmation subjectConfirmation = (SubjectConfirmation)item;
                    if (subjectConfirmation.Method == SubjectConfirmation.BEARER_METHOD)
                        subjectConfirmationPresent = true;

                    SubjectConfirmationValidator.ValidateSubjectConfirmation(subjectConfirmation);
                }
            }
            if (!subjectConfirmationPresent)
                throw new DKSaml20FormatException("The DK-SAML 2.0 Profile requires that a bearer \"SubjectConfirmation\" element is present.");
        }