Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / Protocols.h
index c3300b9..c640a5c 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/Protocols.h
- * 
- * XMLObjects representing the SAML 1.x Protocols schema
+ *
+ * XMLObjects representing the SAML 1.x Protocols schema.
  */
 
 #ifndef __saml1_protocols_h__
 #define __saml1_protocols_h__
 
-#include <saml/saml1/core/Assertions.h>
+#include <saml/RootObject.h>
+#include <saml/util/SAMLConstants.h>
+
+#include <xmltooling/ConcreteXMLObjectBuilder.h>
+#include <xmltooling/ElementExtensibleXMLObject.h>
 
 #define DECL_SAML1POBJECTBUILDER(cname) \
-    DECL_XMLOBJECTBUILDER(SAML_API,cname,opensaml::SAMLConstants::SAML1P_NS,opensaml::SAMLConstants::SAML1P_PREFIX)
+    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 {
+        class SAML_API Action;
+        class SAML_API Assertion;
+        class SAML_API AssertionIDReference;
+        class SAML_API AttributeDesignator;
+        class SAML_API Evidence;
+        class SAML_API Subject;
+    };
+
     /**
      * @namespace opensaml::saml1p
      * 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;
@@ -74,12 +96,11 @@ namespace opensaml {
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
 
-        BEGIN_XMLOBJECT(SAML_API,RequestAbstractType,SignableObject,SAML 1.x RequestAbstractType base type);
+        BEGIN_XMLOBJECT(SAML_API,RequestAbstractType,RootObject,SAML 1.x RequestAbstractType base type);
             DECL_INTEGER_ATTRIB(MinorVersion,MINORVERSION);
             DECL_STRING_ATTRIB(RequestID,REQUESTID);
-            DECL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT);
+            DECL_INHERITED_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT);
             DECL_TYPED_CHILDREN(RespondWith);
-            DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
             /** RequestAbstractType local name */
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
@@ -111,8 +132,7 @@ namespace opensaml {
             static xmltooling::QName VERSIONMISMATCH;
         END_XMLOBJECT;
 
-        BEGIN_XMLOBJECT(SAML_API,StatusDetail,xmltooling::XMLObject,SAML 1.x StatusDetail element);
-            DECL_XMLOBJECT_CHILDREN(Detail);
+        BEGIN_XMLOBJECT(SAML_API,StatusDetail,xmltooling::ElementExtensibleXMLObject,SAML 1.x StatusDetail element);
             /** StatusDetailType local name */
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
@@ -125,13 +145,12 @@ namespace opensaml {
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
 
-        BEGIN_XMLOBJECT(SAML_API,ResponseAbstractType,SignableObject,SAML 1.x ResponseAbstractType base type);
+        BEGIN_XMLOBJECT(SAML_API,ResponseAbstractType,RootObject,SAML 1.x ResponseAbstractType base type);
             DECL_INTEGER_ATTRIB(MinorVersion,MINORVERSION);
             DECL_STRING_ATTRIB(ResponseID,RESPONSEID);
             DECL_STRING_ATTRIB(InResponseTo,INRESPONSETO);
-            DECL_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT);
+            DECL_INHERITED_DATETIME_ATTRIB(IssueInstant,ISSUEINSTANT);
             DECL_STRING_ATTRIB(Recipient,RECIPIENT);
-            DECL_TYPED_FOREIGN_CHILD(Signature,xmlsignature);
             /** ResponseAbstractType local name */
             static const XMLCh TYPE_NAME[];
         END_XMLOBJECT;
@@ -154,16 +173,44 @@ namespace opensaml {
         DECL_SAML1POBJECTBUILDER(StatusCode);
         DECL_SAML1POBJECTBUILDER(StatusDetail);
         DECL_SAML1POBJECTBUILDER(StatusMessage);
-        
+
         /**
-         * Registers builders and validators for SAML 1.x Protocol classes into the runtime.
+         * Builder for Query extension objects.
+         *
+         * This is customized to force the schema type to be specified.
          */
-        void SAML_API registerProtocolClasses();
+        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.");
+            }
+        };
 
         /**
-         * Validator suite for SAML 1.x Protocol schema validation.
+         * Registers builders and validators for SAML 1.x Protocol classes into the runtime.
          */
-        extern SAML_API xmltooling::ValidatorSuite ProtocolSchemaValidators;
+        void SAML_API registerProtocolClasses();
     };
 };