use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetIdentities 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");
}
Element response = zsc.createElement(AccountConstants.GET_IDENTITIES_RESPONSE);
Provisioning prov = Provisioning.getInstance();
for (Identity ident : prov.getAllIdentities(account)) {
ToXML.encodeIdentity(response, ident);
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetOAuthConsumers method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(zsc);
GetOAuthConsumersResponse response = new GetOAuthConsumersResponse();
encodeResponse(account, response);
return zsc.jaxbToElement(response);
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class SearchGal method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(getZimbraSoapContext(context));
if (!canAccessAccount(zsc, account))
throw ServiceException.PERM_DENIED("can not access account");
return searchGal(zsc, account, request);
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class SyncGal method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
disableJettyTimeout(context);
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(getZimbraSoapContext(context));
if (!canAccessAccount(zsc, account))
throw ServiceException.PERM_DENIED("can not access account");
String tokenAttr = request.getAttribute(MailConstants.A_TOKEN, "");
String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null);
boolean idOnly = request.getAttributeBool(AccountConstants.A_ID_ONLY, false);
boolean getCount = request.getAttributeBool(AccountConstants.A_GET_COUNT, false);
int limit = request.getAttributeInt(MailConstants.A_LIMIT, 0);
GalSearchParams params = new GalSearchParams(account, zsc);
params.setType(GalSearchType.all);
ZimbraLog.gal.debug("SyncGalRequest token: %s limit: %d", tokenAttr, limit);
params.setToken(tokenAttr);
params.setRequest(request);
params.setResponseName(AccountConstants.SYNC_GAL_RESPONSE);
params.setIdOnly(idOnly);
params.setGetCount(getCount);
params.setUserAgent(zsc.getUserAgent());
params.setLimit(limit);
if (galAcctId != null)
params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
params.setResultCallback(new SyncGalCallback(params));
GalSearchControl gal = new GalSearchControl(params);
gal.sync();
return params.getResultCallback().getResponse();
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class AddAccountAlias method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
AddAccountAliasRequest req = zsc.elementToJaxb(request);
String id = req.getId();
String alias = req.getAlias();
Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
defendAgainstAccountOrCalendarResourceHarvesting(account, AccountBy.id, id, zsc, Admin.R_addAccountAlias, Admin.R_addCalendarResourceAlias);
// if the admin can create an alias in the domain
checkDomainRightByEmail(zsc, alias, Admin.R_createAlias);
prov.addAlias(account, alias);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddAccountAlias", "name", account.getName(), "alias", alias }));
return zsc.jaxbToElement(new AddAccountAliasResponse());
}
Aggregations