Changeset 314

Show
Ignore:
Timestamp:
03/31/06 11:17:40
Author:
douglm
Message:

Many changes to access control. Most improve performance.

Made all of Privileges static and changed a number of methods as a result.
Creating Acl objects is now cheap.

Also changes to emit current access as xml in user client all view.

Files:

Legend:

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

    r310 r314  
    6969  private boolean debug; 
    7070 
    71   /** The acl we use for evaluation of access. 
    72    */ 
    73   private final static Acl acl = new Acl(); 
    74  
    7571  /** Defines no access */ 
    76   public final static Privilege none = acl.makePriv(Privileges.privNone); 
     72  public final static Privilege none = Privileges.makePriv(Privileges.privNone); 
    7773 
    7874  /** Defines full access to an object */ 
    79   public final static Privilege all = acl.makePriv(Privileges.privAll); 
     75  public final static Privilege all = Privileges.makePriv(Privileges.privAll); 
    8076 
    8177  /** Defines read access to an object */ 
    82   public final static Privilege read = acl.makePriv(Privileges.privRead); 
     78  public final static Privilege read = Privileges.makePriv(Privileges.privRead); 
    8379 
    8480  /** Defines write access to an object */ 
    85   public final static Privilege write = acl.makePriv(Privileges.privWrite); 
     81  public final static Privilege write = Privileges.makePriv(Privileges.privWrite); 
    8682 
    8783  /** Defines write access to an object */ 
    88   public final static Privilege writeContent = acl.makePriv(Privileges.privWriteContent); 
     84  public final static Privilege writeContent = Privileges.makePriv(Privileges.privWriteContent); 
    8985 
    9086  /** Privilege set giving read access to an object */ 
     
    9692  /** Default access for public entities 
    9793   */ 
    98   private static String defaultPublicAccess; 
     94  private static volatile String defaultPublicAccess; 
    9995 
    10096  /** Default access for personal entities 
    10197   */ 
    102   private static String defaultPersonalAccess; 
    103  
     98  private static volatile String defaultPersonalAccess; 
     99 
     100  static { 
     101    Acl acl = new Acl(); 
     102 
     103    try { 
     104      /** Public - write owner, read others, read unauthenticated */ 
     105      acl.clear(); 
     106      acl.addAce(new Ace(null, false, Ace.whoTypeOwner, all)); 
     107      acl.addAce(new Ace(null, false, Ace.whoTypeOther, read)); 
     108      acl.addAce(new Ace(null, false, Ace.whoTypeUnauthenticated, read)); 
     109      defaultPublicAccess = new String(acl.encode()); 
     110       
     111      acl.clear(); 
     112      acl.addAce(new Ace(null, false, Ace.whoTypeOwner, all)); 
     113      acl.addAce(new Ace(null, false, Ace.whoTypeOther, none)); 
     114      defaultPersonalAccess = new String(acl.encode()); 
     115    } catch (Throwable t) { 
     116      throw new RuntimeException(t); 
     117    } 
     118  } 
     119   
    104120  /** Constructor 
    105121   * 
     
    109125  public Access(boolean debug) throws AccessException { 
    110126    this.debug = debug; 
    111     acl.setDebug(debug); 
    112  
    113     /** Calculate default access strings */ 
    114  
    115     /** Public - write owner, read others, read unauthenticated */ 
    116     acl.clear(); 
    117     acl.addAce(new Ace(null, false, Ace.whoTypeOwner, all)); 
    118     acl.addAce(new Ace(null, false, Ace.whoTypeOther, read)); 
    119     acl.addAce(new Ace(null, false, Ace.whoTypeUnauthenticated, read)); 
    120     defaultPublicAccess = new String(acl.encode()); 
    121  
    122     acl.clear(); 
    123     acl.addAce(new Ace(null, false, Ace.whoTypeOwner, all)); 
    124     acl.addAce(new Ace(null, false, Ace.whoTypeOther, none)); 
    125     defaultPersonalAccess = new String(acl.encode()); 
    126127  } 
    127128 
     
    148149   */ 
    149150  public Privilege makePriv(int priv) { 
    150     return acl.makePriv(priv); 
    151   } 
    152  
    153   /** Get the Privileges object from the defautl acl 
    154    * 
    155    * @param privs Privileges  
    156    * @return Privilege object defining access 
    157    */ 
    158   public static Privileges getPrivs() { 
    159     return acl.getPrivs(); 
     151    return Privileges.makePriv(priv); 
    160152  } 
    161153 
     
    198190                                Privilege[] how, String aclString) 
    199191          throws AccessException { 
    200     return acl.evaluateAccess(who, owner, how, aclString.toCharArray()); 
     192    return new Acl(debug).evaluateAccess(who, owner, how, aclString.toCharArray()); 
    201193  } 
    202194 
     
    213205                                Privilege[] how, char[] aclChars) 
    214206          throws AccessException { 
    215     return acl.evaluateAccess(who, owner, how, aclChars); 
     207    return new Acl(debug).evaluateAccess(who, owner, how, aclChars); 
    216208  } 
    217209 
     
    227219                           char[] aclChars) 
    228220          throws AccessException { 
    229     return acl.evaluateAccess(who, owner, privSetRead, aclChars); 
     221    return new Acl(debug).evaluateAccess(who, owner, privSetRead, aclChars); 
    230222  } 
    231223 
     
    241233                                char[] aclChars) 
    242234          throws AccessException { 
    243     return acl.evaluateAccess(who, owner, privSetReadWrite, aclChars); 
     235    return new Acl(debug).evaluateAccess(who, owner, privSetReadWrite, aclChars); 
    244236  } 
    245237 
     
    256248                                int priv, char[] aclChars) 
    257249          throws AccessException { 
    258     if (debug) { 
    259     } 
    260  
    261     return acl.evaluateAccess(who, owner, 
    262                               new Privilege[]{acl.makePriv(priv)}, 
    263                               aclChars); 
     250    return new Acl(debug).evaluateAccess(who, owner, 
     251                                         new Privilege[]{Privileges.makePriv(priv)}, 
     252                                         aclChars); 
    264253  } 
    265254} 
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/Ace.java

    r2 r314  
    374374   * @param acl 
    375375   * @param privs 
    376    * @param getPrivileges 
    377376   * @param name 
    378377   * @param whoType 
     
    381380   */ 
    382381  public boolean decode(EncodedAcl acl, 
    383                         Privileges privs, 
    384382                        boolean getPrivileges, 
    385383                        String name, int whoType) throws AccessException { 
     
    390388 
    391389      if ((whoType != getWhoType()) || !whoMatch(name)) { 
    392         skipHow(acl, privs); 
     390        skipHow(acl); 
    393391      } else { 
    394         decodeHow(acl, privs, getPrivileges); 
     392        decodeHow(acl, getPrivileges); 
    395393        return true; 
    396394      } 
     
    407405   * 
    408406   * @param acl 
    409    * @param privs 
    410407   * @param getPrivileges 
    411408   * @throws AccessException 
    412409   */ 
    413410  public void decode(EncodedAcl acl, 
    414                      Privileges privs, 
    415411                     boolean getPrivileges) throws AccessException { 
    416412    decodeWhoType(acl); 
    417     decodeHow(acl, privs, getPrivileges); 
     413    decodeHow(acl, getPrivileges); 
    418414  } 
    419415 
     
    659655  } 
    660656 
    661   private void skipHow(EncodedAcl acl, 
    662                        Privileges privs) throws AccessException { 
    663     privs.skip(acl); 
     657  private void skipHow(EncodedAcl acl) throws AccessException { 
     658    Privileges.skip(acl); 
    664659  } 
    665660 
    666661  private void decodeHow(EncodedAcl acl, 
    667                          Privileges privs, 
    668662                         boolean getPrivileges) throws AccessException { 
    669663    int pos = acl.getPos(); 
    670     setHow(privs.fromEncoding(acl)); 
     664    setHow(Privileges.fromEncoding(acl)); 
    671665    if (getPrivileges) { 
    672666      acl.setPos(pos); 
    673       setPrivs(privs.getPrivs(acl)); 
     667      setPrivs(Privileges.getPrivs(acl)); 
    674668    } 
    675669  } 
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/Acl.java

    r120 r314  
    8383  boolean debug; 
    8484 
    85   Privileges privs; 
    86  
    8785  private TreeSet aces; 
    8886 
     
    105103  public Acl(boolean debug) { 
    106104    this.debug = debug; 
    107     privs = new Privileges(); 
    108105  } 
    109106 
     
    184181    getPrivileges: { 
    185182      if (!authenticated) { 
    186         if (ace.decode(this, privs, false, null, Ace.whoTypeUnauthenticated)) { 
     183        if (ace.decode(this, false, null, Ace.whoTypeUnauthenticated)) { 
    187184          privileges = ace.getHow(); 
    188185        } 
     
    192189 
    193190      if (isOwner) { 
    194         if (ace.decode(this, privs, false, null, Ace.whoTypeOwner)) { 
     191        if (ace.decode(this, false, null, Ace.whoTypeOwner)) { 
    195192          privileges = ace.getHow(); 
    196193        } else { 
     
    202199 
    203200      // Not owner - look for user 
    204       if (ace.decode(this, privs, false, who.getAccount(), Ace.whoTypeUser)) { 
     201      if (ace.decode(this, false, who.getAccount(), Ace.whoTypeUser)) { 
    205202        privileges = ace.getHow(); 
    206203        if (debug) { 
     
    221218            debugsb.append("...Try access for group " + group); 
    222219          } 
    223           if (ace.decode(this, privs, false, group, Ace.whoTypeGroup)) { 
     220          if (ace.decode(this, false, group, Ace.whoTypeGroup)) { 
    224221            privileges = mergePrivileges(privileges, ace.getHow()); 
    225222          } 
     
    236233 
    237234      // "other" access set? 
    238       if (ace.decode(this, privs, false, null, Ace.whoTypeOther)) { 
     235      if (ace.decode(this, false, null, Ace.whoTypeOther)) { 
    239236        privileges = ace.getHow(); 
    240237 
     
    303300  } 
    304301 
    305   /** 
    306    * @return Privileges 
    307    */ 
    308   public Privileges getPrivs() { 
    309     return privs; 
    310   } 
    311  
    312302  /** Set the ace collection for this acl 
    313303   * 
     
    340330  } 
    341331 
    342   /** 
    343    * @param privType 
    344    * @return Privilege 
    345    */ 
    346   public Privilege makePriv(int privType) { 
    347     return privs.makePriv(privType); 
    348   } 
    349  
    350332  /** Set to default access 
    351333   * 
     
    355337 
    356338    addAce(new Ace(null, false, Ace.whoTypeOwner, 
    357                    privs.makePriv(Privileges.privAll))); 
     339                   Privileges.makePriv(Privileges.privAll))); 
    358340 
    359341    addAce(new Ace(null, false, Ace.whoTypeOther, 
    360                    privs.makePriv(Privileges.privNone))); 
     342                   Privileges.makePriv(Privileges.privNone))); 
    361343  } 
    362344 
     
    421403        Ace ace = new Ace(); 
    422404 
    423         ace.decode(this, privs, true); 
     405        ace.decode(this, true); 
    424406 
    425407        ts.add(ace); 
     
    452434      Ace ace = new Ace(); 
    453435 
    454       ace.decode(this, privs, true); 
     436      ace.decode(this, true); 
    455437      ace.setInherited(true); 
    456438 
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/Privilege.java

    r2 r314  
    5454package edu.rpi.cct.uwcal.access; 
    5555 
     56import java.util.ArrayList; 
    5657import java.util.Iterator; 
    57 import java.util.Vector; 
    5858 
    5959/** Define the properties of a privilege for the calendar. 
     
    8383  private char encoding; 
    8484 
    85   private Vector containedPrivileges = new Vector(); 
     85  private ArrayList containedPrivileges = new ArrayList(); 
    8686 
    8787  /** Constructor 
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/Privileges.java

    r2 r314  
    101101   */ 
    102102 
    103   private Privilege[] privs; 
    104  
    105   /** Constructor 
    106    * 
    107    */ 
    108   public Privileges() { 
    109     privs = new Privilege[privMaxType + 1]; 
    110  
     103  private final static Privilege[] privs = new Privilege[privMaxType + 1]; 
     104   
     105  static { 
    111106    privs[privAll] = new Privilege("all", "All privileges", false, false, 
    112                     privAll); 
     107                                   privAll); 
    113108 
    114109    privs[privRead] = new Privilege("read", "Read any calendar object", false, false, 
    115                     privRead); 
    116  
     110                                    privRead); 
     111     
    117112    privs[privReadAcl] = new Privilege("read-acl", "Read calendar accls", false, false, 
    118                     privReadAcl); 
    119  
     113                                       privReadAcl); 
     114     
    120115    privs[privReadCurrentUserPrivilegeSet] = 
    121116      new Privilege("read-current-user-privilege-set", 
    122117                    "Read current user privilege set property", false, false, 
    123118                    privReadCurrentUserPrivilegeSet); 
    124  
    125     privs[privReadFreeBusy] = new Privilege("view-free-busy", "View a users free busy information", false, false, 
    126                     privReadFreeBusy); 
    127  
     119     
     120    privs[privReadFreeBusy] = new Privilege("view-free-busy",  
     121                                            "View a users free busy information",  
     122                                            false, false, privReadFreeBusy); 
     123     
    128124    privs[privWrite] = new Privilege("write", "Write any calendar object", false, false, 
    129                     privWrite); 
    130  
     125                                     privWrite); 
     126     
    131127    privs[privWriteAcl] = new Privilege("write-acl", "Write ACL", false, false, 
    132                     privWriteAcl); 
    133  
     128                                        privWriteAcl); 
     129     
    134130    privs[privWriteProperties] = new Privilege("write-properties", "Write calendar properties", false, false, 
    135                     privWriteProperties); 
    136  
     131                                               privWriteProperties); 
     132     
    137133    privs[privWriteContent] = new Privilege("write-content", "Write calendar content", false, false, 
    138                     privWriteContent); 
    139  
     134                                            privWriteContent); 
     135     
    140136    privs[privBind] = new Privilege("create", "Create a calendar object", false, false, 
    141                     privBind); 
    142  
     137                                    privBind); 
     138     
    143139    privs[privUnbind] = new Privilege("delete", "Delete a calendar object", false, false, 
    144                     privUnbind); 
    145  
     140                                      privUnbind); 
     141     
    146142    privs[privUnlock] = new Privilege("unlock", "Remove a lock", false, false, 
    147                     privUnlock); 
    148  
     143                                      privUnlock); 
     144     
    149145    privs[privNone] = (Privilege)privs[privAll].clone(); 
    150146    privs[privNone].setDenial(true); 
    151  
     147     
    152148    privs[privAll].addContainedPrivilege(privs[privRead]); 
    153149    privs[privAll].addContainedPrivilege(privs[privWrite]); 
    154150    privs[privAll].addContainedPrivilege(privs[privUnlock]); 
    155  
     151     
    156152    privs[privRead].addContainedPrivilege(privs[privReadAcl]); 
    157153    privs[privRead].addContainedPrivilege(privs[privReadCurrentUserPrivilegeSet]); 
    158154    privs[privRead].addContainedPrivilege(privs[privReadFreeBusy]); 
    159  
     155     
    160156    privs[privWrite].addContainedPrivilege(privs[privWriteAcl]); 
    161157    privs[privWrite].addContainedPrivilege(privs[privWriteProperties]); 
     
    165161  } 
    166162 
     163  /** Constructor 
     164   * 
     165   */ 
     166  private Privileges() { 
     167  } 
     168 
    167169  /** 
    168170   * @return Privilege defining all access 
    169171   */ 
    170   public Privilege getPrivAll() { 
     172  public static Privilege getPrivAll() { 
    171173    return privs[privAll]; 
    172174  } 
     
    175177   * @return Privilege defining no access 
    176178   */ 
    177   public Privilege getPrivNone() { 
     179  public static Privilege getPrivNone() { 
    178180    return privs[privNone]; 
    179181  } 
     
    184186   * @return Privilege defining access 
    185187   */ 
    186   public Privilege makePriv(int privType) { 
     188  public static Privilege makePriv(int privType) { 
    187189    return (Privilege)privs[privType].clone(); 
    188190  } 
     
    195197   * @throws AccessException 
    196198   */ 
    197   public char[] fromEncoding(EncodedAcl acl) throws AccessException { 
     199  public static char[] fromEncoding(EncodedAcl acl) throws AccessException { 
    198200    char[] privStates = { 
    199201      unspecified,   // privAll 
     
    236238   * @throws AccessException 
    237239   */ 
    238   public void skip(EncodedAcl acl) throws AccessException { 
     240  public static void skip(EncodedAcl acl) throws AccessException { 
    239241    while (acl.hasMore()) { 
    240242      if (acl.getChar() == ' ') { 
     
    251253   * @throws AccessException 
    252254   */ 
    253   public Collection getPrivs(EncodedAcl acl) throws AccessException { 
     255  public static Collection getPrivs(EncodedAcl acl) throws AccessException { 
    254256    Vector v = new Vector(); 
    255257 
     
    272274  } 
    273275 
    274   private void setState(char[] states, Privilege p, boolean denial) { 
     276  private static void setState(char[] states, Privilege p, boolean denial) { 
    275277    if (!denial) { 
    276278      states[p.getIndex()] = allowed; 
     
    290292   * that matches the privilege in the acl. 
    291293   */ 
    292   private Privilege findPriv(Privilege p, EncodedAcl acl) 
     294  private static Privilege findPriv(Privilege p, EncodedAcl acl) 
    293295          throws AccessException { 
    294296    if (p.match(acl)) { 
     
    308310    return null; 
    309311  } 
    310  
    311   /* ==================================================================== 
    312    *                   Object methods 
    313    * ==================================================================== */ 
    314 /* 
    315   public int hashCode() { 
    316     return 31 * entityId * entityType; 
    317   } 
    318  
    319   public boolean equals(Object obj) { 
    320     if (this == obj) { 
    321       return true; 
    322     } 
    323  
    324     if (obj == null) { 
    325       return false; 
    326     } 
    327  
    328     if (!(obj instanceof AttendeeVO)) { 
    329       return false; 
    330     } 
    331  
    332     AttendeePK that = (AttendeePK)obj; 
    333  
    334     return (entityId == that.entityId) && 
    335            (entityType == that.entityType); 
    336   } 
    337   */ 
    338  
    339   public String toString() { 
    340     StringBuffer sb = new StringBuffer(); 
    341  
    342     sb.append("AclVO{"); 
    343 //    sb.append(entityId); 
    344     sb.append("}"); 
    345  
    346     return sb.toString(); 
    347   } 
    348  
    349   /* 
    350   public Object clone() { 
    351     return new AttendeePK(getEntityId(), 
    352                           getEntityType()); 
    353   }*/ 
    354312} 
    355313 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessUtil.java

    r313 r314  
    5858import org.bedework.davdefs.WebdavTags; 
    5959 
    60 import edu.rpi.cct.uwcal.access.Access; 
    6160import edu.rpi.cct.uwcal.access.Ace; 
    6261import edu.rpi.cct.uwcal.access.Acl; 
    6362import edu.rpi.cct.uwcal.access.Privilege; 
     63import edu.rpi.cct.uwcal.access.Privileges; 
    6464import edu.rpi.sss.util.xml.QName; 
    6565import edu.rpi.sss.util.xml.XmlEmit; 
    6666 
    6767import java.io.Serializable; 
     68import java.io.StringWriter; 
    6869import java.util.Collection; 
    6970import java.util.Iterator; 
     
    100101    this.xml = xml; 
    101102  } 
     103   
     104  public static String getXmlString(Acl acl) throws CalFacadeException { 
     105    try { 
     106      XmlEmit xml = new XmlEmit(true);  // no headers 
     107      StringWriter su = new StringWriter(); 
     108      xml.startEmit(su); 
     109      AccessUtil au = new AccessUtil(xml); 
     110       
     111      au.emitAcl(acl); 
     112       
     113      su.close(); 
     114       
     115      return su.toString(); 
     116    } catch (CalFacadeException cfe) { 
     117      throw cfe; 
     118    } catch (Throwable t) { 
     119      throw new CalFacadeException(t); 
     120    } 
     121  } 
    102122 
    103123  /** (Re)set the xml writer 
     
    170190      xml.openTag(WebdavTags.supportedPrivilegeSet); 
    171191       
    172       emitSupportedPriv(Access.getPrivs().getPrivAll()); 
     192      emitSupportedPriv(Privileges.getPrivAll()); 
    173193       
    174194      xml.closeTag(WebdavTags.supportedPrivilegeSet); 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java

    r278 r314  
    5959import org.bedework.calfacade.ifs.CalTimezones; 
    6060import org.bedework.calfacade.svc.EventInfo; 
     61import org.bedework.calsvci.CalSvcI; 
    6162 
    6263import java.io.Serializable; 
     
    6566 
    6667import org.apache.log4j.Logger; 
     68 
     69import edu.rpi.cct.uwcal.access.Acl; 
    6770 
    6871/** Object to provide formatting services for a BwEvent. 
     
    7881 
    7982  private CalTimezones ctz; 
     83   
     84  private CalSvcI svci; 
    8085 
    8186  /** The view currently in place. 
     
    8388  //private TimeView view; 
    8489 
    85   /** Set so that questions can be asked about the time */ 
     90  /* Set so that questions can be asked about the time */ 
    8691  private MyCalendarVO today; 
    8792 
    88   /** Set dynamically on request to represent start date/time */ 
     93  /* Set dynamically on request to represent start date/time */ 
    8994  private DateTimeFormatter start; 
    9095 
    91   /** Set dynamically on request to represent end date/time */ 
     96  /* Set dynamically on request to represent end date/time */ 
    9297  private DateTimeFormatter end; 
    9398 
     99  private String xmlAccess; 
     100   
    94101  /** Constructor 
    95102   * 
     
    99106   * @param ctz 
    100107   */ 
    101   public EventFormatter(EventInfo eventInfo, TimeView view, 
     108  public EventFormatter(CalSvcI svci, EventInfo eventInfo, TimeView view, 
    102109                        CalendarInfo calInfo, CalTimezones ctz) { 
    103110    this.eventInfo = eventInfo; 
    104111    this.calInfo = calInfo; 
    105112    this.ctz= ctz; 
     113    this.svci = svci; 
    106114  } 
    107115 
     
    198206    return end; 
    199207  } 
     208   
     209  public String getXmlAccess() { 
     210    try { 
     211      if (xmlAccess == null) { 
     212        Acl acl = svci.getAcl(getEvent()); 
     213        xmlAccess = AccessUtil.getXmlString(acl); 
     214      } 
     215    } catch (Throwable t) { 
     216      error(t); 
     217    } 
     218 
     219    return xmlAccess; 
     220  } 
    200221 
    201222  /* =================================================================== 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/FormattedEvents.java

    r297 r314  
    5757import org.bedework.calfacade.ifs.CalTimezones; 
    5858import org.bedework.calfacade.svc.EventInfo; 
     59import org.bedework.calsvci.CalSvcI; 
    5960 
    6061import java.util.AbstractCollection; 
     
    7172  private CalendarInfo calInfo; 
    7273  private CalTimezones ctz; 
     74  private CalSvcI svci; 
    7375 
    7476  /** Constructor 
     
    7880   * @param ctz 
    7981   */ 
    80   public FormattedEvents(Collection events, 
     82  public FormattedEvents(CalSvcI svci, Collection events, 
    8183                         CalendarInfo calInfo, CalTimezones ctz) { 
    8284    if (events == null) { 
     
    8789    this.calInfo = calInfo; 
    8890    this.ctz = ctz; 
     91    this.svci = svci; 
    8992  } 
    9093 
     
    111114      EventInfo ev = (EventInfo)it.next(); 
    112115 
    113       return new EventFormatter(ev, null, calInfo, ctz); 
     116      return new EventFormatter(svci, ev, null, calInfo, ctz); 
    114117    } 
    115118 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java

    r297 r314  
    162162    return cal.getTimezones(); 
    163163  } 
     164   
     165  /** 
     166   * @return CalSvcI 
     167   */ 
     168  public CalSvcI getSvcI() { 
     169    return cal; 
     170  } 
    164171 
    165172  /** Override this for a single day view 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeViewDailyInfo.java

    r297 r314  
    565565 
    566566        while (it.hasNext()) { 
    567           eventFormatters.add(new EventFormatter((EventInfo)it.next(), view, 
    568                               calInfo, view.getTimezones())); 
     567          eventFormatters.add(new EventFormatter(view.getSvcI(),  
     568                                                 (EventInfo)it.next(), view, 
     569                                                 calInfo, view.getTimezones())); 
    569570        } 
    570571      } 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/AccessUtil.java

    r310 r314  
    169169  public void changeAccess(BwShareableDbentity ent,  
    170170                           Collection aces) throws CalFacadeException { 
    171     Collection oldAces = getAces(ent); 
    172  
    173     try { 
    174       Acl acl = new Acl(debug); 
    175       acl.setAces(oldAces); 
     171    try { 
     172      Acl acl = getAces(ent, privWriteAcl); 
    176173 
    177174      Iterator it = aces.iterator(); 
     
    189186  } 
    190187 
    191   /** Return the aces representing the allowed access for the given object. This 
     188  /** Return the acl representing the allowed access for the given object. This 
    192189   * may be derived from an object higher up the tree. 
    193190   * 
    194    * @param o 
    195    * @return Collection 
     191   * @param ent 
     192   * @return Acl 
    196193   * @throws CalFacadeException 
    197194   */ 
    198   public Collection getAces(BwShareableDbentity ent) throws CalFacadeException { 
    199     return getAces(ent, privWriteAcl); 
     195  public Acl getAcl(BwShareableDbentity ent) throws CalFacadeException { 
     196    try { 
     197      return getAces(ent, privReadAcl); 
     198    } catch (CalFacadeAccessException cae) { 
     199      Acl acl = new Acl(); 
     200      acl.defaultAccess(); 
     201       
     202      return acl; 
     203    } catch (Throwable t) { 
     204      throw new CalFacadeException(t); 
     205    } 
    200206  } 
    201207 
     
    264270   * @throws CalFacadeException 
    265271   */ 
    266   Collection getAces(BwShareableDbentity ent, int desiredAccess) 
     272  Acl getAces(BwShareableDbentity ent, int desiredAccess) 
    267273          throws CalFacadeException { 
    268274    if (ent == null) { 
     
    288294      acl.decode(aclChars); 
    289295 
    290       return acl.getAces()
     296      return acl
    291297    } catch (Throwable t) { 
    292298      throw new CalFacadeException(t); 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r310 r314  
    5454package org.bedework.calcore.hibernate; 
    5555 
     56import edu.rpi.cct.uwcal.access.Acl; 
    5657import edu.rpi.cct.uwcal.access.PrivilegeDefs; 
    5758 
     
    692693  } 
    693694 
    694   public Collection getAces(BwShareableDbentity ent) throws CalFacadeException { 
    695     checkOpen(); 
    696     return access.getAces(ent); 
     695  public Acl getAcl(BwShareableDbentity ent) throws CalFacadeException { 
     696    checkOpen(); 
     697    return access.getAcl(ent); 
    697698  } 
    698699 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java

    r310 r314  
    8585import org.apache.log4j.Logger; 
    8686 
     87import edu.rpi.cct.uwcal.access.Acl; 
     88 
    8789/** Base Implementation of CalIntf which throws exceptions for most methods. 
    8890* 
     
    375377  } 
    376378 
    377   public Collection getAces(BwShareableDbentity ent) throws CalFacadeException { 
     379  public Acl getAcl(BwShareableDbentity ent) throws CalFacadeException { 
    378380    checkOpen(); 
    379381    throw new CalFacadeUnimplementedException(); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java

    r310 r314  
    6868import org.bedework.calfacade.filter.BwFilter; 
    6969import org.bedework.calfacade.ifs.Groups; 
     70 
     71import edu.rpi.cct.uwcal.access.Acl; 
    7072 
    7173import java.util.Collection; 
     
    363365                           Collection aces) throws CalFacadeException; 
    364366 
    365   /** Return the ace representing the allowed access for the given object. This 
     367  /** Return the acl representing the allowed access for the given object. This 
    366368   * may be derived from an object higher up the tree. 
    367369   * 
    368370   * @param ent 
    369    * @return Collection 
    370    * @throws CalFacadeException 
    371    */ 
    372   public Collection getAces(BwShareableDbentity ent) throws CalFacadeException; 
     371   * @return Acl 
     372   * @throws CalFacadeException 
     373   */ 
     374  public Acl getAcl(BwShareableDbentity ent) throws CalFacadeException; 
    373375 
    374376  /* ==================================================================== 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java

    r310 r314  
    7272import edu.rpi.cct.uwcal.access.Ace; 
    7373import edu.rpi.cct.uwcal.access.Acl; 
     74import edu.rpi.cct.uwcal.access.Privileges; 
    7475 
    7576import edu.rpi.cct.uwcal.caldav.filter.Filter; 
     
    149150  private HashMap uriMap = new HashMap(); 
    150151 
    151   /**  Used for creating ace objects */ 
    152   private static Acl acl = new Acl(); 
    153  
    154152  /** An object representing the current users access 
    155153   */ 
     
    792790    } 
    793791 
    794     info.aces.add(new Ace(info.who, info.notWho, info.whoType, acl.makePriv(priv))); 
     792    info.aces.add(new Ace(info.who, info.notWho, info.whoType,  
     793                          Privileges.makePriv(priv))); 
    795794  } 
    796795 
     
    824823    CaldavBwNode uwnode = getBwnode(node); 
    825824    CaldavURI cdUri = uwnode.getCDURI(); 
    826     Collection aces = null; 
     825    Acl acl = null; 
    827826 
    828827    try { 
    829828      if (cdUri.isCalendar()) { 
    830         aces = getSvci().getAces(cdUri.getCal()); 
     829        acl = getSvci().getAcl(cdUri.getCal()); 
    831830      } else { 
    832         aces = getSvci().getAces(((CaldavComponentNode)node).getEvent()); 
    833       } 
    834  
    835       emitAccess.emitAces(aces); 
     831        acl = getSvci().getAcl(((CaldavComponentNode)node).getEvent()); 
     832      } 
     833 
     834      emitAccess.emitAcl(acl); 
    836835    } catch (Throwable t) { 
    837836      throw new WebdavIntfException(t); 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r310 r314  
    9797//import org.bedework.mail.MailerIntf; 
    9898 
     99import edu.rpi.cct.uwcal.access.Acl; 
    99100import edu.rpi.cct.uwcal.resources.Resources; 
    100101 
     
    568569  } 
    569570 
    570   public Collection getAces(BwShareableDbentity ent) throws CalFacadeException { 
    571     return getCal().getAces(ent); 
     571  public Acl getAcl(BwShareableDbentity ent) throws CalFacadeException { 
     572    return getCal().getAcl(ent); 
    572573  } 
    573574 
  • trunk/calendar3/calsvci/build.xml

    r2 r314  
    3434      <pathelement location="${org.bedework.ical.jar}"/> 
    3535      <pathelement location="${org.bedework.locale.jar}"/> 
     36      <pathelement location="${org.bedework.access.jar}"/> 
    3637    </path> 
    3738 
  • trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java

    r310 r314  
    8282import org.bedework.icalendar.IcalCallback; 
    8383 
     84import edu.rpi.cct.uwcal.access.Acl; 
    8485import edu.rpi.cct.uwcal.resources.Resources; 
    8586 
     
    414415  * 
    415416  * @param ent 
    416   * @return Collection 
     417  * @return Acl 
    417418  * @throws CalFacadeException 
    418419  */ 
    419  public abstract Collection getAces(BwShareableDbentity ent) throws CalFacadeException; 
     420 public abstract Acl getAcl(BwShareableDbentity ent) throws CalFacadeException; 
    420421 
    421422  /* ==================================================================== 
  • trunk/calendar3/common/src/edu/rpi/sss/util/xml/XmlEmit.java

    r310 r314  
    6969  private Writer wtr; 
    7070  private boolean mustEmitNS; 
     71   
     72  private boolean noHeaders = false; 
    7173 
    7274  /** We need to map the namespaces onto a set of reasonable abbreviations 
     
    8890   */ 
    8991  public XmlEmit() { 
     92    this(false); 
     93  } 
     94 
     95  /** construct an object which will be used to collect namespace names 
     96   * during the first phase and emit xml afetr startEmit is called. 
     97   *  
     98   * @param noHeaders    boolean true to suppress headers 
     99   */ 
     100  public XmlEmit(boolean noHeaders) { 
    90101    nsMap = new HashMap(); 
    91102    nsIndex = 0; 
     103    this.noHeaders = noHeaders; 
    92104  } 
    93105 
     
    108120  public void startEmit(Writer wtr) throws IOException { 
    109121    this.wtr = wtr; 
    110     mustEmitNS = true; 
    111  
    112     writeHeader(); 
     122     
     123    if (!noHeaders) { 
     124      mustEmitNS = true; 
     125       
     126      writeHeader(); 
     127    } 
    113128    newline(); 
    114129  } 
     
    302317    wtr.write(tag.getLocalPart()); 
    303318 
    304     if (mustEmitNS) { 
     319    if (!noHeaders && mustEmitNS) { 
    305320      Iterator nss = nsMap.keySet().iterator(); 
    306321 
  • trunk/calendar3/test/src/org/bedework/tests/access/AccessTest.java

    r2 r314  
    9393      auserInGroup.addGroup(bgroup); 
    9494 
    95       Privilege read = acl.makePriv(Privileges.privRead); 
    96       Privilege write = acl.makePriv(Privileges.privWrite); 
     95      Privilege read = Privileges.makePriv(Privileges.privRead); 
     96      Privilege write = Privileges.makePriv(Privileges.privWrite); 
    9797 
    9898      Privilege[] privSetRead = {read}; 
     
    113113      acl.clear(); 
    114114      acl.addAce(new Ace(null, false, Ace.whoTypeOther, 
    115                          acl.makePriv(Privileges.privRead))); 
     115                         Privileges.makePriv(Privileges.privRead))); 
    116116      encoded = logEncoded(acl, "read others"); 
    117117      tryDecode(encoded, "read others"); 
     
    128128      acl.clear(); 
    129129      Ace ace = new Ace("agroup", false, Ace.whoTypeGroup, 
    130                         acl.makePriv(Privileges.privRead)); 
     130                        Privileges.makePriv(Privileges.privRead)); 
    131131      acl.addAce(ace); 
    132132 
    133133      ace = new Ace("auser", false, Ace.whoTypeUser); 
    134       ace.addPriv(acl.makePriv(Privileges.privRead)); 
    135       ace.addPriv(acl.makePriv(Privileges.privWrite)); 
     134      ace.addPriv(Privileges.makePriv(Privileges.privRead)); 
     135      ace.addPriv(Privileges.makePriv(Privileges.privWrite)); 
    136136      acl.addAce(ace); 
    137137      encoded = logEncoded(acl, "read g=agroup,rw auser"); 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEGetFormattedEventsAction.java

    r189 r314  
    9595    form.assignAddingEvent(false); 
    9696 
    97     form.setFormattedEvents(new FormattedEvents(getEvents(request, false, form), 
     97    form.setFormattedEvents(new FormattedEvents(form.fetchSvci(),  
     98                                                getEvents(request, false, form), 
    9899                                                form.getCalInfo(), 
    99100                                                form.fetchSvci().getTimezones())); 
  • trunk/calendar3/webclient/src/org/bedework/webclient/BwAccessAction.java

    r55 r314  
    6262 
    6363import edu.rpi.cct.uwcal.access.Ace; 
    64 import edu.rpi.cct.uwcal.access.Acl; 
    6564import edu.rpi.cct.uwcal.access.PrivilegeDefs; 
    66  
    67 import java.util.Vector; 
     65import edu.rpi.cct.uwcal.access.Privileges; 
     66 
     67import java.util.ArrayList; 
    6868import javax.servlet.http.HttpServletRequest; 
    6969 
     
    9494 */ 
    9595public class BwAccessAction extends BwCalAbstractAction { 
    96   /**  Used for creating ace objects */ 
    97   private static Acl acl = new Acl(); 
    98  
    9996  /* (non-Javadoc) 
    10097   * @see org.bedework.webclient.BwCalAbstractAction#doAction(javax.servlet.http.HttpServletRequest, org.bedework.webclient.BwActionForm) 
     
    208205    } 
    209206 
    210     Vector v = new Vector(); 
    211     v.add(new Ace(who, false, whoType, acl.makePriv(desiredAccess))); 
     207    ArrayList aces = new ArrayList(); 
     208    aces.add(new Ace(who, false, whoType, Privileges.makePriv(desiredAccess))); 
    212209 
    213210    if (calid) { 
    214       svci.changeAccess(cal, v); 
     211      svci.changeAccess(cal, aces); 
    215212      svci.updateCalendar(cal); 
    216213    } else { 
    217       svci.changeAccess(ev, v); 
     214      svci.changeAccess(ev, aces); 
    218215      svci.updateEvent(ev); 
    219216    } 
  • trunk/calendar3/webclient/src/org/bedework/webclient/BwEventAction.java

    r55 r314  
    8686    // Not export - just set up for display 
    8787 
    88     EventFormatter ef = new EventFormatter(ev, 
     88    EventFormatter ef = new EventFormatter(form.fetchSvci(), ev, 
    8989                                           form.getCurTimeView(), 
    9090                                           form.getCalInfo(), 
  • trunk/calendar3/webclient/war/docs/event/emitEventAll.jsp

    r312 r314  
    11<%@ taglib uri='struts-bean' prefix='bean' %> 
    22<%@ taglib uri='struts-logic' prefix='logic' %> 
     3<%@ taglib uri='bedework' prefix='bw' %> 
     4 
    35    <%-- Output any additional event fields for full format displays --%> 
    46    <logic:present  name="event" property="organizer"> 
     
    3335      </organizer> 
    3436    </logic:iterate> 
     37    <bw:emitText name="eventFormatter" property="xmlAccess" tagName="access" 
     38                 filter="no"/> 
    3539