use of com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest 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());
}
use of com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest 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");
}
}
use of com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest 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");
}
}
use of com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest in project zm-mailbox by Zimbra.
the class TestDelegatedDL method noHomeServerZimbraAdmin.
/*
* Verify groups without a home server will get executed for zimbraAdmin
* SOAP calls.
*/
@Test
@Bug(bug = 66412)
public void noHomeServerZimbraAdmin() throws Exception {
String groupName = TestUtil.getAddress(genGroupNameLocalPart(), DOMAIN_NAME);
Group group = provUtil.createGroup(groupName, DYNAMIC);
String groupId = group.getId();
// remove zimbraMailHost
Map<String, Object> attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraMailHost, null);
prov.modifyAttrs(group, attrs);
SoapTransport transport = authAdmin(ADMIN);
Object req;
com.zimbra.soap.admin.type.DistributionListInfo dlInfo;
/*
* GetDistributionList
*/
req = new com.zimbra.soap.admin.message.GetDistributionListRequest(com.zimbra.soap.admin.type.DistributionListSelector.fromName(groupName));
com.zimbra.soap.admin.message.GetDistributionListResponse getDLResp = invokeJaxb(transport, req);
dlInfo = getDLResp.getDl();
assertEquals(groupId, dlInfo.getId());
/*
* ModifyDistributionList
*/
req = new ModifyDistributionListRequest(groupId);
ModifyDistributionListResponse modifyDLResp = invokeJaxb(transport, req);
dlInfo = modifyDLResp.getDl();
assertEquals(groupId, dlInfo.getId());
/*
* AddDistributionAlias
*/
req = new AddDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
AddDistributionListAliasResponse addDLAliasResp = invokeJaxb(transport, req);
/*
* RemoveDistributionAlias
*/
req = new RemoveDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
RemoveDistributionListAliasResponse removeDLAliasResp = invokeJaxb(transport, req);
/*
* AddDistributionListMember
*/
req = new AddDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
AddDistributionListMemberResponse addDLMemberResp = invokeJaxb(transport, req);
/*
* RemoveDistributionListMember
*/
req = new RemoveDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
RemoveDistributionListMemberResponse removeDLMemberResp = invokeJaxb(transport, req);
/*
* DeleteDistributionList
*/
req = new DeleteDistributionListRequest(groupId);
DeleteDistributionListResponse deleteDLResp = invokeJaxb(transport, req);
}
Aggregations