// Create the message.
  private static Message createMessage(
      ServerManagedObject<?> partialManagedObject, Collection<PropertyException> causes) {
    Validator.ensureNotNull(causes);
    Validator.ensureTrue(!causes.isEmpty());

    ManagedObjectDefinition<?, ?> d = partialManagedObject.getManagedObjectDefinition();
    if (causes.size() == 1) {
      return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_SINGLE.get(
          d.getUserFriendlyName(), causes.iterator().next().getMessageObject());
    } else {
      MessageBuilder builder = new MessageBuilder();

      boolean isFirst = true;
      for (PropertyException cause : causes) {
        if (!isFirst) {
          builder.append("; ");
        }
        builder.append(cause.getMessageObject());
        isFirst = false;
      }

      return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_PLURAL.get(
          d.getUserFriendlyName(), builder.toMessage());
    }
  }
예제 #2
0
  /** {@inheritDoc} */
  @Override()
  public DynamicGroup newInstance(Entry groupEntry) throws DirectoryException {
    ensureNotNull(groupEntry);

    // Get the memberURL attribute from the entry, if there is one, and parse
    // out the LDAP URLs that it contains.
    LinkedHashSet<LDAPURL> memberURLs = new LinkedHashSet<LDAPURL>();
    AttributeType memberURLType = DirectoryConfig.getAttributeType(ATTR_MEMBER_URL_LC, true);
    List<Attribute> attrList = groupEntry.getAttribute(memberURLType);
    if (attrList != null) {
      for (Attribute a : attrList) {
        for (AttributeValue v : a) {
          try {
            memberURLs.add(LDAPURL.decode(v.getValue().toString(), true));
          } catch (DirectoryException de) {
            if (debugEnabled()) {
              TRACER.debugCaught(DebugLogLevel.ERROR, de);
            }

            Message message =
                ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL.get(
                    v.getValue().toString(),
                    String.valueOf(groupEntry.getDN()),
                    de.getMessageObject());
            ErrorLogger.logError(message);
          }
        }
      }
    }

    return new DynamicGroup(groupEntry.getDN(), memberURLs);
  }
예제 #3
0
  /**
   * Creates a new dynamic group instance with the provided information.
   *
   * @param groupEntryDN The DN of the entry that holds the definition for this group. It must not
   *     be {@code null}.
   * @param memberURLs The set of LDAP URLs that define the membership criteria for this group. It
   *     must not be {@code null}.
   */
  public DynamicGroup(DN groupEntryDN, LinkedHashSet<LDAPURL> memberURLs) {
    super();

    ensureNotNull(groupEntryDN, memberURLs);

    this.groupEntryDN = groupEntryDN;
    this.memberURLs = memberURLs;
  }
예제 #4
0
  /** {@inheritDoc} */
  @Override()
  public boolean isGroupDefinition(Entry entry) {
    ensureNotNull(entry);

    // FIXME -- This needs to exclude enhanced groups once we have support for
    // them.
    ObjectClass groupOfURLsClass = DirectoryConfig.getObjectClass(OC_GROUP_OF_URLS_LC, true);
    return entry.hasObjectClass(groupOfURLsClass);
  }
  /** {@inheritDoc} */
  @Override
  public String normalizeValue(String value) throws IllegalPropertyValueException {
    ensureNotNull(value);

    if (isCaseInsensitive()) {
      return value.trim().toLowerCase();
    } else {
      return value.trim();
    }
  }
  /** {@inheritDoc} */
  @Override
  public void validateValue(String value) throws IllegalPropertyValueException {
    ensureNotNull(value);

    if (pattern != null) {
      Matcher matcher = pattern.matcher(value);
      if (!matcher.matches()) {
        throw new IllegalPropertyValueException(this, value);
      }
    }
  }
예제 #7
0
  /** {@inheritDoc} */
  @Override
  public void configureBackend(Configuration cfg) throws ConfigException {
    Validator.ensureNotNull(cfg);
    Validator.ensureTrue(cfg instanceof LocalDBBackendCfg);

    this.cfg = (LocalDBBackendCfg) cfg;

    Set<DN> dnSet = this.cfg.getBaseDN();
    baseDNs = new DN[dnSet.size()];
    dnSet.toArray(baseDNs);
  }
  /** {@inheritDoc} */
  @Override
  public String decodeValue(String value) throws IllegalPropertyValueStringException {
    ensureNotNull(value);

    try {
      validateValue(value);
    } catch (IllegalPropertyValueException e) {
      throw new IllegalPropertyValueStringException(this, value);
    }

    return value;
  }
 /**
  * Add an attribute which should be part of the add operation.
  *
  * @param expectedName The name of the expected attribute.
  * @param expectedValues The attribute's expected values (never empty).
  */
 public void addExpectedAttribute(String expectedName, String... expectedValues) {
   Validator.ensureNotNull(expectedName);
   Validator.ensureNotNull(expectedValues);
   Validator.ensureTrue(expectedValues.length > 0);
   attributes.put(expectedName, Arrays.asList(expectedValues));
 }