use of org.apache.harmony.security.asn1.ASN1OctetString in project zm-mailbox by Zimbra.
the class UBIDModificationList method addAttr.
@Override
public void addAttr(String name, String[] value, Entry entry, boolean containsBinaryData, boolean isBinaryTransfer) {
String[] currentValues = entry.getMultiAttr(name, false, true);
List<ASN1OctetString> valuesToAdd = null;
for (int i = 0; i < value.length; i++) {
if (LdapUtil.contains(currentValues, value[i])) {
continue;
}
if (valuesToAdd == null) {
valuesToAdd = new ArrayList<ASN1OctetString>();
}
valuesToAdd.add(UBIDUtil.newASN1OctetString(containsBinaryData, value[i]));
}
if (valuesToAdd != null) {
String transferAttrName = LdapUtil.attrNameToBinaryTransferAttrName(isBinaryTransfer, name);
Modification mod = new Modification(ModificationType.ADD, transferAttrName, valuesToAdd.toArray(new ASN1OctetString[valuesToAdd.size()]));
modList.add(mod);
}
}
use of org.apache.harmony.security.asn1.ASN1OctetString in project zm-mailbox by Zimbra.
the class UBIDModificationList method modifyAttr.
@Override
public void modifyAttr(String name, String[] value, boolean containsBinaryData, boolean isBinaryTransfer) {
List<ASN1OctetString> valuesToMod = new ArrayList<ASN1OctetString>();
for (int i = 0; i < value.length; i++) {
valuesToMod.add(UBIDUtil.newASN1OctetString(containsBinaryData, value[i]));
}
String transferAttrName = LdapUtil.attrNameToBinaryTransferAttrName(isBinaryTransfer, name);
Modification mod = new Modification(ModificationType.REPLACE, transferAttrName, valuesToMod.toArray(new ASN1OctetString[valuesToMod.size()]));
modList.add(mod);
}
use of org.apache.harmony.security.asn1.ASN1OctetString in project zm-mailbox by Zimbra.
the class UBIDMutableEntry method mapToAttrs.
// ZMutableEntry
@Override
public void mapToAttrs(Map<String, Object> mapAttrs) {
AttributeManager attrMgr = AttributeManager.getInst();
for (Map.Entry<String, Object> me : mapAttrs.entrySet()) {
String attrName = me.getKey();
Object v = me.getValue();
boolean containsBinaryData = attrMgr == null ? false : attrMgr.containsBinaryData(attrName);
boolean isBinaryTransfer = attrMgr == null ? false : attrMgr.isBinaryTransfer(attrName);
if (v instanceof String) {
ASN1OctetString value = UBIDUtil.newASN1OctetString(containsBinaryData, (String) v);
Attribute a = UBIDUtil.newAttribute(isBinaryTransfer, attrName, value);
entry.addAttribute(a);
} else if (v instanceof String[]) {
String[] sa = (String[]) v;
ASN1OctetString[] values = new ASN1OctetString[sa.length];
for (int i = 0; i < sa.length; i++) {
values[i] = UBIDUtil.newASN1OctetString(containsBinaryData, sa[i]);
}
Attribute a = UBIDUtil.newAttribute(isBinaryTransfer, attrName, values);
entry.addAttribute(a);
} else if (v instanceof Collection) {
Collection c = (Collection) v;
ASN1OctetString[] values = new ASN1OctetString[c.size()];
int i = 0;
for (Object o : c) {
values[i] = UBIDUtil.newASN1OctetString(containsBinaryData, o.toString());
i++;
}
Attribute a = UBIDUtil.newAttribute(isBinaryTransfer, attrName, values);
entry.addAttribute(a);
}
}
}
Aggregations