Search in sources :

Example 66 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetAlwaysOnCluster method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Set<String> reqAttrs = getReqAttrs(request, AttributeClass.alwaysOnCluster);
    Element d = request.getElement(AdminConstants.E_ALWAYSONCLUSTER);
    String method = d.getAttribute(AdminConstants.A_BY);
    String name = d.getText();
    if (name == null || name.equals(""))
        throw ServiceException.INVALID_REQUEST("must specify a value for a server", null);
    AlwaysOnCluster cluster = prov.get(Key.AlwaysOnClusterBy.fromString(method), name);
    if (cluster == null)
        throw AccountServiceException.NO_SUCH_ALWAYSONCLUSTER(name);
    AdminAccessControl aac = checkRight(zsc, context, cluster, AdminRight.PR_ALWAYS_ALLOW);
    // reload the server
    prov.reload(cluster);
    Element response = zsc.createElement(AdminConstants.GET_ALWAYSONCLUSTER_RESPONSE);
    encodeAlwaysOnCluster(response, cluster, reqAttrs, aac.getAttrRightChecker(cluster));
    return response;
}
Also used : AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 67 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetCalendarResource method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    GetCalendarResourceRequest req = JaxbUtil.elementToJaxb(request);
    boolean applyCos = !Boolean.FALSE.equals(req.getApplyCos());
    CalendarResourceBy calresBy = req.getCalResource().getBy().toKeyCalendarResourceBy();
    String value = req.getCalResource().getKey();
    CalendarResource resource = prov.get(calresBy, value);
    defendAgainstCalResourceHarvesting(resource, calresBy, value, zsc, Admin.R_getCalendarResourceInfo);
    AdminAccessControl aac = checkCalendarResourceRight(zsc, resource, AdminRight.PR_ALWAYS_ALLOW);
    Element response = zsc.createElement(AdminConstants.GET_CALENDAR_RESOURCE_RESPONSE);
    Set<String> reqAttrs = getReqAttrs(req.getAttrs(), AttributeClass.calendarResource);
    ToXML.encodeCalendarResource(response, resource, applyCos, reqAttrs, aac.getAttrRightChecker(resource));
    return response;
}
Also used : GetCalendarResourceRequest(com.zimbra.soap.admin.message.GetCalendarResourceRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) CalendarResourceBy(com.zimbra.common.account.Key.CalendarResourceBy) Element(com.zimbra.common.soap.Element) CalendarResource(com.zimbra.cs.account.CalendarResource) Provisioning(com.zimbra.cs.account.Provisioning)

Example 68 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetFreeBusyQueueInfo method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    // allow only system admin for now
    checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
    String name = null;
    Element provider = request.getOptionalElement(AdminConstants.E_PROVIDER);
    if (provider != null)
        name = provider.getAttribute(AdminConstants.A_NAME);
    Element response = zsc.createElement(AdminConstants.GET_FREE_BUSY_QUEUE_INFO_RESPONSE);
    if (name != null) {
        FreeBusyProvider prov = FreeBusyProvider.getProvider(name);
        if (prov == null)
            throw ServiceException.INVALID_REQUEST("provider not found: " + name, null);
        handleProvider(response, prov);
    } else {
        for (FreeBusyProvider prov : FreeBusyProvider.getProviders()) {
            handleProvider(response, prov);
        }
    }
    return response;
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) FreeBusyProvider(com.zimbra.cs.fb.FreeBusyProvider)

Example 69 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetGrants method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    String targetType = null;
    TargetBy targetBy = null;
    String target = null;
    Element eTarget = request.getOptionalElement(AdminConstants.E_TARGET);
    if (eTarget != null) {
        targetType = eTarget.getAttribute(AdminConstants.A_TYPE);
        if (TargetType.fromCode(targetType).needsTargetIdentity()) {
            targetBy = TargetBy.fromString(eTarget.getAttribute(AdminConstants.A_BY));
            target = eTarget.getText();
        }
        // check if the authed admin has right to view grants on the desired target
        TargetType tt = TargetType.fromCode(targetType);
        Entry targetEntry = TargetType.lookupTarget(prov, tt, targetBy, target);
        // targetEntry cannot be null by now, because lookupTarget would have thrown
        // if the specified target does not exist
        checkRight(zsc, targetEntry, Admin.R_viewGrants);
    }
    String granteeType = null;
    GranteeBy granteeBy = null;
    String grantee = null;
    boolean granteeIncludeGroupsGranteeBelongs = true;
    Element eGrantee = request.getOptionalElement(AdminConstants.E_GRANTEE);
    if (eGrantee != null) {
        granteeType = eGrantee.getAttribute(AdminConstants.A_TYPE);
        granteeBy = GranteeBy.fromString(eGrantee.getAttribute(AdminConstants.A_BY));
        grantee = eGrantee.getText();
        granteeIncludeGroupsGranteeBelongs = eGrantee.getAttributeBool(AdminConstants.A_ALL);
    }
    RightCommand.Grants grants = RightCommand.getGrants(prov, targetType, targetBy, target, granteeType, granteeBy, grantee, granteeIncludeGroupsGranteeBelongs);
    // check if the authed admin can see the zimbraACE attr on
    // each of the target on which grants for the specified grantee are found
    Set<String> OKedTarget = new HashSet<String>();
    for (RightCommand.ACE ace : grants.getACEs()) {
        TargetType tt = TargetType.fromCode(ace.targetType());
        // has to look up target by name, because zimlet can only be looked up by name
        Entry targetEntry = TargetType.lookupTarget(prov, tt, TargetBy.name, ace.targetName());
        String targetKey = ace.targetType() + "-" + ace.targetId();
        if (!OKedTarget.contains(targetKey)) {
            checkRight(zsc, targetEntry, Admin.R_viewGrants);
            // add the target to our OKed set, so we don't check again
            OKedTarget.add(targetKey);
        }
    }
    Element resp = zsc.createElement(AdminConstants.GET_GRANTS_RESPONSE);
    grants.toXML(resp);
    return resp;
}
Also used : Element(com.zimbra.common.soap.Element) TargetBy(com.zimbra.soap.type.TargetBy) Provisioning(com.zimbra.cs.account.Provisioning) Entry(com.zimbra.cs.account.Entry) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) GranteeBy(com.zimbra.soap.admin.type.GranteeSelector.GranteeBy) TargetType(com.zimbra.cs.account.accesscontrol.TargetType) RightCommand(com.zimbra.cs.account.accesscontrol.RightCommand) HashSet(java.util.HashSet)

Example 70 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetRight method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    boolean expandAllAtrts = request.getAttributeBool(AdminConstants.A_EXPAND_ALL_ATTRS, false);
    Element eRight = request.getElement(AdminConstants.E_RIGHT);
    String value = eRight.getText();
    Right right = RightManager.getInstance().getRight(value);
    Element response = zsc.createElement(AdminConstants.GET_RIGHT_RESPONSE);
    RightCommand.rightToXML(response, right, expandAllAtrts, account.getLocale());
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) AdminRight(com.zimbra.cs.account.accesscontrol.AdminRight) Right(com.zimbra.cs.account.accesscontrol.Right)

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