use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class RecalculateMailboxCounts method proxyIfNecessary.
@Override
protected Element proxyIfNecessary(Element request, Map<String, Object> context) throws ServiceException {
// if we've explicitly been told to execute here, don't proxy
ZimbraSoapContext zsc = getZimbraSoapContext(context);
if (zsc.getProxyTarget() != null)
return null;
// check whether we need to proxy to the home server of a target account
Provisioning prov = Provisioning.getInstance();
String[] xpath = getProxiedAccountPath();
String acctId = (xpath != null ? getXPath(request, xpath) : null);
if (acctId != null) {
Account acct = getAccount(prov, AccountBy.id, acctId, zsc.getAuthToken());
if (acct != null && !Provisioning.onLocalServer(acct))
return proxyRequest(request, context, acctId);
}
return null;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class RefreshRegisteredAuthTokens method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
Provisioning prov = Provisioning.getInstance();
Server localServer = prov.getLocalServer();
if (localServer.getLowestSupportedAuthVersion() < 2) {
return JaxbUtil.jaxbToElement(new RefreshRegisteredAuthTokensResponse());
}
RefreshRegisteredAuthTokensRequest req = JaxbUtil.elementToJaxb(request);
List<String> tokens = req.getTokens();
if (tokens != null && !tokens.isEmpty()) {
for (String token : tokens) {
try {
AuthToken zt = ZimbraAuthToken.getAuthToken(token);
if (zt.isRegistered()) {
Account acc = zt.getAccount();
Provisioning.getInstance().reload(acc);
ZimbraLog.soap.debug("Refreshed token %s for account %s", token, acc.getName());
}
} catch (AuthTokenException | ServiceException e) {
ZimbraLog.soap.error("Failed to refresh deregistered authtoken %s", token, e);
}
}
}
return JaxbUtil.jaxbToElement(new RefreshRegisteredAuthTokensResponse());
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class ReloadLocalConfig method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
try {
LC.reload();
} catch (DocumentException e) {
ZimbraLog.misc.error("Failed to reload LocalConfig", e);
throw AdminServiceException.FAILURE("Failed to reload LocalConfig", e);
} catch (ConfigException e) {
ZimbraLog.misc.error("Failed to reload LocalConfig", e);
throw AdminServiceException.FAILURE("Failed to reload LocalConfig", e);
}
ZimbraLog.misc.info("LocalConfig reloaded");
ZimbraSoapContext zsc = getZimbraSoapContext(context);
return zsc.jaxbToElement(new ReloadLocalConfigResponse());
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class RemoveDistributionListMember method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
List<String> memberList = getMemberList(request, context);
Group group = getGroupFromContext(context);
String id = request.getAttribute(AdminConstants.E_ID);
defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_removeGroupMember, Admin.R_removeDistributionListMember);
memberList = addMembersFromAccountElements(request, memberList, group);
String[] members = memberList.toArray(new String[0]);
prov.removeGroupMembers(group, members);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RemoveDistributionListMember", "name", group.getName(), "member", Arrays.deepToString(members) }));
return zsc.jaxbToElement(new RemoveDistributionListMemberResponse());
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class RenameCalendarResource method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
RenameCalendarResourceRequest req = JaxbUtil.elementToJaxb(request);
String id = req.getId();
String newName = req.getNewName();
CalendarResource resource = prov.get(CalendarResourceBy.id, id);
defendAgainstCalResourceHarvesting(resource, CalendarResourceBy.id, id, zsc, Admin.R_renameCalendarResource);
String oldName = resource.getName();
// check if the admin can rename the calendar resource
checkAccountRight(zsc, resource, Admin.R_renameCalendarResource);
// check if the admin can "create calendar resource" in the domain (can be same or diff)
checkDomainRightByEmail(zsc, newName, Admin.R_createCalendarResource);
prov.renameCalendarResource(id, newName);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RenameCalendarResource", "name", oldName, "newName", newName }));
// get again with new name...
resource = prov.get(CalendarResourceBy.id, id);
if (resource == null) {
throw ServiceException.FAILURE("unable to get calendar resource after rename: " + id, null);
}
Element response = zsc.createElement(AdminConstants.RENAME_CALENDAR_RESOURCE_RESPONSE);
ToXML.encodeCalendarResource(response, resource, true);
return response;
}
Aggregations