X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-sp-resolver.git;a=blobdiff_plain;f=src%2Fshibresolver%2Fresolver.cpp;h=2098f8f857018d988d226997e749078520bf3240;hp=6b847e76cf65d7bd2ff6fa83d339fc2ca94babc4;hb=974b56a2885609d4415949b42100b542379d67fd;hpb=6538a9e5bb4a3a5918a8306b00e32f5a507b4147 diff --git a/src/shibresolver/resolver.cpp b/src/shibresolver/resolver.cpp index 6b847e7..2098f8f 100644 --- a/src/shibresolver/resolver.cpp +++ b/src/shibresolver/resolver.cpp @@ -1,9 +1,8 @@ -/* - * Copyright 2010-2011 JANET(UK) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/** + * See the NOTICE file distributed with this work for information + * regarding copyright ownership. Licensed under the Apache License, + * Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -23,7 +22,9 @@ #include "internal.h" #ifdef SHIBRESOLVER_HAVE_GSSAPI_NAMINGEXTS -# include +# ifdef SHIBRESOLVER_HAVE_GSSMIT +# include +# endif #endif #include @@ -157,12 +158,28 @@ void ShibbolethResolver::addToken(gss_ctx_id_t* ctx) } if (ctx && *ctx != GSS_C_NO_CONTEXT) { - OM_uint32 major, minor; + OM_uint32 minor; gss_buffer_desc contextbuf = GSS_C_EMPTY_BUFFER; - - major = gss_export_sec_context(&minor, ctx, &contextbuf); + OM_uint32 major = gss_export_sec_context(&minor, ctx, &contextbuf); if (major == GSS_S_COMPLETE) { - addToken(&contextbuf); + xsecsize_t len=0; + XMLByte* out=Base64::encode(reinterpret_cast(contextbuf.value), contextbuf.length, &len); + if (out) { + string s; + s.append(reinterpret_cast(out), len); + auto_ptr_XMLCh temp(s.c_str()); +#ifdef SHIBSP_XERCESC_HAS_XMLBYTE_RELEASE + XMLString::release(&out); +#else + XMLString::release((char**)&out); +#endif + static const XMLCh _GSSAPI[] = UNICODE_LITERAL_13(G,S,S,A,P,I,C,o,n,t,e,x,t); + m_gsswrapper = new AnyElementImpl(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _GSSAPI); + m_gsswrapper->setTextContent(temp.get()); + } + else { + Category::getInstance(SHIBRESOLVER_LOGCAT).error("error while base64-encoding GSS context"); + } gss_release_buffer(&minor, &contextbuf); } else { @@ -171,6 +188,27 @@ void ShibbolethResolver::addToken(gss_ctx_id_t* ctx) } } +#ifdef SHIBRESOLVER_HAVE_GSSAPI_NAMINGEXTS +void ShibbolethResolver::addToken(gss_name_t name) +{ + if (m_gsswrapper) { + delete m_gsswrapper; + m_gsswrapper = NULL; + } + + OM_uint32 minor; + gss_buffer_desc namebuf = GSS_C_EMPTY_BUFFER; + OM_uint32 major = gss_export_name_composite(&minor, name, &namebuf); + if (major == GSS_S_COMPLETE) { + addToken(&namebuf); + gss_release_buffer(&minor, &namebuf); + } + else { + Category::getInstance(SHIBRESOLVER_LOGCAT).error("error exporting GSS name"); + } +} +#endif + void ShibbolethResolver::addToken(const gss_buffer_t contextbuf) { if (m_gsswrapper) { @@ -189,53 +227,15 @@ void ShibbolethResolver::addToken(const gss_buffer_t contextbuf) #else XMLString::release((char**)&out); #endif - static const XMLCh _GSSAPI[] = UNICODE_LITERAL_13(G,S,S,A,P,I,C,o,n,t,e,x,t); + static const XMLCh _GSSAPI[] = UNICODE_LITERAL_10(G,S,S,A,P,I,N,a,m,e); m_gsswrapper = new AnyElementImpl(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _GSSAPI); m_gsswrapper->setTextContent(temp.get()); } else { - Category::getInstance(SHIBRESOLVER_LOGCAT).error("error while base64-encoding GSS context"); + Category::getInstance(SHIBRESOLVER_LOGCAT).error("error while base64-encoding GSS name"); } } -#ifdef SHIBRESOLVER_HAVE_GSSAPI_NAMINGEXTS -void ShibbolethResolver::addToken(gss_name_t name) -{ - if (m_gsswrapper) { - delete m_gsswrapper; - m_gsswrapper = NULL; - } - - OM_uint32 major, minor; - gss_buffer_desc namebuf = GSS_C_EMPTY_BUFFER; - - major = gss_export_name_composite(&minor, name, &namebuf); - if (major == GSS_S_COMPLETE) { - xsecsize_t len=0; - XMLByte* out=Base64::encode(reinterpret_cast(namebuf.value), namebuf.length, &len); - if (out) { - string s; - s.append(reinterpret_cast(out), len); - auto_ptr_XMLCh temp(s.c_str()); - #ifdef SHIBSP_XERCESC_HAS_XMLBYTE_RELEASE - XMLString::release(&out); - #else - XMLString::release((char**)&out); - #endif - static const XMLCh _GSSAPI[] = UNICODE_LITERAL_10(G,S,S,A,P,I,N,a,m,e); - m_gsswrapper = new AnyElementImpl(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _GSSAPI); - m_gsswrapper->setTextContent(temp.get()); - } - else { - Category::getInstance(SHIBRESOLVER_LOGCAT).error("error while base64-encoding GSS name"); - } - gss_release_buffer(&minor, &namebuf); - } - else { - Category::getInstance(SHIBRESOLVER_LOGCAT).error("error exporting GSS name"); - } -} -#endif #endif void ShibbolethResolver::addAttribute(Attribute* attr) @@ -404,7 +404,7 @@ void RemotedResolver::resolve( log.warn("no metadata providers are configured"); } else { - if (!issuerstr.empty()) { + if (issuerstr.empty()) { // Attempt to locate an issuer based on input token. for (vector::const_iterator t = tokens.begin(); t!=tokens.end(); ++t) { const saml2::Assertion* assertion = dynamic_cast(*t);