e103108f1955883f0ce509fea72b9447bdc1db62
[shibboleth/cpp-sp.git] / shib-target / internal.h
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 /* internal.h - internally visible declarations
18
19    Scott Cantor
20    6/29/03
21
22    $History:$
23 */
24
25 #ifndef __shibtarget_internal_h__
26 #define __shibtarget_internal_h__
27
28 #ifdef WIN32
29 # define _CRT_SECURE_NO_DEPRECATE 1
30 # define _CRT_NONSTDC_NO_DEPRECATE 1
31 #endif
32
33 #ifdef WIN32
34 # define SHIBTARGET_EXPORTS __declspec(dllexport)
35 #endif
36
37 // eventually we might be able to support autoconf via cygwin...
38 #if defined (_MSC_VER) || defined(__BORLANDC__)
39 # include "config_win32.h"
40 #else
41 # include "config.h"
42 #endif
43
44 #include <shibsp/util/SPConstants.h>
45
46 #include "shib-target.h"
47 #include "hresult.h"
48
49 #include <log4cpp/Category.hh>
50 #include <log4cpp/FixedContextCategory.hh>
51 #include <shibsp/exceptions.h>
52 #include <xmltooling/PluginManager.h>
53 #include <xmltooling/util/NDC.h>
54 #include <xmltooling/util/Threads.h>
55
56
57 #define SHIBT_L(s) shibtarget::XML::Literals::s
58 #define SHIBT_L_QNAME(p,s) shibtarget::XML::Literals::p##_##s
59 #define SHIBT_LOGCAT "shibtarget"
60 #define SHIBTRAN_LOGCAT "Shibboleth-TRANSACTION"
61
62 namespace shibtarget {
63     // ST-aware class that maps SAML artifacts to appropriate binding information
64     class STArtifactMapper : public virtual saml::SAMLBrowserProfile::ArtifactMapper
65     {
66     public:
67         STArtifactMapper(const IApplication* application) : m_app(application) {}
68         virtual ~STArtifactMapper() {}
69         saml::SAMLResponse* resolve(saml::SAMLRequest* request);
70     
71     private:
72         const IApplication* m_app;
73     };
74
75     class STConfig : public ShibTargetConfig
76     {
77     public:
78         STConfig() : m_tranLog(NULL), m_tranLogLock(NULL) {}
79         ~STConfig() {}
80         
81         bool init(const char* schemadir);
82         bool load(const char* config);
83         void shutdown();
84
85         log4cpp::Category& getTransactionLog() { m_tranLogLock->lock(); return *m_tranLog; }
86         void releaseTransactionLog() { m_tranLogLock->unlock();}
87     private:
88         log4cpp::FixedContextCategory* m_tranLog;
89         xmltooling::Mutex* m_tranLogLock;
90     };
91     
92     // TODO: move this over to shibsp lib.
93     xmltooling::PluginManager<shibsp::ServiceProvider,const DOMElement*>::Factory XMLServiceProviderFactory;
94 }
95
96 #endif