use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class SoapProvisioning method getAllGroups.
@Override
public List<Group> getAllGroups(Domain domain) throws ServiceException {
ArrayList<Group> result = new ArrayList<Group>();
GetAllDistributionListsResponse resp = invokeJaxb(new GetAllDistributionListsRequest(getSelector(domain)));
for (DistributionListInfo dl : resp.getDls()) {
result.add(makeGroup(dl));
}
return result;
}
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();
}
Aggregations