use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class CreateDistributionList method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Account acct = getAuthenticatedAccount(zsc);
String name = request.getAttribute(AccountConstants.E_NAME).toLowerCase();
if (!AccessManager.getInstance().canCreateGroup(acct, name)) {
throw ServiceException.PERM_DENIED("you do not have sufficient rights to create distribution list");
}
Map<String, Object> attrs = AccountService.getKeyValuePairs(request, AccountConstants.E_A, AccountConstants.A_N);
boolean dynamic = request.getAttributeBool(AccountConstants.A_DYNAMIC, true);
// creator of the group will automatically become the first owner of the group
Account creator = getAuthenticatedAccount(zsc);
Group group = prov.createDelegatedGroup(name, attrs, dynamic, creator);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateDistributionList", "name", name }, attrs));
Element response = zsc.createElement(AccountConstants.CREATE_DISTRIBUTION_LIST_RESPONSE);
Element eDL = response.addElement(AccountConstants.E_DL);
eDL.addAttribute(AccountConstants.A_NAME, group.getName());
if (group.isDynamic()) {
eDL.addAttribute(AccountConstants.A_REF, ((LdapDynamicGroup) group).getDN());
} else {
eDL.addAttribute(AccountConstants.A_REF, ((LdapDistributionList) group).getDN());
}
eDL.addAttribute(AccountConstants.A_ID, group.getId());
GetDistributionList.encodeAttrs(group, eDL, null);
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class DistributionListAction method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Account acct = getAuthenticatedAccount(zsc);
Group group = getGroupBasic(request, prov);
DistributionListActionHandler handler = new DistributionListActionHandler(group, request, prov, acct);
handler.handle();
Element response = zsc.createElement(AccountConstants.DISTRIBUTION_LIST_ACTION_RESPONSE);
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class RevokeOAuthConsumer method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
account = getRequestedAccount(zsc);
RevokeOAuthConsumerRequest revokeRequest = zsc.elementToJaxb(request);
accessTokenToBeRemoved = revokeRequest.getAccessToken();
removeOAuthAccessor();
removeAccessTokenFromForeignPrincipal();
// Remove from cache
OAuthTokenCache.remove(accessTokenToBeRemoved, OAuthTokenCache.ACCESS_TOKEN_TYPE);
RevokeOAuthConsumerResponse response = new RevokeOAuthConsumerResponse();
return zsc.jaxbToElement(response);
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAvailableLocales method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(zsc);
if (!canAccessAccount(zsc, account)) {
throw ServiceException.PERM_DENIED("can not access account");
}
Locale displayLocale = getDisplayLocale(account, context);
// get installed locales, sorted
Locale[] installedLocales = WebClientL10nUtil.getLocales(displayLocale);
// get avail locales for this account/COS
Set<String> allowedLocales = account.getMultiAttrSet(Provisioning.A_zimbraAvailableLocale);
Locale[] availLocales = null;
if (allowedLocales.size() > 0) {
availLocales = computeAvailLocales(installedLocales, allowedLocales);
} else {
availLocales = installedLocales;
}
Element response = zsc.createElement(AccountConstants.GET_AVAILABLE_LOCALES_RESPONSE);
for (Locale locale : availLocales) {
if (locale != null) {
ToXML.encodeLocale(response, locale, displayLocale);
} else {
break;
}
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetDistributionList method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Account acct = getAuthenticatedAccount(zsc);
Element response = zsc.createElement(AccountConstants.GET_DISTRIBUTION_LIST_RESPONSE);
Group group = getGroupBasic(request, prov);
GetDistributionListHandler handler = new GetDistributionListHandler(group, request, response, prov, acct);
handler.handle();
return response;
}
Aggregations