Esempio n. 1
0
 public static String writeAttribute(Attribute attr) throws ToolLdapException {
   try {
     return LdifUtils.convertToLdif(attr);
   } catch (LdapException e) {
     throw new ToolLdapException(
         String.format(
             "Unable to write LDAP attribute (upId={%s}, values=[%s]) to LDIF string.",
             attr.getUpId(), ToolStringUtils.joinDelimit(attr, ", ")),
         e);
   }
 }
Esempio n. 2
0
  public static Attribute readAttribute(String str) throws ToolLdapException {
    LdifReader attrLdifReader = new LdifReader();
    LdifEntry attrLdifEntry = new LdifEntry();

    // noinspection ConstantConditions
    for (String strLine : ToolStringUtils.splitLines(str)) {
      try {
        attrLdifReader.parseAttributeValue(attrLdifEntry, strLine, strLine.toLowerCase());
      } catch (LdapException e) {
        throw new ToolLdapException(
            String.format("Unable to read LDAP attribute from LDIF string line: %s", strLine), e);
      }
    }

    return attrLdifEntry.getEntry().iterator().next();
  }