2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 * @file saml/SAMLConfig.h
\r
20 * Library configuration
\r
23 #ifndef __saml_config_h__
\r
24 #define __saml_config_h__
\r
26 #include <saml/base.h>
\r
27 #include <saml/binding/ArtifactMap.h>
\r
29 #include <xmltooling/PluginManager.h>
\r
30 #include <xmltooling/XMLToolingConfig.h>
\r
35 * @namespace opensaml
\r
36 * Common classes for OpenSAML library
\r
38 namespace opensaml {
\r
40 class SAML_API MessageEncoder;
\r
41 class SAML_API MessageDecoder;
\r
42 class SAML_API SAMLArtifact;
\r
43 class SAML_API TrustEngine;
\r
46 class SAML_API MetadataProvider;
\r
47 class SAML_API MetadataFilter;
\r
50 #if defined (_MSC_VER)
\r
51 #pragma warning( push )
\r
52 #pragma warning( disable : 4250 4251 )
\r
56 * Singleton object that manages library startup/shutdown.configuration.
\r
58 class SAML_API SAMLConfig
\r
60 MAKE_NONCOPYABLE(SAMLConfig);
\r
62 virtual ~SAMLConfig() {}
\r
65 * Returns the global configuration object for the library.
\r
67 * @return reference to the global library configuration object
\r
69 static SAMLConfig& getConfig();
\r
72 * Initializes library
\r
74 * Each process using the library MUST call this function exactly once
\r
75 * before using any library classes. The flag controls whether this is the
\r
76 * "dominant" library or not and can allow the SAML library to be loaded
\r
77 * as an extension of XMLTooling rather than subsuming it.
\r
79 * @param initXMLTooling true iff this method should initialize the XMLTooling layer
\r
80 * @return true iff initialization was successful
\r
82 virtual bool init(bool initXMLTooling=true)=0;
\r
85 * Shuts down library
\r
87 * Each process using the library SHOULD call this function exactly once
\r
88 * before terminating itself. The flag controls whether this is the
\r
89 * "dominant" library or not and can allow the SAML library to be loaded
\r
90 * as an extension of XMLTooling rather than subsuming it.
\r
92 * @param termXMLTooling true iff this method should shutdown the XMLTooling layer
\r
94 virtual void term(bool termXMLTooling=true)=0;
\r
97 * Sets the global ArtifactMap instance.
\r
98 * This method must be externally synchronized with any code that uses the object.
\r
99 * Any previously set object is destroyed.
\r
101 * @param artifactMap new ArtifactMap instance to store
\r
103 void setArtifactMap(ArtifactMap* artifactMap) {
\r
104 delete m_artifactMap;
\r
105 m_artifactMap = artifactMap;
\r
109 * Returns the global ArtifactMap instance.
\r
111 * @return global ArtifactMap
\r
113 ArtifactMap* getArtifactMap() const {
\r
114 return m_artifactMap;
\r
118 * Generate random information using the underlying security library
\r
120 * @param buf buffer for the information
\r
121 * @param len number of bytes to write into buffer
\r
123 virtual void generateRandomBytes(void* buf, unsigned int len)=0;
\r
126 * Generate random information using the underlying security library
\r
128 * @param buf string buffer for the information
\r
129 * @param len number of bytes to write into buffer
\r
131 virtual void generateRandomBytes(std::string& buf, unsigned int len)=0;
\r
134 * Generate a valid XML identifier of the form _X{32} where X is a
\r
135 * random hex character. The caller is responsible for freeing the result.
\r
137 * @return a valid null-terminated XML ID
\r
139 virtual XMLCh* generateIdentifier()=0;
\r
142 * Generate the SHA-1 hash of a string
\r
144 * @param s NULL-terminated string to hash
\r
145 * @param toHex true iff the result should be encoded in hexadecimal form or left as raw bytes
\r
147 * @return SHA-1 hash of the data
\r
149 virtual std::string hashSHA1(const char* s, bool toHex=false)=0;
\r
152 * Manages factories for MessageDecoder plugins.
\r
154 xmltooling::PluginManager<MessageDecoder,const DOMElement*> MessageDecoderManager;
\r
157 * Manages factories for MessageEncoder plugins.
\r
159 xmltooling::PluginManager<MessageEncoder,const DOMElement*> MessageEncoderManager;
\r
162 * Manages factories for SAMLArtifact plugins.
\r
164 xmltooling::PluginManager<SAMLArtifact,const char*> SAMLArtifactManager;
\r
167 * Manages factories for TrustEngine plugins.
\r
169 xmltooling::PluginManager<TrustEngine,const DOMElement*> TrustEngineManager;
\r
172 * Manages factories for MetadataProvider plugins.
\r
174 xmltooling::PluginManager<saml2md::MetadataProvider,const DOMElement*> MetadataProviderManager;
\r
177 * Manages factories for MetadataFilter plugins.
\r
179 xmltooling::PluginManager<saml2md::MetadataFilter,const DOMElement*> MetadataFilterManager;
\r
182 SAMLConfig() : m_artifactMap(NULL) {}
\r
184 /** Global ArtifactMap instance for use by artifact-related functions. */
\r
185 ArtifactMap* m_artifactMap;
\r
188 #if defined (_MSC_VER)
\r
189 #pragma warning( pop )
\r
194 #endif /* __saml_config_h__ */
\r