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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations