Search in sources :

Example 41 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class SendShareNotification method sendNotificationEmailToGroupGrantees.

private void sendNotificationEmailToGroupGrantees(OperationContext octxt, Mailbox mbox, Account authAccount, Account ownerAccount, Collection<ShareInfoData> sids, String notes, Action action) throws ServiceException, MessagingException {
    Provisioning prov = Provisioning.getInstance();
    for (ShareInfoData sid : sids) {
        String granteeId = sid.getGranteeId();
        Group group = prov.getGroupBasic(DistributionListBy.id, granteeId);
        if (group == null) {
            // huh?  grantee type is GROUP but the group cannot be found by id.
            // just log a warning and do not send.
            // This is not likely to happen because validateRequest had already
            // checked existance of the grantee.
            sLog.warn("Group not found for sending share notificaiton to: " + granteeId + "(" + sid.getGranteeNotifName() + ")" + ", share notification not sent");
            continue;
        }
        /*
             * send to group members
             */
        GroupMemberEmailAddrs addrs = prov.getMemberAddrs(group);
        if (addrs.groupAddr() != null) {
            // just send to the group's address, no treatment needed for recipients
            sendNotificationEmail(octxt, mbox, authAccount, ownerAccount, sid, notes, action, null, null);
        } else {
            // send one common notif email to all internal members,
            if (addrs.internalAddrs() != null) {
                sendNotificationEmail(octxt, mbox, authAccount, ownerAccount, sid, notes, action, addrs.internalAddrs(), null);
            }
            // send one personalized notif email to each external member
            Collection<String> extMembers = addrs.externalAddrs();
            if (extMembers != null) {
                if (extMembers.size() <= DebugConfig.sendGroupShareNotificationSynchronouslyThreshold) {
                    // send synchronously
                    sendNotificationEmailToGroupExternalMembers(octxt, mbox, authAccount, ownerAccount, sid, notes, action, extMembers);
                } else {
                    // send asynchronously in a separate thread to avoid holding up the request
                    sendNotificationEmailToGroupExternalMembersAsync(octxt, mbox, authAccount, ownerAccount, sid, notes, action, extMembers);
                }
            }
        }
    }
}
Also used : Group(com.zimbra.cs.account.Group) GroupMemberEmailAddrs(com.zimbra.cs.account.Provisioning.GroupMemberEmailAddrs) ShareInfoData(com.zimbra.cs.account.ShareInfoData) Provisioning(com.zimbra.cs.account.Provisioning)

Example 42 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class GetDistributionList method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    GetDistributionListRequest req = JaxbUtil.elementToJaxb(request);
    int limit = (req.getLimit() == null) ? 0 : req.getLimit();
    if (limit < 0) {
        throw ServiceException.INVALID_REQUEST("limit" + limit + " is negative", null);
    }
    int offset = (req.getOffset() == null) ? 0 : req.getOffset();
    if (offset < 0) {
        throw ServiceException.INVALID_REQUEST("offset" + offset + " is negative", null);
    }
    boolean sortAscending = !Boolean.FALSE.equals(req.isSortAscending());
    Set<String> reqAttrs = getReqAttrs(req.getAttrs(), AttributeClass.distributionList);
    DistributionListSelector dlSel = req.getDl();
    DistributionListBy dlBy = dlSel.getBy().toKeyDistributionListBy();
    AttrRightChecker arc = null;
    Group group = getGroupFromContext(context);
    if (group == null) {
        if (DistributionListBy.name.equals(dlBy)) {
            Entry pseudoTarget = pseudoTargetInSameDomainAsEmail(TargetType.dl, dlSel.getKey());
            if (null != pseudoTarget) {
                AdminAccessControl aac = checkDistributionListRight(zsc, (DistributionList) pseudoTarget, AdminRight.PR_ALWAYS_ALLOW);
                arc = aac.getAttrRightChecker(pseudoTarget);
            }
        }
        if (arc != null) {
            defendAgainstGroupHarvestingWhenAbsent(dlBy, dlSel.getKey(), zsc, new GroupHarvestingCheckerUsingGetAttrsPerms(zsc, arc, Arrays.asList(minimumAttrs)));
        } else {
            defendAgainstGroupHarvestingWhenAbsent(dlBy, dlSel.getKey(), zsc, Admin.R_getDistributionList);
        }
    } else if (group.isDynamic()) {
        AdminAccessControl aac = checkDynamicGroupRight(zsc, (DynamicGroup) group, AdminRight.PR_ALWAYS_ALLOW);
        arc = aac.getAttrRightChecker(group);
    } else {
        AdminAccessControl aac = checkDistributionListRight(zsc, (DistributionList) group, AdminRight.PR_ALWAYS_ALLOW);
        arc = aac.getAttrRightChecker(group);
    }
    defendAgainstGroupHarvesting(group, dlBy, dlSel.getKey(), zsc, new GroupHarvestingCheckerUsingGetAttrsPerms(zsc, arc, Arrays.asList(minimumAttrs)));
    Element response = zsc.createElement(AdminConstants.GET_DISTRIBUTION_LIST_RESPONSE);
    Element eDL = encodeDistributionList(response, group, true, false, reqAttrs, arc);
    // return member info only if the authed has right to see zimbraMailForwardingAddress
    boolean allowMembers = true;
    if (group.isDynamic()) {
        allowMembers = arc == null ? true : arc.allowAttr(Provisioning.A_member);
    } else {
        allowMembers = arc == null ? true : arc.allowAttr(Provisioning.A_zimbraMailForwardingAddress);
    }
    if (allowMembers) {
        encodeMembers(response, eDL, group, offset, limit, sortAscending);
    }
    return response;
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) Group(com.zimbra.cs.account.Group) DynamicGroup(com.zimbra.cs.account.DynamicGroup) DistributionListBy(com.zimbra.common.account.Key.DistributionListBy) Element(com.zimbra.common.soap.Element) DistributionListSelector(com.zimbra.soap.admin.type.DistributionListSelector) GetDistributionListRequest(com.zimbra.soap.admin.message.GetDistributionListRequest) AttrRightChecker(com.zimbra.cs.account.AccessManager.AttrRightChecker) Entry(com.zimbra.cs.account.Entry) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) DistributionList(com.zimbra.cs.account.DistributionList)

