+DDF
+gss_eap_attr_ctx::marshall(void) const
+{
+ DDF obj(NULL);
+ unsigned int i;
+
+ obj.addmember("version").integer(1);
+ obj.addmember("flags").integer(m_flags);
+
+ DDF sources = obj.addmember("sources").list();
+
+ for (i = ATTR_TYPE_MIN; i <= ATTR_TYPE_MAX; i++) {
+ gss_eap_attr_provider *provider = m_providers[i];
+
+ if (provider == NULL)
+ continue; /* provider not initialised */
+
+ const char *key = provider->marshallingKey();
+ if (key == NULL)
+ continue; /* provider does not have state */
+
+ DDF source = provider->marshall();
+ sources.add(source.name(key));
+ }
+
+ return obj;
+}
+
+/*
+ * Initialize a context from an exported context or name token
+ */
+bool
+gss_eap_attr_ctx::initFromBuffer(const gss_buffer_t buffer)
+{
+ bool ret;
+
+ if (buffer->length == 0)
+ return false;
+
+ DDF obj(NULL);
+ std::string str((const char *)buffer->value, buffer->length);
+ std::istringstream source(str);
+
+ source >> obj;
+
+ ret = unmarshallAndInit(obj);
+
+ obj.destroy();
+
+ return ret;
+}
+