Implemented EncryptionMethod schema snippet.
[shibboleth/cpp-xmltooling.git] / xmltooling / encryption / impl / EncryptionSchemaValidators.cpp
1 /*
2 *  Copyright 2001-2006 Internet2
3  * 
4 * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * EncryptionSchemaValidators.cpp
19  * 
20  * Schema validators for XML Encryption schema
21  */
22
23 #include "internal.h"
24 #include "exceptions.h"
25 #include "encryption/Encryption.h"
26
27 using namespace xmlencryption;
28 using namespace xmltooling;
29 using namespace std;
30
31 namespace xmlencryption {
32
33     XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,KeySize);
34     XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,OAEPparams);
35     
36     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,EncryptionMethod);
37         XMLOBJECTVALIDATOR_REQUIRE(EncryptionMethod,Algorithm);
38     END_XMLOBJECTVALIDATOR;
39
40 };
41
42 #define REGISTER_ELEMENT(namespaceURI,cname) \
43     q=QName(namespaceURI,cname::LOCAL_NAME); \
44     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
45     Validator::registerValidator(q,new cname##SchemaValidator())
46     
47 #define REGISTER_TYPE(namespaceURI,cname) \
48     q=QName(namespaceURI,cname::TYPE_NAME); \
49     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
50     Validator::registerValidator(q,new cname##SchemaValidator())
51
52 void xmlencryption::registerEncryptionClasses()
53 {
54     QName q;
55     REGISTER_ELEMENT(XMLConstants::XMLENC_NS,KeySize);
56     REGISTER_ELEMENT(XMLConstants::XMLENC_NS,OAEPparams);
57     REGISTER_ELEMENT(XMLConstants::XMLENC_NS,EncryptionMethod);
58     REGISTER_TYPE(XMLConstants::XMLENC_NS,EncryptionMethod);
59 }