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 10
[20] 515 lines
[+20] [+] finishNavigate = function(preferences) {
516
 *
516
 *
517
 * @param {function=} callback Function to run when container token is valid.
517
 * @param {function=} callback Function to run when container token is valid.
518
 * @param {String=} token The containers new security token.
518
 * @param {String=} token The containers new security token.
519
 * @param {number=} ttl The token's ttl in seconds. If token is specified and ttl is 0,
519
 * @param {number=} ttl The token's ttl in seconds. If token is specified and ttl is 0,
520
 *   token refresh will be disabled.
520
 *   token refresh will be disabled.

    
   
521
 * @see osapi.container.ContainerConfig.GET_CONTAINER_TOKEN (constants.js)
521
 */
522
 */
522
osapi.container.Container.prototype.updateContainerSecurityToken = function(callback, token, ttl) {
523
osapi.container.Container.prototype.updateContainerSecurityToken = function(callback, token, ttl) {
523
  this.service_.updateContainerSecurityToken(callback, token, ttl);
524
  this.service_.updateContainerSecurityToken(callback, token, ttl);
524
}
525
}
525

    
   
526

   
[+20] [20] 213 lines
[+20] [+] arbitrate = function(serviceId, from) {
739
    var site = this.sites_[siteId];
740
    var site = this.sites_[siteId];
740
    if (site instanceof osapi.container.GadgetSite) {
741
    if (site instanceof osapi.container.GadgetSite) {
741
      var holder = site.getActiveGadgetHolder();
742
      var holder = site.getActiveGadgetHolder();
742
      if (holder) {
743
      if (holder) {
743
        var url = holder.getUrl();
744
        var url = holder.getUrl();
744
            moduleId = site.getModuleId();
745
            mid = site.getModuleId();
745

    
   
746

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

    
   
755

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

   
815
          }

   
816
          var tokenInfo = response[url];

   
817
          if (tokenInfo.error) {
816
          if (tokenInfo.error) {
818
            gadgets.warn(['Failed to get token for gadget ',
817
            gadgets.warn(['Failed to get token for gadget ',
819
                url, '.'].join(''));
818
                url, '.'].join(''));
820
          } else {
819
          } else {
821
            gadgets.rpc.call(holder.getIframeId(), 'update_security_token', null,
820
            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 10
 
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.gadget/gadget_site.js
Diff Revision 8 Diff Revision 10
 
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.util/constant.js
Diff Revision 8 Diff Revision 10
 
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.util/util.js
Diff Revision 8 Diff Revision 10
 
http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AbstractSecurityToken.java
Diff Revision 8 Diff Revision 10 - 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/constant.js: Loading...
  5. http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/container.util/util.js: Loading...
  6. http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AbstractSecurityToken.java: Loading...