[cpp-sp COMMIT] in /branches/REL_2/shibsp: binding/ArtifactResolver.h binding/impl/ArtifactResolver.cpp util/SPConsta...

noreply at shibboleth.net noreply at shibboleth.net
Tue Apr 17 21:06:04 BST 2012


Author: scantor
Date: Tue Apr 17 21:06:03 2012
New Revision: 3626

URL: http://svn.shibboleth.net/view/cpp-sp?rev=3626&view=rev
Log:
SSPCPP-437 and SSPCPP-438

Modified:
    branches/REL_2/shibsp/binding/ArtifactResolver.h
    branches/REL_2/shibsp/binding/impl/ArtifactResolver.cpp
    branches/REL_2/shibsp/util/SPConstants.cpp
    branches/REL_2/shibsp/util/SPConstants.h

Modified: branches/REL_2/shibsp/binding/ArtifactResolver.h
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/binding/ArtifactResolver.h?rev=3626&r1=3625&r2=3626&view=diff
==============================================================================
--- branches/REL_2/shibsp/binding/ArtifactResolver.h (original)
+++ branches/REL_2/shibsp/binding/ArtifactResolver.h Tue Apr 17 21:06:03 2012
@@ -40,6 +40,8 @@
         ArtifactResolver();
         virtual ~ArtifactResolver();
 
+        bool isSupported(const opensaml::saml2md::SSODescriptorType& ssoDescriptor) const;
+
         opensaml::saml1p::Response* resolve(
             const std::vector<opensaml::SAMLArtifact*>& artifacts,
             const opensaml::saml2md::IDPSSODescriptor& idpDescriptor,

Modified: branches/REL_2/shibsp/binding/impl/ArtifactResolver.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/shibsp/binding/impl/ArtifactResolver.cpp?rev=3626&r1=3625&r2=3626&view=diff
==============================================================================
--- branches/REL_2/shibsp/binding/impl/ArtifactResolver.cpp (original)
+++ branches/REL_2/shibsp/binding/impl/ArtifactResolver.cpp Tue Apr 17 21:06:03 2012
@@ -29,13 +29,21 @@
 #include "binding/ArtifactResolver.h"
 #include "binding/SOAPClient.h"
 #include "security/SecurityPolicy.h"
-
+#include "util/SPConstants.h"
+
+#include <fstream>
+#include <boost/bind.hpp>
+#include <boost/algorithm/string.hpp>
+#include <xmltooling/XMLToolingConfig.h>
+#include <xmltooling/util/ParserPool.h>
+#include <xmltooling/util/PathResolver.h>
 #include <saml/exceptions.h>
 #include <saml/saml1/core/Protocols.h>
 #include <saml/saml1/binding/SAML1SOAPClient.h>
 #include <saml/saml2/core/Protocols.h>
 #include <saml/saml2/binding/SAML2Artifact.h>
 #include <saml/saml2/binding/SAML2SOAPClient.h>
+#include <saml/saml2/metadata/EndpointManager.h>
 #include <saml/saml2/metadata/Metadata.h>
 #include <saml/saml2/metadata/MetadataCredentialCriteria.h>
 #include <saml/util/SAMLConstants.h>
@@ -47,6 +55,7 @@
 using namespace opensaml::saml2md;
 using namespace opensaml;
 using namespace xmltooling;
+using namespace boost;
 using namespace std;
 
 ArtifactResolver::ArtifactResolver()
@@ -55,6 +64,19 @@
 
 ArtifactResolver::~ArtifactResolver()
 {
+}
+
+bool ArtifactResolver::isSupported(const SSODescriptorType& ssoDescriptor) const
+{
+    if (MessageDecoder::ArtifactResolver::isSupported(ssoDescriptor))
+        return true;
+
+    EndpointManager<ArtifactResolutionService> mgr(ssoDescriptor.getArtifactResolutionServices());
+    if (ssoDescriptor.hasSupport(samlconstants::SAML20P_NS)) {
+        return (mgr.getByBinding(shibspconstants::SHIB2_BINDING_FILE) != nullptr);
+    }
+
+    return false;
 }
 
 saml1p::Response* ArtifactResolver::resolve(
@@ -90,7 +112,7 @@
             client.sendSAML(request, sppolicy.getApplication().getId(), mcc, loc.get());
             response = client.receiveSAML();
         }
-        catch (exception& ex) {
+        catch (std::exception& ex) {
             Category::getInstance(SHIBSP_LOGCAT".ArtifactResolver").error("exception resolving SAML 1.x artifact(s): %s", ex.what());
             soaper.reset();
         }
@@ -103,7 +125,7 @@
     const xmltooling::QName* code = (response->getStatus() && response->getStatus()->getStatusCode()) ? response->getStatus()->getStatusCode()->getValue() : nullptr;
     if (!code || *code != saml1p::StatusCode::SUCCESS) {
         auto_ptr<saml1p::Response> wrapper(response);
-        BindingException ex("Identity provider returned a SAML error in response to artifact.");
+        BindingException ex("Identity provider returned a SAML error during artifact resolution.");
         annotateException(&ex, &idpDescriptor, response->getStatus());  // rethrow
     }
 
@@ -118,6 +140,8 @@
     opensaml::SecurityPolicy& policy
     ) const
 {
+    Category& log = Category::getInstance(SHIBSP_LOGCAT".ArtifactResolver");
+
     MetadataCredentialCriteria mcc(ssoDescriptor);
     shibsp::SecurityPolicy& sppolicy = dynamic_cast<shibsp::SecurityPolicy&>(policy);
     shibsp::SOAPClient soaper(sppolicy);
@@ -125,32 +149,96 @@
     bool foundEndpoint = false;
     auto_ptr_XMLCh binding(samlconstants::SAML20_BINDING_SOAP);
     ArtifactResponse* response=nullptr;
-    const vector<ArtifactResolutionService*>& endpoints=ssoDescriptor.getArtifactResolutionServices();
-    for (vector<ArtifactResolutionService*>::const_iterator ep=endpoints.begin(); !response && ep!=endpoints.end(); ++ep) {
+
+    vector<ArtifactResolutionService*>::const_iterator ep_start, ep_end;
+    const vector<ArtifactResolutionService*>& endpoints = ssoDescriptor.getArtifactResolutionServices();

[... 159 lines stripped ...]


More information about the commits mailing list