Update gitignore to account for subdirs / missing files.
[shibboleth/cpp-opensaml.git] / saml / internal.h
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  *  internal.h - internally visible classes
23  */
24
25 #ifndef __saml_internal_h__
26 #define __saml_internal_h__
27
28 #ifdef WIN32
29 # define _CRT_SECURE_NO_DEPRECATE 1
30 # define _CRT_NONSTDC_NO_DEPRECATE 1
31 # define _SCL_SECURE_NO_WARNINGS 1
32 #endif
33
34 // Export public APIs
35 #define SAML_EXPORTS
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 "base.h"
45 #include "SAMLConfig.h"
46
47 #include <limits.h>
48 #include <vector>
49 #include <boost/scoped_ptr.hpp>
50 #include <xmltooling/unicode.h>
51
52 using namespace xercesc;
53
54 // C99 defines LLONG_MIN, LLONG_MAX and ULLONG_MAX, but this part of
55 // C99 is not yet included into the C++ standard.
56 // GCC defines LONG_LONG_MIN, LONG_LONG_MAX and ULONG_LONG_MAX.
57 // Some compilers (such as Comeau C++ up to and including version 4.3.3)
58 // define nothing.  In this last case we make a reasonable guess.
59 #ifndef LLONG_MIN
60 #if defined(LONG_LONG_MIN)
61 #define LLONG_MIN LONG_LONG_MIN
62 #elif SIZEOF_LONG_LONG == 8
63 #define LLONG_MIN 0x8000000000000000LL
64 #endif
65 #endif
66  
67 #ifndef LLONG_MAX
68 #if defined(LONG_LONG_MAX)
69 #define LLONG_MAX LONG_LONG_MAX
70 #elif SIZEOF_LONG_LONG == 8
71 #define LLONG_MAX 0x7fffffffffffffffLL
72 #endif
73 #endif
74  
75 #ifndef ULLONG_MAX
76 #if defined(ULONG_LONG_MAX)
77 #define ULLONG_MAX ULONG_LONG_MAX
78 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
79 #define ULLONG_MAX 0xffffffffffffffffULL
80 #endif
81 #endif
82
83 #define SAMLTIME_MAX (sizeof(time_t) == 8 ? LLONG_MAX : INT_MAX)
84
85 #define SAML_LOGCAT "OpenSAML"
86
87 namespace xmltooling {
88     class XMLTOOL_API Mutex;
89 };
90
91 namespace opensaml {
92     
93     /// @cond OFF
94     class SAML_DLLLOCAL SAMLInternalConfig : public SAMLConfig
95     {
96     public:
97         SAMLInternalConfig();
98         ~SAMLInternalConfig();
99
100         static SAMLInternalConfig& getInternalConfig();
101
102         // global per-process setup and shutdown of runtime
103         bool init(bool initXMLTooling=true);
104         void term(bool termXMLTooling=true);
105
106         void generateRandomBytes(void* buf, unsigned int len);
107         void generateRandomBytes(std::string& buf, unsigned int len);
108         XMLCh* generateIdentifier();
109         std::string hashSHA1(const char* data, bool toHex=false);
110         void setContactPriority(const XMLCh*);
111         const saml2md::ContactPerson* getContactPerson(const saml2md::EntityDescriptor&) const;
112         const saml2md::ContactPerson* getContactPerson(const saml2md::RoleDescriptor&) const;
113
114     private:
115         int m_initCount;
116         boost::scoped_ptr<xmltooling::Mutex> m_lock;
117         std::vector<xmltooling::xstring> m_contactPriority;
118     };
119     /// @endcond
120
121 };
122
123 #endif /* __saml_internal_h__ */