use of com.zimbra.cs.dav.property.Acl.Ace in project zm-mailbox by Zimbra.
the class MailItemResource method setAce.
public void setAce(DavContext ctxt, List<Ace> aceList) throws ServiceException, DavException {
ACL acl = new ACL();
for (Ace ace : aceList) {
if (ace.getRights() > 0)
acl.grantAccess(ace.getZimbraId(), ace.getGranteeType(), ace.getRights(), null);
}
Mailbox mbox = getMailbox(ctxt);
mbox.setPermissions(ctxt.getOperationContext(), getId(), acl);
}
use of com.zimbra.cs.dav.property.Acl.Ace in project zm-mailbox by Zimbra.
the class MailItemResource method getAce.
public List<Ace> getAce(DavContext ctxt) throws ServiceException, DavException {
ArrayList<Ace> aces = new ArrayList<Ace>();
Mailbox mbox = getMailbox(ctxt);
MailItem item = mbox.getItemById(ctxt.getOperationContext(), mId, MailItem.Type.UNKNOWN);
Folder f = null;
if (item.getType() == MailItem.Type.FOLDER)
f = (Folder) item;
else
f = mbox.getFolderById(ctxt.getOperationContext(), item.getParentId());
ACL effectiveAcl = f.getEffectiveACL();
if (effectiveAcl == null) {
return aces;
}
List<Grant> grants = effectiveAcl.getGrants();
if (grants == null) {
return aces;
}
for (ACL.Grant g : grants) {
if (!g.hasGrantee())
continue;
aces.add(new Ace(g.getGranteeId(), g.getGrantedRights(), g.getGranteeType()));
}
return aces;
}
use of com.zimbra.cs.dav.property.Acl.Ace in project zm-mailbox by Zimbra.
the class Acl method handle.
public void handle(DavContext ctxt) throws DavException, IOException, ServiceException {
DavResource rs = ctxt.getRequestedResource();
if (!rs.isCollection() || !(rs instanceof MailItemResource))
throw new DavException("acl not implemented for non-collection resource", HttpServletResponse.SC_NOT_IMPLEMENTED);
if (!ctxt.hasRequestMessage())
throw new DavException("empty request", HttpServletResponse.SC_BAD_REQUEST);
Document reqMsg = ctxt.getRequestMessage();
Element acl = reqMsg.getRootElement();
if (!acl.getQName().equals(DavElements.E_ACL))
throw new DavException("request does not start with acl element", HttpServletResponse.SC_BAD_REQUEST);
List<Element> aceElements = acl.elements(DavElements.E_ACE);
ArrayList<Ace> aceList = new ArrayList<Ace>();
for (Element ace : aceElements) aceList.add(new Ace(ace));
MailItemResource mir = (MailItemResource) rs;
mir.setAce(ctxt, aceList);
}
use of com.zimbra.cs.dav.property.Acl.Ace in project zm-mailbox by Zimbra.
the class AclReports method getAclPrincipals.
private ArrayList<DavResource> getAclPrincipals(DavContext ctxt) throws DavException, ServiceException {
ArrayList<DavResource> ret = new ArrayList<DavResource>();
DavResource res = ctxt.getRequestedResource();
if (!(res instanceof MailItemResource))
return ret;
List<Ace> aces = ((MailItemResource) res).getAce(ctxt);
Provisioning prov = Provisioning.getInstance();
for (Ace ace : aces) {
if (ace.hasHref()) {
Account acct = prov.get(Key.AccountBy.id, ace.getZimbraId());
if (acct != null)
ret.add(UrlNamespace.getPrincipal(ctxt, acct));
}
}
return ret;
}
Aggregations