use of com.zimbra.cs.account.AttributeManager in project zm-mailbox by Zimbra.
the class ToXML method encodeAttrs.
private static void encodeAttrs(Element e, Map attrs, String key, Set<String> reqAttrs, AttrRightChecker attrRightChecker) {
AttributeManager attrMgr = null;
try {
attrMgr = AttributeManager.getInstance();
} catch (ServiceException se) {
ZimbraLog.account.warn("failed to get AttributeManager instance", se);
}
for (Iterator iter = attrs.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Entry) iter.next();
String name = (String) entry.getKey();
Object value = entry.getValue();
// Never return data source passwords
if (name.equalsIgnoreCase(Provisioning.A_zimbraDataSourcePassword))
continue;
value = Provisioning.sanitizedAttrValue(name, value);
// only returns requested attrs
if (reqAttrs != null && !reqAttrs.contains(name))
continue;
boolean allowed = attrRightChecker == null ? true : attrRightChecker.allowAttr(name);
IDNType idnType = AttributeManager.idnType(attrMgr, name);
if (value instanceof String[]) {
String[] sv = (String[]) value;
for (int i = 0; i < sv.length; i++) {
encodeAttr(e, name, sv[i], AccountConstants.E_A, key, idnType, allowed);
}
} else if (value instanceof String) {
value = fixupZimbraPrefTimeZoneId(name, (String) value);
encodeAttr(e, name, (String) value, AccountConstants.E_A, key, idnType, allowed);
}
}
}
use of com.zimbra.cs.account.AttributeManager 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;
}
use of com.zimbra.cs.account.AttributeManager in project zm-mailbox by Zimbra.
the class TestBuildInfo method testInVersion.
@Test
public void testInVersion() throws Exception {
AttributeManager am = AttributeManager.getInstance();
assertTrue(am.inVersion("zimbraId", "0"));
assertTrue(am.inVersion("zimbraId", "5.0.10"));
assertFalse(am.inVersion("zimbraZimletDomainAvailableZimlets", "5.0.9"));
assertTrue(am.inVersion("zimbraZimletDomainAvailableZimlets", "5.0.10"));
assertTrue(am.inVersion("zimbraZimletDomainAvailableZimlets", "5.0.11"));
assertTrue(am.inVersion("zimbraZimletDomainAvailableZimlets", "5.5"));
assertTrue(am.inVersion("zimbraZimletDomainAvailableZimlets", "6"));
}
use of com.zimbra.cs.account.AttributeManager in project zm-mailbox by Zimbra.
the class AttributeConstraint method loadConstraints.
private static Map<String, AttributeConstraint> loadConstraints(Entry constraintEntry) throws ServiceException {
Map<String, AttributeConstraint> constraints = new HashMap<String, AttributeConstraint>();
Set<String> cstrnts = constraintEntry.getMultiAttrSet(Provisioning.A_zimbraConstraint);
AttributeManager am = AttributeManager.getInstance();
for (String c : cstrnts) {
AttributeConstraint constraint = AttributeConstraint.fromString(am, c);
constraints.put(constraint.getAttrName(), constraint);
}
return constraints;
}
Aggregations