Пример #1
0
 static String getLDAPPropertyName(AnnotatedConfigurableProperty property)
     throws ConfigurationException {
   LDAP ldapAnno = property.getAnnotation(LDAP.class);
   if (ldapAnno != null) {
     if (!ldapAnno.overriddenName().equals("")) {
       return ldapAnno.overriddenName();
     } else {
       return property.getAnnotatedName();
     }
   } else {
     return property.getAnnotatedName();
   }
 }
Пример #2
0
  static String getDistinguishingField(AnnotatedConfigurableProperty property) {
    LDAP propLdapAnno = property.getAnnotation(LDAP.class);

    String distinguishingField;
    if (propLdapAnno != null) distinguishingField = propLdapAnno.distinguishingField();
    else distinguishingField = LDAP.DEFAULT_DISTINGUISHING_FIELD;

    if (distinguishingField.equals(LDAP.DEFAULT_DISTINGUISHING_FIELD)) {
      Annotation classLdapAnno = property.getRawClass().getAnnotation(LDAP.class);
      if (classLdapAnno != null) distinguishingField = ((LDAP) classLdapAnno).distinguishingField();
    }

    return distinguishingField;
  }
Пример #3
0
  static boolean isNoContainerNode(AnnotatedConfigurableProperty property) {
    LDAP propLdapAnno = property.getAnnotation(LDAP.class);

    LDAP classLdapAnno = null;
    if (property.isConfObject()) classLdapAnno = propLdapAnno;
    else {
      AnnotatedConfigurableProperty pseudoProperty =
          property.getPseudoPropertyForConfigClassCollectionElement();
      if (pseudoProperty != null)
        classLdapAnno = (LDAP) pseudoProperty.getRawClass().getAnnotation(LDAP.class);
    }

    if (propLdapAnno == null || classLdapAnno == null) return false;

    return propLdapAnno.noContainerNode() || classLdapAnno.noContainerNode();
  }
Пример #4
0
  /**
   * Resolve map/collection key field for a property
   *
   * @param property
   * @return
   */
  static String getDistinguishingFieldForCollectionElement(AnnotatedConfigurableProperty property) {

    // by default use what annotated on the property
    LDAP annotation = property.getAnnotation(LDAP.class);
    String elementDistinguishingField =
        annotation == null ? LDAP.DEFAULT_DISTINGUISHING_FIELD : annotation.distinguishingField();

    // if property is default, check the annotation on the element class if its a confclass
    if (elementDistinguishingField.equals(LDAP.DEFAULT_DISTINGUISHING_FIELD))
      if (property.isArrayOfConfObjects()
          || property.isCollectionOfConfObjects()
          || property.isMapOfConfObjects())
        elementDistinguishingField =
            ((LDAP)
                    property
                        .getPseudoPropertyForConfigClassCollectionElement()
                        .getRawClass()
                        .getAnnotation(LDAP.class))
                .distinguishingField();

    return elementDistinguishingField;
  }
Пример #5
0
  protected static NamingEnumeration<SearchResult> searchForCollectionElements(
      LdapConfigurationStorage ldapConfigurationStorage,
      String dn,
      AnnotatedConfigurableProperty property)
      throws NamingException, ConfigurationException {
    NamingEnumeration<SearchResult> enumeration;
    AnnotatedConfigurableProperty elemProperty =
        property.getPseudoPropertyForConfigClassCollectionElement();

    // figure out the objectClass
    String childObjClass;
    if (elemProperty == null)
      childObjClass = property.getAnnotation(LDAP.class).mapEntryObjectClass();
    else childObjClass = extractObjectClasses(elemProperty.getRawClass()).get(0);

    try {
      enumeration = searchSubcontextWithClass(ldapConfigurationStorage, childObjClass, dn);
    } catch (IndexOutOfBoundsException e) {
      throw new ConfigurationException(
          "No object class defined for class " + elemProperty.getRawClass(), e);
    }
    return enumeration;
  }
Пример #6
0
 static ArrayList<String> extractObjectClasses(AnnotatedConfigurableProperty property) {
   return new ArrayList<String>(Arrays.asList(property.getAnnotation(LDAP.class).objectClasses()));
 }