use of com.zimbra.cs.account.accesscontrol.AttributeConstraint in project zm-mailbox by Zimbra.
the class GetDelegatedAdminConstraints method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Entry entry = getEntry(request);
AdminAccessControl.GetAttrsRight gar = new AdminAccessControl.GetAttrsRight();
gar.addAttr(Provisioning.A_zimbraConstraint);
checkRight(zsc, context, entry, gar);
Map<String, AttributeConstraint> constraints = AttributeConstraint.getConstraint(entry);
Element response = zsc.createElement(AdminConstants.GET_DELEGATED_ADMIN_CONSTRAINTS_RESPONSE);
// return constraints for requested attrs
boolean hasRequestedAttrs = false;
for (Element a : request.listElements(AdminConstants.E_A)) {
hasRequestedAttrs = true;
String attrName = a.getAttribute(AdminConstants.A_NAME);
AttributeConstraint ac = constraints.get(attrName);
if (ac != null) {
Element eAttr = response.addElement(AdminConstants.E_A).addAttribute(AdminConstants.A_NAME, attrName);
ac.toXML(eAttr);
}
}
// no attr is specifically requested, return all
if (!hasRequestedAttrs) {
for (Map.Entry<String, AttributeConstraint> cons : constraints.entrySet()) {
String attrName = cons.getKey();
AttributeConstraint ac = cons.getValue();
Element eAttr = response.addElement(AdminConstants.E_A).addAttribute(AdminConstants.A_NAME, attrName);
ac.toXML(eAttr);
}
}
return response;
}
use of com.zimbra.cs.account.accesscontrol.AttributeConstraint in project zm-mailbox by Zimbra.
the class ModifyDelegatedAdminConstraints method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Entry entry = GetDelegatedAdminConstraints.getEntry(request);
AdminAccessControl.SetAttrsRight sar = new AdminAccessControl.SetAttrsRight();
sar.addAttr(Provisioning.A_zimbraConstraint);
checkRight(zsc, context, entry, sar);
AttributeManager am = AttributeManager.getInstance();
List<AttributeConstraint> constraints = new ArrayList<AttributeConstraint>();
for (Element a : request.listElements(AdminConstants.E_A)) {
String attrName = a.getAttribute(AdminConstants.A_NAME);
Element eConstraint = a.getElement(AdminConstants.E_CONSTRAINT);
constraints.add(AttributeConstraint.fromXML(am, attrName, eConstraint));
}
AttributeConstraint.modifyConstraint(entry, constraints);
// log it
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(CONSTRAINT_ATTR, entry.getMultiAttr(CONSTRAINT_ATTR, false));
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyDelegatedAdminConstraints", "name", entry.getLabel() }, attrs));
Element response = zsc.createElement(AdminConstants.MODIFY_DELEGATED_ADMIN_CONSTRAINTS_RESPONSE);
return response;
}
Aggregations