Search in sources :

Example 86 with ZimbraSoapContext

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;
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Provisioning(com.zimbra.cs.account.Provisioning)

Example 87 with ZimbraSoapContext

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());
}
Also used : Account(com.zimbra.cs.account.Account) Server(com.zimbra.cs.account.Server) ServiceException(com.zimbra.common.service.ServiceException) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) AuthTokenException(com.zimbra.cs.account.AuthTokenException) ZimbraAuthToken(com.zimbra.cs.account.ZimbraAuthToken) AuthToken(com.zimbra.cs.account.AuthToken) Provisioning(com.zimbra.cs.account.Provisioning) RefreshRegisteredAuthTokensResponse(com.zimbra.soap.admin.message.RefreshRegisteredAuthTokensResponse) RefreshRegisteredAuthTokensRequest(com.zimbra.soap.admin.message.RefreshRegisteredAuthTokensRequest)

Example 88 with ZimbraSoapContext

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());
}
Also used : ReloadLocalConfigResponse(com.zimbra.soap.admin.message.ReloadLocalConfigResponse) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) DocumentException(org.dom4j.DocumentException) ConfigException(com.zimbra.common.localconfig.ConfigException)

Example 89 with ZimbraSoapContext

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());
}
Also used : Group(com.zimbra.cs.account.Group) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) RemoveDistributionListMemberResponse(com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse) Provisioning(com.zimbra.cs.account.Provisioning)

Example 90 with ZimbraSoapContext

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;
}
Also used : RenameCalendarResourceRequest(com.zimbra.soap.admin.message.RenameCalendarResourceRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)382 Element (com.zimbra.common.soap.Element)315 Provisioning (com.zimbra.cs.account.Provisioning)162 Account (com.zimbra.cs.account.Account)158 Mailbox (com.zimbra.cs.mailbox.Mailbox)106 OperationContext (com.zimbra.cs.mailbox.OperationContext)82 ItemId (com.zimbra.cs.service.util.ItemId)58 Server (com.zimbra.cs.account.Server)47 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)44 ServiceException (com.zimbra.common.service.ServiceException)40 HashMap (java.util.HashMap)37 Domain (com.zimbra.cs.account.Domain)32 HashSet (java.util.HashSet)25 ArrayList (java.util.ArrayList)23 IOException (java.io.IOException)20 Group (com.zimbra.cs.account.Group)17 CalendarItem (com.zimbra.cs.mailbox.CalendarItem)17 Message (com.zimbra.cs.mailbox.Message)17 MimeMessage (javax.mail.internet.MimeMessage)16 Map (java.util.Map)15