use of com.zimbra.cs.account.MailTarget in project zm-mailbox by Zimbra.
the class ACLAccessManager method domainAdminAllowedToChangeUserRight.
/**
* Bug 88604
* This allows delegate admins to assign user rights without having to be given the right they want to assign.
* Currently restricted to just user rights as those seem to be what a delegate admin might want to assign
*/
private boolean domainAdminAllowedToChangeUserRight(MailTarget grantee, boolean asAdmin, Entry target, Right rightNeeded) {
if (!asAdmin || !rightNeeded.isUserRight() || !(grantee instanceof Account) || !(target instanceof MailTarget)) {
return false;
}
Account authedAcct = (Account) grantee;
MailTarget mailTarget = (MailTarget) target;
if (!AccessControlUtil.isDelegatedAdmin(authedAcct, asAdmin)) {
return false;
}
try {
Domain domain = Provisioning.getInstance().getDomain(mailTarget);
if (domain == null) {
return false;
}
checkDomainStatus(domain);
Map<String, Object> attrsNeeded = Maps.newHashMap();
attrsNeeded.put(Provisioning.A_zimbraACE, rightNeeded.getName());
if (canSetAttrs(authedAcct, target, attrsNeeded, asAdmin)) {
ZimbraLog.acl.debug("Right [%s] ALLOWED to '%s' for target '%s' because '%s' is allowed to set '%s' for '%s'", rightNeeded.getName(), authedAcct.getName(), mailTarget.getName(), authedAcct.getName(), Provisioning.A_zimbraACE, mailTarget.getName());
return true;
}
} catch (ServiceException e) {
return false;
}
return false;
}
use of com.zimbra.cs.account.MailTarget in project zm-mailbox by Zimbra.
the class TestCalDav method testCreateModifyDeleteAttendeeModifyAndCancel.
/** Mostly checking that if attendees cease to exist (even via DLs) then modification and cancel iTip
* messages still work to the remaining attendees.
*/
@Test
public void testCreateModifyDeleteAttendeeModifyAndCancel() throws ServiceException, IOException {
Account dav1 = users[1].create();
Account dav2 = users[2].create();
Account dav3 = users[3].create();
Account dav4 = users[4].create();
DistributionList dl = TestUtil.createDistributionList(DL1);
String[] members = { dav4.getName() };
prov.addMembers(dl, members);
List<MailTarget> attendees = Lists.newArrayList();
attendees.add(dav1);
attendees.add(dav2);
attendees.add(dav3);
attendees.add(dl);
ZVCalendar vCal = simpleMeeting(dav1, attendees, "1", 8);
ZProperty uidProp = vCal.getComponent(ICalTok.VEVENT).getProperty(ICalTok.UID);
String uid = uidProp.getValue();
String davBaseName = uid + ".ics";
String url = String.format("%s%s", getFolderUrl(dav1, "Calendar"), davBaseName);
doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED);
String inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
// attendee via DL
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav4, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav4, HttpStatus.SC_NO_CONTENT);
vCal = simpleMeeting(dav1, attendees, uid, "2", 9);
doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED);
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
// attendee via DL
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav4, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav4, HttpStatus.SC_NO_CONTENT);
// Test that iTip handling still happens when some of the attendees no longer exist.
users[3].cleanup();
// attendee via DL
users[4].cleanup();
vCal = simpleMeeting(dav1, attendees, uid, "3", 10);
doIcalPut(url, dav1, zvcalendarToBytes(vCal), HttpStatus.SC_CREATED);
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
String dav2Url = String.format("%s%s", getFolderUrl(dav2, "Calendar"), davBaseName);
doGetMethod(dav2Url, dav2, HttpStatus.SC_OK);
// Cancel meeting by deleting it
doDeleteMethod(url, dav1, HttpStatus.SC_NO_CONTENT);
inboxhref = TestCalDav.waitForNewSchedulingRequestByUID(dav2, uid);
assertTrue("Found meeting request for newly created item", inboxhref.contains(uid));
doDeleteMethod(getLocalServerRoot().append(inboxhref).toString(), dav2, HttpStatus.SC_NO_CONTENT);
// The associated calendar item should have been deleted as a result of the Cancel
doGetMethod(dav2Url, dav2, HttpStatus.SC_NOT_FOUND);
}
use of com.zimbra.cs.account.MailTarget in project zm-mailbox by Zimbra.
the class TestDistListACL method doCheckSentToDistListEmailRight.
private void doCheckSentToDistListEmailRight(DistributionList targetDl, String email, String grantEmail, boolean expected) throws ServiceException {
ZimbraLog.test.info("DL name %s ID %s", targetDl.getName(), targetDl.getId());
Group group = prov.getGroupBasic(Key.DistributionListBy.name, listAddress);
Assert.assertNotNull("Unable to find Group object for DL by name", group);
AccessManager.ViaGrant via = new AccessManager.ViaGrant();
NamedEntry ne = GranteeType.lookupGrantee(prov, GranteeType.GT_EMAIL, GranteeBy.name, email);
MailTarget grantee = null;
if (ne instanceof MailTarget) {
grantee = (MailTarget) ne;
}
boolean result = RightCommand.checkRight(prov, "dl", /* targetType */
TargetBy.name, listAddress, grantee, RightConsts.RT_sendToDistList, null, /* attrs */
via);
if (expected) {
Assert.assertTrue(String.format("%s should be able to send to DL (using email %s)", email, grantEmail), accessMgr.canDo(email, group, User.R_sendToDistList, false));
Assert.assertTrue(String.format("%s should have right to send to DL (using email %s)", email, grantEmail), result);
ZimbraLog.test.info("Test for %s against dom %s Via=%s", email, grantEmail, via);
} else {
Assert.assertFalse(String.format("%s should NOT be able to send to DL (because not email %s)", email, grantEmail), accessMgr.canDo(email, group, User.R_sendToDistList, false));
Assert.assertFalse(String.format("%s should NOT have right to send to DL (because not email %s)", email, grantEmail), result);
}
}
use of com.zimbra.cs.account.MailTarget in project zm-mailbox by Zimbra.
the class TestDistListACL method doCheckSentToDistListGuestRight.
private void doCheckSentToDistListGuestRight(DistributionList targetDl, String email, String guest, boolean expected) throws ServiceException {
ZimbraLog.test.info("DL name %s ID %s", targetDl.getName(), targetDl.getId());
Group group = prov.getGroupBasic(Key.DistributionListBy.name, listAddress);
Assert.assertNotNull("Unable to find Group object for DL by name", group);
AccessManager.ViaGrant via = new AccessManager.ViaGrant();
NamedEntry ne = GranteeType.lookupGrantee(prov, GranteeType.GT_GUEST, GranteeBy.name, email);
MailTarget grantee = null;
if (ne instanceof MailTarget) {
grantee = (MailTarget) ne;
}
boolean result = RightCommand.checkRight(prov, "dl", /* targetType */
TargetBy.name, listAddress, grantee, RightConsts.RT_sendToDistList, null, /* attrs */
via);
if (expected) {
Assert.assertTrue(String.format("%s should be able to send to DL (as guest %s)", email, guest), accessMgr.canDo(email, group, User.R_sendToDistList, false));
Assert.assertTrue(String.format("%s should have right to send to DL (as guest %s)", email, guest), result);
ZimbraLog.test.info("Test for %s against dom %s Via=%s", email, guest, via);
} else {
Assert.assertFalse(String.format("%s should NOT be able to send to DL (because not guest %s)", email, guest), accessMgr.canDo(email, group, User.R_sendToDistList, false));
Assert.assertFalse(String.format("%s should NOT have right to send to DL (because not guest %s)", email, guest), result);
}
}
use of com.zimbra.cs.account.MailTarget in project zm-mailbox by Zimbra.
the class TestDistListACL method doCheckSentToDistListUserRight.
private void doCheckSentToDistListUserRight(DistributionList targetDl, String email, String user, boolean expected) throws ServiceException {
ZimbraLog.test.info("DL name %s ID %s", targetDl.getName(), targetDl.getId());
Group group = prov.getGroupBasic(Key.DistributionListBy.name, listAddress);
Assert.assertNotNull("Unable to find Group object for DL by name", group);
AccessManager.ViaGrant via = new AccessManager.ViaGrant();
// More permissive that GT_USER - want to test called functions
NamedEntry ne = GranteeType.lookupGrantee(prov, GranteeType.GT_EMAIL, GranteeBy.name, email);
MailTarget grantee = null;
if (ne instanceof MailTarget) {
grantee = (MailTarget) ne;
}
boolean result = RightCommand.checkRight(prov, "dl", /* targetType */
TargetBy.name, listAddress, grantee, RightConsts.RT_sendToDistList, null, /* attrs */
via);
if (expected) {
Assert.assertTrue(String.format("%s should be able to send to DL (as user %s)", email, user), accessMgr.canDo(email, group, User.R_sendToDistList, false));
Assert.assertTrue(String.format("%s should have right to send to DL (as user %s)", email, user), result);
ZimbraLog.test.info("Test for %s against dom %s Via=%s", email, user, via);
} else {
Assert.assertFalse(String.format("%s should NOT be able to send to DL (because not user %s)", email, user), accessMgr.canDo(email, group, User.R_sendToDistList, false));
Assert.assertFalse(String.format("%s should NOT have right to send to DL (because not user %s)", email, user), result);
}
}
Aggregations