Search in sources :

Example 16 with AttributeManager

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);
        }
    }
}
Also used : Entry(java.util.Map.Entry) Entry(java.util.Map.Entry) AttributeManager(com.zimbra.cs.account.AttributeManager) ServiceException(com.zimbra.common.service.ServiceException) Iterator(java.util.Iterator) Map(java.util.Map) IDNType(com.zimbra.cs.account.AttributeManager.IDNType)

Example 17 with AttributeManager

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;
}
Also used : HashMap(java.util.HashMap) Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) Provisioning(com.zimbra.cs.account.Provisioning) Entry(com.zimbra.cs.account.Entry) AttributeManager(com.zimbra.cs.account.AttributeManager) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) AttributeConstraint(com.zimbra.cs.account.accesscontrol.AttributeConstraint)

Example 18 with AttributeManager

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"));
}
Also used : AttributeManager(com.zimbra.cs.account.AttributeManager)

Example 19 with AttributeManager

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;
}
Also used : AttributeManager(com.zimbra.cs.account.AttributeManager) HashMap(java.util.HashMap)

Aggregations

AttributeManager (com.zimbra.cs.account.AttributeManager)19 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ServiceException (com.zimbra.common.service.ServiceException)4 AttributeInfo (com.zimbra.cs.account.AttributeInfo)4 Element (com.zimbra.common.soap.Element)3 IDNType (com.zimbra.cs.account.AttributeManager.IDNType)3 Provisioning (com.zimbra.cs.account.Provisioning)3 Iterator (java.util.Iterator)3 Entry (java.util.Map.Entry)3 Attribute (com.unboundid.ldap.sdk.Attribute)2 AttributeClass (com.zimbra.cs.account.AttributeClass)2 Config (com.zimbra.cs.account.Config)2 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)2 Collection (java.util.Collection)2 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1 Version (com.zimbra.common.util.Version)1 Account (com.zimbra.cs.account.Account)1 AttributeFlag (com.zimbra.cs.account.AttributeFlag)1 Cos (com.zimbra.cs.account.Cos)1