Search in sources :

Example 1 with GetDistributionListRequest

use of com.zimbra.soap.admin.message.GetDistributionListRequest 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 2 with GetDistributionListRequest

use of com.zimbra.soap.admin.message.GetDistributionListRequest in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testGetDistributionListInDomAdminDomain.

@Test
public void testGetDistributionListInDomAdminDomain() throws Exception {
    String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    CreateDistributionListResponse caResp;
    caResp = domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest(TARGET_DL));
    assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", caResp);
    String dlId = caResp.getDl().getId();
    GetDistributionListRequest getDlReq = new GetDistributionListRequest(DistributionListSelector.fromName(TARGET_DL));
    GetDistributionListResponse getDlResp = domAdminSoapProv.invokeJaxb(getDlReq);
    assertNotNull("GetDistributionListResponse for " + TARGET_DL + " simple as domAdmin", getDlResp);
    AddDistributionListAliasResponse aaaResp;
    aaaResp = domAdminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
    assertNotNull("AddDistributionListAliasResponse for " + TARGET_DL + " simple as domAdmin", aaaResp);
    RemoveDistributionListAliasResponse daaResp;
    daaResp = domAdminSoapProv.invokeJaxb(new RemoveDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
    assertNotNull("RemoveDistributionListAliasResponse for " + TARGET_DL + " simple as domAdmin", daaResp);
    RenameDistributionListResponse renAResp;
    renAResp = domAdminSoapProv.invokeJaxb(new RenameDistributionListRequest(dlId, TARGET_DL_RENAMED));
    assertNotNull("RenameDistributionListResponse for " + TARGET_DL + " simple as domAdmin", renAResp);
    DeleteDistributionListRequest delDLReq;
    DeleteDistributionListResponse delDlResp;
    delDLReq = new DeleteDistributionListRequest(null);
    try {
        delDlResp = domAdminSoapProv.invokeJaxb(delDLReq);
        fail("DeleteDistributionListRequest succeeded in spite of having no 'id' specified!!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "invalid request: missing required attribute: id");
    }
    delDLReq = new DeleteDistributionListRequest(dlId);
    delDlResp = domAdminSoapProv.invokeJaxb(delDLReq);
    assertNotNull("DeleteDistributionListResponse for " + TARGET_DL + " as domAdmin", delDlResp);
    try {
        getDlResp = domAdminSoapProv.invokeJaxb(getDlReq);
        fail("GetDistributionListRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "no such distribution list:");
    }
    try {
        getDlResp = domAdminSoapProv.invokeJaxb(new GetDistributionListRequest(DistributionListSelector.fromId(dlId)));
        fail("GetDistributionListRequest succeeded after delete!");
    } catch (SoapFaultException sfe) {
        // because by id not name
        checkSoapReason(sfe, "permission denied: can not access distribution list");
    }
}
Also used : GetDistributionListResponse(com.zimbra.soap.admin.message.GetDistributionListResponse) RemoveDistributionListAliasRequest(com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest) AddDistributionListAliasRequest(com.zimbra.soap.admin.message.AddDistributionListAliasRequest) CreateDistributionListResponse(com.zimbra.soap.admin.message.CreateDistributionListResponse) GetDistributionListRequest(com.zimbra.soap.admin.message.GetDistributionListRequest) SoapFaultException(com.zimbra.common.soap.SoapFaultException) RemoveDistributionListAliasResponse(com.zimbra.soap.admin.message.RemoveDistributionListAliasResponse) RenameDistributionListResponse(com.zimbra.soap.admin.message.RenameDistributionListResponse) RenameDistributionListRequest(com.zimbra.soap.admin.message.RenameDistributionListRequest) CreateDistributionListRequest(com.zimbra.soap.admin.message.CreateDistributionListRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) DeleteDistributionListRequest(com.zimbra.soap.admin.message.DeleteDistributionListRequest) DeleteDistributionListResponse(com.zimbra.soap.admin.message.DeleteDistributionListResponse) AddDistributionListAliasResponse(com.zimbra.soap.admin.message.AddDistributionListAliasResponse) Test(org.junit.Test)

Example 3 with GetDistributionListRequest

use of com.zimbra.soap.admin.message.GetDistributionListRequest in project zm-mailbox by Zimbra.

the class TestDomainAdmin method testGetDistributionListInDiffDomain.

@Test
public void testGetDistributionListInDiffDomain() throws Exception {
    String domAdminId = createAdminConsoleStyleDomainAdmin(DOMADMIN);
    CreateDistributionListResponse caResp;
    caResp = adminSoapProv.invokeJaxb(new CreateDistributionListRequest(DIFF_DL));
    assertNotNull("CreateDistributionListResponse for " + DIFF_DL + " as FULL ADMIN", caResp);
    String dlId = caResp.getDl().getId();
    SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
    GetDistributionListRequest getAcctReq = new GetDistributionListRequest(DistributionListSelector.fromName(DIFF_DL));
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetDistributionListRequest succeeded for DistributionList in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access distribution list");
    }
    // try non-existent acct
    getAcctReq = new GetDistributionListRequest(DistributionListSelector.fromName(DIFF_DL2));
    try {
        domAdminSoapProv.invokeJaxb(getAcctReq);
        fail("GetDistributionListRequest succeeded for non-existent DistributionList in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access distribution list");
    }
    AddDistributionListAliasResponse aaaResp;
    try {
        aaaResp = domAdminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
        fail("AddDistributionListAliasRequest succeeded for DistributionList in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access distribution list");
    }
    aaaResp = adminSoapProv.invokeJaxb(new AddDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
    assertNotNull("AddDistributionListAliasResponse for " + TARGET_DL + " as FULL ADMIN", aaaResp);
    try {
        domAdminSoapProv.invokeJaxb(new RemoveDistributionListAliasRequest(dlId, ALIAS_FOR_TARGET_DL));
        fail("RemoveDistributionListAliasRequest succeeded for DistributionList in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access distribution list");
    }
    try {
        domAdminSoapProv.invokeJaxb(new RenameDistributionListRequest(dlId, TARGET_DL_RENAMED));
        fail("RenameDistributionListRequest succeeded for DistributionList in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access distribution list");
    }
    try {
        domAdminSoapProv.invokeJaxb(new DeleteDistributionListRequest(dlId));
        fail("DeleteDistributionListRequest succeeded for DistributionList in other domain!");
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, "permission denied: can not access distribution list");
    }
}
Also used : RenameDistributionListRequest(com.zimbra.soap.admin.message.RenameDistributionListRequest) CreateDistributionListRequest(com.zimbra.soap.admin.message.CreateDistributionListRequest) RemoveDistributionListAliasRequest(com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AddDistributionListAliasRequest(com.zimbra.soap.admin.message.AddDistributionListAliasRequest) DeleteDistributionListRequest(com.zimbra.soap.admin.message.DeleteDistributionListRequest) CreateDistributionListResponse(com.zimbra.soap.admin.message.CreateDistributionListResponse) GetDistributionListRequest(com.zimbra.soap.admin.message.GetDistributionListRequest) AddDistributionListAliasResponse(com.zimbra.soap.admin.message.AddDistributionListAliasResponse) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Aggregations

GetDistributionListRequest (com.zimbra.soap.admin.message.GetDistributionListRequest)3 SoapFaultException (com.zimbra.common.soap.SoapFaultException)2 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)2 AddDistributionListAliasRequest (com.zimbra.soap.admin.message.AddDistributionListAliasRequest)2 AddDistributionListAliasResponse (com.zimbra.soap.admin.message.AddDistributionListAliasResponse)2 CreateDistributionListRequest (com.zimbra.soap.admin.message.CreateDistributionListRequest)2 CreateDistributionListResponse (com.zimbra.soap.admin.message.CreateDistributionListResponse)2 DeleteDistributionListRequest (com.zimbra.soap.admin.message.DeleteDistributionListRequest)2 RemoveDistributionListAliasRequest (com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest)2 RenameDistributionListRequest (com.zimbra.soap.admin.message.RenameDistributionListRequest)2 Test (org.junit.Test)2 DistributionListBy (com.zimbra.common.account.Key.DistributionListBy)1 Element (com.zimbra.common.soap.Element)1 AttrRightChecker (com.zimbra.cs.account.AccessManager.AttrRightChecker)1 DistributionList (com.zimbra.cs.account.DistributionList)1 DynamicGroup (com.zimbra.cs.account.DynamicGroup)1 Entry (com.zimbra.cs.account.Entry)1 Group (com.zimbra.cs.account.Group)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 DeleteDistributionListResponse (com.zimbra.soap.admin.message.DeleteDistributionListResponse)1