| | |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | | import javax.naming.directory.DirContext; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.messages.BackendMessages; |
| | | import org.opends.messages.CoreMessages; |
| | |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | | import org.forgerock.opendj.config.client.ldap.LDAPManagementContext; |
| | | import org.forgerock.opendj.server.config.client.BackendCfgClient; |
| | | import org.forgerock.opendj.server.config.client.CryptoManagerCfgClient; |
| | | import org.forgerock.opendj.server.config.client.ReplicationDomainCfgClient; |
| | |
| | | |
| | | /** |
| | | * Deletes a backend on the server. |
| | | * @param ctx the connection to the server. |
| | | * @param connWrapper the connection to the server. |
| | | * @param backendName the name of the backend to be deleted. |
| | | * @param serverDisplay the server display. |
| | | * @throws ApplicationException if something goes wrong. |
| | | */ |
| | | public void deleteBackend(InitialLdapContext ctx, String backendName, |
| | | String serverDisplay) |
| | | throws ApplicationException |
| | | public void deleteBackend(ConnectionWrapper connWrapper, String backendName, String serverDisplay) |
| | | throws ApplicationException |
| | | { |
| | | try |
| | | { |
| | | ManagementContext mCtx = LDAPManagementContext.createFromContext( |
| | | JNDIDirContextAdaptor.adapt(ctx)); |
| | | RootCfgClient root = mCtx.getRootConfiguration(); |
| | | root.removeBackend(backendName); |
| | | connWrapper.getRootConfiguration().removeBackend(backendName); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | |
| | | /** |
| | | * Creates a database backend on the server. |
| | | * |
| | | * @param ctx |
| | | * @param connWrapper |
| | | * the connection to the server. |
| | | * @param backendName |
| | | * the name of the backend to be created. |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | public void createBackend(DirContext ctx, String backendName, Set<String> baseDNs, String serverDisplay, |
| | | ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType) |
| | | public void createBackend(ConnectionWrapper connWrapper, String backendName, Set<String> baseDNs, |
| | | String serverDisplay, ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType) |
| | | throws ApplicationException |
| | | { |
| | | try |
| | | { |
| | | ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx)); |
| | | RootCfgClient root = mCtx.getRootConfiguration(); |
| | | RootCfgClient root = connWrapper.getRootConfiguration(); |
| | | BackendCfgClient backend = root.createBackend(backendType, backendName, null); |
| | | backend.setEnabled(true); |
| | | backend.setBaseDN(toByteStrings(baseDNs)); |
| | |
| | | |
| | | /** |
| | | * Sets the base DNs on a given backend. |
| | | * @param ctx the connection to the server. |
| | | * @param connWrapper the connection to the server. |
| | | * @param backendName the name of the backend where the base Dns must be |
| | | * defined. |
| | | * @param baseDNs the list of base DNs to be defined on the server. |
| | | * @param serverDisplay the server display. |
| | | * @throws ApplicationException if something goes wrong. |
| | | */ |
| | | public void setBaseDns(InitialLdapContext ctx, |
| | | String backendName, |
| | | Set<String> baseDNs, |
| | | String serverDisplay) |
| | | throws ApplicationException |
| | | public void setBaseDns(ConnectionWrapper connWrapper, String backendName, Set<String> baseDNs, String serverDisplay) |
| | | throws ApplicationException |
| | | { |
| | | try |
| | | { |
| | | ManagementContext mCtx = LDAPManagementContext.createFromContext( |
| | | JNDIDirContextAdaptor.adapt(ctx)); |
| | | RootCfgClient root = mCtx.getRootConfiguration(); |
| | | BackendCfgClient backend = root.getBackend(backendName); |
| | | BackendCfgClient backend = connWrapper.getRootConfiguration().getBackend(backendName); |
| | | backend.setBaseDN(toByteStrings(baseDNs)); |
| | | backend.commit(); |
| | | } |
| | |
| | | |
| | | /** |
| | | * Configures the replication on a given server. |
| | | * @param remoteCtx the connection to the server where we want to configure |
| | | * @param connWrapper the connection to the server where we want to configure |
| | | * the replication. |
| | | * @param replicationServers a Map where the key value is the base dn and |
| | | * the value is the list of replication servers for that base dn (or domain). |
| | |
| | | * @return a ConfiguredReplication object describing what has been configured. |
| | | */ |
| | | public ConfiguredReplication configureReplication( |
| | | InitialLdapContext remoteCtx, Map<String,Set<String>> replicationServers, |
| | | ConnectionWrapper connWrapper, Map<String,Set<String>> replicationServers, |
| | | int replicationPort, boolean useSecureReplication, String serverDisplay, |
| | | Set<Integer> usedReplicationServerIds, Set<Integer> usedServerIds) |
| | | throws ApplicationException |
| | |
| | | boolean secureReplicationEnabled; |
| | | try |
| | | { |
| | | ManagementContext mCtx = LDAPManagementContext.createFromContext( |
| | | JNDIDirContextAdaptor.adapt(remoteCtx)); |
| | | RootCfgClient root = mCtx.getRootConfiguration(); |
| | | RootCfgClient root = connWrapper.getRootConfiguration(); |
| | | |
| | | /* |
| | | * Configure Synchronization plugin. |
| | |
| | | /** |
| | | * Configures the replication on a given server. |
| | | * |
| | | * @param remoteCtx |
| | | * @param connWrapper |
| | | * the connection to the server where we want to configure the |
| | | * replication. |
| | | * @param replConf |
| | |
| | | * @throws ApplicationException |
| | | * if something goes wrong. |
| | | */ |
| | | public void unconfigureReplication(InitialLdapContext remoteCtx, ConfiguredReplication replConf, String serverDisplay) |
| | | throws ApplicationException |
| | | public void unconfigureReplication(ConnectionWrapper connWrapper, ConfiguredReplication replConf, |
| | | String serverDisplay) throws ApplicationException |
| | | { |
| | | try |
| | | { |
| | | ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(remoteCtx)); |
| | | RootCfgClient root = mCtx.getRootConfiguration(); |
| | | RootCfgClient root = connWrapper.getRootConfiguration(); |
| | | final String syncProvider = "Multimaster Synchronization"; |
| | | // Unconfigure Synchronization plugin. |
| | | if (replConf.isSynchProviderCreated()) |