Class ADSContext


  • public class ADSContext
    extends Object
    Class used to update and read the contents of the Administration Data.
    • Constructor Detail

      • ADSContext

        public ADSContext​(ConnectionWrapper connectionWrapper)
        Constructor of the ADSContext.
        Parameters:
        connectionWrapper - provide an Ldap Connection
    • Method Detail

      • getConnection

        public ConnectionWrapper getConnection()
        Returns the connection used to retrieve information by this ADSContext.
        Returns:
        the connection
      • getHostPort

        public HostPort getHostPort()
        Returns the host name and port number of this connection.
        Returns:
        the hostPort of this connection
      • unregisterServer

        public void unregisterServer​(Map<ADSContext.ServerProperty,​Object> serverProperties)
                              throws ADSContextException
        Method called to unregister a server in the ADS. Note that the server's instance key-pair public-key certificate entry (created in registerServer()) is left untouched.
        Parameters:
        serverProperties - the properties of the server.
        Throws:
        ADSContextException - if the server could not be unregistered.
      • registerOrUpdateServer

        public int registerOrUpdateServer​(Map<ADSContext.ServerProperty,​Object> serverProperties)
                                   throws ADSContextException
        A convenience method that takes some server properties as parameter and if there is no server registered associated with those properties, registers it and if it is already registered, updates it.
        Parameters:
        serverProperties - the server properties.
        Returns:
        0 if the server was registered; 1 if updated (i.e., the server entry was already in ADS).
        Throws:
        ADSContextException - if something goes wrong.
      • createAdminData

        public void createAdminData​(String backendName)
                             throws ADSContextException
        Creates the Administration Data in the server. The call to this method assumes that OpenDJ.jar has already been loaded.
        Parameters:
        backendName - the backend name which will handle admin information. null to use the default backend name for the admin information.
        Throws:
        ADSContextException - if something goes wrong.
      • removeAdminData

        public void removeAdminData​(boolean removeAdministrators)
                             throws ADSContextException
        Removes the administration data.
        Parameters:
        removeAdministrators - true if administrators should be removed. It may not be possible to remove administrators if the operation is being performed by one of the administrators because it will cause the administrator to be disconnected.
        Throws:
        ADSContextException - if something goes wrong.
      • hasAdminData

        public boolean hasAdminData()
                             throws ADSContextException
        Returns true if the server contains Administration Data and false otherwise.
        Returns:
        true if the server contains Administration Data and false otherwise.
        Throws:
        ADSContextException - if something goes wrong.
      • getAdministratorDN

        public static DN getAdministratorDN​(String uid)
        Returns the DN of the administrator for a given UID.
        Parameters:
        uid - the UID to be used to generate the DN.
        Returns:
        the DN of the administrator for the given UID:
      • getAdministrationSuffixDN

        public static DN getAdministrationSuffixDN()
        Returns the DN of the suffix that contains the administration data.
        Returns:
        the DN of the suffix that contains the administration data.
      • getAdministratorContainerDN

        public static DN getAdministratorContainerDN()
        Returns the parent entry of the administrator entries.
        Returns:
        the parent entry of the administrator entries.
      • getDefaultBackendName

        public static String getDefaultBackendName()
        Returns the default backend name of the administration data.
        Returns:
        the default backend name of the administration data.
      • isRegistered

        public static boolean isRegistered​(ServerDescriptor server,
                                           Set<Map<ADSContext.ServerProperty,​Object>> registry)
        Tells whether the provided server is registered in the registry.
        Parameters:
        server - the server.
        registry - the registry.
        Returns:
        true if the server is registered in the registry and false otherwise.
      • getTrustedCertificates

        public Map<String,​byte[]> getTrustedCertificates()
                                                        throws ADSContextException
        Return the set of valid (i.e., not tagged as compromised) instance key-pair public-key certificate entries in ADS. NOTE: calling this method assumes that all the jar files are present in the classpath.
        Returns:
        The set of valid (i.e., not tagged as compromised) instance key-pair public-key certificate entries in ADS represented as a Map from ds-cfg-key-id value to ds-cfg-public-key-certificate;binary value. Note that the collection might be empty.
        Throws:
        ADSContextException - in case of problems with the entry search.
        See Also:
        CryptoManagerImpl.getTrustedCertificates()
      • mergeWithRegistry

        public void mergeWithRegistry​(ADSContext adsCtx)
                               throws ADSContextException
        Merge the contents of this ADSContext with the contents of the provided ADSContext. Note that only the contents of this ADSContext will be updated.
        Parameters:
        adsCtx - the other ADSContext to merge the contents with.
        Throws:
        ADSContextException - if there was an error during the merge.