summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/js/htdocs/component.js
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-11-21 08:47:12 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-11-21 08:47:12 +0000
commit57ff384203570508e81cdf5dfaa0cb96478e7654 (patch)
treebaa71ee27ee1354cb633cd578c9d36fb15485124 /sca-cpp/trunk/modules/js/htdocs/component.js
parent5a4e8af02b6fc5fefc5f7a2a95cc1e735759c40a (diff)
Improvements to the auth implementation. Refactor logout page, handle auth redirects in XHR responses and allow auth to work off an OpenID AX attribute or OAuth resource attribute.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1204401 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/js/htdocs/component.js')
-rw-r--r--sca-cpp/trunk/modules/js/htdocs/component.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/component.js b/sca-cpp/trunk/modules/js/htdocs/component.js
index d991f9aa61..10b4535470 100644
--- a/sca-cpp/trunk/modules/js/htdocs/component.js
+++ b/sca-cpp/trunk/modules/js/htdocs/component.js
@@ -265,13 +265,16 @@ HTTPBindingClient.prototype.get = function(id, cb) {
if (http.getResponseHeader("X-Login") != null) {
// Detect redirect to a login page
try {
- cb(null, new HTTPBindingClient.Exception(403, 'X-Login'));
+ var le = new HTTPBindingClient.Exception(403, 'X-Login');
+ if (window.onloginredirect)
+ window.onloginredirect(le);
+ return cb(null, le);
} catch(cbe) {}
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
// Report empty response
try {
- cb(null, new HTTPBindingClient.Exception(403, 'No-Content'));
+ return cb(null, new HTTPBindingClient.Exception(403, 'No-Content'));
} catch(cbe) {}
} else {
@@ -282,7 +285,7 @@ HTTPBindingClient.prototype.get = function(id, cb) {
localStorage.setItem(u, http.responseText);
}
try {
- cb(http.responseText);
+ return cb(http.responseText);
} catch(cbe) {}
}
}
@@ -291,7 +294,7 @@ HTTPBindingClient.prototype.get = function(id, cb) {
// Pass exception if we didn't have a local result
if (item == null) {
try {
- cb(null, new HTTPBindingClient.Exception(http.status, http.statusText));
+ return cb(null, new HTTPBindingClient.Exception(http.status, http.statusText));
} catch(cbe) {}
}
}
@@ -309,7 +312,10 @@ HTTPBindingClient.prototype.get = function(id, cb) {
if (http.getResponseHeader("X-Login") != null) {
// Detect redirect to a login page
- throw new HTTPBindingClient.Exception(403, 'X-Login');
+ var le = new HTTPBindingClient.Exception(403, 'X-Login');
+ if (window.onloginredirect)
+ window.onloginredirect(le);
+ throw le;
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
@@ -341,7 +347,10 @@ HTTPBindingClient.prototype.getnocache = function(id, cb) {
if (http.getResponseHeader("X-Login") != null) {
// Detect redirect to a login page
try {
- return cb(null, new HTTPBindingClient.Exception(403, 'X-Login'));
+ var le = new HTTPBindingClient.Exception(403, 'X-Login');
+ if (window.onloginredirect)
+ window.onloginredirect(le);
+ return cb(null, le);
} catch(cbe) {}
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
@@ -352,12 +361,12 @@ HTTPBindingClient.prototype.getnocache = function(id, cb) {
} else {
try {
- cb(http.responseText);
+ return cb(http.responseText);
} catch(cbe) {}
}
} else {
try {
- cb(null, new HTTPBindingClient.Exception(http.status, http.statusText));
+ return cb(null, new HTTPBindingClient.Exception(http.status, http.statusText));
} catch(cbe) {}
}
}
@@ -374,7 +383,10 @@ HTTPBindingClient.prototype.getnocache = function(id, cb) {
if (http.getResponseHeader("X-Login") != null) {
// Detect redirect to a login page
- throw new HTTPBindingClient.Exception(403, 'X-Login');
+ var le = new HTTPBindingClient.Exception(403, 'X-Login');
+ if (window.onloginredirect)
+ window.onloginredirect(le);
+ throw le;
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {