Class Directory

  • All Implemented Interfaces:
    org.bedework.util.logging.Logged
    Direct Known Subclasses:
    LdapDirectory, Ldif

    public abstract class Directory
    extends Object
    implements org.bedework.util.logging.Logged
    Provide access to directory services. If the object is provided with a Properties object it will be queried for a number of properties. If they are absent or no Properties object is provided they will default to some value. Properties are defined in javax.naming.Context and are: java.naming.factory.initial java.naming.provider.url Service provider, e.g. ldap://ldap.example.com:389 java.naming.security.authentication e.g. "simple" java.naming.security.principal e.g. cn=dirManager java.naming.security.credentials Usually the password The intention is that this class should be able to represent various forms of directory, even a sequential input stream of records.
    • Method Detail

      • reInit

        public abstract void reInit()
                             throws NamingException
        If possible, reInit should allow reuse after a close
        Throws:
        NamingException - on fatal error
      • search

        public boolean search​(String base,
                              String filter)
                       throws NamingException
        Carry out a subtree search
        Parameters:
        base - for search
        filter - ldap filter
        Returns:
        DirSearchResult
        Throws:
        NamingException
      • searchBase

        public boolean searchBase​(String base,
                                  String filter)
                           throws NamingException
        Carry out a base level search. This should be the default if the scope is not specified.
        Parameters:
        base - for search
        filter - ldap filter
        Returns:
        DirSearchResult or null
        Throws:
        NamingException - on fatal error
      • searchOne

        public boolean searchOne​(String base,
                                 String filter)
                          throws NamingException
        Carry out a one level search
        Parameters:
        base - for search
        filter - ldap filter
        Returns:
        DirSearchResult
        Throws:
        NamingException - on fatal error
      • search

        public abstract boolean search​(String base,
                                       String filter,
                                       int scope)
                                throws NamingException
        Carry out a search with specified scope.
        Parameters:
        base - for search
        filter - ldap filter
        scope -
        Returns:
        false means no record(s) found. true means it's safe to call nextRecord.
        Throws:
        NamingException
      • newRecord

        public DirRecord newRecord​(String entryDn)
                            throws NamingException
        newRecord - Return a record which can have attribute values added. create should be called to create the directory entry.
        Parameters:
        entryDn -
        Returns:
        DirRecord
        Throws:
        NamingException - on fatal error
      • create

        public abstract boolean create​(DirRecord rec)
                                throws NamingException
        Parameters:
        rec - directory record
        Returns:
        boolean true if created, false if already exists
        Throws:
        NamingException - on fatal error
      • replace

        public abstract void replace​(String dn,
                                     String attrName,
                                     Object val)
                              throws NamingException
        Replace an entire attribute with one containing only the given value
        Parameters:
        dn - for record
        attrName - name of attribute
        val - new value
        Throws:
        NamingException - on fatal error
      • replace

        public abstract void replace​(String dn,
                                     String attrName,
                                     Object[] val)
                              throws NamingException
        Replace an entire attribute with one containing only the given values
        Parameters:
        dn - for record
        attrName - name of attribute
        val - new value
        Throws:
        NamingException - on fatal error
      • replace

        public abstract void replace​(String dn,
                                     String attrName,
                                     Object oldval,
                                     Object newval)
                              throws NamingException
        Replace a single given attribute value with the given value
        Parameters:
        dn - for record
        attrName - name of attribute
        oldval - current value
        newval - new value
        Throws:
        NamingException - on fatal error
      • close

        public abstract void close()