InternalCCacheEntry(SAMLAuthenticationStatement *s, const char *client_addr);
~InternalCCacheEntry();
- virtual Iterator<SAMLAssertion*> getAssertions(Resource& resource);
- virtual void preFetch(Resource& resource, int prefetch_window);
+ virtual Iterator<SAMLAssertion*> getAssertions(const char* resource);
+ virtual void preFetch(const char* resource, int prefetch_window);
virtual bool isSessionValid(time_t lifetime, time_t timeout);
virtual const char* getClientAddress() { return m_clientAddress.c_str(); }
virtual const char* getSerializedStatement() { return m_statement.c_str(); }
void rdlock() { cacheitem_lock->rdlock(); }
void wrlock() { cacheitem_lock->wrlock(); }
- static vector<SAMLAssertion*> g_emptyVector;
-
private:
- ResourceEntry* populate(Resource& resource, int slop);
+ ResourceEntry* populate(const char* resource, int slop);
ResourceEntry* find(const char* resource);
void insert(const char* resource, ResourceEntry* entry);
void remove(const char* resource);
class ResourceLock
{
public:
- ResourceLock(InternalCCacheEntry* entry, string resource);
+ ResourceLock(InternalCCacheEntry* entry, const char* resource);
~ResourceLock();
private:
- Mutex* find(string& resource);
+ Mutex* find(const char* resource);
InternalCCacheEntry* entry;
- string resource;
+ string m_resource;
};
friend class ResourceLock;
virtual ~InternalCCache();
virtual CCacheEntry* find(const char* key);
- virtual void insert(const char* key, SAMLAuthenticationStatement *s,
- const char *client_addr);
+ virtual void insert(const char* key, SAMLAuthenticationStatement *s, const char *client_addr);
virtual void remove(const char* key);
InternalCCacheEntry* findi(const char* key);
return (CCache*) new InternalCCache();
}
-// static members
-vector<SAMLAssertion*> InternalCCacheEntry::g_emptyVector;
-
/******************************************************************************/
/* InternalCCache: A Credential Cache */
InternalCCache::InternalCCache()
{
- string ctx="shibtarget.InternalCCache";
- log = &(log4cpp::Category::getInstance(ctx));
+ log = &(log4cpp::Category::getInstance("shibtarget.InternalCCache"));
lock = RWLock::create();
shutdown_wait = CondWait::create();
return dynamic_cast<CCacheEntry*>(entry);
}
-void InternalCCache::insert(const char* key, SAMLAuthenticationStatement *s,
- const char *client_addr)
+void InternalCCache::insert(const char* key, SAMLAuthenticationStatement *s, const char *client_addr)
{
log->debug("caching new entry for \"%s\"", key);
InternalCCacheEntry::InternalCCacheEntry(SAMLAuthenticationStatement *s, const char *client_addr)
: m_hasbinding(false)
{
- string ctx = "shibtarget::InternalCCacheEntry";
- log = &(log4cpp::Category::getInstance(ctx));
+ log = &(log4cpp::Category::getInstance("shibtarget::InternalCCacheEntry"));
pop_locks_lock = Mutex::create();
access_lock = Mutex::create();
resource_lock = RWLock::create();
const XMLCh* name = m_subject->getName();
const XMLCh* qual = m_subject->getNameQualifier();
- auto_ptr<char> h(XMLString::transcode(name));
- auto_ptr<char> d(XMLString::transcode(qual));
+ auto_ptr_char h(name);
+ auto_ptr_char d(qual);
m_handle = h.get();
m_originSite = d.get();
m_statement = os.str();
log->info("New Session Created...");
- log->debug("Handle: \"%s\", Site: \"%s\", Address: %s", h.get(), d.get(),
- client_addr);
+ log->debug("Handle: \"%s\", Site: \"%s\", Address: %s", h.get(), d.get(), client_addr);
}
InternalCCacheEntry::~InternalCCacheEntry()
return true;
}
-Iterator<SAMLAssertion*> InternalCCacheEntry::getAssertions(Resource& resource)
+Iterator<SAMLAssertion*> InternalCCacheEntry::getAssertions(const char* resource)
{
saml::NDC ndc("getAssertions");
ResourceEntry* entry = populate(resource, 0);
if (entry)
return entry->getAssertions();
- return Iterator<SAMLAssertion*>(InternalCCacheEntry::g_emptyVector);
+ return EMPTY(SAMLAssertion*);
}
-void InternalCCacheEntry::preFetch(Resource& resource, int prefetch_window)
+void InternalCCacheEntry::preFetch(const char* resource, int prefetch_window)
{
saml::NDC ndc("preFetch");
- ResourceEntry* entry = populate(resource, prefetch_window);
+ populate(resource, prefetch_window);
}
-ResourceEntry* InternalCCacheEntry::populate(Resource& resource, int slop)
+ResourceEntry* InternalCCacheEntry::populate(const char* resource, int slop)
{
saml::NDC ndc("populate");
- log->debug("populating entry for %s (%s)",
- resource.getResource(), resource.getURL());
+ log->debug("populating entry for %s", resource);
// Lock the resource within this entry...
- InternalCCacheEntry::ResourceLock lock(this, resource.getResource());
+ InternalCCacheEntry::ResourceLock lock(this, resource);
// Can we use what we have?
- ResourceEntry *entry = find(resource.getResource());
+ ResourceEntry *entry = find(resource);
if (entry) {
log->debug("found resource");
if (entry->isValid(slop))
// entry is invalid (expired) -- go fetch a new one.
log->debug("removing resource cache; assertion is invalid");
- remove (resource.getResource());
+ remove(resource);
delete entry;
}
}
log->info("trying to request attributes for %s@%s -> %s",
- m_handle.c_str(), m_originSite.c_str(), resource.getURL());
+ m_handle.c_str(), m_originSite.c_str(), resource);
try {
entry = new ResourceEntry(resource, *m_subject, m_cache, p_auth->getBindings());
} catch (ShibTargetException&) {
return NULL;
}
- insert (resource.getResource(), entry);
+ insert(resource, entry);
log->info("fetched and stored SAML response");
return entry;
}
-ResourceEntry* InternalCCacheEntry::find(const char* resource_url)
+ResourceEntry* InternalCCacheEntry::find(const char* resource)
{
ReadLock rwlock(resource_lock);
- log->debug("find: %s", resource_url);
- map<string,ResourceEntry*>::const_iterator i=m_resources.find(resource_url);
+ log->debug("find: %s", resource);
+ map<string,ResourceEntry*>::const_iterator i=m_resources.find(resource);
if (i==m_resources.end()) {
log->debug("no match found");
return NULL;
// will obtain and hold the proper lock until it goes out of scope and
// deconstructs.
-InternalCCacheEntry::ResourceLock::ResourceLock(InternalCCacheEntry* entry,
- string resource) :
- entry(entry), resource(resource)
+InternalCCacheEntry::ResourceLock::ResourceLock(InternalCCacheEntry* entry, const char* resource) :
+ entry(entry), m_resource(resource)
{
Mutex *mutex = find(resource);
mutex->lock();
InternalCCacheEntry::ResourceLock::~ResourceLock()
{
- Mutex *mutex = find(resource);
+ Mutex *mutex = find(m_resource.c_str());
mutex->unlock();
}
-Mutex* InternalCCacheEntry::ResourceLock::find(string& resource)
+Mutex* InternalCCacheEntry::ResourceLock::find(const char* resource)
{
Lock(entry->pop_locks_lock);