/// <summary>
        /// Validates the encrypted element.
        /// </summary>
        /// <param name="encryptedElement">The encrypted element.</param>
        /// <param name="parentNodeName">Name of the parent node.</param>
        public void ValidateEncryptedElement(EncryptedElement encryptedElement, string parentNodeName)
        {
            if (encryptedElement == null)
            {
                throw new ArgumentNullException("encryptedElement");
            }

            if (encryptedElement.EncryptedData == null)
            {
                throw new Saml20FormatException(string.Format("An {0} MUST contain an xenc:EncryptedData element", parentNodeName));
            }

            if (encryptedElement.EncryptedData.Type != null
                && !string.IsNullOrEmpty(encryptedElement.EncryptedData.Type)
                && encryptedElement.EncryptedData.Type != Saml20Constants.Xenc + "Element")
            {
                throw new Saml20FormatException(string.Format("Type attribute of EncryptedData MUST have value {0} if it is present", Saml20Constants.Xenc + "Element"));
            }
        }
 /// <summary>
 /// Validates the encrypted ID.
 /// </summary>
 /// <param name="encryptedId">The encrypted ID.</param>
 public void ValidateEncryptedId(EncryptedElement encryptedId)
 {
     _encryptedElementValidator.ValidateEncryptedElement(encryptedId, "EncryptedID");
 }
Beispiel #3
0
            public void ThrowsExceptionWhenXmlAttributeStatementEncryptedAttributeWrongType()
            {
                // Arrange
                var saml20Assertion = AssertionUtil.GetBasicAssertion();
                var statements = new List<StatementAbstract>(saml20Assertion.Items);
                var attributeStatments = (AttributeStatement)statements.Find(x => x is AttributeStatement);

                var attributes = new List<object>(attributeStatments.Items);
                var ee = new EncryptedElement
                             {
                                 EncryptedData = new EncryptedData
                                                     {
                                                         Type = "SomeWrongType"
                                                     }
                             };
                attributes.Add(ee);
                attributeStatments.Items = attributes.ToArray();
                saml20Assertion.Items = statements.ToArray();

                // Act
                var assertion = new Saml20Assertion(AssertionUtil.ConvertAssertionToXml(saml20Assertion).DocumentElement, null, false, TestConfiguration.Configuration);
            }
 /// <summary>
 /// Validates the encrypted attribute.
 /// </summary>
 /// <remarks>
 /// [SAML2.0 standard] section 2.7.3.2
 /// </remarks>
 /// <param name="encryptedElement">The encrypted element.</param>
 public void ValidateEncryptedAttribute(EncryptedElement encryptedElement)
 {
     _encryptedElementValidator.ValidateEncryptedElement(encryptedElement, "EncryptedAttribute");
 }