Skip extra attempts when SAML response comes back.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Fri, 6 Jul 2007 22:49:02 +0000 (22:49 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Fri, 6 Jul 2007 22:49:02 +0000 (22:49 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2340 cb58f699-b61c-0410-a6fe-9272a202ed29

util/samlquery.cpp

index 1e07339..e00c546 100644 (file)
@@ -183,7 +183,7 @@ int main(int argc,char* argv[])
                     nameid->setFormat(format.get() ? format.get() : NameID::TRANSIENT);\r
                     nameid->setNameQualifier(domain.get());\r
                     iss->setName(issuer.get());\r
-                    SAML2SOAPClient client(soaper);\r
+                    SAML2SOAPClient client(soaper, false);\r
                     client.sendSAML(query, mcc, loc.get());\r
                     srt = client.receiveSAML();\r
                 }\r
@@ -194,7 +194,11 @@ int main(int argc,char* argv[])
             }\r
 \r
             if (!srt)\r
-                throw BindingException("Unable to successfully query for attributes.");\r
+                throw BindingException("Unable to obtain a SAML response from attribute authority.");\r
+            else if (!XMLString::equals(srt->getStatus()->getStatusCode()->getValue(), saml2p::StatusCode::SUCCESS)) {\r
+                delete srt;\r
+                throw BindingException("Attribute authority returned a SAML error.");\r
+            }\r
             const opensaml::saml2p::Response* response = dynamic_cast<opensaml::saml2p::Response*>(srt);\r
 \r
             const vector<opensaml::saml2::Assertion*>& assertions = response->getAssertions();\r
@@ -226,7 +230,7 @@ int main(int argc,char* argv[])
                     nameid->setNameQualifier(domain.get());\r
                     query->setResource(issuer.get());\r
                     request->setMinorVersion(ver==v11 ? 1 : 0);\r
-                    SAML1SOAPClient client(soaper);\r
+                    SAML1SOAPClient client(soaper, false);\r
                     client.sendSAML(request, mcc, loc.get());\r
                     response = client.receiveSAML();\r
                 }\r
@@ -237,7 +241,11 @@ int main(int argc,char* argv[])
             }\r
 \r
             if (!response)\r
-                throw BindingException("Unable to successfully query for attributes.");\r
+                throw BindingException("Unable to obtain a SAML response from attribute authority.");\r
+            else if (*(response->getStatus()->getStatusCode()->getValue()) != saml1p::StatusCode::SUCCESS) {\r
+                delete const_cast<opensaml::saml1p::Response*>(response);\r
+                throw BindingException("Attribute authority returned a SAML error.");\r
+            }\r
 \r
             const vector<opensaml::saml1::Assertion*>& assertions = response->getAssertions();\r
             if (assertions.size())\r