make possible build without OpenSAML and/or Shib
[moonshot.git] / moonshot / mech_eap / util_saml.cpp
1 /*
2  * Copyright (c) 2011, JANET(UK)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. Neither the name of JANET(UK) nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32
33 /*
34  * SAML attribute provider implementation.
35  */
36
37 #include "gssapiP_eap.h"
38
39 #include <sstream>
40
41 #include <xercesc/util/XMLUniDefs.hpp>
42 #include <xmltooling/unicode.h>
43 #include <xmltooling/XMLToolingConfig.h>
44 #include <xmltooling/util/XMLHelper.h>
45 #include <xmltooling/util/ParserPool.h>
46 #include <xmltooling/util/DateTime.h>
47
48 #include <saml/exceptions.h>
49 #include <saml/SAMLConfig.h>
50 #include <saml/saml1/core/Assertions.h>
51 #include <saml/saml2/core/Assertions.h>
52 #include <saml/saml2/metadata/Metadata.h>
53 #include <saml/saml2/metadata/MetadataProvider.h>
54
55 using namespace xmltooling;
56 using namespace opensaml::saml2md;
57 using namespace opensaml;
58 using namespace xercesc;
59 using namespace std;
60
61 static const XMLCh
62 base64Binary[] = {'b','a','s','e','6','4','B','i','n','a','r','y',0};
63
64 /*
65  * gss_eap_saml_assertion_provider is for retrieving the underlying
66  * assertion.
67  */
68 gss_eap_saml_assertion_provider::gss_eap_saml_assertion_provider(void)
69 {
70     m_assertion = NULL;
71     m_authenticated = false;
72 }
73
74 gss_eap_saml_assertion_provider::~gss_eap_saml_assertion_provider(void)
75 {
76     delete m_assertion;
77 }
78
79 bool
80 gss_eap_saml_assertion_provider::initWithExistingContext(const gss_eap_attr_ctx *manager,
81                                                          const gss_eap_attr_provider *ctx)
82 {
83     /* Then we may be creating from an existing attribute context */
84     const gss_eap_saml_assertion_provider *saml;
85
86     assert(m_assertion == NULL);
87
88     if (!gss_eap_attr_provider::initWithExistingContext(manager, ctx))
89         return false;
90
91     saml = static_cast<const gss_eap_saml_assertion_provider *>(ctx);
92     setAssertion(saml->getAssertion(), saml->authenticated());
93
94     return true;
95 }
96
97 bool
98 gss_eap_saml_assertion_provider::initWithGssContext(const gss_eap_attr_ctx *manager,
99                                                     const gss_cred_id_t gssCred,
100                                                     const gss_ctx_id_t gssCtx)
101 {
102     const gss_eap_radius_attr_provider *radius;
103     gss_buffer_desc value = GSS_C_EMPTY_BUFFER;
104     int authenticated, complete;
105     OM_uint32 minor;
106
107     assert(m_assertion == NULL);
108
109     if (!gss_eap_attr_provider::initWithGssContext(manager, gssCred, gssCtx))
110         return false;
111
112     /*
113      * XXX TODO we need to support draft-howlett-radius-saml-attr-00
114      */
115     radius = static_cast<const gss_eap_radius_attr_provider *>
116         (m_manager->getProvider(ATTR_TYPE_RADIUS));
117     if (radius != NULL &&
118         radius->getFragmentedAttribute(PW_SAML_AAA_ASSERTION,
119                                        VENDORPEC_UKERNA,
120                                        &authenticated, &complete, &value)) {
121         setAssertion(&value, authenticated);
122         gss_release_buffer(&minor, &value);
123     } else {
124         m_assertion = NULL;
125     }
126
127     return true;
128 }
129
130 void
131 gss_eap_saml_assertion_provider::setAssertion(const saml2::Assertion *assertion,
132                                               bool authenticated)
133 {
134
135     delete m_assertion;
136
137     if (assertion != NULL) {
138 #ifdef __APPLE__
139         m_assertion = (saml2::Assertion *)((void *)assertion->clone());
140 #else
141         m_assertion = dynamic_cast<saml2::Assertion *>(assertion->clone());
142 #endif
143         m_authenticated = authenticated;
144     } else {
145         m_assertion = NULL;
146         m_authenticated = false;
147     }
148 }
149
150 void
151 gss_eap_saml_assertion_provider::setAssertion(const gss_buffer_t buffer,
152                                               bool authenticated)
153 {
154     delete m_assertion;
155
156     m_assertion = parseAssertion(buffer);
157     m_authenticated = (m_assertion != NULL && authenticated);
158 }
159
160 saml2::Assertion *
161 gss_eap_saml_assertion_provider::parseAssertion(const gss_buffer_t buffer)
162 {
163     string str((char *)buffer->value, buffer->length);
164     istringstream istream(str);
165     DOMDocument *doc;
166     const XMLObjectBuilder *b;
167
168     try {
169         doc = XMLToolingConfig::getConfig().getParser().parse(istream);
170         if (doc == NULL)
171             return NULL;
172
173         b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
174
175 #ifdef __APPLE__
176         return (saml2::Assertion *)((void *)b->buildFromDocument(doc));
177 #else
178         return dynamic_cast<saml2::Assertion *>(b->buildFromDocument(doc));
179 #endif
180     } catch (exception &e) {
181         return NULL;
182     }
183 }
184
185 bool
186 gss_eap_saml_assertion_provider::getAttributeTypes(gss_eap_attr_enumeration_cb addAttribute,
187                                                    void *data) const
188 {
189     bool ret;
190
191     /* just add the prefix */
192     if (m_assertion != NULL)
193         ret = addAttribute(m_manager, this, GSS_C_NO_BUFFER, data);
194     else
195         ret = true;
196
197     return ret;
198 }
199
200 bool
201 gss_eap_saml_assertion_provider::setAttribute(int complete GSSEAP_UNUSED,
202                                               const gss_buffer_t attr,
203                                               const gss_buffer_t value)
204 {
205     if (attr == GSS_C_NO_BUFFER || attr->length == 0) {
206         setAssertion(value);
207         return true;
208     }
209
210     return false;
211 }
212
213 bool
214 gss_eap_saml_assertion_provider::deleteAttribute(const gss_buffer_t value GSSEAP_UNUSED)
215 {
216     delete m_assertion;
217     m_assertion = NULL;
218     m_authenticated = false;
219
220     return true;
221 }
222
223 time_t
224 gss_eap_saml_assertion_provider::getExpiryTime(void) const
225 {
226     saml2::Conditions *conditions;
227     time_t expiryTime = 0;
228
229     if (m_assertion == NULL)
230         return 0;
231
232     conditions = m_assertion->getConditions();
233
234     if (conditions != NULL && conditions->getNotOnOrAfter() != NULL)
235         expiryTime = conditions->getNotOnOrAfter()->getEpoch();
236
237     return expiryTime;
238 }
239
240 OM_uint32
241 gss_eap_saml_assertion_provider::mapException(OM_uint32 *minor,
242                                               std::exception &e) const
243 {
244     if (typeid(e) == typeid(SecurityPolicyException))
245         *minor = GSSEAP_SAML_SEC_POLICY_FAILURE;
246     else if (typeid(e) == typeid(BindingException))
247         *minor = GSSEAP_SAML_BINDING_FAILURE;
248     else if (typeid(e) == typeid(ProfileException))
249         *minor = GSSEAP_SAML_PROFILE_FAILURE;
250     else if (typeid(e) == typeid(FatalProfileException))
251         *minor = GSSEAP_SAML_FATAL_PROFILE_FAILURE;
252     else if (typeid(e) == typeid(RetryableProfileException))
253         *minor = GSSEAP_SAML_RETRY_PROFILE_FAILURE;
254     else if (typeid(e) == typeid(MetadataException))
255         *minor = GSSEAP_SAML_METADATA_FAILURE;
256     else
257         return GSS_S_CONTINUE_NEEDED;
258
259     gssEapSaveStatusInfo(*minor, "%s", e.what());
260
261     return GSS_S_FAILURE;
262 }
263
264 bool
265 gss_eap_saml_assertion_provider::getAttribute(const gss_buffer_t attr,
266                                               int *authenticated,
267                                               int *complete,
268                                               gss_buffer_t value,
269                                               gss_buffer_t display_value GSSEAP_UNUSED,
270                                               int *more) const
271 {
272     string str;
273
274     if (attr != GSS_C_NO_BUFFER && attr->length != 0)
275         return false;
276
277     if (m_assertion == NULL)
278         return false;
279
280     if (*more != -1)
281         return false;
282
283     if (authenticated != NULL)
284         *authenticated = m_authenticated;
285     if (complete != NULL)
286         *complete = true;
287
288     XMLHelper::serialize(m_assertion->marshall((DOMDocument *)NULL), str);
289
290     if (value != NULL)
291         duplicateBuffer(str, value);
292     if (display_value != NULL)
293         duplicateBuffer(str, display_value);
294
295     *more = 0;
296
297     return true;
298 }
299
300 gss_any_t
301 gss_eap_saml_assertion_provider::mapToAny(int authenticated,
302                                           gss_buffer_t type_id GSSEAP_UNUSED) const
303 {
304     if (authenticated && !m_authenticated)
305         return (gss_any_t)NULL;
306
307     return (gss_any_t)m_assertion;
308 }
309
310 void
311 gss_eap_saml_assertion_provider::releaseAnyNameMapping(gss_buffer_t type_id GSSEAP_UNUSED,
312                                                        gss_any_t input) const
313 {
314     delete ((saml2::Assertion *)input);
315 }
316
317 const char *
318 gss_eap_saml_assertion_provider::prefix(void) const
319 {
320     return "urn:ietf:params:gss-eap:saml-aaa-assertion";
321 }
322
323 bool
324 gss_eap_saml_assertion_provider::init(void)
325 {
326     bool ret = false;
327
328     try {
329         ret = SAMLConfig::getConfig().init();
330     } catch (exception &e) {
331     }
332
333     if (ret)
334         gss_eap_attr_ctx::registerProvider(ATTR_TYPE_SAML_ASSERTION, createAttrContext);
335
336     return ret;
337 }
338
339 void
340 gss_eap_saml_assertion_provider::finalize(void)
341 {
342     gss_eap_attr_ctx::unregisterProvider(ATTR_TYPE_SAML_ASSERTION);
343 }
344
345 gss_eap_attr_provider *
346 gss_eap_saml_assertion_provider::createAttrContext(void)
347 {
348     return new gss_eap_saml_assertion_provider;
349 }
350
351 saml2::Assertion *
352 gss_eap_saml_assertion_provider::initAssertion(void)
353 {
354     delete m_assertion;
355     m_assertion = saml2::AssertionBuilder::buildAssertion();
356     m_authenticated = false;
357
358     return m_assertion;
359 }
360
361 /*
362  * gss_eap_saml_attr_provider is for retrieving the underlying attributes.
363  */
364 bool
365 gss_eap_saml_attr_provider::getAssertion(int *authenticated,
366                                          saml2::Assertion **pAssertion,
367                                          bool createIfAbsent) const
368 {
369     gss_eap_saml_assertion_provider *saml;
370
371     if (authenticated != NULL)
372         *authenticated = false;
373     if (pAssertion != NULL)
374         *pAssertion = NULL;
375
376     saml = static_cast<gss_eap_saml_assertion_provider *>
377         (m_manager->getProvider(ATTR_TYPE_SAML_ASSERTION));
378     if (saml == NULL)
379         return false;
380
381     if (authenticated != NULL)
382         *authenticated = saml->authenticated();
383     if (pAssertion != NULL)
384         *pAssertion = saml->getAssertion();
385
386     if (saml->getAssertion() == NULL) {
387         if (createIfAbsent) {
388             if (authenticated != NULL)
389                 *authenticated = false;
390             if (pAssertion != NULL)
391                 *pAssertion = saml->initAssertion();
392         } else
393             return false;
394     }
395
396     return true;
397 }
398
399 bool
400 gss_eap_saml_attr_provider::getAttributeTypes(gss_eap_attr_enumeration_cb addAttribute,
401                                               void *data) const
402 {
403     saml2::Assertion *assertion;
404     int authenticated;
405
406     if (!getAssertion(&authenticated, &assertion))
407         return true;
408
409     /*
410      * Note: the first prefix is added by the attribute provider manager
411      *
412      * From draft-hartman-gss-eap-naming-00:
413      *
414      *   Each attribute carried in the assertion SHOULD also be a GSS name
415      *   attribute.  The name of this attribute has three parts, all separated
416      *   by an ASCII space character.  The first part is
417      *   urn:ietf:params:gss-eap:saml-attr.  The second part is the URI for
418      *   the SAML attribute name format.  The final part is the name of the
419      *   SAML attribute.  If the mechanism performs an additional attribute
420      *   query, the retrieved attributes SHOULD be GSS-API name attributes
421      *   using the same name syntax.
422      */
423     /* For each attribute statement, look for an attribute match */
424     const vector <saml2::AttributeStatement *> &statements =
425         const_cast<const saml2::Assertion *>(assertion)->getAttributeStatements();
426
427     for (vector<saml2::AttributeStatement *>::const_iterator s = statements.begin();
428         s != statements.end();
429         ++s) {
430         const vector<saml2::Attribute*> &attrs =
431             const_cast<const saml2::AttributeStatement*>(*s)->getAttributes();
432
433         for (vector<saml2::Attribute*>::const_iterator a = attrs.begin(); a != attrs.end(); ++a) {
434             const XMLCh *attributeName, *attributeNameFormat;
435             XMLCh space[2] = { ' ', 0 };
436             gss_buffer_desc utf8;
437
438             attributeName = (*a)->getName();
439             attributeNameFormat = (*a)->getNameFormat();
440             if (attributeNameFormat == NULL || attributeNameFormat[0] == '\0')
441                 attributeNameFormat = saml2::Attribute::UNSPECIFIED;
442
443             XMLCh qualifiedName[XMLString::stringLen(attributeNameFormat) + 1 +
444                                 XMLString::stringLen(attributeName) + 1];
445             XMLString::copyString(qualifiedName, attributeNameFormat);
446             XMLString::catString(qualifiedName, space);
447             XMLString::catString(qualifiedName, attributeName);
448
449             utf8.value = (void *)toUTF8(qualifiedName);
450             utf8.length = strlen((char *)utf8.value);
451
452             if (!addAttribute(m_manager, this, &utf8, data))
453                 return false;
454         }
455     }
456
457     return true;
458 }
459
460 static BaseRefVectorOf<XMLCh> *
461 decomposeAttributeName(const gss_buffer_t attr)
462 {
463     BaseRefVectorOf<XMLCh> *components;
464     string str((const char *)attr->value, attr->length);
465     auto_ptr_XMLCh qualifiedAttr(str.c_str());
466
467     components = XMLString::tokenizeString(qualifiedAttr.get());
468
469     if (components->size() != 2) {
470         delete components;
471         components = NULL;
472     }
473
474     return components;
475 }
476
477 bool
478 gss_eap_saml_attr_provider::setAttribute(int complete GSSEAP_UNUSED,
479                                          const gss_buffer_t attr,
480                                          const gss_buffer_t value)
481 {
482     saml2::Assertion *assertion;
483     saml2::Attribute *attribute;
484     saml2::AttributeValue *attributeValue;
485     saml2::AttributeStatement *attributeStatement;
486
487     if (!getAssertion(NULL, &assertion, true))
488         return false;
489
490     if (assertion->getAttributeStatements().size() != 0) {
491         attributeStatement = assertion->getAttributeStatements().front();
492     } else {
493         attributeStatement = saml2::AttributeStatementBuilder::buildAttributeStatement();
494         assertion->getAttributeStatements().push_back(attributeStatement);
495     }
496
497     /* Check the attribute name consists of name format | whsp | name */
498     BaseRefVectorOf<XMLCh> *components = decomposeAttributeName(attr);
499     if (components == NULL)
500         return false;
501
502     attribute = saml2::AttributeBuilder::buildAttribute();
503     attribute->setNameFormat(components->elementAt(0));
504     attribute->setName(components->elementAt(1));
505
506     attributeValue = saml2::AttributeValueBuilder::buildAttributeValue();
507     auto_ptr_XMLCh unistr((char *)value->value, value->length);
508     attributeValue->setTextContent(unistr.get());
509
510     attribute->getAttributeValues().push_back(attributeValue);
511
512     assert(attributeStatement != NULL);
513     attributeStatement->getAttributes().push_back(attribute);
514
515     delete components;
516
517     return true;
518 }
519
520 bool
521 gss_eap_saml_attr_provider::deleteAttribute(const gss_buffer_t attr)
522 {
523     saml2::Assertion *assertion;
524     bool ret = false;
525
526     if (!getAssertion(NULL, &assertion) ||
527         assertion->getAttributeStatements().size() == 0)
528         return false;
529
530     /* Check the attribute name consists of name format | whsp | name */
531     BaseRefVectorOf<XMLCh> *components = decomposeAttributeName(attr);
532     if (components == NULL)
533         return false;
534
535     /* For each attribute statement, look for an attribute match */
536     const vector<saml2::AttributeStatement *> &statements =
537         const_cast<const saml2::Assertion *>(assertion)->getAttributeStatements();
538
539     for (vector<saml2::AttributeStatement *>::const_iterator s = statements.begin();
540         s != statements.end();
541         ++s) {
542         const vector<saml2::Attribute *> &attrs =
543             const_cast<const saml2::AttributeStatement *>(*s)->getAttributes();
544         ssize_t index = -1, i = 0;
545
546         /* There's got to be an easier way to do this */
547         for (vector<saml2::Attribute *>::const_iterator a = attrs.begin();
548              a != attrs.end();
549              ++a) {
550             if (XMLString::equals((*a)->getNameFormat(), components->elementAt(0)) &&
551                 XMLString::equals((*a)->getName(), components->elementAt(1))) {
552                 index = i;
553                 break;
554             }
555             ++i;
556         }
557         if (index != -1) {
558             (*s)->getAttributes().erase((*s)->getAttributes().begin() + index);
559             ret = true;
560         }
561     }
562
563     delete components;
564
565     return ret;
566 }
567
568 bool
569 gss_eap_saml_attr_provider::getAttribute(const gss_buffer_t attr,
570                                          int *authenticated,
571                                          int *complete,
572                                          const saml2::Attribute **pAttribute) const
573 {
574     saml2::Assertion *assertion;
575
576     if (authenticated != NULL)
577         *authenticated = false;
578     if (complete != NULL)
579         *complete = true;
580     *pAttribute = NULL;
581
582     if (!getAssertion(authenticated, &assertion) ||
583         assertion->getAttributeStatements().size() == 0)
584         return false;
585
586     /* Check the attribute name consists of name format | whsp | name */
587     BaseRefVectorOf<XMLCh> *components = decomposeAttributeName(attr);
588     if (components == NULL)
589         return false;
590
591     /* For each attribute statement, look for an attribute match */
592     const vector <saml2::AttributeStatement *> &statements =
593         const_cast<const saml2::Assertion *>(assertion)->getAttributeStatements();
594     const saml2::Attribute *ret = NULL;
595
596     for (vector<saml2::AttributeStatement *>::const_iterator s = statements.begin();
597         s != statements.end();
598         ++s) {
599         const vector<saml2::Attribute *> &attrs =
600             const_cast<const saml2::AttributeStatement*>(*s)->getAttributes();
601
602         for (vector<saml2::Attribute *>::const_iterator a = attrs.begin(); a != attrs.end(); ++a) {
603             const XMLCh *attributeName, *attributeNameFormat;
604
605             attributeName = (*a)->getName();
606             attributeNameFormat = (*a)->getNameFormat();
607             if (attributeNameFormat == NULL || attributeNameFormat[0] == '\0')
608                 attributeNameFormat = saml2::Attribute::UNSPECIFIED;
609
610             if (XMLString::equals(attributeNameFormat, components->elementAt(0)) &&
611                 XMLString::equals(attributeName, components->elementAt(1))) {
612                 ret = *a;
613                 break;
614             }
615         }
616
617         if (ret != NULL)
618             break;
619     }
620
621     delete components;
622
623     *pAttribute = ret;
624
625     return (ret != NULL);
626 }
627
628 static bool
629 isBase64EncodedAttributeValueP(const saml2::AttributeValue *av)
630 {
631     const xmltooling::QName *type = av->getSchemaType();
632
633     if (type == NULL)
634         return false;
635
636     if (!type->hasNamespaceURI() ||
637         !XMLString::equals(type->getNamespaceURI(), xmlconstants::XSD_NS))
638         return false;
639
640     if (!type->hasLocalPart() ||
641         !XMLString::equals(type->getLocalPart(), base64Binary))
642         return false;
643
644     return true;
645 }
646
647 bool
648 gss_eap_saml_attr_provider::getAttribute(const gss_buffer_t attr,
649                                          int *authenticated,
650                                          int *complete,
651                                          gss_buffer_t value,
652                                          gss_buffer_t display_value,
653                                          int *more) const
654 {
655     const saml2::Attribute *a;
656     const saml2::AttributeValue *av;
657     int nvalues, i = *more;
658
659     *more = 0;
660
661     if (!getAttribute(attr, authenticated, complete, &a))
662         return false;
663
664     nvalues = a->getAttributeValues().size();
665
666     if (i == -1)
667         i = 0;
668     if (i >= nvalues)
669         return false;
670 #ifdef __APPLE__
671     av = (const saml2::AttributeValue *)((void *)(a->getAttributeValues().at(i)));
672 #else
673     av = dynamic_cast<const saml2::AttributeValue *>(a->getAttributeValues().at(i));
674 #endif
675     if (av != NULL) {
676         bool base64Encoded = isBase64EncodedAttributeValueP(av);
677
678         if (value != NULL) {
679             char *stringValue = toUTF8(av->getTextContent(), true);
680             size_t stringValueLen = strlen(stringValue);
681
682             if (base64Encoded) {
683                 ssize_t octetLen;
684
685                 value->value = GSSEAP_MALLOC(stringValueLen);
686                 if (value->value == NULL) {
687                     GSSEAP_FREE(stringValue);
688                     throw new std::bad_alloc;
689                 }
690
691                 octetLen = base64Decode(stringValue, value->value);
692                 if (octetLen < 0) {
693                     GSSEAP_FREE(value->value);
694                     GSSEAP_FREE(stringValue);
695                     value->value = NULL;
696                     return false;
697                 }
698                 value->length = octetLen;
699                 GSSEAP_FREE(stringValue);
700             } else {
701                 value->value = stringValue;
702                 value->length = stringValueLen;
703             }
704         }
705         if (display_value != NULL && base64Encoded == false) {
706             display_value->value = toUTF8(av->getTextContent(), true);
707             display_value->length = strlen((char *)value->value);
708         }
709     }
710
711     if (nvalues > ++i)
712         *more = i;
713
714     return true;
715 }
716
717 gss_any_t
718 gss_eap_saml_attr_provider::mapToAny(int authenticated GSSEAP_UNUSED,
719                                      gss_buffer_t type_id GSSEAP_UNUSED) const
720 {
721     return (gss_any_t)NULL;
722 }
723
724 void
725 gss_eap_saml_attr_provider::releaseAnyNameMapping(gss_buffer_t type_id GSSEAP_UNUSED,
726                                                   gss_any_t input GSSEAP_UNUSED) const
727 {
728 }
729
730 const char *
731 gss_eap_saml_attr_provider::prefix(void) const
732 {
733     return "urn:ietf:params:gss-eap:saml-attr";
734 }
735
736 bool
737 gss_eap_saml_attr_provider::init(void)
738 {
739     gss_eap_attr_ctx::registerProvider(ATTR_TYPE_SAML, createAttrContext);
740     return true;
741 }
742
743 void
744 gss_eap_saml_attr_provider::finalize(void)
745 {
746     gss_eap_attr_ctx::unregisterProvider(ATTR_TYPE_SAML);
747 }
748
749 gss_eap_attr_provider *
750 gss_eap_saml_attr_provider::createAttrContext(void)
751 {
752     return new gss_eap_saml_attr_provider;
753 }
754
755 OM_uint32
756 gssEapSamlAttrProvidersInit(OM_uint32 *minor)
757 {
758     if (!gss_eap_saml_assertion_provider::init() ||
759         !gss_eap_saml_attr_provider::init()) {
760         *minor = GSSEAP_SAML_INIT_FAILURE;
761         return GSS_S_FAILURE;
762     }
763
764     return GSS_S_COMPLETE;
765 }
766
767 OM_uint32
768 gssEapSamlAttrProvidersFinalize(OM_uint32 *minor)
769 {
770     gss_eap_saml_attr_provider::finalize();
771     gss_eap_saml_assertion_provider::finalize();
772
773     *minor = 0;
774     return GSS_S_COMPLETE;
775 }