X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=util_saml.h;h=0a14d3e2ad1d1f6cef051cf70d6b928631ed687a;hb=e063ba4e45d12dbc1a397653f9e77228835e4a2b;hp=283ce60899e2f98edb108e027ab98e9f068d90c0;hpb=2e206b746716b821cebe55a5faf3a0de8fd4967b;p=mech_eap.orig diff --git a/util_saml.h b/util_saml.h index 283ce60..0a14d3e 100644 --- a/util_saml.h +++ b/util_saml.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, JANET(UK) + * Copyright (c) 2011, JANET(UK) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,53 +30,147 @@ * SUCH DAMAGE. */ -#include "gssapiP_eap.h" +/* + * SAML attribute provider. + */ #ifndef _UTIL_SAML_H_ #define _UTIL_SAML_H_ 1 -struct eap_gss_saml_assertion; - -OM_uint32 -samlDuplicateAssertion(OM_uint32 *minor, - const struct eap_gss_saml_assertion *in, - struct eap_gss_saml_assertion **out); - -OM_uint32 -samlImportAssertion(OM_uint32 *minor, - gss_buffer_t buffer, - struct eap_gss_saml_assertion *pAssertion); - -OM_uint32 -samlExportAssertion(OM_uint32 *minor, - struct eap_gss_saml_assertion *assertion, - gss_buffer_t buffer); - -OM_uint32 -samlFreeAssertion(OM_uint32 *minor, - struct eap_gss_saml_assertion *assertion); - -OM_uint32 -samlGetAttributeTypes(OM_uint32 *minor, - const struct eap_gss_saml_assertion *assertion, - void *data, - OM_uint32 (*addAttribute)(OM_uint32 *, void *, gss_buffer_t)); - -OM_uint32 -samlGetAttribute(OM_uint32 *minor, - const struct eap_gss_saml_assertion *assertion, - gss_buffer_t attr, - int *authenticated, - int *complete, - gss_buffer_t value, - gss_buffer_t display_value, - int *more); - -OM_uint32 -samlSetAttribute(OM_uint32 *minor, - struct eap_gss_saml_assertion *assertion, - int complete, - gss_buffer_t attr, - gss_buffer_t value); +#ifdef __cplusplus + +namespace opensaml { + namespace saml2 { + class Attribute; + class Assertion; + class NameID; + }; +}; + +struct gss_eap_saml_assertion_provider : gss_eap_attr_provider { +public: + gss_eap_saml_assertion_provider(void); + ~gss_eap_saml_assertion_provider(void); + + bool initFromExistingContext(const gss_eap_attr_ctx *source, + const gss_eap_attr_provider *ctx); + bool initFromGssContext(const gss_eap_attr_ctx *source, + const gss_cred_id_t cred, + const gss_ctx_id_t ctx); + + bool getAttributeTypes(gss_eap_attr_enumeration_cb, void *data) const; + bool setAttribute(int complete, + const gss_buffer_t attr, + const gss_buffer_t value); + bool deleteAttribute(const gss_buffer_t value); + bool getAttribute(const gss_buffer_t attr, + int *authenticated, + int *complete, + gss_buffer_t value, + gss_buffer_t display_value, + int *more) const; + gss_any_t mapToAny(int authenticated, + gss_buffer_t type_id) const; + void releaseAnyNameMapping(gss_buffer_t type_id, + gss_any_t input) const; + + const char *prefix(void) const; + const char *name(void) const { return NULL; } + bool initWithJsonObject(const gss_eap_attr_ctx *manager GSSEAP_UNUSED, + json_t *object GSSEAP_UNUSED) { + return false; + } + json_t *jsonRepresentation(void) const { + return NULL; + } + + opensaml::saml2::Assertion *initAssertion(void); + + opensaml::saml2::Assertion *getAssertion(void) const { + return m_assertion; + } + bool authenticated(void) const { + return m_authenticated; + } + + time_t getExpiryTime(void) const; + OM_uint32 mapException(OM_uint32 *minor, std::exception &e) const; + + static bool init(void); + static void finalize(void); + + static gss_eap_attr_provider *createAttrContext(void); + +private: + static opensaml::saml2::Assertion * + parseAssertion(const gss_buffer_t buffer); + + void setAssertion(const opensaml::saml2::Assertion *assertion, + bool authenticated = false); + void setAssertion(const gss_buffer_t buffer, + bool authenticated = false); + + opensaml::saml2::Assertion *m_assertion; + bool m_authenticated; +}; + +struct gss_eap_saml_attr_provider : gss_eap_attr_provider { +public: + gss_eap_saml_attr_provider(void) {} + ~gss_eap_saml_attr_provider(void) {} + + bool getAttributeTypes(gss_eap_attr_enumeration_cb, void *data) const; + bool setAttribute(int complete, + const gss_buffer_t attr, + const gss_buffer_t value); + bool deleteAttribute(const gss_buffer_t value); + bool getAttribute(const gss_buffer_t attr, + int *authenticated, + int *complete, + gss_buffer_t value, + gss_buffer_t display_value, + int *more) const; + gss_any_t mapToAny(int authenticated, + gss_buffer_t type_id) const; + void releaseAnyNameMapping(gss_buffer_t type_id, + gss_any_t input) const; + + const char *prefix(void) const; + const char *name(void) const { + return NULL; + } + bool initWithJsonObject(const gss_eap_attr_ctx *manager GSSEAP_UNUSED, + json_t *object GSSEAP_UNUSED) { + return false; + } + json_t *jsonRepresentation(void) const { + return NULL; + } + + bool getAttribute(const gss_buffer_t attr, + int *authenticated, + int *complete, + const opensaml::saml2::Attribute **pAttribute) const; + bool getAssertion(int *authenticated, + opensaml::saml2::Assertion **pAssertion, + bool createIfAbsent = false) const; + + static bool init(void); + static void finalize(void); + + static gss_eap_attr_provider *createAttrContext(void); + +private: +}; + +extern "C" { +#endif + +OM_uint32 gssEapSamlAttrProvidersInit(OM_uint32 *minor); +OM_uint32 gssEapSamlAttrProvidersFinalize(OM_uint32 *minor); + +#ifdef __cplusplus +} +#endif #endif /* _UTIL_SAML_H_ */