Search in sources :

Example 6 with Attribute

use of org.opends.server.types.Attribute in project midpoint by Evolveum.

the class OpenDJController method getAttributeValues.

public static Collection<String> getAttributeValues(Entry response, String name) {
    List<Attribute> attrs = response.getAttribute(name.toLowerCase());
    if (attrs == null || attrs.size() == 0) {
        return null;
    }
    assertEquals("Too many attributes for name " + name + ": ", 1, attrs.size());
    Attribute attribute = attrs.get(0);
    Collection<String> values = new ArrayList<String>(attribute.size());
    Iterator<AttributeValue> iterator = attribute.iterator();
    while (iterator.hasNext()) {
        AttributeValue attributeValue = iterator.next();
        values.add(attributeValue.getValue().toString());
    }
    return values;
}
Also used : AttributeValue(org.opends.server.types.AttributeValue) Attribute(org.opends.server.types.Attribute) ArrayList(java.util.ArrayList) ByteString(org.opends.server.types.ByteString)

Example 7 with Attribute

use of org.opends.server.types.Attribute in project midpoint by Evolveum.

the class OpenDJController method getAttributeValueBinary.

public static byte[] getAttributeValueBinary(Entry response, String name) {
    List<Attribute> attrs = response.getAttribute(name.toLowerCase());
    if (attrs == null || attrs.size() == 0) {
        return null;
    }
    assertEquals("Too many attributes for name " + name + ": ", 1, attrs.size());
    Attribute attribute = attrs.get(0);
    ByteString value = attribute.iterator().next().getValue();
    return value.toByteArray();
}
Also used : Attribute(org.opends.server.types.Attribute) ByteString(org.opends.server.types.ByteString)

Example 8 with Attribute

use of org.opends.server.types.Attribute in project midpoint by Evolveum.

the class OpenDJController method toHumanReadableLdifoid.

public String toHumanReadableLdifoid(Entry entry) {
    StringBuilder sb = new StringBuilder();
    sb.append("dn: ").append(entry.getDN()).append("\n");
    for (Attribute attribute : entry.getAttributes()) {
        for (AttributeValue val : attribute) {
            sb.append(attribute.getName());
            sb.append(": ");
            sb.append(val);
            sb.append("\n");
        }
    }
    return sb.toString();
}
Also used : AttributeValue(org.opends.server.types.AttributeValue) Attribute(org.opends.server.types.Attribute)

Aggregations

Attribute (org.opends.server.types.Attribute)8 AttributeValue (org.opends.server.types.AttributeValue)3 ByteString (org.opends.server.types.ByteString)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ByteString (org.forgerock.opendj.ldap.ByteString)1