Propagate expiry time from assertion
authorLuke Howard <lukeh@padl.com>
Sun, 19 Sep 2010 19:44:56 +0000 (21:44 +0200)
committerLuke Howard <lukeh@padl.com>
Sun, 19 Sep 2010 19:44:56 +0000 (21:44 +0200)
mech_eap/util_attr.cpp
mech_eap/util_attr.h
mech_eap/util_saml.cpp
mech_eap/util_saml.h

index 098dcb6..c6388d7 100644 (file)
@@ -372,6 +372,25 @@ gss_eap_attr_ctx::initFromBuffer(const gss_buffer_t buffer)
     return ret;
 }
 
+time_t
+gss_eap_attr_ctx::getExpiryTime(void) const
+{
+    unsigned int i;
+    time_t expiryTime = 0;
+
+    for (i = ATTR_TYPE_MIN; i < ATTR_TYPE_MAX; i++) {
+        time_t providerExpiryTime = m_providers[i]->getExpiryTime();
+
+        if (providerExpiryTime == 0)
+            continue;
+
+        if (expiryTime == 0 || providerExpiryTime < expiryTime)
+            expiryTime = providerExpiryTime;
+    }
+
+    return expiryTime;
+}
+
 /*
  * C wrappers
  */
@@ -734,5 +753,7 @@ gssEapCreateAttrContext(gss_cred_id_t gssCred,
         return NULL;
     }
 
+    gssCtx->expiryTime = ctx->getExpiryTime();
+
     return ctx;
 }
index 206e424..90b0953 100644 (file)
@@ -104,6 +104,8 @@ public:
         return initWithManager(manager);
     }
 
+    virtual time_t getExpiryTime(void) const { return 0; }
+
     static bool init() { return true; }
     static void finalize() {}
 
@@ -191,6 +193,8 @@ public:
     static void
     unregisterProvider(unsigned int type);
 
+    time_t getExpiryTime(void) const;
+
 private:
     gss_eap_attr_provider *getPrimaryProvider(void) const;
 
index cdac5c8..5879709 100644 (file)
@@ -170,6 +170,23 @@ gss_eap_saml_assertion_provider::deleteAttribute(const gss_buffer_t value)
     m_authenticated = false;
 }
 
+time_t
+gss_eap_saml_assertion_provider::getExpiryTime(void) const
+{
+    saml2::Conditions *conditions;
+    time_t expiryTime = 0;
+
+    if (m_assertion == NULL)
+        return 0;
+
+    conditions = m_assertion->getConditions();
+
+    if (conditions != NULL && conditions->getNotOnOrAfter() != NULL)
+        expiryTime = conditions->getNotOnOrAfter()->getEpoch();
+
+    return expiryTime;
+}
+
 bool
 gss_eap_saml_assertion_provider::getAttribute(const gss_buffer_t attr,
                                               int *authenticated,
index b35cf49..73e64e5 100644 (file)
@@ -79,6 +79,8 @@ public:
         return m_authenticated;
     }
 
+    time_t getExpiryTime(void) const;
+
     static bool init();
     static void finalize();