コード例 #1
0
 /** Exctract specified attributes from the ldapMatchingRule */
 Attributes extractAttributeIds(String[] attrIds) throws NamingException {
   Attributes attrs = new BasicAttributes();
   String val = null;
   for (int i = 0; i < attrIds.length; i++) {
     if (attrIds[i].equals(NUMERICOID)) {
       val = m_ldapMatchingRule.getID();
       if (val != null) {
         attrs.put(new BasicAttribute(NUMERICOID, val));
       }
     } else if (attrIds[i].equals(NAME)) {
       val = m_ldapMatchingRule.getName();
       if (val != null) {
         attrs.put(new BasicAttribute(NAME, val));
       }
     } else if (attrIds[i].equals(DESC)) {
       val = m_ldapMatchingRule.getDescription();
       if (val != null) {
         attrs.put(new BasicAttribute(DESC, val));
       }
     } else if (attrIds[i].equals(SYNTAX)) {
       val = m_ldapMatchingRule.getSyntaxString();
       if (val != null) {
         attrs.put(new BasicAttribute(SYNTAX, val));
       }
     } else if (attrIds[i].equals(APPLIES)) {
       String[] appliesToAttrs = m_ldapMatchingRule.getAttributes();
       if (appliesToAttrs != null && appliesToAttrs.length > 0) {
         BasicAttribute applies = new BasicAttribute(APPLIES);
         for (int a = 0; a < appliesToAttrs.length; a++) {
           applies.add(appliesToAttrs[a]);
         }
         attrs.put(applies);
       }
     } else if (attrIds[i].equals(OBSOLETE)) {
       if (m_ldapMatchingRule.getQualifier(OBSOLETE) != null) {
         attrs.put(new BasicAttribute(OBSOLETE, "true"));
       }
     } else {
       throw new NamingException(
           "Invalid schema attribute type for matching rule definition " + attrIds[i]);
     }
   }
   return attrs;
 }
コード例 #2
0
  /** Parse Definition Attributes for a LDAP matching rule */
  static LDAPMatchingRuleSchema parseDefAttributes(Attributes attrs) throws NamingException {
    String name = null, oid = null, desc = null, syntax = null;
    boolean obsolete = false;
    Vector applies = new Vector();

    for (Enumeration attrEnum = attrs.getAll(); attrEnum.hasMoreElements(); ) {
      Attribute attr = (Attribute) attrEnum.nextElement();
      String attrName = attr.getID();
      if (attrName.equals(NAME)) {
        name = getSchemaAttrValue(attr);
      } else if (attrName.equals(NUMERICOID)) {
        oid = getSchemaAttrValue(attr);
      } else if (attrName.equals(SYNTAX)) {
        syntax = getSchemaAttrValue(attr);
      } else if (attrName.equals(DESC)) {
        desc = getSchemaAttrValue(attr);
      } else if (attrName.equals(APPLIES)) {
        for (Enumeration valEnum = attr.getAll(); valEnum.hasMoreElements(); ) {
          applies.addElement((String) valEnum.nextElement());
        }
      } else if (attrName.equals(OBSOLETE)) {
        obsolete = parseTrueFalseValue(attr);
      } else {
        throw new NamingException(
            "Invalid schema attribute type for matching rule definition " + attrName);
      }
    }

    LDAPMatchingRuleSchema mrule =
        new LDAPMatchingRuleSchema(name, oid, desc, vectorToStringAry(applies), syntax);

    if (obsolete) {
      mrule.setQualifier(OBSOLETE, "");
    }
    return mrule;
  }