Use shibboleth-sp as package name for compatibility.
[shibboleth/cpp-sp.git] / plugins / plugins.cpp
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * plugins.cpp
23  *
24  * Extension plugins for Shibboleth SP.
25  */
26
27 #include "internal.h"
28 #include <shibsp/SPConfig.h>
29 #include <shibsp/util/SPConstants.h>
30 #include <xmltooling/impl/AnyElement.h>
31
32 using namespace shibsp;
33 using namespace xmltooling;
34 using namespace xercesc;
35 using namespace std;
36
37 #ifdef WIN32
38 # define PLUGINS_EXPORTS __declspec(dllexport)
39 #else
40 # define PLUGINS_EXPORTS
41 #endif
42
43 namespace shibsp {
44     PluginManager<AccessControl,string,const DOMElement*>::Factory TimeAccessControlFactory;
45 #ifndef SHIBSP_LITE
46 # ifdef HAVE_GSSAPI_NAMINGEXTS
47     PluginManager<AttributeExtractor,string,const DOMElement*>::Factory GSSAPIExtractorFactory;
48 # endif
49     PluginManager<AttributeResolver,string,const DOMElement*>::Factory TemplateAttributeResolverFactory;
50     PluginManager<AttributeResolver,string,const DOMElement*>::Factory TransformAttributeResolverFactory;
51     PluginManager<AttributeResolver,string,const DOMElement*>::Factory UpperCaseAttributeResolverFactory;
52     PluginManager<AttributeResolver,string,const DOMElement*>::Factory LowerCaseAttributeResolverFactory;
53 #endif
54 };
55
56 extern "C" int PLUGINS_EXPORTS xmltooling_extension_init(void*)
57 {
58     SPConfig& conf = SPConfig::getConfig();
59     conf.AccessControlManager.registerFactory("Time", TimeAccessControlFactory);
60 #ifndef SHIBSP_LITE
61 # ifdef HAVE_GSSAPI_NAMINGEXTS
62     conf.AttributeExtractorManager.registerFactory("GSSAPI", GSSAPIExtractorFactory);
63     static const XMLCh _GSSAPIName[] = UNICODE_LITERAL_10(G,S,S,A,P,I,N,a,m,e);
64     static const XMLCh _GSSAPIContext[] = UNICODE_LITERAL_13(G,S,S,A,P,I,C,o,n,t,e,x,t);
65     XMLObjectBuilder::registerBuilder(xmltooling::QName(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _GSSAPIName), new AnyElementBuilder());
66     XMLObjectBuilder::registerBuilder(xmltooling::QName(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _GSSAPIContext), new AnyElementBuilder());
67 # endif
68     conf.AttributeResolverManager.registerFactory("Template", TemplateAttributeResolverFactory);
69     conf.AttributeResolverManager.registerFactory("Transform", TransformAttributeResolverFactory);
70     conf.AttributeResolverManager.registerFactory("UpperCase", UpperCaseAttributeResolverFactory);
71     conf.AttributeResolverManager.registerFactory("LowerCase", LowerCaseAttributeResolverFactory);
72 #endif
73     return 0;   // signal success
74 }
75
76 extern "C" void PLUGINS_EXPORTS xmltooling_extension_term()
77 {
78     // Factories normally get unregistered during library shutdown, so no work usually required here.
79 }