Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / encryption / impl / EncryptionSchemaValidators.cpp
index 90407b8..ed781e6 100644 (file)
@@ -1,17 +1,21 @@
-/*
-*  Copyright 2001-2006 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
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you 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
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
 #include "internal.h"
 #include "exceptions.h"
 #include "encryption/Encryption.h"
+#include "validation/Validator.h"
+#include "validation/ValidatorSuite.h"
 
 using namespace xmlencryption;
 using namespace xmltooling;
 using namespace std;
+using xmlconstants::XMLENC_NS;
 
 namespace xmlencryption {
 
@@ -55,7 +62,7 @@ namespace xmlencryption {
     public:
         void operator()(const XMLObject* xmlObject) const {
             const XMLCh* ns=xmlObject->getElementQName().getNamespaceURI();
-            if (XMLString::equals(ns,XMLConstants::XMLENC_NS) || !ns || !*ns) {
+            if (XMLString::equals(ns,XMLENC_NS) || !ns || !*ns) {
                 throw ValidationException(
                     "Object contains an illegal extension child element ($1).",
                     params(1,xmlObject->getElementQName().toString().c_str())
@@ -67,7 +74,7 @@ namespace xmlencryption {
     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,EncryptionProperty);
         if (!ptr->hasChildren())
             throw ValidationException("EncryptionProperty must have at least one child element.");
-        const list<XMLObject*>& anys=ptr->getXMLObjects();
+        const vector<XMLObject*>& anys=ptr->getUnknownXMLObjects();
         for_each(anys.begin(),anys.end(),checkWildcardNS());
     END_XMLOBJECTVALIDATOR;
 
@@ -77,7 +84,7 @@ namespace xmlencryption {
 
     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,ReferenceType);
         XMLOBJECTVALIDATOR_REQUIRE(DataReference,URI);
-        const list<XMLObject*>& anys=ptr->getXMLObjects();
+        const vector<XMLObject*>& anys=ptr->getUnknownXMLObjects();
         for_each(anys.begin(),anys.end(),checkWildcardNS());
     END_XMLOBJECTVALIDATOR;
 
@@ -111,35 +118,35 @@ namespace xmlencryption {
 #define REGISTER_ELEMENT(namespaceURI,cname) \
     q=QName(namespaceURI,cname::LOCAL_NAME); \
     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
-    Validator::registerValidator(q,new cname##SchemaValidator())
+    SchemaValidators.registerValidator(q,new cname##SchemaValidator())
     
 #define REGISTER_TYPE(namespaceURI,cname) \
     q=QName(namespaceURI,cname::TYPE_NAME); \
     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
-    Validator::registerValidator(q,new cname##SchemaValidator())
+    SchemaValidators.registerValidator(q,new cname##SchemaValidator())
 
 void xmlencryption::registerEncryptionClasses()
 {
     QName q;
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,CarriedKeyName);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,CipherData);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,CipherReference);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,CipherValue);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,DataReference);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,EncryptedData);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,EncryptedKey);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,EncryptionMethod);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,EncryptionProperties);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,EncryptionProperty);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,KeyReference);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,KeySize);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,OAEPparams);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,ReferenceList);
-    REGISTER_ELEMENT(XMLConstants::XMLENC_NS,Transforms);
-    REGISTER_TYPE(XMLConstants::XMLENC_NS,CipherData);
-    REGISTER_TYPE(XMLConstants::XMLENC_NS,CipherReference);
-    REGISTER_TYPE(XMLConstants::XMLENC_NS,EncryptionMethod);
-    REGISTER_TYPE(XMLConstants::XMLENC_NS,EncryptionProperties);
-    REGISTER_TYPE(XMLConstants::XMLENC_NS,EncryptionProperty);
-    REGISTER_TYPE(XMLConstants::XMLENC_NS,Transforms);
+    REGISTER_ELEMENT(XMLENC_NS,CarriedKeyName);
+    REGISTER_ELEMENT(XMLENC_NS,CipherData);
+    REGISTER_ELEMENT(XMLENC_NS,CipherReference);
+    REGISTER_ELEMENT(XMLENC_NS,CipherValue);
+    REGISTER_ELEMENT(XMLENC_NS,DataReference);
+    REGISTER_ELEMENT(XMLENC_NS,EncryptedData);
+    REGISTER_ELEMENT(XMLENC_NS,EncryptedKey);
+    REGISTER_ELEMENT(XMLENC_NS,EncryptionMethod);
+    REGISTER_ELEMENT(XMLENC_NS,EncryptionProperties);
+    REGISTER_ELEMENT(XMLENC_NS,EncryptionProperty);
+    REGISTER_ELEMENT(XMLENC_NS,KeyReference);
+    REGISTER_ELEMENT(XMLENC_NS,KeySize);
+    REGISTER_ELEMENT(XMLENC_NS,OAEPparams);
+    REGISTER_ELEMENT(XMLENC_NS,ReferenceList);
+    REGISTER_ELEMENT(XMLENC_NS,Transforms);
+    REGISTER_TYPE(XMLENC_NS,CipherData);
+    REGISTER_TYPE(XMLENC_NS,CipherReference);
+    REGISTER_TYPE(XMLENC_NS,EncryptionMethod);
+    REGISTER_TYPE(XMLENC_NS,EncryptionProperties);
+    REGISTER_TYPE(XMLENC_NS,EncryptionProperty);
+    REGISTER_TYPE(XMLENC_NS,Transforms);
 }