Search in sources :

Example 46 with ASN1OctetString

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);
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Modification(com.unboundid.ldap.sdk.Modification) ASN1OctetString(com.unboundid.asn1.ASN1OctetString)

Example 47 with ASN1OctetString

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);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Modification(com.unboundid.ldap.sdk.Modification) ArrayList(java.util.ArrayList) ASN1OctetString(com.unboundid.asn1.ASN1OctetString)

Example 48 with ASN1OctetString

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);
        }
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) AttributeManager(com.zimbra.cs.account.AttributeManager) Attribute(com.unboundid.ldap.sdk.Attribute) Collection(java.util.Collection) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Map(java.util.Map)

Aggregations

ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)40 IOException (java.io.IOException)22 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)17 X509Certificate (java.security.cert.X509Certificate)11 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)11 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)11 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)10 DEROctetString (org.bouncycastle.asn1.DEROctetString)10 CertificateException (java.security.cert.CertificateException)9 Enumeration (java.util.Enumeration)9 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)8 CertificateEncodingException (java.security.cert.CertificateEncodingException)8 DERObject (org.bouncycastle.asn1.DERObject)8 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)8 X962Parameters (org.bouncycastle.asn1.x9.X962Parameters)8 X9ECParameters (org.bouncycastle.asn1.x9.X9ECParameters)8 X9ECPoint (org.bouncycastle.asn1.x9.X9ECPoint)8 DERBitString (org.bouncycastle.asn1.DERBitString)7