DDF marshall() const;
static eap_gss_saml_attr_ctx *unmarshall(DDF &in);
- bool marshall(gss_buffer_t buffer);
+ void marshall(gss_buffer_t buffer);
static eap_gss_saml_attr_ctx *unmarshall(const gss_buffer_t buffer);
private:
parseAssertion(buffer);
}
+static OM_uint32
+mapException(OM_uint32 *minor, exception &e)
+{
+ return GSS_S_FAILURE;
+}
+
bool
eap_gss_saml_attr_ctx::parseAssertion(const gss_buffer_t buffer)
{
return (m_assertion != NULL);
}
-static inline bool
+static inline void
+duplicateBuffer(gss_buffer_desc &src, gss_buffer_t dst)
+{
+ OM_uint32 minor;
+
+ if (GSS_ERROR(duplicateBuffer(&minor, &src, dst)))
+ throw new bad_alloc();
+}
+
+static inline void
duplicateBuffer(string &str, gss_buffer_t buffer)
{
gss_buffer_desc tmp;
- OM_uint32 minor;
tmp.length = str.length();
tmp.value = (char *)str.c_str();
- if (GSS_ERROR(duplicateBuffer(&minor, &tmp, buffer)))
- return false;
-
- return true;
+ duplicateBuffer(tmp, buffer);
}
DDF
return ctx;
}
-bool
+void
eap_gss_saml_attr_ctx::marshall(gss_buffer_t buffer)
{
DDF obj;
sink << obj;
str = sink.str();
- return duplicateBuffer(str, buffer);
+ duplicateBuffer(str, buffer);
}
eap_gss_saml_attr_ctx *
{
string str;
+ if (m_assertion == NULL)
+ return false;
+
buffer->value = NULL;
buffer->length = 0;
XMLHelper::serialize(m_assertion->marshall((DOMDocument *)NULL), str);
- return duplicateBuffer(str, buffer);
+ duplicateBuffer(str, buffer);
+
+ return true;
}
void
eap_gss_saml_attr_ctx::addAttribute(Attribute *attribute, bool copy)
{
Attribute *a;
+
if (copy) {
DDF obj = attribute->marshall();
a = Attribute::unmarshall(obj);
} else {
a = attribute;
}
+
m_attributes.push_back(a);
}
gss_buffer_t display_value,
int *more)
{
- OM_uint32 major, minor;
const Attribute *shibAttr = NULL;
gss_buffer_desc buf;
buf.value = (void *)shibAttr->getString(*more);
buf.length = strlen((char *)buf.value);
- major = duplicateBuffer(&minor, &buf, value);
- if (GSS_ERROR(major))
- return false;
+ duplicateBuffer(buf, value);
*authenticated = TRUE;
*complete = FALSE;
NULL, &tokens);
ctx->setAttributes(resolverContext->getResolvedAttributes());
} catch (exception &ex) {
- major = GSS_S_BAD_NAME;
+ major = mapException(minor, ex);
goto cleanup;
}
try {
ctx->setAttribute(complete, attr, value);
} catch (exception &e) {
- return GSS_S_FAILURE;
+ return mapException(minor, e);
}
return GSS_S_COMPLETE;
try {
ctx->deleteAttribute(attr);
} catch (exception &e) {
- return GSS_S_FAILURE;
+ return mapException(minor, e);
}
return GSS_S_COMPLETE;
gss_buffer_t buffer)
{
try {
- if (!ctx->marshall(buffer))
- return GSS_S_FAILURE;
+ ctx->marshall(buffer);
} catch (exception &e) {
- return GSS_S_FAILURE;
+ return mapException(minor, e);
}
return GSS_S_COMPLETE;
try {
*pCtx = eap_gss_saml_attr_ctx::unmarshall(buffer);
} catch (exception &e) {
- return GSS_S_FAILURE;
+ return mapException(minor, e);
}
return GSS_S_COMPLETE;
try {
ctx->getAssertion(assertion);
} catch (exception &e) {
- return GSS_S_FAILURE;
+ return mapException(minor, e);
}
return GSS_S_COMPLETE;
try {
*out = new eap_gss_saml_attr_ctx(*in);
} catch (exception &e) {
- return GSS_S_FAILURE;
+ return mapException(minor, e);
}
return GSS_S_COMPLETE;