Review Board 1.7.22


CommonContainer token refresh changes for a better UX when tokens expire.

Review Request #3180 - Created Dec. 13, 2011 and submitted

Dan Dumont
SHINDIG-1681
Reviewers
shindig
hsaputra, jcian, lixu, rbaxter, ssievers
shindig
Initial review of 1st change.  Allowing common container to manage container token refreshes.  Also, refresh of gadget security tokens will now wait for valid container security token before trying to refresh.
Tested code in a private container with some examples of setting no refresh (ttl = 0) and setting an initial token (if it was written by jsp page to avoid transaction) etc..
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container/container.js
Diff Revision 8 Diff Revision 9
[20] 738 lines
[+20] [+] arbitrate = function(serviceId, from) {
739
    var site = this.sites_[siteId];
739
    var site = this.sites_[siteId];
740
    if (site instanceof osapi.container.GadgetSite) {
740
    if (site instanceof osapi.container.GadgetSite) {
741
      var holder = site.getActiveGadgetHolder();
741
      var holder = site.getActiveGadgetHolder();
742
      if (holder) {
742
      if (holder) {
743
        var url = holder.getUrl();
743
        var url = holder.getUrl();
744
            moduleId = site.getModuleId();
744
            mid = site.getModuleId();
745

    
   
745

   
746
        // If this gadget token does not require refresh
746
        // If this gadget token does not require refresh
747
        // (baseurl is not already in result), don't add it.
747
        // (baseurl is not already in result), don't add it.
748
        if (result[url] && moduleId) {
748
        if (result[url]) {
749
          result[shindig.uri(url).setFragment(moduleId).toString()] = 1;
749
          result[osapi.container.util.buildTokenRequestUrl(url, mid)] = 1;
750
        }
750
        }
751
      }
751
      }
752
    }
752
    }
753
  }
753
  }
754

    
   
754

   
[+20] [20] 51 lines
[+20] arbitrate = function(serviceId, from) {
806
      var site = self.sites_[siteId];
806
      var site = self.sites_[siteId];
807
      if (site instanceof osapi.container.GadgetSite) {
807
      if (site instanceof osapi.container.GadgetSite) {
808
        var holder = site.getActiveGadgetHolder();
808
        var holder = site.getActiveGadgetHolder();
809
        var gadgetInfo = self.service_.getCachedGadgetMetadata(holder.getUrl());
809
        var gadgetInfo = self.service_.getCachedGadgetMetadata(holder.getUrl());
810
        if (gadgetInfo[osapi.container.MetadataResponse.NEEDS_TOKEN_REFRESH]) {
810
        if (gadgetInfo[osapi.container.MetadataResponse.NEEDS_TOKEN_REFRESH]) {
811
          var url = holder.getUrl(),
811
          var mid = site.getModuleId(),
812
              moduleId = site.getModuleId();
812
              url = osapi.container.util.buildTokenRequestUrl(holder.getUrl(), mid),
813
          if (moduleId) {
813
              tokenInfo = response[url];
814
            url = shindig.uri(url).setFragment(moduleId).toString();
814

   
815
          }

   
816
          var tokenInfo = response[url];

   
817
          if (tokenInfo.error) {
815
          if (tokenInfo.error) {
818
            gadgets.warn(['Failed to get token for gadget ',
816
            gadgets.warn(['Failed to get token for gadget ',
819
                url, '.'].join(''));
817
                url, '.'].join(''));
820
          } else {
818
          } else {
821
            gadgets.rpc.call(holder.getIframeId(), 'update_security_token', null,
819
            gadgets.rpc.call(holder.getIframeId(), 'update_security_token', null,
[+20] [20] 72 lines
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container/service.js
Diff Revision 8 Diff Revision 9
 
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.gadget/gadget_site.js
Diff Revision 8 Diff Revision 9
 
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.util/util.js
Diff Revision 8 Diff Revision 9
 
http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AbstractSecurityToken.java
Diff Revision 8 Diff Revision 9 - File Reverted
 
  1. http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container/container.js: Loading...
  2. http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container/service.js: Loading...
  3. http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.gadget/gadget_site.js: Loading...
  4. http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.util/util.js: Loading...
  5. http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AbstractSecurityToken.java: Loading...