use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class LdapProvisioning method createDelegatedGroup.
@Override
public Group createDelegatedGroup(String name, Map<String, Object> attrs, boolean dynamic, Account creator) throws ServiceException {
if (creator == null) {
throw ServiceException.INVALID_REQUEST("must have a creator account", null);
}
Group group = dynamic ? createDynamicGroup(name, attrs, creator) : createDistributionList(name, attrs, creator);
grantRight(TargetType.dl.getCode(), TargetBy.id, group.getId(), GranteeType.GT_USER.getCode(), GranteeBy.id, creator.getId(), null, Group.GroupOwner.GROUP_OWNER_RIGHT.getName(), null);
return group;
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class AddDistributionListAlias method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
AddDistributionListAliasRequest req = JaxbUtil.elementToJaxb(request);
String alias = req.getAlias();
Group group = getGroupFromContext(context);
String id = req.getId();
defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_addGroupAlias, Admin.R_addDistributionListAlias);
// if the admin can create an alias in the domain
checkDomainRightByEmail(zsc, alias, Admin.R_createAlias);
prov.addGroupAlias(group, alias);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddDistributionListAlias", "name", group.getName(), "alias", alias }));
return zsc.jaxbToElement(new AddDistributionListAliasResponse());
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class AddDistributionListMember method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
OperationContext octxt = getOperationContext(zsc, context);
Provisioning prov = Provisioning.getInstance();
Group group = getGroupFromContext(context);
String id = request.getAttribute(AdminConstants.E_ID);
defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_addGroupMember, Admin.R_addDistributionListMember);
List<String> memberList = getMemberList(request, context);
if (memberList.isEmpty()) {
throw ServiceException.INVALID_REQUEST("members to add not specified", null);
}
String[] members = memberList.toArray(new String[0]);
prov.addGroupMembers(group, members);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddDistributionListMember", "name", group.getName(), "members", Arrays.deepToString(members) }));
// send share notification email
if (group.isDynamic()) {
// do nothing for now
} else {
boolean sendShareInfoMsg = group.getBooleanAttr(Provisioning.A_zimbraDistributionListSendShareMessageToNewMembers, true);
if (sendShareInfoMsg) {
ShareInfo.NotificationSender.sendShareInfoMessage(octxt, (DistributionList) group, members);
}
}
return zsc.jaxbToElement(new AddDistributionListMemberResponse());
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class ModifyDistributionList method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
ModifyDistributionListRequest req = JaxbUtil.elementToJaxb(request);
String id = req.getId();
Group group = getGroupFromContext(context);
Map<String, Object> attrs = req.getAttrsAsOldMultimap();
defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, attrs, attrs);
// pass in true to checkImmutable
prov.modifyAttrs(group, attrs, true);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyDistributionList", "name", group.getName() }, attrs));
Element response = zsc.createElement(AdminConstants.MODIFY_DISTRIBUTION_LIST_RESPONSE);
GetDistributionList.encodeDistributionList(response, group);
return response;
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method removeMembersBasic.
/*
* Test remove members
*/
@Test
public void removeMembersBasic() throws Exception {
Group group = createDynamicGroup(genGroupNameLocalPart());
Account acct1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
Account acct2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
String extAddr1 = "user1@external.com";
String extAddr2 = "user2@external.com";
prov.addGroupMembers(group, new String[] { acct1.getName(), acct2.getName(), extAddr1, extAddr2 });
String[] members = prov.getGroupMembers(group);
Set<String> expected = Sets.newHashSet(acct1.getName(), acct2.getName(), extAddr1, extAddr2);
Verify.verifyEquals(expected, members);
prov.removeGroupMembers(group, new String[] { acct1.getName(), extAddr1 });
members = prov.getGroupMembers(group);
expected = Sets.newHashSet(acct2.getName(), extAddr2);
Verify.verifyEquals(expected, members);
// remove non-existing members, should not throw any exception
prov.removeGroupMembers(group, new String[] { group.getName() });
prov.removeGroupMembers(group, new String[] { "bogus" });
}
Aggregations