Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / Assertions.h
index 0da3ecf..e9b4186 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  Copyright 2001-2006 Internet2
- * 
+ *  Copyright 2001-2010 Internet2
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 /**
  * @file saml/saml1/core/Assertions.h
- * 
- * XMLObjects representing the SAML 1.x Assertions schema
+ *
+ * XMLObjects representing the SAML 1.x Assertions schema.
  */
 
 #ifndef __saml1_assertions_h__
 #define __saml1_assertions_h__
 
-#include <saml/RootObject.h>
+#include <saml/Assertion.h>
 #include <saml/util/SAMLConstants.h>
 
-#include <xmltooling/AttributeExtensibleXMLObject.h>
 #include <xmltooling/ElementProxy.h>
-#include <xmltooling/XMLObjectBuilder.h>
-#include <xmltooling/signature/KeyInfo.h>
-#include <xmltooling/signature/Signature.h>
-#include <xmltooling/util/DateTime.h>
+#include <xmltooling/ConcreteXMLObjectBuilder.h>
 
 #define DECL_SAML1OBJECTBUILDER(cname) \
     DECL_XMLOBJECTBUILDER(SAML_API,cname,samlconstants::SAML1_NS,samlconstants::SAML1_PREFIX)
 
+namespace xmltooling {
+    class XMLTOOL_API DateTime;
+};
+
+namespace xmlsignature {
+    class XMLTOOL_API KeyInfo;
+    class XMLTOOL_API Signature;
+};
+
 namespace opensaml {
 
     /**
@@ -43,17 +48,17 @@ namespace opensaml {
      * SAML 1.x assertion namespace
      */
     namespace saml1 {
-        
+
         // Forward references
         class SAML_API Assertion;
-        
+
         DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionIDReference,AssertionID,SAML 1.x AssertionIDReference element);
         DECL_XMLOBJECT_SIMPLE(SAML_API,Audience,AudienceURI,SAML 1.x Audience element);
         DECL_XMLOBJECT_SIMPLE(SAML_API,ConfirmationMethod,Method,SAML 1.x ConfirmationMethod element);
-        
+
         BEGIN_XMLOBJECT(SAML_API,Condition,xmltooling::XMLObject,SAML 1.x Condition element);
         END_XMLOBJECT;
-        
+
         BEGIN_XMLOBJECT(SAML_API,AudienceRestrictionCondition,Condition,SAML 1.x AudienceRestrictionCondition element);
             DECL_TYPED_CHILDREN(Audience);
             /** AudienceRestrictionConditionType local name */
@@ -91,9 +96,9 @@ namespace opensaml {
             static const XMLCh WIN_DOMAIN_QUALIFIED[];
         END_XMLOBJECT;
 
-        BEGIN_XMLOBJECT2(SAML_API,SubjectConfirmationData,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SAML 1.x SubjectConfirmationData element);
+        BEGIN_XMLOBJECT(SAML_API,SubjectConfirmationData,xmltooling::ElementProxy,SAML 1.x SubjectConfirmationData element);
         END_XMLOBJECT;
-        
+
         BEGIN_XMLOBJECT(SAML_API,SubjectConfirmation,xmltooling::XMLObject,SAML 1.x SubjectConfirmation element);
             DECL_TYPED_CHILDREN(ConfirmationMethod);
             DECL_XMLOBJECT_CHILD(SubjectConfirmationData);
@@ -200,7 +205,7 @@ namespace opensaml {
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
 
-        BEGIN_XMLOBJECT2(SAML_API,AttributeValue,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SAML 1.x AttributeValue element);
+        BEGIN_XMLOBJECT(SAML_API,AttributeValue,xmltooling::ElementProxy,SAML 1.x AttributeValue element);
         END_XMLOBJECT;
 
         BEGIN_XMLOBJECT(SAML_API,AttributeStatement,SubjectStatement,SAML 1.x AttributeStatement element);
@@ -209,15 +214,14 @@ namespace opensaml {
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
 
-        BEGIN_XMLOBJECT(SAML_API,Advice,xmltooling::XMLObject,SAML 1.x Advice element);
+        BEGIN_XMLOBJECT(SAML_API,Advice,xmltooling::ElementExtensibleXMLObject,SAML 1.x Advice element);
             DECL_TYPED_CHILDREN(AssertionIDReference);
             DECL_TYPED_CHILDREN(Assertion);
-            DECL_XMLOBJECT_CHILDREN(Other);
             /** AdviceType local name */
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
 
-        BEGIN_XMLOBJECT(SAML_API,Assertion,RootObject,SAML 1.x Assertion element);
+        BEGIN_XMLOBJECT(SAML_API,Assertion,opensaml::Assertion,SAML 1.x Assertion element);
             DECL_INTEGER_ATTRIB(MinorVersion,MINORVERSION);
             DECL_STRING_ATTRIB(AssertionID,ASSERTIONID);
             DECL_STRING_ATTRIB(Issuer,ISSUER);
@@ -229,7 +233,6 @@ namespace opensaml {
             DECL_TYPED_CHILDREN(AuthenticationStatement);
             DECL_TYPED_CHILDREN(AttributeStatement);
             DECL_TYPED_CHILDREN(AuthorizationDecisionStatement);
-            DECL_INHERITED_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
             /** AssertionType local name */
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
@@ -256,7 +259,73 @@ namespace opensaml {
         DECL_SAML1OBJECTBUILDER(SubjectConfirmation);
         DECL_SAML1OBJECTBUILDER(SubjectConfirmationData);
         DECL_SAML1OBJECTBUILDER(SubjectLocality);
-        
+
+        /**
+         * Builder for Condition extension objects.
+         *
+         * This is customized to force the schema type to be specified.
+         */
+        class SAML_API ConditionBuilder : public xmltooling::XMLObjectBuilder {
+        public:
+            virtual ~ConditionBuilder() {}
+            /** Builder that allows element/type override. */
+#ifdef HAVE_COVARIANT_RETURNS
+            virtual Condition* buildObject(
+#else
+            virtual xmltooling::XMLObject* buildObject(
+#endif
+                const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr
+                ) const;
+
+            /** Singleton builder. */
+            static Condition* buildCondition(const xmltooling::QName& schemaType) {
+                const ConditionBuilder* b = dynamic_cast<const ConditionBuilder*>(
+                    XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML1_NS,Condition::LOCAL_NAME))
+                    );
+                if (b) {
+#ifdef HAVE_COVARIANT_RETURNS
+                    return b->buildObject(samlconstants::SAML1_NS, Condition::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType);
+#else
+                    return dynamic_cast<Condition*>(b->buildObject(samlconstants::SAML1_NS, Condition::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType));
+#endif
+                }
+                throw xmltooling::XMLObjectException("Unable to obtain typed builder for Condition.");
+            }
+        };
+
+        /**
+         * Builder for Statement extension objects.
+         *
+         * This is customized to force the schema type to be specified.
+         */
+        class SAML_API StatementBuilder : public xmltooling::XMLObjectBuilder {
+        public:
+            virtual ~StatementBuilder() {}
+            /** Builder that allows element/type override. */
+#ifdef HAVE_COVARIANT_RETURNS
+            virtual Statement* buildObject(
+#else
+            virtual xmltooling::XMLObject* buildObject(
+#endif
+                const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr
+                ) const;
+
+            /** Singleton builder. */
+            static Statement* buildStatement(const xmltooling::QName& schemaType) {
+                const StatementBuilder* b = dynamic_cast<const StatementBuilder*>(
+                    XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML1_NS,Statement::LOCAL_NAME))
+                    );
+                if (b) {
+#ifdef HAVE_COVARIANT_RETURNS
+                    return b->buildObject(samlconstants::SAML1_NS, Statement::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType);
+#else
+                    return dynamic_cast<Statement*>(b->buildObject(samlconstants::SAML1_NS, Statement::LOCAL_NAME, samlconstants::SAML1_PREFIX, &schemaType));
+#endif
+                }
+                throw xmltooling::XMLObjectException("Unable to obtain typed builder for Statement.");
+            }
+        };
+
         /**
          * Registers builders and validators for SAML 1.x Assertion classes into the runtime.
          */