Porting changes from 1.2 branch
[shibboleth/sp.git] / shib-target / shib-shire.cpp
index 37869d4..eacb67a 100644 (file)
@@ -269,7 +269,7 @@ const char* SHIRE::getShireURL(const char* resource) const
     }
     
     // Should never happen...
-    if (!shire)
+    if (!shire || (*shire!='/' && strncmp(shire,"http:",5) && strncmp(shire,"https:",6)))
         return NULL;
 
     // The "shireURL" property can be in one of three formats:
@@ -343,7 +343,7 @@ const char* SHIRE::getAuthnRequest(const char* resource) const
             if (!old.first || !old.second) {
                 wayf=m_app->getString("providerId");
                 if (wayf.first)
-                    m_authnRequest=m_authnRequest + "&providerId=" + wayf.second;
+                    m_authnRequest=m_authnRequest + "&providerId=" + url_encode(wayf.second);
             }
         }
     }
@@ -415,20 +415,18 @@ RPCError* SHIRE::sessionIsValid(const char* session_id, const char* ip) const
   RPC rpc;
   do {
     clnt = rpc->connect();
-    if (shibrpc_session_is_valid_1(&arg, &ret, clnt) != RPC_SUCCESS) {
+    clnt_stat status = shibrpc_session_is_valid_1(&arg, &ret, clnt);
+    if (status != RPC_SUCCESS) {
       // FAILED.  Release, disconnect, and try again...
-      log.debug("RPC Failure: %p (%p): %s", this, clnt, clnt_spcreateerror(""));
+      log.error("RPC Failure: %p (%p) (%d) %s", this, clnt, status, clnt_spcreateerror("shibrpc_session_is_valid_1"));
       rpc->disconnect();
       if (retry)
           retry--;
-      else {
-        log.error("RPC Failure: %p (%p)", this, clnt);
-        return new RPCError(-1, "RPC Failure");
-      }
+      else
+          return new RPCError(-1, "RPC Failure");
     }
     else {
-      // SUCCESS.  Return to the pool.
-      rpc.pool();
+      // SUCCESS
       retry = -1;
     }
   } while (retry>=0);
@@ -442,6 +440,7 @@ RPCError* SHIRE::sessionIsValid(const char* session_id, const char* ip) const
     retval = new RPCError();
 
   clnt_freeres (clnt, (xdrproc_t)xdr_shibrpc_session_is_valid_ret_1, (caddr_t)&ret);
+  rpc.pool();
 
   log.debug("returning");
   return retval;
@@ -487,20 +486,18 @@ RPCError* SHIRE::sessionCreate(const char* response, const char* ip, string& coo
   RPC rpc;
   do {
     clnt = rpc->connect();
-    if (shibrpc_new_session_1 (&arg, &ret, clnt) != RPC_SUCCESS) {
+    clnt_stat status = shibrpc_new_session_1 (&arg, &ret, clnt);
+    if (status != RPC_SUCCESS) {
       // FAILED.  Release, disconnect, and retry
-      log.debug("RPC Failure: %p (%p): %s", this, clnt, clnt_spcreateerror (""));
+      log.error("RPC Failure: %p (%p) (%d): %s", this, clnt, status, clnt_spcreateerror("shibrpc_new_session_1"));
       rpc->disconnect();
       if (retry)
-       retry--;
-      else {
-        log.error("RPC Failure: %p (%p)", this, clnt);
+        retry--;
+      else
         return new RPCError(-1, "RPC Failure");
-      }
     }
     else {
       // SUCCESS.  Pool and continue
-      rpc.pool();
       retry = -1;
     }
   } while (retry>=0);
@@ -517,6 +514,7 @@ RPCError* SHIRE::sessionCreate(const char* response, const char* ip, string& coo
   }
 
   clnt_freeres(clnt, (xdrproc_t)xdr_shibrpc_new_session_ret_1, (caddr_t)&ret);
+  rpc.pool();
 
   log.debug("returning");
   return retval;