org.opends.admin.ads
Class ADSContext

java.lang.Object
  extended by org.opends.admin.ads.ADSContext

public class ADSContext
extends java.lang.Object

Class used to update and read the contents of the Administration Data.


Nested Class Summary
static class ADSContext.AdministratorProperty
          The enumeration containing the different Administrator properties.
static class ADSContext.ADSPropertySyntax
          Enumeration containing the different server properties syntaxes that could be stored in the ADS.
static class ADSContext.ServerGroupProperty
          Enumeration containing the different server group properties that are stored in the ADS.
static class ADSContext.ServerProperty
          Enumeration containing the different server properties that are stored in the ADS.
 
Field Summary
static java.lang.String ALL_SERVERGROUP_NAME
          The default server group which will contain all registered servers.
static java.lang.String GLOBAL_ADMIN_UID
          Default global admin UID.
 
Constructor Summary
ADSContext(javax.naming.ldap.InitialLdapContext dirContext)
          Constructor of the ADSContext.
 
Method Summary
 void createAdminData(java.lang.String backendName)
          Creates the Administration Data in the server.
 void createAdministrationSuffix(java.lang.String backendName)
          Creates the Administration Suffix.
 void createAdministrator(java.util.Map<ADSContext.AdministratorProperty,java.lang.Object> adminProperties)
          Creates an Administrator in the ADS.
 void createServerGroup(java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object> serverGroupProperties)
          Creates a Server Group in the ADS.
 void deleteAdministrator(java.util.Map<ADSContext.AdministratorProperty,java.lang.Object> adminProperties)
          Deletes the administrator in the ADS.
 void deleteServerGroup(java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object> serverGroupProperties)
          Deletes a Server Group in the ADS.
static java.lang.String getAdministrationSuffixDN()
          Returns the DN of the suffix that contains the administration data.
static java.lang.String getAdministratorContainerDN()
          Returns the parent entry of the administrator entries.
static java.lang.String getAdministratorDN(java.lang.String uid)
          Returns the DN of the administrator for a given UID.
static java.lang.String getAdminLDIFFile()
          Returns the LDIF file of the administration data.
static ADSContext.AdministratorProperty getAdminUserPropFromName(java.lang.String name)
          Get a AdministratorProperty associated to a name.
static java.lang.String getDefaultBackendName()
          Returns the default backend name of the administration data.
 javax.naming.ldap.InitialLdapContext getDirContext()
          Returns the DirContext used to retrieve information by this ADSContext.
static java.lang.String getInstanceKeysContainerDN()
          Returns the parent entry of the server key entries in ADS.
static java.lang.String getSecretKeysContainerDN()
          Returns the parent entry of the secret key entries in ADS.
 java.util.Set<java.lang.String> getServerGroupMemberList(java.lang.String serverGroupId)
          Returns the member list of a group of server.
static java.lang.String getServerIdFromServerProperties(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties)
          This method returns the DN of the entry that corresponds to the given server properties.
