Class AttributeUtils

    • Method Detail

      • containsValueCaseIgnore

        public static boolean containsValueCaseIgnore​(Attribute attr,
                                                      Object value)
        Check if an attribute contains a value. The test is case insensitive, and the value is supposed to be a String. If the value is a byte[], then the case sensitivity is useless.
        Parameters:
        attr - The attribute to check
        value - The value to look for
        Returns:
        true if the value is present in the attribute
      • toCaseInsensitive

        public static Attributes toCaseInsensitive​(Attributes attributes)
        Check if the attributes is a BasicAttributes, and if so, switch the case sensitivity to false to avoid tricky problems in the server. (Ldap attributeTypes are *always* case insensitive)
        Parameters:
        attributes - The Attributes to check
        Returns:
        The modified Attributes
      • parseAttribute

        public static String parseAttribute​(char[] str,
                                            Position pos,
                                            boolean withOption,
                                            boolean relaxed)
                                     throws ParseException
        Parse an attribute. The grammar is : attributedescription = attributetype options attributetype = oid oid = descr / numericoid descr = keystring numericoid = number 1*( '.' number ) options = *( ';' option ) option = 1*keychar keystring = leadkeychar *keychar leadkeychar = 'a'-z' | 'A'-'Z' keychar = 'a'-z' | 'A'-'Z' / '0'-'9' / '-' number = '0'-'9' / ( '1'-'9' 1*'0'-'9' )
        Parameters:
        str - The parsed attribute,
        pos - The position of the attribute in the current string
        withOption - A flag set if we want to parse the options
        relaxed - A flag set if we want to parse without being too strict
        Returns:
        The parsed attribute if valid
        Throws:
        ParseException - If we had an issue while parsing the attribute
      • parseAttribute

        public static String parseAttribute​(byte[] bytes,
                                            Position pos,
                                            boolean withOption,
                                            boolean relaxed)
                                     throws ParseException
        Parse an attribute. The grammar is : attributedescription = attributetype options attributetype = oid oid = descr / numericoid descr = keystring numericoid = number 1*( '.' number ) options = *( ';' option ) option = 1*keychar keystring = leadkeychar *keychar leadkeychar = 'a'-z' | 'A'-'Z' keychar = 'a'-z' | 'A'-'Z' / '0'-'9' / '-' number = '0'-'9' / ( '1'-'9' 1*'0'-'9' )
        Parameters:
        bytes - The parsed attribute,
        pos - The position of the attribute in the current string
        withOption - A flag set if we want to parse the options
        relaxed - A flag set if we want to parse without being too strict
        Returns:
        The parsed attribute if valid
        Throws:
        ParseException - If we had an issue while parsing the attribute
      • applyModification

        public static void applyModification​(Entry entry,
                                             Modification modification)
                                      throws LdapException
        A method to apply a modification to an existing entry.
        Parameters:
        entry - The entry on which we want to apply a modification
        modification - the Modification to be applied
        Throws:
        LdapException - if some operation fails.
      • toEntry

        public static Entry toEntry​(Attributes attributes,
                                    Dn dn)
                             throws LdapException
        Convert a BasicAttributes or a AttributesImpl to an Entry
        Parameters:
        attributes - the BasicAttributes or AttributesImpl instance to convert
        dn - The Dn which is needed by the Entry
        Returns:
        An instance of a Entry object
        Throws:
        LdapException - If we get an invalid attribute