Author: dumindu
Date: Sun Feb 24 19:09:01 2008
New Revision: 14113

Log:

Fixed UNAUTH_REDIRECT.



Modified:
   trunk/solutions/identity/modules/mod-cspace/mod_cspace.c

Modified: trunk/solutions/identity/modules/mod-cspace/mod_cspace.c
==============================================================================
--- trunk/solutions/identity/modules/mod-cspace/mod_cspace.c    (original)
+++ trunk/solutions/identity/modules/mod-cspace/mod_cspace.c    Sun Feb 24 
19:09:01 2008
@@ -39,7 +39,7 @@
 
 #define MYMIN(a, b) ((a)<(b)?(a):(b))
 
-#define UNAUTHORIZED_REDIRECT(r, u) redirect((r), (u))
+#define UNAUTHORIZED_REDIRECT(r, u) redirect_external((r), (u))
 
 #define CARDSPACE_HEADER_PFX "cardspace_"
 
@@ -66,16 +66,26 @@
 }
 */
 
-/* TODO:This function should ideally redirect the browser to the url specified
+static int redirect_external(request_rec *r, char *url)
+{
+    /* set a "Location:" header and 302 redirect. */
+    printf("redirecting to: %s", url);
+    apr_table_setn(r->headers_out, "Location", url);
+
+    return HTTP_MOVED_TEMPORARILY;
+  
+}
+
+/* TODO:DONE This function should ideally redirect the browser to the url 
specified
  * by url. This is only used to redirect the browser to the login page when an
  * HTTP_UNAUTHORIZED occurs.
  *
  * We can live with the plain HTTP_UNAUTHORIZED for the moment
  */ 
-static int redirect(request_rec *r, char* url)
+static int redirect_internal(request_rec *r, char* url)
 {
-    /*remove_cspace_headers(r);
-    ap_internal_redirect(url, r);*/
+    remove_cspace_headers(r);
+    ap_internal_redirect(url, r);
     return OK;
     /*return HTTP_UNAUTHORIZED;*/
 }
@@ -91,9 +101,18 @@
                 strlen(*(char **)tmp), uri, strlen(uri),
                 MYMIN(strlen(*(char **)tmp), strlen(uri)));
 #endif
+        if (strcmp(uri, "/") == 0) {
+            if (strcmp(*(char **)tmp, "/") == 0) {
+                return SUCC;
+            } else {
+                return FAIL;
+            }
+        }
+
         if (strncmp(*(char **)tmp, uri,
-                    MYMIN(strlen(*(char **)tmp), strlen(uri))) == 0)
+                    MYMIN(strlen(*(char **)tmp), strlen(uri))) == 0) {
             return SUCC;
+        }
         tmp = (char *)tmp + a->elt_size;
     }
 

_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev

Reply via email to