static ADSContext.ServerProperty getServerPropFromName(java.lang.String name)
          Get a ServerProperty associated to a name.
 java.util.Map<java.lang.String,byte[]> getTrustedCertificates()
          Return the set of valid (i.e., not tagged as compromised) instance key-pair public-key certificate entries in ADS.
 boolean hasAdminData()
          Returns true if the server contains Administration Data and false otherwise.
 boolean isAdministratorAlreadyRegistered(java.util.Map<ADSContext.AdministratorProperty,java.lang.Object> adminProperties)
          Returns whether a given administrator is already registered or not.
 boolean isServerAlreadyRegistered(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties)
          Returns whether a given server is already registered or not.
 java.util.Set<java.util.Map<ADSContext.AdministratorProperty,java.lang.Object>> readAdministratorRegistry()
          Returns a set containing the administrators that are defined in the ADS.
 java.util.Set<java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object>> readServerGroupRegistry()
          Returns a set containing the server groups that are defined in the ADS.
 java.util.Set<java.util.Map<ADSContext.ServerProperty,java.lang.Object>> readServerRegistry()
          Returns a set containing the servers that are registered in the ADS.
 int registerOrUpdateServer(java.util.Map<ADSContext.ServerProperty,java.lang.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.
 void registerServer(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties)
          Method called to register a server in the ADS.
 void removeAdminData()
          Removes the administration data.
 void removeServerGroupProp(java.lang.String groupID, java.util.Set<ADSContext.ServerGroupProperty> serverGroupProperties)
          Updates the properties of a Server Group in the ADS.
 void unregisterServer(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties)
          Method called to unregister a server in the ADS.
 void updateAdministrator(java.util.Map<ADSContext.AdministratorProperty,java.lang.Object> adminProperties, java.lang.String newAdminUserId)
          Updates and administrator registered in the ADS.
 void updateServer(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties, java.lang.String newServerId)
          Method called to udpate the properties of a server in the ADS.
 void updateServerGroup(java.lang.String groupID, java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object> serverGroupProperties)
          Updates the properties of a Server Group in the ADS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL_ADMIN_UID

public static final java.lang.String GLOBAL_ADMIN_UID
Default global admin UID.

See Also:
Constant Field Values

ALL_SERVERGROUP_NAME

public static final java.lang.String ALL_SERVERGROUP_NAME
The default server group which will contain all registered servers.

See Also:
Constant Field Values
Constructor Detail

ADSContext

public ADSContext(javax.naming.ldap.InitialLdapContext dirContext)
Constructor of the ADSContext.

Parameters:
dirContext - the DirContext that must be used to retrieve information.
Method Detail

getServerPropFromName

public static ADSContext.ServerProperty getServerPropFromName(java.lang.String name)
Get a ServerProperty associated to a name.

Parameters:
name - The name of the property to retrieve.
Returns:
The corresponding ServerProperty or null if name doesn't match with an existing property.

getAdminUserPropFromName

public static ADSContext.AdministratorProperty getAdminUserPropFromName(java.lang.String name)
Get a AdministratorProperty associated to a name.

Parameters:
name - The name of the property to retrieve.
Returns:
The corresponding AdministratorProperty or null if name doesn't match with an existing property.

getDirContext

public javax.naming.ldap.InitialLdapContext getDirContext()
Returns the DirContext used to retrieve information by this ADSContext.

Returns:
the DirContext used to retrieve information by this ADSContext.

registerServer

public void registerServer(java.util.Map<ADSContext.ServerProperty,java.lang.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.

updateServer

public void updateServer(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties,
                         java.lang.String newServerId)
                  throws ADSContextException
Method called to udpate the properties of a server in the ADS.

Parameters:
serverProperties - the new properties of the server.
newServerId - The new server Identifier, or null.
Throws:
ADSContextException - if the server could not be registered.

unregisterServer

public void unregisterServer(java.util.Map<ADSContext.ServerProperty,java.lang.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.

isServerAlreadyRegistered

public boolean isServerAlreadyRegistered(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties)
                                  throws ADSContextException
Returns whether a given server is already registered or not.

Parameters:
serverProperties - the server properties.
Returns:
true if the server was registered and false otherwise.
Throws:
ADSContextException - if something went wrong.

isAdministratorAlreadyRegistered

public boolean isAdministratorAlreadyRegistered(java.util.Map<ADSContext.AdministratorProperty,java.lang.Object> adminProperties)
                                         throws ADSContextException
Returns whether a given administrator is already registered or not.

Parameters:
adminProperties - the administrator properties.
Returns:
true if the administrator was registered and false otherwise.
Throws:
ADSContextException - if something went wrong.

registerOrUpdateServer

public int registerOrUpdateServer(java.util.Map<ADSContext.ServerProperty,java.lang.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 udpated (i.e., the server entry was already in ADS).
Throws:
ADSContextException - if something goes wrong.

getServerGroupMemberList

public java.util.Set<java.lang.String> getServerGroupMemberList(java.lang.String serverGroupId)
                                                         throws ADSContextException
Returns the member list of a group of server.

Parameters:
serverGroupId - The group name.
Returns:
the member list of a group of server.
Throws:
ADSContextException - if something goes wrong.

readServerRegistry

public java.util.Set<java.util.Map<ADSContext.ServerProperty,java.lang.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.

createServerGroup

public void createServerGroup(java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object> serverGroupProperties)
                       throws ADSContextException
Creates a Server Group in the ADS.

Parameters:
serverGroupProperties - the properties of the server group to be created.
Throws:
ADSContextException - if somethings goes wrong.

updateServerGroup

public void updateServerGroup(java.lang.String groupID,
                              java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object> serverGroupProperties)
                       throws ADSContextException
Updates the properties of a Server Group in the ADS.

Parameters:
serverGroupProperties - the new properties of the server group to be updated.
groupID - The group name.
Throws:
ADSContextException - if somethings goes wrong.

removeServerGroupProp

public void removeServerGroupProp(java.lang.String groupID,
                                  java.util.Set<ADSContext.ServerGroupProperty> serverGroupProperties)
                           throws ADSContextException
Updates the properties of a Server Group in the ADS.

Parameters:
serverGroupProperties - the new properties of the server group to be updated.
groupID - The group name.
Throws:
ADSContextException - if somethings goes wrong.

deleteServerGroup

public void deleteServerGroup(java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object> serverGroupProperties)
                       throws ADSContextException
Deletes a Server Group in the ADS.

Parameters:
serverGroupProperties - the properties of the server group to be deleted.
Throws:
ADSContextException - if somethings goes wrong.

readServerGroupRegistry

public java.util.Set<java.util.Map<ADSContext.ServerGroupProperty,java.lang.Object>> readServerGroupRegistry()
                                                                                                      throws ADSContextException
Returns a set containing the server groups that are defined in the ADS.

Returns:
a set containing the server groups that are defined in the ADS.
Throws:
ADSContextException - if something goes wrong.

readAdministratorRegistry

public java.util.Set<java.util.Map<ADSContext.AdministratorProperty,java.lang.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(java.lang.String backendName)
                     throws ADSContextException
Creates the Administration Data in the server. The call to this method assumes that OpenDS.jar has already been loaded. So this should not be called by the Java Web Start before being sure that this jar is 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()
                     throws ADSContextException
Removes the administration data.

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 java.lang.String getAdministratorDN(java.lang.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(java.util.Map<ADSContext.AdministratorProperty,java.lang.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(java.util.Map<ADSContext.AdministratorProperty,java.lang.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.

updateAdministrator

public void updateAdministrator(java.util.Map<ADSContext.AdministratorProperty,java.lang.Object> adminProperties,
                                java.lang.String newAdminUserId)
                         throws ADSContextException
Updates and administrator registered in the ADS.

Parameters:
adminProperties - the new properties of the administrator.
newAdminUserId - The new admin user Identifier, or null.
Throws:
ADSContextException - if something goes wrong.

getAdministrationSuffixDN

public static java.lang.String getAdministrationSuffixDN()
Returns the DN of the suffix that contains the administration data.

Returns:
the DN of the suffix that contains the administration data.

getServerIdFromServerProperties

public static java.lang.String getServerIdFromServerProperties(java.util.Map<ADSContext.ServerProperty,java.lang.Object> serverProperties)
                                                        throws ADSContextException
This method returns the DN of the entry that corresponds to the given server properties.

Parameters:
serverProperties - the server properties.
Returns:
the DN of the entry that corresponds to the given server properties.
Throws:
ADSContextException - if something goes wrong.

getAdministratorContainerDN

public static java.lang.String getAdministratorContainerDN()
Returns the parent entry of the administrator entries.

Returns:
the parent entry of the administrator entries.

createAdministrationSuffix

public void createAdministrationSuffix(java.lang.String backendName)
                                throws ADSContextException
Creates the Administration Suffix.

Parameters:
backendName - the backend name to be used for the Administration Suffix. If this value is null the default backendName for the Administration Suffix will be used.
Throws:
ADSContextException - if something goes wrong.

getDefaultBackendName

public static java.lang.String getDefaultBackendName()
Returns the default backend name of the administration data.

Returns:
the default backend name of the administration data.

getAdminLDIFFile

public static java.lang.String getAdminLDIFFile()
Returns the LDIF file of the administration data.

Returns:
the LDIF file of the administration data.

getInstanceKeysContainerDN

public static java.lang.String getInstanceKeysContainerDN()
Returns the parent entry of the server key entries in ADS.

Returns:
the parent entry of the server key entries in ADS.

getSecretKeysContainerDN

public static java.lang.String getSecretKeysContainerDN()
Returns the parent entry of the secret key entries in ADS.

Returns:
the parent entry of the secret key entries in ADS.

getTrustedCertificates

public java.util.Map<java.lang.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()