projects
/
cyrus-sasl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f5bdfb8
)
some cleanup work on marshalling
provider
author
Luke Howard
<lukeh@padl.com>
Sat, 18 Sep 2010 10:03:14 +0000
(12:03 +0200)
committer
Luke Howard
<lukeh@padl.com>
Sat, 18 Sep 2010 10:03:14 +0000
(12:03 +0200)
mech_eap/util_attr.cpp
patch
|
blob
|
history
mech_eap/util_attr.h
patch
|
blob
|
history
mech_eap/util_radius.cpp
patch
|
blob
|
history
mech_eap/util_radius.h
patch
|
blob
|
history
mech_eap/util_saml.cpp
patch
|
blob
|
history
mech_eap/util_saml.h
patch
|
blob
|
history
mech_eap/util_shib.cpp
patch
|
blob
|
history
mech_eap/util_shib.h
patch
|
blob
|
history
diff --git
a/mech_eap/util_attr.cpp
b/mech_eap/util_attr.cpp
index
74cf43b
..
28a9161
100644
(file)
--- a/
mech_eap/util_attr.cpp
+++ b/
mech_eap/util_attr.cpp
@@
-44,22
+44,15
@@
gss_eap_attr_factories[ATTR_TYPE_MAX] = {
gss_eap_shib_attr_provider::createAttrContext
};
gss_eap_shib_attr_provider::createAttrContext
};
-gss_eap_attr_ctx *
-gss_eap_attr_ctx::createAttrContext(void)
+gss_eap_attr_ctx::gss_eap_attr_ctx(void)
{
{
- gss_eap_attr_ctx *ctx;
-
- ctx = new gss_eap_attr_ctx;
-
for (unsigned int i = 0; i < ATTR_TYPE_MAX; i++) {
gss_eap_attr_provider *provider;
provider = (gss_eap_attr_factories[i])();
if (provider != NULL)
for (unsigned int i = 0; i < ATTR_TYPE_MAX; i++) {
gss_eap_attr_provider *provider;
provider = (gss_eap_attr_factories[i])();
if (provider != NULL)
-
ctx->
m_providers[i] = provider;
+ m_providers[i] = provider;
}
}
-
- return ctx;
}
bool
}
bool
@@
-304,22
+297,32
@@
gss_eap_attr_ctx::releaseAnyNameMapping(gss_buffer_t type_id,
}
void
}
void
-gss_eap_attr_ctx::
marshall
(gss_buffer_t buffer) const
+gss_eap_attr_ctx::
exportToBuffer
(gss_buffer_t buffer) const
{
{
- /* For now, just marshall the RADIUS context. */
+ m_providers[ATTR_TYPE_RADIUS]->exportToBuffer(buffer);
}
bool
}
bool
-gss_eap_attr_ctx::
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer)
+gss_eap_attr_ctx::
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer)
{
unsigned int i;
{
unsigned int i;
+ bool ret;
- for (i = 0; i < ATTR_TYPE_MAX; i++) {
+ ret = m_providers[ATTR_TYPE_RADIUS]->initFromBuffer(this, buffer);
+ if (!ret)
+ return false;
+
+ for (i = ATTR_TYPE_RADIUS + 1; i < ATTR_TYPE_MAX; i++) {
gss_eap_attr_provider *provider = m_providers[i];
gss_eap_attr_provider *provider = m_providers[i];
+
+ ret = provider->initFromGssContext(
+ this, GSS_C_NO_CREDENTIAL, GSS_C_NO_CONTEXT);
+ if (!ret)
+ break;
}
}
- return
false
;
+ return
ret
;
}
}
@@
-574,7
+577,7
@@
gssEapExportAttrContext(OM_uint32 *minor,
};
try {
};
try {
- name->attrCtx->
marshall
(buffer);
+ name->attrCtx->
exportToBuffer
(buffer);
} catch (std::exception &e) {
return mapException(minor, e);
}
} catch (std::exception &e) {
return mapException(minor, e);
}
@@
-587,8
+590,20
@@
gssEapImportAttrContext(OM_uint32 *minor,
gss_buffer_t buffer,
gss_name_t name)
{
gss_buffer_t buffer,
gss_name_t name)
{
- if (buffer->length)
- GSSEAP_NOT_IMPLEMENTED;
+ if (buffer->length != 0) {
+ gss_eap_attr_ctx *ctx = new gss_eap_attr_ctx;
+
+ try {
+ if (!ctx->initFromBuffer(NULL, buffer)) {
+ delete ctx;
+ return GSS_S_DEFECTIVE_TOKEN;
+ }
+ name->attrCtx = ctx;
+ } catch (std::exception &e) {
+ delete ctx;
+ return mapException(minor, e);
+ }
+ }
return GSS_S_COMPLETE;
}
return GSS_S_COMPLETE;
}
@@
-598,19
+613,20
@@
gssEapDuplicateAttrContext(OM_uint32 *minor,
gss_name_t in,
gss_name_t out)
{
gss_name_t in,
gss_name_t out)
{
+ gss_eap_attr_ctx *ctx = NULL;
+
+ assert(out->attrCtx == NULL);
+
try {
if (in->attrCtx != NULL) {
try {
if (in->attrCtx != NULL) {
- gss_eap_attr_ctx *ctx = new gss_eap_attr_ctx;
-
- out->attrCtx = new gss_eap_attr_ctx;
if (!ctx->initFromExistingContext(NULL, in->attrCtx)) {
delete ctx;
return GSS_S_FAILURE;
}
out->attrCtx = ctx;
if (!ctx->initFromExistingContext(NULL, in->attrCtx)) {
delete ctx;
return GSS_S_FAILURE;
}
out->attrCtx = ctx;
- } else
- out->attrCtx = NULL;
+ }
} catch (std::exception &e) {
} catch (std::exception &e) {
+ delete ctx;
return mapException(minor, e);
}
return mapException(minor, e);
}
@@
-693,7
+709,7
@@
gssEapCreateAttrContext(gss_cred_id_t gssCred,
{
gss_eap_attr_ctx *ctx;
{
gss_eap_attr_ctx *ctx;
- ctx =
gss_eap_attr_ctx::createAttrContext()
;
+ ctx =
new gss_eap_attr_ctx
;
if (!ctx->initFromGssContext(NULL, gssCred, gssCtx)) {
delete ctx;
return NULL;
if (!ctx->initFromGssContext(NULL, gssCred, gssCtx)) {
delete ctx;
return NULL;
diff --git
a/mech_eap/util_attr.h
b/mech_eap/util_attr.h
index
43a5c88
..
6141658
100644
(file)
--- a/
mech_eap/util_attr.h
+++ b/
mech_eap/util_attr.h
@@
-92,9
+92,9
@@
public:
virtual void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const {}
virtual void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const {}
- virtual void
marshall
(gss_buffer_t buffer) const {}
- virtual bool
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer) { return false; }
+ virtual void
exportToBuffer
(gss_buffer_t buffer) const {}
+ virtual bool
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer) { return false; }
static bool init() { return true; }
static void finalize() {}
static bool init() { return true; }
static void finalize() {}
@@
-110,7
+110,7
@@
typedef gss_eap_attr_provider *(*gss_eap_attr_create_factory)(void);
struct gss_eap_attr_ctx : gss_eap_attr_provider
{
public:
struct gss_eap_attr_ctx : gss_eap_attr_provider
{
public:
- gss_eap_attr_ctx(void)
{}
+ gss_eap_attr_ctx(void)
;
~gss_eap_attr_ctx(void);
bool initFromExistingContext(const gss_eap_attr_ctx *source,
~gss_eap_attr_ctx(void);
bool initFromExistingContext(const gss_eap_attr_ctx *source,
@@
-119,8
+119,6
@@
public:
const gss_cred_id_t cred,
const gss_ctx_id_t ctx);
const gss_cred_id_t cred,
const gss_ctx_id_t ctx);
- static gss_eap_attr_ctx *createAttrContext(void);
-
bool getAttributeTypes(gss_eap_attr_enumeration_cb, void *data) const;
bool getAttributeTypes(gss_buffer_set_t *attrs);
bool getAttributeTypes(gss_eap_attr_enumeration_cb, void *data) const;
bool getAttributeTypes(gss_buffer_set_t *attrs);
@@
-139,9
+137,9
@@
public:
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
- void
marshall
(gss_buffer_t buffer) const;
- bool
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer);
+ void
exportToBuffer
(gss_buffer_t buffer) const;
+ bool
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer);
static bool init();
static void finalize();
static bool init();
static void finalize();
diff --git
a/mech_eap/util_radius.cpp
b/mech_eap/util_radius.cpp
index
7fe84a4
..
1440d4c
100644
(file)
--- a/
mech_eap/util_radius.cpp
+++ b/
mech_eap/util_radius.cpp
@@
-111,13
+111,13
@@
gss_eap_radius_attr_provider::releaseAnyNameMapping(gss_buffer_t type_id,
}
void
}
void
-gss_eap_radius_attr_provider::
marshall
(gss_buffer_t buffer) const
+gss_eap_radius_attr_provider::
exportToBuffer
(gss_buffer_t buffer) const
{
}
bool
{
}
bool
-gss_eap_radius_attr_provider::
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer)
+gss_eap_radius_attr_provider::
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer)
{
return false;
}
{
return false;
}
diff --git
a/mech_eap/util_radius.h
b/mech_eap/util_radius.h
index
8d91a9c
..
3265fa8
100644
(file)
--- a/
mech_eap/util_radius.h
+++ b/
mech_eap/util_radius.h
@@
-60,9
+60,9
@@
public:
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
- void
marshall
(gss_buffer_t buffer) const;
- bool
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer);
+ void
exportToBuffer
(gss_buffer_t buffer) const;
+ bool
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer);
bool getAttribute(unsigned int attribute,
int *authenticated,
bool getAttribute(unsigned int attribute,
int *authenticated,
diff --git
a/mech_eap/util_saml.cpp
b/mech_eap/util_saml.cpp
index
2a9e650
..
03ccb4e
100644
(file)
--- a/
mech_eap/util_saml.cpp
+++ b/
mech_eap/util_saml.cpp
@@
-225,7
+225,7
@@
gss_eap_saml_assertion_provider::releaseAnyNameMapping(gss_buffer_t type_id,
}
void
}
void
-gss_eap_saml_assertion_provider::
marshall
(gss_buffer_t buffer) const
+gss_eap_saml_assertion_provider::
exportToBuffer
(gss_buffer_t buffer) const
{
ostringstream sink;
string str;
{
ostringstream sink;
string str;
@@
-243,8
+243,8
@@
gss_eap_saml_assertion_provider::marshall(gss_buffer_t buffer) const
}
bool
}
bool
-gss_eap_saml_assertion_provider::
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer)
+gss_eap_saml_assertion_provider::
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer)
{
assert(m_assertion == NULL);
{
assert(m_assertion == NULL);
@@
-418,15
+418,15
@@
gss_eap_saml_attr_provider::releaseAnyNameMapping(gss_buffer_t type_id,
}
void
}
void
-gss_eap_saml_attr_provider::
marshall
(gss_buffer_t buffer) const
+gss_eap_saml_attr_provider::
exportToBuffer
(gss_buffer_t buffer) const
{
buffer->length = 0;
buffer->value = NULL;
}
bool
{
buffer->length = 0;
buffer->value = NULL;
}
bool
-gss_eap_saml_attr_provider::
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer)
+gss_eap_saml_attr_provider::
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer)
{
return true;
}
{
return true;
}
diff --git
a/mech_eap/util_saml.h
b/mech_eap/util_saml.h
index
c380803
..
730ebd4
100644
(file)
--- a/
mech_eap/util_saml.h
+++ b/
mech_eap/util_saml.h
@@
-68,9
+68,9
@@
public:
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
- void
marshall
(gss_buffer_t buffer) const;
- bool
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer);
+ void
exportToBuffer
(gss_buffer_t buffer) const;
+ bool
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer);
void setAssertion(const opensaml::saml2::Assertion *assertion);
void setAssertion(const opensaml::saml2::Assertion *assertion);
@@
-111,9
+111,9
@@
public:
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
- void
marshall
(gss_buffer_t buffer) const;
- bool
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer);
+ void
exportToBuffer
(gss_buffer_t buffer) const;
+ bool
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer);
const opensaml::saml2::Attribute *
getAttribute(const gss_buffer_t attr) const;
const opensaml::saml2::Attribute *
getAttribute(const gss_buffer_t attr) const;
diff --git
a/mech_eap/util_shib.cpp
b/mech_eap/util_shib.cpp
index
352fbed
..
596521b
100644
(file)
--- a/
mech_eap/util_shib.cpp
+++ b/
mech_eap/util_shib.cpp
@@
-338,15
+338,15
@@
gss_eap_shib_attr_provider::releaseAnyNameMapping(gss_buffer_t type_id,
}
void
}
void
-gss_eap_shib_attr_provider::
marshall
(gss_buffer_t buffer) const
+gss_eap_shib_attr_provider::
exportToBuffer
(gss_buffer_t buffer) const
{
buffer->length = 0;
buffer->value = NULL;
}
bool
{
buffer->length = 0;
buffer->value = NULL;
}
bool
-gss_eap_shib_attr_provider::
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer)
+gss_eap_shib_attr_provider::
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer)
{
return true;
}
{
return true;
}
diff --git
a/mech_eap/util_shib.h
b/mech_eap/util_shib.h
index
0d61fa2
..
a97bb75
100644
(file)
--- a/
mech_eap/util_shib.h
+++ b/
mech_eap/util_shib.h
@@
-70,9
+70,9
@@
public:
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
void releaseAnyNameMapping(gss_buffer_t type_id,
gss_any_t input) const;
- void
marshall
(gss_buffer_t buffer) const;
- bool
unmarshall
(const gss_eap_attr_ctx *ctx,
- const gss_buffer_t buffer);
+ void
exportToBuffer
(gss_buffer_t buffer) const;
+ bool
initFromBuffer
(const gss_eap_attr_ctx *ctx,
+
const gss_buffer_t buffer);
static bool init();
static bool init();