Add configuration options for the cacheType, cacheClean, cacheTimeout,
authorDerek Atkins <derek@ihtfp.com>
Tue, 25 Feb 2003 01:28:39 +0000 (01:28 +0000)
committerDerek Atkins <derek@ihtfp.com>
Tue, 25 Feb 2003 01:28:39 +0000 (01:28 +0000)
and requestAttributes

configs/shibboleth.ini
shib-target/shib-ccache.cpp
shib-target/shib-config.cpp
shib-target/shib-resource.cpp
shib-target/shib-target.h

index c6b85f6..55a6567 100644 (file)
@@ -36,8 +36,20 @@ logger=/opt/shibboleth/etc/shibboleth/shar.logger
 #keypass=
 calist=/opt/shibboleth/etc/shibboleth/ca-bundle.crt
 
+# The following shar items are for caching parameters
+cacheType=memory
+# how often to run the cache cleanup (in seconds)  (300 == 5*60 == 5 minutes)
+cacheClean=300
+# idle timeout (in minutes)  (240 == 8*60 == 8 hours)
+cacheTimeout=240
+
 [extensions:saml]
 eduPerson=/opt/shibboleth/lib/libeduPerson.so
 
 [policies]
-InCommon=urn:mace:InCommon:pilot:2003
\ No newline at end of file
+InCommon=urn:mace:InCommon:pilot:2003
+
+[my.server.name]
+# list of attributes to request for server "my.server.name"
+# requests everything if this doesn't exist or is empty
+requestAttributes = 
index 39a0a6c..6ff6de7 100644 (file)
@@ -326,14 +326,33 @@ void InternalCCache::cleanup()
   Mutex* mutex = Mutex::create();
   saml::NDC ndc("InternalCCache::cleanup()");
 
+  ShibTargetConfig& config = ShibTargetConfig::getConfig();
+  ShibINI& ini = config.getINI();
+
+  int rerun_timer = 0;
+  int timeout_life = 0;
+
+  string tag;
+  if (ini.get_tag (SHIBTARGET_SHAR, SHIBTARGET_TAG_CACHECLEAN, true, &tag))
+    rerun_timer = atoi(tag.c_str());
+  if (ini.get_tag (SHIBTARGET_SHAR, SHIBTARGET_TAG_CACHETIMEOUT, true, &tag))
+    timeout_life = atoi(tag.c_str());
+
+  if (rerun_timer <= 0)
+    rerun_timer = 300;         // rerun every 5 minutes
+
+  if (timeout_life <= 0)
+    timeout_life = 28800;      // timeout after 8 hours
+
   mutex->lock();
 
-  log->debug("Cleanup thread started...");
+  log->debug("Cleanup thread started...  Run every %d secs; timeout after %d secs",
+            rerun_timer, timeout_life);
 
   while (shutdown == false) {
     struct timespec ts;
     memset (&ts, 0, sizeof(ts));
-    ts.tv_sec = time(NULL) + 3600;     // run every hour
+    ts.tv_sec = time(NULL) + rerun_timer;
 
     shutdown_wait->timedwait(mutex, &ts);
 
@@ -351,7 +370,7 @@ void InternalCCache::cleanup()
     // Pass 1: iterate over the map and find all entries that have not been
     // used in X hours
     vector<string> stale_keys;
-    time_t stale = time(NULL) - 8 * 3600; // XXX: 8 hour timeout.
+    time_t stale = time(NULL) - timeout_life;
 
     lock->rdlock();
     for (map<string,InternalCCacheEntry*>::iterator i=m_hashtable.begin();
@@ -375,6 +394,8 @@ void InternalCCache::cleanup()
 
   }
 
+  log->debug("Cleanup thread finished.");
+
   mutex->unlock();
   delete mutex;
   Thread::exit(NULL);
index a0e9397..055a1bf 100644 (file)
@@ -184,8 +184,13 @@ STConfig::STConfig(const char* app_name, const char* inifile)
   }
 
   // Initialize the SHAR Cache
-  if (!strcmp (app_name, SHIBTARGET_SHAR))
-    g_shibTargetCCache = CCache::getInstance(NULL);
+  if (!strcmp (app_name, SHIBTARGET_SHAR)) {
+    const char * cache_type = NULL;
+    if (ini->get_tag (app, SHIBTARGET_TAG_CACHETYPE, true, &tag))
+      cache_type = tag.c_str();
+
+    g_shibTargetCCache = CCache::getInstance(cache_type);
+  }
 
   // Load any SAML extensions
   string ext = "extensions:saml";
index 3322d05..10e6626 100644 (file)
@@ -45,6 +45,39 @@ ResourcePriv::ResourcePriv(const char *str)
   m_resource = m_url.substr(0, slash-str);
 
   log->info("creating resource: \"%s\" -> \"%s\"", str, m_resource.c_str());
+
+  // Now figure out the designators
+  string server = m_url.substr(colon-str+3);
+
+  log->debug("server is \"%s\"", server.c_str());
+
+  ShibTargetConfig& config = ShibTargetConfig::getConfig();
+  ShibINI& ini = config.getINI();
+
+  string tag;
+  if (ini.get_tag (server, SHIBTARGET_TAG_REQATTRS, true, &tag)) {
+    // Now parse the request attributes tag...
+
+    const char * the_tag = tag.c_str();
+    const char * tag_ptr, *end_ptr;
+
+    // XXX: should we use strtok_r()?
+    for (tag_ptr = the_tag; tag_ptr && *tag_ptr; tag_ptr = end_ptr) {
+      end_ptr = strchr(tag_ptr, ' ');
+
+      // parse out the attribute substring
+      string a = tag.substr(the_tag-tag_ptr, (end_ptr ? end_ptr-tag_ptr : -1));
+      auto_ptr<XMLCh> temp(XMLString::transcode(a.c_str()));
+
+      log->debug ("Parsed attribute string: \"%s\"", a.c_str());
+
+      // Now create the SAML Attribute from this name
+      
+
+      // and prepare for the next run through the loop.
+      if (end_ptr) end_ptr++;
+    }
+  }
 }
 
 ResourcePriv::~ResourcePriv() {}
index 703ec9c..5025f22 100644 (file)
@@ -96,6 +96,12 @@ void shib_sock_close (ShibSocket s, ShibSockName name);
 #define SHIBTARGET_TAG_SITESCERT "sitesCertFile"
 #define SHIBTARGET_TAG_SITESREFRESH "sitesRefresh"
 
+#define SHIBTARGET_TAG_CACHETYPE       "cacheType"
+#define SHIBTARGET_TAG_CACHECLEAN      "cacheClean"
+#define SHIBTARGET_TAG_CACHETIMEOUT    "cacheTimeout"
+
+#define SHIBTARGET_TAG_REQATTRS                "requestAttributes"
+
 /* initialize and finalize the target library (return 0 on success, 1 on failure) */
 int shib_target_initialize (const char* application, const char* ini_file);
 void shib_target_finalize (void);