use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvAttrCallback method zimbraIsACLGroupAndMemberURLModify.
@Test
public void zimbraIsACLGroupAndMemberURLModify() throws Exception {
String SOME_URL = "blah";
String SOME_URL_2 = "blah blah";
Map<String, Object> attrs = Maps.newHashMap();
boolean caughtException;
DynamicGroup group;
group = createDynamicGroup(genGroupNameLocalPart("3"));
attrs.clear();
attrs.put(Provisioning.A_memberURL, SOME_URL);
caughtException = false;
try {
prov.modifyAttrs(group, attrs, true);
} catch (ServiceException e) {
if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
caughtException = true;
} else {
throw e;
}
}
assertTrue(caughtException);
deleteDynamicGroup(group);
group = createDynamicGroup(genGroupNameLocalPart("4"));
attrs.clear();
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.TRUE);
attrs.put(Provisioning.A_memberURL, SOME_URL);
caughtException = false;
try {
prov.modifyAttrs(group, attrs);
} catch (ServiceException e) {
if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
caughtException = true;
} else {
throw e;
}
}
assertTrue(caughtException);
deleteDynamicGroup(group);
attrs.clear();
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.FALSE);
attrs.put(Provisioning.A_memberURL, SOME_URL);
group = createDynamicGroup(genGroupNameLocalPart("8"), attrs);
attrs.clear();
attrs.put(Provisioning.A_memberURL, SOME_URL_2);
prov.modifyAttrs(group, attrs, true);
verifyIsNotACLGroup(group, SOME_URL_2);
deleteDynamicGroup(group);
attrs.clear();
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.FALSE);
attrs.put(Provisioning.A_memberURL, SOME_URL);
group = createDynamicGroup(genGroupNameLocalPart("9"), attrs);
attrs.clear();
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.TRUE);
attrs.put(Provisioning.A_memberURL, SOME_URL);
caughtException = false;
try {
prov.modifyAttrs(group, attrs, true);
} catch (ServiceException e) {
if (ServiceException.INVALID_REQUEST.equals(e.getCode())) {
caughtException = true;
} else {
throw e;
}
}
assertTrue(caughtException);
deleteDynamicGroup(group);
}
use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method zimbraIsACLGroup_and_memeberURL_5.
/*
* On modify: memeberURL can be modified if zimbraIsACLGroup is FALSE.
*/
@Test
public void zimbraIsACLGroup_and_memeberURL_5() throws Exception {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_memberURL, "foo");
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.FALSE);
DynamicGroup group = createDynamicGroup(genGroupNameLocalPart(seq), attrs);
assertEquals(false, group.isIsACLGroup());
attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_memberURL, "bar");
prov.modifyAttrs(group, attrs, true);
assertEquals("bar", group.getMemberURL());
}
use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method zimbraIsACLGroup_and_memeberURL_1.
/*
* ================================================
* Testing zimbraIsACLGroup and memeberURL settings
* ================================================
*/
/*
* On create: if memeberURL is specified, zimbraIsACLGroup must also be specified
* an set to FALSE.
*/
@Test
public void zimbraIsACLGroup_and_memeberURL_1() throws Exception {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_memberURL, "blah");
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.FALSE);
DynamicGroup group = createDynamicGroup(genGroupNameLocalPart(seq), attrs);
assertEquals(false, group.isIsACLGroup());
String errCode = null;
attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_memberURL, "blah");
try {
createDynamicGroup(genGroupNameLocalPart(seq), attrs);
} catch (ServiceException e) {
errCode = e.getCode();
}
assertEquals(LdapException.OBJECT_CLASS_VIOLATION, errCode);
errCode = null;
attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_memberURL, "blah");
attrs.put(Provisioning.A_zimbraIsACLGroup, ProvisioningConstants.TRUE);
try {
createDynamicGroup(genGroupNameLocalPart(seq), attrs);
} catch (ServiceException e) {
assertTrue("Unexpected Exception e thrown", false);
errCode = e.getCode();
}
}
use of com.zimbra.cs.account.DynamicGroup in project zm-mailbox by Zimbra.
the class GetAccountMembership method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
GetAccountMembershipRequest req = JaxbUtil.elementToJaxb(request);
AccountBy acctBy = req.getAccount().getBy().toKeyAccountBy();
String accountSelectorKey = req.getAccount().getKey();
Account account = prov.get(acctBy, accountSelectorKey, zsc.getAuthToken());
defendAgainstAccountHarvesting(account, acctBy, accountSelectorKey, zsc, Admin.R_getAccountMembership);
HashMap<String, String> via = new HashMap<String, String>();
List<Group> groups = prov.getGroups(account, false, via);
Element response = zsc.createElement(AdminConstants.GET_ACCOUNT_MEMBERSHIP_RESPONSE);
for (Group group : groups) {
Element eDL = response.addNonUniqueElement(AdminConstants.E_DL);
eDL.addAttribute(AdminConstants.A_NAME, group.getName());
eDL.addAttribute(AdminConstants.A_ID, group.getId());
eDL.addAttribute(AdminConstants.A_DYNAMIC, group.isDynamic());
String viaDl = via.get(group.getName());
if (viaDl != null) {
eDL.addAttribute(AdminConstants.A_VIA, viaDl);
}
try {
if (group.isDynamic()) {
checkDynamicGroupRight(zsc, (DynamicGroup) group, needGetAttrsRight());
} else {
checkDistributionListRight(zsc, (DistributionList) group, needGetAttrsRight());
}
String isAdminGroup = group.getAttr(Provisioning.A_zimbraIsAdminGroup);
if (isAdminGroup != null) {
eDL.addNonUniqueElement(AdminConstants.E_A).addAttribute(AdminConstants.A_N, Provisioning.A_zimbraIsAdminGroup).setText(isAdminGroup);
}
} catch (ServiceException e) {
if (ServiceException.PERM_DENIED.equals(e.getCode())) {
ZimbraLog.acl.warn("no permission to view %s of dl %s", Provisioning.A_zimbraIsAdminGroup, group.getName());
}
}
}
return response;
}
Aggregations