Package org.opends.admin.ads
Class ADSContext
- java.lang.Object
-
- org.opends.admin.ads.ADSContext
-
public class ADSContext extends Object
Class used to update and read the contents of the Administration Data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classADSContext.AdministratorPropertyThe enumeration containing the different Administrator properties.static classADSContext.ADSPropertySyntaxEnumeration containing the different server properties syntaxes that could be stored in the ADS.static classADSContext.ServerPropertyEnumeration containing the different server properties that are stored in the ADS.
-
Field Summary
Fields Modifier and Type Field Description static StringGLOBAL_ADMIN_UIDDefault global admin UID.
-
Constructor Summary
Constructors Constructor Description ADSContext(ConnectionWrapper connectionWrapper)Constructor of the ADSContext.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateAdminData(String backendName)Creates the Administration Data in the server.voidcreateAdministrator(Map<ADSContext.AdministratorProperty,Object> adminProperties)Creates an Administrator in the ADS.voiddeleteAdministrator(Map<ADSContext.AdministratorProperty,Object> adminProperties)Deletes the administrator in the ADS.static DNgetAdministrationSuffixDN()Returns the DN of the suffix that contains the administration data.static DNgetAdministratorContainerDN()Returns the parent entry of the administrator entries.static DNgetAdministratorDN(String uid)Returns the DN of the administrator for a given UID.ConnectionWrappergetConnection()Returns the connection used to retrieve information by this ADSContext.static StringgetDefaultBackendName()Returns the default backend name of the administration data.HostPortgetHostPort()Returns the host name and port number of this connection.Map<String,byte[]>getTrustedCertificates()Return the set of valid (i.e., not tagged as compromised) instance key-pair public-key certificate entries in ADS.booleanhasAdminData()Returnstrueif the server contains Administration Data andfalseotherwise.static booleanisRegistered(ServerDescriptor server, Set<Map<ADSContext.ServerProperty,Object>> registry)Tells whether the provided server is registered in the registry.voidmergeWithRegistry(ADSContext adsCtx)Merge the contents of this ADSContext with the contents of the provided ADSContext.Set<Map<ADSContext.AdministratorProperty,Object>>readAdministratorRegistry()Returns a set containing the administrators that are defined in the ADS.Set<Map<ADSContext.ServerProperty,Object>>readServerRegistry()Returns a set containing the servers that are registered in the ADS.intregisterOrUpdateServer(Map<ADSContext.ServerProperty,Object> serverProperties)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.voidregisterServer(Map<ADSContext.ServerProperty,Object> serverProperties)Method called to register a server in the ADS.voidremoveAdminData(boolean removeAdministrators)Removes the administration data.StringtoString()voidunregisterServer(Map<ADSContext.ServerProperty,Object> serverProperties)Method called to unregister a server in the ADS.
-
-
-
Field Detail
-
GLOBAL_ADMIN_UID
public static final String GLOBAL_ADMIN_UID
Default global admin UID.- See Also:
- Constant Field Values
-
-
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
-
registerServer
public void registerServer(Map<ADSContext.ServerProperty,Object> serverProperties) throws ADSContextException
Method called to register a server in the ADS.- Parameters:
serverProperties- the properties of the server.- Throws:
ADSContextException- if the server could not be registered.
-
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 inregisterServer()) 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.
-
readServerRegistry
public Set<Map<ADSContext.ServerProperty,Object>> readServerRegistry() throws ADSContextException
Returns a set containing the servers that are registered in the ADS.- Returns:
- a set containing the servers that are registered in the ADS.
- Throws:
ADSContextException- if something goes wrong.
-
readAdministratorRegistry
public Set<Map<ADSContext.AdministratorProperty,Object>> readAdministratorRegistry() throws ADSContextException
Returns a set containing the administrators that are defined in the ADS.- Returns:
- a set containing the administrators that are defined in the 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.nullto use the default backend name for the admin information.- Throws:
ADSContextException- if something goes wrong.
-
removeAdminData
public void removeAdminData(boolean removeAdministrators) throws ADSContextExceptionRemoves the administration data.- Parameters:
removeAdministrators-trueif 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 ADSContextExceptionReturnstrueif the server contains Administration Data andfalseotherwise.- Returns:
trueif the server contains Administration Data andfalseotherwise.- 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:
-
createAdministrator
public void createAdministrator(Map<ADSContext.AdministratorProperty,Object> adminProperties) throws ADSContextException
Creates an Administrator in the ADS.- Parameters:
adminProperties- the properties of the administrator to be created.- Throws:
ADSContextException- if something goes wrong.
-
deleteAdministrator
public void deleteAdministrator(Map<ADSContext.AdministratorProperty,Object> adminProperties) throws ADSContextException
Deletes the administrator in the ADS.- Parameters:
adminProperties- the properties of the administrator to be deleted.- Throws:
ADSContextException- if something goes wrong.
-
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:
trueif the server is registered in the registry andfalseotherwise.
-
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.
-
-