Better logging for remoted errors.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 8 May 2007 21:17:54 +0000 (21:17 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 8 May 2007 21:17:54 +0000 (21:17 +0000)
Raise metadata exceptions when IdP is unknown.
Cleanup error templates.

git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2241 cb58f699-b61c-0410-a6fe-9272a202ed29

configs/metadataError.html
configs/sessionError.html
shibsp/handler/impl/SAML2SessionInitiator.cpp
shibsp/handler/impl/Shib1SessionInitiator.cpp
shibsp/remoting/impl/SocketListener.cpp

index f4751ff..931b525 100644 (file)
 
 <p>The identity provider supplying your login credentials is not authorized for use with this service.</p>
 
-<shibmlpif originContactName>
-<h3><u>Identity Provider Support Information</u></h3>
-<div>Contact: <shibmlp originContactName/> </div>
-<div>E-Mail: <a href="mailto:<shibmlp originContactEmail/>"><shibmlp originContactEmail/></a></div>
-</shibmlpif>
-<shibmlpif originErrorURL>
-<div>URL: <a href="<shibmlp originErrorURL/>"><shibmlp originErrorURL/></a></div>
-</shibmlpif>
-
-You should inquire with your identity provider as to whether this service is intended to be
-enabled for your use.
+<p>You should inquire with your identity provider as to whether this service is intended to be
+enabled for your use.</p>
 
 <p>Please include the following error message in any email:</p>
 <p class="error">Metadata lookup failure at (<shibmlp requestURL/>)</p>
-<p><shibmlp errorType/></p>
+<shibmlpif entityID>
+<p><strong>EntityID:</strong> <shibmlp entityID/></p>
+</shibmlpif>
+<p><shibmlp errorType/>: <shibmlp errorText/></p>
 
 </body>
 </html>
index 5331c6f..d9f4485 100644 (file)
 <p>The inter-institutional access system was unable to successfully build a
 login session for you at <shibmlp now /></p>
 
-<shibmlpif originContactName>
-<h3><u>Identity Provider Support Information</u></h3>
-<div>Contact: <shibmlp originContactName/> </div>
-<div>E-Mail: <a href="mailto:<shibmlp originContactEmail/>"><shibmlp originContactEmail/></a></div>
-</shibmlpif>
-<shibmlpif originErrorURL>
-<div>URL: <a href="<shibmlp originErrorURL/>"><shibmlp originErrorURL/></a></div>
-</shibmlpif>
-
 <p>To report this problem, please contact the site administrator at
 <a href="mailto:<shibmlp supportContact/>"><shibmlp supportContact/></a>.
 </p>
index 58401f9..1da89c6 100644 (file)
@@ -390,7 +390,8 @@ pair<bool,long> SAML2SessionInitiator::doRequest(
     const EntityDescriptor* entity=m->getEntityDescriptor(entityID);
     if (!entity) {
         m_log.error("unable to locate metadata for provider (%s)", entityID);
-        return make_pair(false,0);
+        throw MetadataException("Unable to locate metadata for identity provider ($entityID)",
+            namedparams(1, "entityID", entityID));
     }
     const IDPSSODescriptor* role=entity->getIDPSSODescriptor(samlconstants::SAML20P_NS);
     if (!role) {
index af6e5d3..4c5b807 100644 (file)
@@ -213,10 +213,11 @@ pair<bool,long> Shib1SessionInitiator::doRequest(
     MetadataProvider* m=app.getMetadataProvider();
     Locker locker(m);
     const EntityDescriptor* entity=m->getEntityDescriptor(entityID);
-    if (!entity) {
-        m_log.error("unable to locate metadata for provider (%s)", entityID);
-        return make_pair(false,0);
-    }
+    if (!entity) {\r
+        m_log.error("unable to locate metadata for provider (%s)", entityID);\r
+        throw MetadataException("Unable to locate metadata for identity provider ($entityID)",\r
+            namedparams(1, "entityID", entityID));\r
+    }\r
     const IDPSSODescriptor* role=entity->getIDPSSODescriptor(shibspconstants::SHIB1_PROTOCOL_ENUM);
     if (!role) {
         m_log.error("unable to locate Shibboleth-aware identity provider role for provider (%s)", entityID);
index 95a887f..17cecb9 100644 (file)
@@ -253,7 +253,7 @@ DDF SocketListener::send(const DDF& in)
     NDC ndc("send");
 #endif
 
-    log->debug("sending message: %s", in.name());
+    log->debug("sending message (%s)", in.name() ? in.name() : "unnamed");
 
     // Serialize data for transmission.
     ostringstream os;
@@ -324,6 +324,7 @@ DDF SocketListener::send(const DDF& in)
         XMLToolingException* except=NULL;
         try { 
             except=XMLToolingException::fromString(out.string());
+            log->error("remoted message returned an error: %s", except->what());
         }
         catch (XMLToolingException& e) {
             log->error("caught XMLToolingException while building the XMLToolingException: %s", e.what());
@@ -447,6 +448,7 @@ bool ServerThread::job()
 {
     Category& log = Category::getInstance("shibd.Listener");
 
+    bool incomingError = true;  // set false once incoming message is received
     ostringstream sink;
 #ifdef WIN32
     u_long len;
@@ -479,17 +481,23 @@ bool ServerThread::job()
         DDFJanitor jin(in);
         is >> in;
 
+        log.debug("dispatching message (%s)", in.name() ? in.name() : "unnamed");
+
+        incomingError = false;
+
         // Dispatch the message.
         m_listener->receive(in, sink);
     }
     catch (XMLToolingException& e) {
-        log.error("error processing incoming message: %s", e.what());
+        if (incomingError)
+            log.error("error processing incoming message: %s", e.what());
         DDF out=DDF("exception").string(e.toString().c_str());
         DDFJanitor jout(out);
         sink << out;
     }
     catch (exception& e) {
-        log.error("error processing incoming message: %s", e.what());
+        if (incomingError)
+            log.error("error processing incoming message: %s", e.what());
         ListenerException ex(e.what());
         DDF out=DDF("exception").string(ex.toString().c_str());
         DDFJanitor jout(out);
@@ -497,7 +505,8 @@ bool ServerThread::job()
     }
 #ifndef _DEBUG
     catch (...) {
-        log.error("unexpected error processing incoming message");
+        if (incomingError)
+            log.error("unexpected error processing incoming message");
         ListenerException ex("An unexpected error occurred while processing an incoming message.");
         DDF out=DDF("exception").string(ex.toString().c_str());
         DDFJanitor jout(out);