use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class MilterHandler method SMFIC_BodyEOB.
private void SMFIC_BodyEOB() throws IOException {
ZimbraLog.milter.debug("SMFIC_BodyEOB");
Set<String> listAddrs = Sets.newHashSetWithExpectedSize(lists.size());
Set<String> replyToAddrs = Sets.newHashSetWithExpectedSize(lists.size());
for (Group group : lists) {
if (group == null) {
ZimbraLog.milter.warn("null group in group list!?!");
continue;
}
if (visibleAddresses.contains(group.getMail().toLowerCase())) {
listAddrs.add(group.getMail());
if (group.isPrefReplyToEnabled()) {
String addr = group.getPrefReplyToAddress();
if (Strings.isNullOrEmpty(addr)) {
// fallback to the default email address
addr = group.getMail();
}
String disp = group.getPrefReplyToDisplay();
if (Strings.isNullOrEmpty(disp)) {
// fallback to the default display name
disp = group.getDisplayName();
}
replyToAddrs.add(new InternetAddress(disp, addr).toString());
}
}
}
if (!listAddrs.isEmpty()) {
SMFIR_ChgHeader(1, "X-Zimbra-DL", Joiner.on(", ").join(listAddrs));
}
if (!replyToAddrs.isEmpty()) {
SMFIR_ChgHeader(1, "Reply-To", Joiner.on(", ").join(replyToAddrs));
}
connection.send(new MilterPacket(SMFIR_ACCEPT));
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class MilterHandler method SMFIC_Rcpt.
private void SMFIC_Rcpt() throws ServiceException {
ZimbraLog.milter.debug("SMFIC_Rcpt");
String sender = context.get(Context.SENDER);
if (sender == null) {
ZimbraLog.milter.warn("Empty sender");
}
String rcpt = context.get(Context.RECIPIENT);
if (rcpt == null) {
ZimbraLog.milter.warn("Empty recipient");
}
if (sender == null || rcpt == null) {
connection.send(new MilterPacket(SMFIR_TEMPFAIL));
return;
}
if (prov.isDistributionList(rcpt)) {
Group group = prov.getGroupBasic(Key.DistributionListBy.name, rcpt);
if (group != null) {
if (!accessMgr.canDo(sender, group, User.R_sendToDistList, false)) {
ZimbraLog.milter.debug("Sender is not allowed to email this distribution list: %s", rcpt);
SMFIR_ReplyCode("571", "571 Sender is not allowed to email this distribution list: " + rcpt);
return;
}
lists.add(group);
ZimbraLog.milter.debug("group %s has been added into the list.", group);
} else {
ZimbraLog.milter.debug("rcpt %s is a list but not a group?", rcpt);
}
} else {
ZimbraLog.milter.debug("%s is not a distribution list.", rcpt);
}
connection.send(new MilterPacket(SMFIR_CONTINUE));
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class GetAllDistributionLists method doDomain.
private void doDomain(ZimbraSoapContext zsc, Element e, Domain d, AdminAccessControl aac) throws ServiceException {
List dls = Provisioning.getInstance().getAllGroups(d);
for (Iterator it = dls.iterator(); it.hasNext(); ) {
Group dl = (Group) it.next();
boolean hasRightToList = true;
if (dl.isDynamic()) {
// TODO: fix me
hasRightToList = true;
} else {
hasRightToList = aac.hasRightsToList(dl, Admin.R_listDistributionList, null);
}
if (hasRightToList) {
GetDistributionList.encodeDistributionList(e, dl, true, false, null, aac.getAttrRightChecker(dl));
}
}
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class SmtpRecipientValidator method validate.
@Override
public Iterable<String> validate(String recipient) {
try {
Provisioning prov = Provisioning.getInstance();
Account account = prov.get(AccountBy.name, recipient);
if (account != null) {
return Arrays.asList(account.getName());
} else {
Group group = prov.getGroup(Key.DistributionListBy.name, recipient);
if (group != null) {
String[] members;
if (group instanceof DynamicGroup) {
members = ((DynamicGroup) group).getAllMembers(true);
} else {
members = group.getAllMembers();
}
return Arrays.asList(members);
}
}
} catch (ServiceException e) {
log.error("Unable to validate recipient %s", recipient, e);
}
return Collections.emptyList();
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestACLEffectiveRights method bug70206.
@Bug(bug = 70206)
@Test
public void bug70206() throws Exception {
Account acct = provUtil.createDelegatedAdmin(genAcctNameLocalPart(), domain);
Group group = provUtil.createGroup(genGroupNameLocalPart(), domain, false);
Account grantingAccount = globalAdmin;
String presetRightUnderTest = Right.RT_deleteDistributionList;
String attrUnderTest = Provisioning.A_zimbraHideInGal;
String attrRightUnderTest = InlineAttrRight.composeSetRight(TargetType.dl, attrUnderTest);
// grant a combo right on global level
RightCommand.grantRight(prov, grantingAccount, TargetType.global.getCode(), null, null, GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, Right.RT_adminConsoleDLRights, null);
// deny a preset right (in the combo right) on global level
RightCommand.grantRight(prov, grantingAccount, TargetType.global.getCode(), null, null, GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, presetRightUnderTest, RightModifier.RM_DENY);
// grant the preset right on the target
RightCommand.grantRight(prov, grantingAccount, TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, attrRightUnderTest, null);
// deny an attr right (in the combo right) on global level
RightCommand.grantRight(prov, grantingAccount, TargetType.global.getCode(), null, null, GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, attrRightUnderTest, RightModifier.RM_DENY);
// grant the attr right on the target
RightCommand.grantRight(prov, grantingAccount, TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, presetRightUnderTest, null);
EffectiveRights effRights = RightCommand.getEffectiveRights(prov, TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeBy.name, acct.getName(), false, false);
List<String> presetRights = effRights.presetRights();
SortedMap<String, EffectiveAttr> setAttrRights = effRights.canSetAttrs();
/*
for (String right : presetRights) {
System.out.println(right);
}
*/
assertTrue(presetRights.contains(Right.RT_deleteDistributionList));
assertTrue(setAttrRights.containsKey(attrUnderTest));
}
Aggregations