Changeset 376

Show
Ignore:
Timestamp:
04/14/06 10:18:58
Author:
douglm
Message:

Access changes:

Inherited flag was not being processed correctly - now encoded and passed around.
Only non-inherited aces are stored in entities
Update pathinfo table when access changed

Moved access action into common component and changed to use correct event refs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/Ace.java

    r331 r376  
    354354                         String name, int whoType) throws AccessException { 
    355355    Iterator it = acl.getAces().iterator(); 
    356      
     356 
    357357    while (it.hasNext()) { 
    358358      Ace ace = (Ace)it.next(); 
     
    360360      if ((whoType == ace.getWhoType()) && 
    361361          ((whoType == whoTypeUnauthenticated) || 
    362            (whoType == whoTypeOwner) ||  
     362           (whoType == whoTypeOwner) || 
    363363            ace.whoMatch(name))) { 
    364364        return ace; 
     
    368368    return null; 
    369369  } 
    370    
     370 
    371371  /* ==================================================================== 
    372372   *                 Decoding methods 
     
    464464      Privilege p = (Privilege)it.next(); 
    465465      p.encode(acl); 
     466    } 
     467 
     468    if (inherited) { 
     469      acl.addChar(PrivilegeDefs.inheritedFlag); 
    466470    } 
    467471 
     
    693697      setPrivs(Privileges.getPrivs(acl)); 
    694698    } 
     699 
     700    // See if we got an inherited flag 
     701    acl.back(); 
     702    if (acl.getChar() == PrivilegeDefs.inheritedFlag) { 
     703      inherited = true; 
     704      if (acl.getChar() != ' ') { 
     705        throw new AccessException("malformedAcl"); 
     706      } 
     707    } 
    695708  } 
    696709} 
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/PrivilegeDefs.java

    r320 r376  
    7575   */ 
    7676  public static final char unspecified = '1'; 
     77 
     78  public static final char inheritedFlag = 'I'; 
    7779 
    7880  // ENUM 
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/Privileges.java

    r331 r376  
    102102 
    103103  private final static Privilege[] privs = new Privilege[privMaxType + 1]; 
    104    
     104 
    105105  static { 
    106106    privs[privAll] = new Privilege("all", "All privileges", privAll); 
    107107 
    108108    privs[privRead] = new Privilege("read", "Read any calendar object", privRead); 
    109      
    110     privs[privReadAcl] = new Privilege("read-acl", "Read calendar accls",  
     109 
     110    privs[privReadAcl] = new Privilege("read-acl", "Read calendar accls", 
    111111                                       privReadAcl); 
    112      
     112 
    113113    privs[privReadCurrentUserPrivilegeSet] = 
    114114      new Privilege("read-current-user-privilege-set", 
    115                     "Read current user privilege set property",  
     115                    "Read current user privilege set property", 
    116116                    privReadCurrentUserPrivilegeSet); 
    117      
    118     privs[privReadFreeBusy] = new Privilege("view-free-busy",  
    119                                             "View a users free busy information",  
     117 
     118    privs[privReadFreeBusy] = new Privilege("view-free-busy", 
     119                                            "View a users free busy information", 
    120120                                            privReadFreeBusy); 
    121      
    122     privs[privWrite] = new Privilege("write", "Write any calendar object",  
     121 
     122    privs[privWrite] = new Privilege("write", "Write any calendar object", 
    123123                                     privWrite); 
    124      
     124 
    125125    privs[privWriteAcl] = new Privilege("write-acl", "Write ACL", privWriteAcl); 
    126      
    127     privs[privWriteProperties] = new Privilege("write-properties",  
    128                                                "Write calendar properties",  
     126 
     127    privs[privWriteProperties] = new Privilege("write-properties", 
     128                                               "Write calendar properties", 
    129129                                               privWriteProperties); 
    130      
    131     privs[privWriteContent] = new Privilege("write-content",  
    132                                             "Write calendar content",  
     130 
     131    privs[privWriteContent] = new Privilege("write-content", 
     132                                            "Write calendar content", 
    133133                                            privWriteContent); 
    134      
    135     privs[privBind] = new Privilege("create", "Create a calendar object",  
     134 
     135    privs[privBind] = new Privilege("create", "Create a calendar object", 
    136136                                    privBind); 
    137      
    138     privs[privUnbind] = new Privilege("delete", "Delete a calendar object",  
     137 
     138    privs[privUnbind] = new Privilege("delete", "Delete a calendar object", 
    139139                                      privUnbind); 
    140      
    141     privs[privUnlock] = new Privilege("unlock", "Remove a lock",  
     140 
     141    privs[privUnlock] = new Privilege("unlock", "Remove a lock", 
    142142                                      privUnlock); 
    143      
     143 
    144144    privs[privNone] = (Privilege)privs[privAll].clone(); 
    145145    privs[privNone].setDenial(true); 
    146      
     146 
    147147    privs[privAll].addContainedPrivilege(privs[privRead]); 
    148148    privs[privAll].addContainedPrivilege(privs[privWrite]); 
    149149    privs[privAll].addContainedPrivilege(privs[privUnlock]); 
    150      
     150 
    151151    privs[privRead].addContainedPrivilege(privs[privReadAcl]); 
    152152    privs[privRead].addContainedPrivilege(privs[privReadCurrentUserPrivilegeSet]); 
    153153    privs[privRead].addContainedPrivilege(privs[privReadFreeBusy]); 
    154      
     154 
    155155    privs[privWrite].addContainedPrivilege(privs[privWriteAcl]); 
    156156    privs[privWrite].addContainedPrivilege(privs[privWriteProperties]); 
     
    215215    while (acl.hasMore()) { 
    216216      char c = acl.getChar(); 
    217       if (c == ' ') { 
     217      if ((c == ' ') || (c == inheritedFlag)) { 
    218218        break; 
    219219      } 
     
    239239  public static void skip(EncodedAcl acl) throws AccessException { 
    240240    while (acl.hasMore()) { 
    241       if (acl.getChar() == ' ') { 
     241      char c = acl.getChar(); 
     242      if ((c == ' ') || (c == inheritedFlag)) { 
    242243        break; 
    243244      } 
     
    257258    while (acl.hasMore()) { 
    258259      char c = acl.getChar(); 
    259       if (c == ' ') { 
     260      if ((c == ' ') || (c == inheritedFlag)) { 
    260261        break; 
    261262      } 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/AccessUtil.java

    r331 r376  
    121121    superUser = val; 
    122122  } 
    123    
     123 
    124124  boolean getSuperUser() { 
    125125    return superUser; 
    126126  } 
    127    
     127 
    128128  void setAuthUser(BwUser val) { 
    129129    authUser = val; 
     
    164164  /** Change the access to the given calendar entity using the supplied aces. 
    165165   * 
    166    * @param ent      BwShareableDbentity  
     166   * @param ent      BwShareableDbentity 
    167167   * @param aces     Collection of ace objects 
    168168   * @throws CalFacadeException 
    169169   */ 
    170   public void changeAccess(BwShareableDbentity ent,  
     170  public void changeAccess(BwShareableDbentity ent, 
    171171                           Collection aces) throws CalFacadeException { 
    172172    try { 
     
    182182 
    183183      ent.setAccess(new String(acl.encode())); 
     184 
     185      if (ent instanceof BwCalendar) { 
     186        updatePathInfo((BwCalendar)ent, acl); 
     187      } 
    184188    } catch (Throwable t) { 
    185189      throw new CalFacadeException(t); 
     
    230234      CurrentAccess ca; 
    231235      String account = ent.getOwner().getAccount(); 
    232        
     236 
    233237      char[] aclChars = getAclChars(ent); 
    234238 
     
    243247      if ((authUser != null) && superUser) { 
    244248        // Nobody can stop us - BWAAA HAA HAA 
    245         ca.accessAllowed = true;  
    246       } 
    247        
     249        ca.accessAllowed = true; 
     250      } 
     251 
    248252      if (!ca.accessAllowed && !returnResult) { 
    249253        throw new CalFacadeAccessException(); 
     
    359363   */ 
    360364  private PathInfo getPathInfo(BwCalendar cal) throws CalFacadeException { 
    361     boolean isPublic = cal.getPublick(); 
    362365    Acl acl = null; 
    363366    PathInfo pi = new PathInfo(); 
     
    377380        if ((aclString == null) && (cal.getCalendar() == null)) { 
    378381          // At root 
    379           if (isPublic) { 
    380             throw new CalFacadeException("Public calendars must have access set at root"); 
    381           } 
    382  
    383           // XXX temp - set this in /user 
    384           aclString = access.getDefaultPersonalAccess(); 
     382          throw new CalFacadeException("Calendars must have default access set at root"); 
    385383        } 
    386384 
     
    398396 
    399397      pi.pathAcl = acl; 
    400       pi.encoded = acl.getEncoded(); 
     398      pi.encoded = acl.encodeAll(); 
    401399 
    402400      return pi; 
     401    } catch (CalFacadeException cfe) { 
     402      throw cfe; 
     403    } catch (Throwable t) { 
     404      throw new CalFacadeException(t); 
     405    } 
     406  } 
     407 
     408  /* Update the merged Acl for the given calendar. 
     409   */ 
     410  private void updatePathInfo(BwCalendar cal, Acl acl) throws CalFacadeException { 
     411    try { 
     412      String path = cal.getPath(); 
     413      PathInfo pi = (PathInfo)pathInfoTable.get(path); 
     414 
     415      if (pi == null) { 
     416        pi = new PathInfo(); 
     417 
     418        pi.path = cal.getPath(); 
     419      } 
     420 
     421      pi.pathAcl = acl; 
     422      pi.encoded = acl.encodeAll(); 
     423 
     424      pathInfoTable.put(path, pi); 
    403425    } catch (Throwable t) { 
    404426      throw new CalFacadeException(t); 
  • trunk/calendar3/webclient/war/WEB-INF/struts-config.xml

    r359 r376  
    313313 
    314314    <action    path="/setAccess" 
    315                type="org.bedework.webclient.BwAccessAction" 
     315               type="org.bedework.webcommon.access.AccessAction" 
    316316               name="calForm" 
    317317               scope="session"