Example 43 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class RemoveDistributionListMember method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    List<String> memberList = getMemberList(request, context);
    Group group = getGroupFromContext(context);
    String id = request.getAttribute(AdminConstants.E_ID);
    defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_removeGroupMember, Admin.R_removeDistributionListMember);
    memberList = addMembersFromAccountElements(request, memberList, group);
    String[] members = memberList.toArray(new String[0]);
    prov.removeGroupMembers(group, members);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RemoveDistributionListMember", "name", group.getName(), "member", Arrays.deepToString(members) }));
    return zsc.jaxbToElement(new RemoveDistributionListMemberResponse());
}
Also used : Group(com.zimbra.cs.account.Group) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) Provisioning(com.zimbra.cs.account.Provisioning)

Example 44 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class RemoveDistributionListAlias method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    RemoveDistributionListAliasRequest req = JaxbUtil.elementToJaxb(request);
    String id = req.getId();
    String alias = req.getAlias();
    Group group = getGroupFromContext(context);
    String dlName = "";
    try {
        defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_removeGroupAlias, Admin.R_removeDistributionListAlias);
    } catch (AccountServiceException ase) {
    // still may want to remove the alias, even if it doesn't point at anything
    // note: if we got a permission denied instead of AccountServiceException,
    //       means we don't have the rights so shouldn't get any further
    }
    if (group != null) {
        dlName = group.getName();
    }
    // if the admin can remove an alias in the domain
    checkDomainRightByEmail(zsc, alias, Admin.R_deleteAlias);
    // even if dl is null, we still invoke removeAlias and throw an exception afterwards.
    // this is so dangling aliases can be cleaned up as much as possible
    prov.removeGroupAlias(group, alias);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RemoveDistributionListAlias", "name", dlName, "alias", alias }));
    if (group == null) {
        throw AccountServiceException.NO_SUCH_DISTRIBUTION_LIST(id);
    }
    return zsc.jaxbToElement(new RemoveDistributionListAliasResponse());
}
Also used : Group(com.zimbra.cs.account.Group) AccountServiceException(com.zimbra.cs.account.AccountServiceException) RemoveDistributionListAliasResponse(com.zimbra.soap.admin.message.RemoveDistributionListAliasResponse) RemoveDistributionListAliasRequest(com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Provisioning(com.zimbra.cs.account.Provisioning)

Example 45 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class RemoveDistributionListMember method getMemberList.

@Override
protected List<String> getMemberList(Element request, Map<String, Object> context) throws ServiceException {
    List<String> memberList = super.getMemberList(request, context);
    Group group = getGroupFromContext(context);
    memberList = addMembersFromAccountElements(request, memberList, group);
    return memberList;
}
Also used : Group(com.zimbra.cs.account.Group)

Aggregations

Group (com.zimbra.cs.account.Group)110 Account (com.zimbra.cs.account.Account)53 Test (org.junit.Test)42 DynamicGroup (com.zimbra.cs.account.DynamicGroup)27 ServiceException (com.zimbra.common.service.ServiceException)23 SoapTransport (com.zimbra.common.soap.SoapTransport)23 Provisioning (com.zimbra.cs.account.Provisioning)23 LdapDynamicGroup (com.zimbra.cs.account.ldap.entry.LdapDynamicGroup)21 Domain (com.zimbra.cs.account.Domain)17 GuestAccount (com.zimbra.cs.account.GuestAccount)17 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)17 Element (com.zimbra.common.soap.Element)16 AccountServiceException (com.zimbra.cs.account.AccountServiceException)15 NamedEntry (com.zimbra.cs.account.NamedEntry)14 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)12 DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)12 DistributionListAction (com.zimbra.soap.account.type.DistributionListAction)12 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)11 DistributionList (com.zimbra.cs.account.DistributionList)9 Entry (com.zimbra.cs.account.Entry)9