e4a4e56c1a62e69eb2b8f7f823856e560835a8b8
[shibboleth/cpp-sp.git] / shibsp / metadata / MetadataExtSchemaValidators.cpp
1 /*
2 *  Copyright 2001-2007 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  * MetadataExtSchemaValidators.cpp
19  * 
20  * Schema-based validators for Shibboleth metadata extension classes
21  */
22
23 #include "internal.h"
24 #include "exceptions.h"
25 #include "metadata/MetadataExt.h"
26
27 #include <xmltooling/validation/ValidatorSuite.h>
28
29 using namespace shibsp;
30 using namespace xmltooling;
31 using namespace std;
32
33 using shibspconstants::SHIBMD_NS;
34
35 namespace shibsp {
36     XMLOBJECTVALIDATOR_SIMPLE(SHIBSP_DLLLOCAL,Scope);
37
38     BEGIN_XMLOBJECTVALIDATOR(SHIBSP_DLLLOCAL,KeyAuthority);
39         XMLOBJECTVALIDATOR_NONEMPTY(KeyAuthority,KeyInfo);
40     END_XMLOBJECTVALIDATOR;
41 };
42
43 #define REGISTER_ELEMENT(cname) \
44     q=QName(SHIBMD_NS,cname::LOCAL_NAME); \
45     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
46     SchemaValidators.registerValidator(q,new cname##SchemaValidator())
47     
48 void shibsp::registerMetadataExtClasses() {
49     QName q;
50     REGISTER_ELEMENT(Scope);
51     REGISTER_ELEMENT(KeyAuthority);
52 }