Removed ChildlessElement class references, ensure ComplexElement gets copied during...
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / impl / AssertionsSchemaValidators.cpp
index f789011..ca8c002 100644 (file)
@@ -24,6 +24,8 @@
 #include "exceptions.h"
 #include "saml1/core/Assertions.h"
 
+#include <xmltooling/validation/ValidatorSuite.h>
+
 using namespace opensaml::saml1;
 using namespace opensaml;
 using namespace xmltooling;
@@ -108,9 +110,16 @@ namespace opensaml {
             XMLOBJECTVALIDATOR_REQUIRE(Assertion,Issuer);
             XMLOBJECTVALIDATOR_REQUIRE(Assertion,IssueInstant);
             if (ptr->getAuthenticationStatements().empty() &&
+                ptr->getAttributeStatements().empty() &&
+                ptr->getAuthorizationDecisionStatements().empty() &&
                 ptr->getSubjectStatements().empty() &&
                 ptr->getStatements().empty())
                 throw ValidationException("Assertion must have at least one statement.");
+            pair<bool,int> minor=ptr->getMinorVersion();
+            if (!minor.first)
+                throw ValidationException("Assertion must have MinorVersion");
+            if (minor.second==0 && ptr->getConditions() && !ptr->getConditions()->getDoNotCacheConditions().empty())
+                throw ValidationException("SAML 1.0 assertions cannot contain DoNotCacheCondition elements.");
         END_XMLOBJECTVALIDATOR;
 
         class SAML_DLLLOCAL checkWildcardNS {
@@ -137,12 +146,12 @@ namespace opensaml {
 #define REGISTER_ELEMENT(cname) \
     q=QName(SAMLConstants::SAML1_NS,cname::LOCAL_NAME); \
     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
-    Validator::registerValidator(q,new cname##SchemaValidator())
+    SchemaValidators.registerValidator(q,new cname##SchemaValidator())
     
 #define REGISTER_TYPE(cname) \
     q=QName(SAMLConstants::SAML1_NS,cname::TYPE_NAME); \
     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
-    Validator::registerValidator(q,new cname##SchemaValidator())
+    SchemaValidators.registerValidator(q,new cname##SchemaValidator())
 
 #define REGISTER_ELEMENT_NOVAL(cname) \
     q=QName(SAMLConstants::SAML1_NS,cname::LOCAL_NAME); \