Add support for returning 304 responses.
[shibboleth/sp.git] / shibsp / metadata / MetadataExtSchemaValidators.cpp
1 /*
2 *  Copyright 2001-2009 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 <saml/SAMLConfig.h>
28 #include <saml/saml2/metadata/MetadataProvider.h>
29 #include <xmltooling/validation/Validator.h>
30 #include <xmltooling/validation/ValidatorSuite.h>
31
32 using namespace shibsp;
33 using namespace opensaml::saml2md;
34 using namespace xmltooling;
35 using namespace std;
36
37 using shibspconstants::SHIBMD_NS;
38
39 namespace shibsp {
40     XMLOBJECTVALIDATOR_SIMPLE(SHIBSP_DLLLOCAL,Scope);
41
42     BEGIN_XMLOBJECTVALIDATOR(SHIBSP_DLLLOCAL,KeyAuthority);
43         XMLOBJECTVALIDATOR_NONEMPTY(KeyAuthority,KeyInfo);
44     END_XMLOBJECTVALIDATOR;
45     
46     SHIBSP_DLLLOCAL PluginManager<MetadataProvider,string,const DOMElement*>::Factory DynamicMetadataProviderFactory;
47 };
48
49 #define REGISTER_ELEMENT(cname) \
50     q=xmltooling::QName(SHIBMD_NS,cname::LOCAL_NAME); \
51     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
52     SchemaValidators.registerValidator(q,new cname##SchemaValidator())
53     
54 void shibsp::registerMetadataExtClasses() {
55     xmltooling::QName q;
56     REGISTER_ELEMENT(Scope);
57     REGISTER_ELEMENT(KeyAuthority);
58
59     opensaml::SAMLConfig::getConfig().MetadataProviderManager.registerFactory(DYNAMIC_METADATA_PROVIDER, DynamicMetadataProviderFactory);
60 }