Fix up feature options for different builds.
[shibboleth/cpp-sp-resolver.git] / shibresolver / resolver.cpp
index dfea7c3..2164f82 100644 (file)
@@ -53,6 +53,8 @@ ShibbolethResolver* ShibbolethResolver::create()
 
 ShibbolethResolver::ShibbolethResolver()
 {
+    m_mapper = NULL;
+    m_sp = NULL;
 }
 
 ShibbolethResolver::~ShibbolethResolver()
@@ -121,6 +123,37 @@ void RemotedResolver::receive(DDF& in, ostream& out)
 {
 }
 
+bool ShibbolethResolver::init(unsigned long features, const char* config, bool rethrow)
+{
+    if (features && SPConfig::OutOfProcess) {
+#ifndef SHIBSP_LITE
+        features = features | SPConfig::AttributeResolution | SPConfig::Metadata | SPConfig::Trust | SPConfig::Credentials;
+#endif
+        if (!(features && SPConfig::InProcess))
+            features |= SPConfig::Listener;
+    }
+    else if (features && SPConfig::InProcess) {
+        features |= SPConfig::Listener;
+    }
+    SPConfig::getConfig().setFeatures(features);
+    if (!SPConfig::getConfig().init())
+        return false;
+    if (!SPConfig::getConfig().instantiate(config, rethrow))
+        return false;
+    return true;
+}
+
+/**
+    * Shuts down runtime.
+    *
+    * Each process using the library SHOULD call this function exactly once before terminating itself.
+    */
+void ShibbolethResolver::term()
+{
+    SPConfig::getConfig().term();
+}
+
+
 extern "C" int SHIBRESOLVER_EXPORTS xmltooling_extension_init(void*)
 {
 #ifdef SHIBRESOLVER_SHIBSP_HAS_REMOTING