Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / Protocols.h
index 407ed35..c640a5c 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  Copyright 2001-2007 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
@@ -16,8 +16,8 @@
 
 /**
  * @file saml/saml1/core/Protocols.h
- * 
- * XMLObjects representing the SAML 1.x Protocols schema
+ *
+ * XMLObjects representing the SAML 1.x Protocols schema.
  */
 
 #ifndef __saml1_protocols_h__
 #include <saml/RootObject.h>
 #include <saml/util/SAMLConstants.h>
 
-#include <xmltooling/XMLObjectBuilder.h>
-#include <xmltooling/signature/KeyInfo.h>
-#include <xmltooling/signature/Signature.h>
-#include <xmltooling/util/DateTime.h>
+#include <xmltooling/ConcreteXMLObjectBuilder.h>
+#include <xmltooling/ElementExtensibleXMLObject.h>
 
 #define DECL_SAML1POBJECTBUILDER(cname) \
     DECL_XMLOBJECTBUILDER(SAML_API,cname,samlconstants::SAML1P_NS,samlconstants::SAML1P_PREFIX)
 
+namespace xmltooling {
+    class XMLTOOL_API DateTime;
+};
+
+namespace xmlsignature {
+    class XMLTOOL_API KeyInfo;
+    class XMLTOOL_API Signature;
+};
+
 namespace opensaml {
 
     namespace saml1 {
@@ -50,10 +57,10 @@ namespace opensaml {
      * SAML 1.x protocol namespace
      */
     namespace saml1p {
-        
+
         DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionArtifact,Artifact,SAML 1.x AssertionArtifact element);
         DECL_XMLOBJECT_SIMPLE(SAML_API,StatusMessage,Message,SAML 1.x StatusMessage element);
-        
+
         BEGIN_XMLOBJECT(SAML_API,RespondWith,xmltooling::XMLObject,SAML 1.x RespondWith element);
             /** Gets the QName content of the element. */
             virtual xmltooling::QName* getQName() const=0;
@@ -94,7 +101,6 @@ namespace opensaml {
             DECL_STRING_ATTRIB(RequestID,REQUESTID);
             DECL_INHERITED_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT);
             DECL_TYPED_CHILDREN(RespondWith);
-            DECL_INHERITED_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
             /** RequestAbstractType local name */
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
@@ -145,7 +151,6 @@ namespace opensaml {
             DECL_STRING_ATTRIB(InResponseTo,INRESPONSETO);
             DECL_INHERITED_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT);
             DECL_STRING_ATTRIB(Recipient,RECIPIENT);
-            DECL_INHERITED_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
             /** ResponseAbstractType local name */
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
@@ -168,7 +173,40 @@ namespace opensaml {
         DECL_SAML1POBJECTBUILDER(StatusCode);
         DECL_SAML1POBJECTBUILDER(StatusDetail);
         DECL_SAML1POBJECTBUILDER(StatusMessage);
-        
+
+        /**
+         * Builder for Query extension objects.
+         *
+         * This is customized to force the schema type to be specified.
+         */
+        class SAML_API QueryBuilder : public xmltooling::XMLObjectBuilder {
+        public:
+            virtual ~QueryBuilder() {}
+            /** Builder that allows element/type override. */
+#ifdef HAVE_COVARIANT_RETURNS
+            virtual Query* 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 Query* buildQuery(const xmltooling::QName& schemaType) {
+                const QueryBuilder* b = dynamic_cast<const QueryBuilder*>(
+                    XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML1P_NS,Query::LOCAL_NAME))
+                    );
+                if (b) {
+#ifdef HAVE_COVARIANT_RETURNS
+                    return b->buildObject(samlconstants::SAML1P_NS, Query::LOCAL_NAME, samlconstants::SAML1P_PREFIX, &schemaType);
+#else
+                    return dynamic_cast<Query*>(b->buildObject(samlconstants::SAML1P_NS, Query::LOCAL_NAME, samlconstants::SAML1P_PREFIX, &schemaType));
+#endif
+                }
+                throw xmltooling::XMLObjectException("Unable to obtain typed builder for Query.");
+            }
+        };
+
         /**
          * Registers builders and validators for SAML 1.x Protocol classes into the runtime.
          */