| | |
| | | import static org.opends.messages.DSConfigMessages.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.client.IllegalManagedObjectNameException; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinitionUsageBuilder; |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.client.IllegalManagedObjectNameException; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinitionResource; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinitionResource; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | |
| | | |
| | | |
| | |
| | | import static org.opends.messages.ToolMessages.INFO_PROPERTY_PLACEHOLDER; |
| | | import static org.opends.messages.ToolMessages.INFO_TYPE_PLACEHOLDER; |
| | | import static org.opends.messages.ToolMessages.INFO_VALUE_SET_PLACEHOLDER; |
| | | import static org.opends.server.admin.PropertyException. |
| | | propertyIsSingleValuedException; |
| | | import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory. |
| | | displayMissingMandatoryPropertyException; |
| | | import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory. |
| | |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectOption; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.PropertyProvider; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.AggregationPropertyDefinition; |
| | | import org.forgerock.opendj.config.Configuration; |
| | | import org.forgerock.opendj.config.ConfigurationClient; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectOption; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinitionUsageBuilder; |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.PropertyOption; |
| | | import org.forgerock.opendj.config.PropertyProvider; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.client.ConcurrentModificationException; |
| | | import org.forgerock.opendj.config.client.IllegalManagedObjectNameException; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | import org.forgerock.opendj.config.conditions.Condition; |
| | | import org.forgerock.opendj.config.conditions.ContainsCondition; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.IllegalManagedObjectNameException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.admin.condition.Condition; |
| | | import org.opends.server.admin.condition.ContainsCondition; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | |
| | | values.add(value); |
| | | |
| | | if (values.size() > 1 && !pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | PropertyException e = propertyIsSingleValuedException(pd); |
| | | PropertyException e = PropertyException.propertyIsSingleValuedException(pd); |
| | | throw ArgumentExceptionFactory.adaptPropertyException(e, d); |
| | | } |
| | | |
| | |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } |
| | |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, e |
| | | .getMessageObject(), e); |
| | | } |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage()); |
| | | if (app.isInteractive()) { |
| | | app.println(); |
| | |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(irelation |
| | | .getUserFriendlyName()); |
| | | throw new ClientException(ReturnCode.TODO, msg); |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(irelation |
| | | .getUserFriendlyName(), e.getMessage()); |
| | | throw new ClientException(ReturnCode.TODO, msg); |
| | |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } |
| | | catch (CommunicationException e) |
| | | catch (ErrorResultException e) |
| | | { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e |
| | | .getMessage()); |
| | |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.AttributeTypePropertyDefinition; |
| | | import org.opends.server.admin.ClassLoaderProvider; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.Tag; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.forgerock.opendj.config.ConfigurationFramework; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.Tag; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ArgumentGroup; |
| | |
| | | * program. |
| | | */ |
| | | public static void main(String[] args) { |
| | | int exitCode = main(args, true, System.out, System.err); |
| | | int exitCode = main(args, System.out, System.err); |
| | | if (exitCode != 0) { |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | |
| | | * @param args |
| | | * The set of command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer |
| | | * Indicates whether to perform basic initialization (which |
| | | * should not be done if the tool is running in the same |
| | | * JVM as the server). |
| | | * @param outStream |
| | | * The output stream for standard output. |
| | | * @param errStream |
| | |
| | | * @return Zero to indicate that the program completed successfully, |
| | | * or non-zero to indicate that an error occurred. |
| | | */ |
| | | public static int main(String[] args, boolean initializeServer, |
| | | OutputStream outStream, OutputStream errStream) { |
| | | public static int main(String[] args, OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | JDKLogging.disableLogging(); |
| | | DSConfig app = new DSConfig(System.in, outStream, errStream, |
| | | new LDAPManagementContextFactory(alwaysSSL)); |
| | | DSConfig app = |
| | | new DSConfig(System.in, outStream, errStream, |
| | | new LDAPManagementContextFactory(alwaysSSL)); |
| | | app.sessionStartTime = System.currentTimeMillis(); |
| | | // Only initialize the client environment when run as a standalone |
| | | // application. |
| | | if (initializeServer) { |
| | | try { |
| | | app.initializeClientEnvironment(); |
| | | } catch (InitializationException e) { |
| | | // TODO: is this ok as an error message? |
| | | /* |
| | | * FIXME: obtain path info from system properties. |
| | | */ |
| | | if (!ConfigurationFramework.getInstance().isInitialized()) |
| | | { |
| | | try |
| | | { |
| | | ConfigurationFramework.getInstance().initialize( |
| | | DirectoryServer.getServerRoot(), DirectoryServer.getInstanceRoot()); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | app.println(e.getMessageObject()); |
| | | return 1; |
| | | } |
| | |
| | | private BooleanArgument advancedModeArgument; |
| | | |
| | | /** |
| | | * Flag indicating whether or not the application environment has already been |
| | | * initialized. |
| | | */ |
| | | private boolean environmentInitialized = false; |
| | | |
| | | /** |
| | | * The factory which the application should use to retrieve its management |
| | | * context. |
| | | */ |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Initializes core APIs for use when dsconfig will be run as a |
| | | * standalone application. |
| | | * |
| | | * @throws InitializationException |
| | | * If the core APIs could not be initialized. |
| | | */ |
| | | private void initializeClientEnvironment() throws InitializationException { |
| | | if (!environmentInitialized) { |
| | | EmbeddedUtils.initializeForClientUse(); |
| | | |
| | | // Bootstrap definition classes. |
| | | ClassLoaderProvider.getInstance().enable(); |
| | | |
| | | // Switch off class name validation in client. |
| | | ClassPropertyDefinition.setAllowClassValidation(false); |
| | | |
| | | // Switch off attribute type name validation in client. |
| | | AttributeTypePropertyDefinition.setCheckSchema(false); |
| | | |
| | | environmentInitialized = true; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAdvancedMode() { |
| | |
| | | allArguments.addAll(initialArgs); |
| | | String[] allArgsArray = allArguments.toArray(new String[]{}); |
| | | |
| | | int exitCode = |
| | | main(allArgsArray, false, getOutputStream(), getErrorStream()); |
| | | if (exitCode != 0) { |
| | | int exitCode = main(allArgsArray, getOutputStream(), getErrorStream()); |
| | | if (exitCode != 0) |
| | | { |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | | errPrintln(); |
| | |
| | | import java.util.SortedMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.client.ConcurrentModificationException; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } |
| | | |
| | | // Add the naming arguments if they were provided. |
| | |
| | | import java.util.SortedSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.AliasDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefaultBehaviorProviderVisitor; |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.SingletonRelationDefinition; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.forgerock.opendj.config.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.AliasDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.DefaultBehaviorProviderVisitor; |
| | | import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyOption; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.SingletonRelationDefinition; |
| | | import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.client.ConcurrentModificationException; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.AdministratorAction; |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.AliasDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefaultBehaviorProviderVisitor; |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.EnumPropertyDefinition; |
| | | import org.opends.server.admin.ManagedObjectOption; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.PropertyDefinitionVisitor; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.StringPropertyDefinition; |
| | | import org.opends.server.admin.Tag; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.forgerock.opendj.config.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.AdministratorAction; |
| | | import org.forgerock.opendj.config.AggregationPropertyDefinition; |
| | | import org.forgerock.opendj.config.AliasDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.DefaultBehaviorProviderVisitor; |
| | | import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.EnumPropertyDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectOption; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinitionUsageBuilder; |
| | | import org.forgerock.opendj.config.PropertyDefinitionVisitor; |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.PropertyOption; |
| | | import org.forgerock.opendj.config.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.StringPropertyDefinition; |
| | | import org.forgerock.opendj.config.Tag; |
| | | import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | |
| | | */ |
| | | package org.opends.server.tools.dsconfig; |
| | | |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_LONG_HELP; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_SHORT_HELP; |
| | | import static org.opends.messages.DSConfigMessages.*; |
| | | import static org.forgerock.util.Utils.closeSilently; |
| | | |
| | | import java.security.GeneralSecurityException; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import javax.naming.NamingException; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import javax.naming.AuthenticationException; |
| | | import javax.net.ssl.KeyManager; |
| | | import javax.net.ssl.SSLException; |
| | | import javax.net.ssl.SSLHandshakeException; |
| | | import javax.net.ssl.TrustManager; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.config.client.ldap.LDAPManagementContext; |
| | | import org.forgerock.opendj.config.LDAPProfile; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.LDAPConnectionFactory; |
| | | import org.forgerock.opendj.ldap.LDAPOptions; |
| | | import org.forgerock.opendj.ldap.SSLContextBuilder; |
| | | import org.forgerock.opendj.ldap.TrustManagers; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.OpendsCertificateException; |
| | | import org.opends.server.admin.client.AuthenticationException; |
| | | import org.opends.server.admin.client.AuthenticationNotSupportedException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.cli.SecureConnectionCliArgs; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | | import org.opends.server.admin.client.ldap.LDAPConnection; |
| | | import org.opends.server.admin.client.ldap.LDAPManagementContext; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode; |
| | | import org.opends.server.util.cli.LDAPConnectionConsoleInteraction; |
| | | |
| | |
| | | @Override |
| | | public void close() |
| | | { |
| | | if (context != null) |
| | | { |
| | | context.close(); |
| | | } |
| | | closeSilently(context); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | KeyManager keyManager = ci.getKeyManager(); |
| | | |
| | | // Do we have a secure connection ? |
| | | LDAPConnection conn ; |
| | | Connection connection; |
| | | final LDAPOptions options = new LDAPOptions(); |
| | | options.setConnectTimeout(ci.getConnectTimeout(), TimeUnit.MILLISECONDS); |
| | | LDAPConnectionFactory factory = null; |
| | | if (ci.useSSL()) |
| | | { |
| | | InitialLdapContext ctx; |
| | | String ldapsUrl = "ldaps://" + hostName + ":" + portNumber; |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | ctx = ConnectionUtils.createLdapsContext(ldapsUrl, bindDN, |
| | | bindPassword, ci.getConnectTimeout(), null, |
| | | trustManager, keyManager); |
| | | ctx.reconnect(null); |
| | | conn = JNDIDirContextAdaptor.adapt(ctx); |
| | | final SSLContextBuilder sslBuilder = new SSLContextBuilder(); |
| | | sslBuilder.setTrustManager((trustManager==null?TrustManagers.trustAll():trustManager)); |
| | | sslBuilder.setKeyManager(keyManager); |
| | | sslBuilder.setProtocol(SSLContextBuilder.PROTOCOL_SSL); |
| | | options.setUseStartTLS(false); |
| | | options.setSSLContext(sslBuilder.getSSLContext()); |
| | | |
| | | factory = new LDAPConnectionFactory(hostName, portNumber, options); |
| | | connection = factory.getConnection(); |
| | | connection.bind(bindDN, bindPassword.toCharArray()); |
| | | break; |
| | | } |
| | | catch (NamingException e) |
| | | catch (ErrorResultException e) |
| | | { |
| | | if (app.isInteractive() |
| | | && ci.isTrustStoreInMemory() |
| | | && e.getRootCause() != null |
| | | && e.getRootCause().getCause() instanceof OpendsCertificateException) |
| | | && e.getCause() != null |
| | | && e.getCause() instanceof SSLException |
| | | && e.getCause().getCause() instanceof CertificateException) |
| | | { |
| | | OpendsCertificateException oce = |
| | | (OpendsCertificateException) e.getRootCause().getCause(); |
| | | String authType = null; |
| | | if (trustManager instanceof ApplicationTrustManager) |
| | | { |
| | | { // FIXME use PromptingTrustManager |
| | | ApplicationTrustManager appTrustManager = |
| | | (ApplicationTrustManager) trustManager; |
| | | authType = appTrustManager.getLastRefusedAuthType(); |
| | | } |
| | | if (ci.checkServerCertificate(oce.getChain(), authType, hostName)) |
| | | { |
| | | // If the certificate is trusted, update the trust manager. |
| | | trustManager = ci.getTrustManager(); |
| | | // Try to connect again. |
| | | continue; |
| | | X509Certificate[] cert = appTrustManager.getLastRefusedChain(); |
| | | |
| | | if (ci.checkServerCertificate(cert, authType, hostName)) |
| | | { |
| | | // If the certificate is trusted, update the trust manager. |
| | | trustManager = ci.getTrustManager(); |
| | | // Try to connect again. |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | if (e.getRootCause() != null) { |
| | | if (e.getRootCause().getCause() != null |
| | | && (e.getRootCause().getCause() instanceof OpendsCertificateException |
| | | || e.getRootCause() instanceof SSLHandshakeException)) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get( |
| | | hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | if (e.getRootCause() instanceof SSLException) { |
| | | final LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | if (e.getCause() != null && e.getCause() instanceof SSLException) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get( |
| | | hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | final LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT |
| | | .get(hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | catch (GeneralSecurityException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT |
| | | .get(hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else if (ci.useStartTLS()) |
| | | { |
| | | InitialLdapContext ctx; |
| | | String ldapUrl = "ldap://" + hostName + ":" + portNumber; |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | ctx = ConnectionUtils.createStartTLSContext(ldapUrl, bindDN, |
| | | bindPassword, ConnectionUtils.getDefaultLDAPTimeout(), null, |
| | | trustManager, keyManager, null); |
| | | ctx.reconnect(null); |
| | | conn = JNDIDirContextAdaptor.adapt(ctx); |
| | | final SSLContextBuilder sslBuilder = new SSLContextBuilder(); |
| | | sslBuilder.setTrustManager((trustManager == null ? TrustManagers |
| | | .trustAll() : trustManager)); |
| | | sslBuilder.setKeyManager(keyManager); |
| | | sslBuilder.setProtocol(SSLContextBuilder.PROTOCOL_SSL); |
| | | options.setUseStartTLS(true); |
| | | options.setSSLContext(sslBuilder.getSSLContext()); |
| | | |
| | | factory = new LDAPConnectionFactory(hostName, portNumber, options); |
| | | connection = factory.getConnection(); |
| | | connection.bind(bindDN, bindPassword.toCharArray()); |
| | | break; |
| | | } |
| | | catch (NamingException e) |
| | | catch (ErrorResultException e) |
| | | { |
| | | if ( app.isInteractive() && ci.isTrustStoreInMemory()) |
| | | if (app.isInteractive() |
| | | && ci.isTrustStoreInMemory() |
| | | && e.getCause() != null |
| | | && e.getCause() instanceof SSLException |
| | | && e.getCause().getCause() instanceof CertificateException) |
| | | { |
| | | if (e.getRootCause() != null |
| | | && e.getRootCause().getCause() instanceof OpendsCertificateException) |
| | | { |
| | | String authType = null; |
| | | if (trustManager instanceof ApplicationTrustManager) |
| | | { |
| | | ApplicationTrustManager appTrustManager = |
| | | (ApplicationTrustManager)trustManager; |
| | | authType = appTrustManager.getLastRefusedAuthType(); |
| | | } |
| | | OpendsCertificateException oce = |
| | | (OpendsCertificateException) e.getRootCause().getCause(); |
| | | if (ci.checkServerCertificate(oce.getChain(), authType, |
| | | hostName)) |
| | | { |
| | | // If the certificate is trusted, update the trust manager. |
| | | trustManager = ci.getTrustManager(); |
| | | String authType = null; |
| | | if (trustManager instanceof ApplicationTrustManager) |
| | | { // FIXME use PromptingTrustManager |
| | | ApplicationTrustManager appTrustManager = |
| | | (ApplicationTrustManager) trustManager; |
| | | authType = appTrustManager.getLastRefusedAuthType(); |
| | | X509Certificate[] cert = appTrustManager.getLastRefusedChain(); |
| | | |
| | | // Try to connect again. |
| | | continue ; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | hostName, portNumber); |
| | | throw new ClientException( |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | if (ci.checkServerCertificate(cert, authType, hostName)) |
| | | { |
| | | // If the certificate is trusted, update the trust manager. |
| | | trustManager = ci.getTrustManager(); |
| | | // Try to connect again. |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | hostName, portNumber); |
| | | throw new ClientException( |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | if (e.getCause() != null && e.getCause() instanceof SSLException) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get( |
| | | hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT |
| | | .get(hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | catch (GeneralSecurityException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT |
| | | .get(hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | { // FIXME The dsconfig is always using secure connection. This code can be |
| | | // removed in this case but statusCli and uninstall are also using it. Cleanup needed. |
| | | // Create the management context. |
| | | try |
| | | { |
| | | conn = JNDIDirContextAdaptor.simpleBind(hostName, portNumber, |
| | | bindDN, bindPassword); |
| | | factory = new LDAPConnectionFactory(hostName, portNumber, options); |
| | | connection = factory.getConnection(); |
| | | connection.bind(bindDN, bindPassword.toCharArray()); |
| | | } |
| | | catch (AuthenticationNotSupportedException e) |
| | | catch (ErrorResultException e) |
| | | { |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_SIMPLE_BIND_NOT_SUPPORTED |
| | | .get(); |
| | | throw new ClientException(ReturnCode.AUTH_METHOD_NOT_SUPPORTED, |
| | | message); |
| | | } |
| | | catch (AuthenticationException e) |
| | | { |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_SIMPLE_BIND_FAILED |
| | | .get(bindDN); |
| | | throw new ClientException(ReturnCode.INVALID_CREDENTIALS, |
| | | message); |
| | | } |
| | | catch (CommunicationException e) |
| | | { |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | hostName, portNumber); |
| | | if (e.getCause() instanceof AuthorizationException) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_SIMPLE_BIND_NOT_SUPPORTED.get(); |
| | | throw new ClientException(ReturnCode.AUTH_METHOD_NOT_SUPPORTED, |
| | | message); |
| | | } |
| | | else if (e.getCause() instanceof AuthenticationException) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_SIMPLE_BIND_FAILED.get(bindDN); |
| | | throw new ClientException(ReturnCode.INVALID_CREDENTIALS, message); |
| | | } |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | finally |
| | | { |
| | | factory.close(); |
| | | } |
| | | } |
| | | context = LDAPManagementContext.createFromContext(conn); |
| | | context = |
| | | LDAPManagementContext.newManagementContext(connection, LDAPProfile.getInstance()); |
| | | } |
| | | return context; |
| | | } |
| | |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectOption; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectOption; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.client.ConcurrentModificationException; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | |
| | | */ |
| | | package org.opends.server.tools.dsconfig; |
| | | |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | |
| | | /** |
| | | * This class is a data structure that can be used as an interface between |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.AggregationPropertyDefinition; |
| | | import org.forgerock.opendj.config.AliasDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.BooleanPropertyDefinition; |
| | | import org.forgerock.opendj.config.Configuration; |
| | | import org.forgerock.opendj.config.ConfigurationClient; |
| | | import org.forgerock.opendj.config.DefaultBehaviorProviderVisitor; |
| | | import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.EnumPropertyDefinition; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinitionUsageBuilder; |
| | | import org.forgerock.opendj.config.PropertyDefinitionVisitor; |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.PropertyOption; |
| | | import org.forgerock.opendj.config.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.AliasDefaultBehaviorProvider; |
| | | import org.opends.server.admin.BooleanPropertyDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.DefaultBehaviorProviderVisitor; |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.EnumPropertyDefinition; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.PropertyDefinitionVisitor; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | |
| | | .getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (CommunicationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | } catch (ErrorResultException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (CommunicationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | } catch (ErrorResultException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (CommunicationException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | } catch (ErrorResultException e) { |
| | | this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage())); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.admin.BooleanPropertyDefinition; |
| | | import org.opends.server.admin.DurationPropertyDefinition; |
| | | import org.opends.server.admin.DurationUnit; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyValueVisitor; |
| | | import org.opends.server.admin.SizePropertyDefinition; |
| | | import org.opends.server.admin.SizeUnit; |
| | | import org.forgerock.opendj.config.BooleanPropertyDefinition; |
| | | import org.forgerock.opendj.config.DurationPropertyDefinition; |
| | | import org.forgerock.opendj.config.DurationUnit; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyValueVisitor; |
| | | import org.forgerock.opendj.config.SizePropertyDefinition; |
| | | import org.forgerock.opendj.config.SizeUnit; |
| | | |
| | | |
| | | |
| | |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.SingletonRelationDefinition; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.forgerock.opendj.config.AggregationPropertyDefinition; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.PropertyOption; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.SingletonRelationDefinition; |
| | | import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.client.ConcurrentModificationException; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | import org.forgerock.opendj.config.conditions.Condition; |
| | | import org.forgerock.opendj.config.conditions.ContainsCondition; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.admin.condition.Condition; |
| | | import org.opends.server.admin.condition.ContainsCondition; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, e |
| | | .getMessageObject(), e); |
| | | } |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectAlreadyExistsException e) { |
| | |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_AUTHZ.get(ufn); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (CommunicationException e) { |
| | | } catch (ErrorResultException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } |
| | |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.DurationUnit; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectOption; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.ManagedObjectPathSerializer; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.SingletonRelationDefinition; |
| | | import org.opends.server.admin.SizeUnit; |
| | | import org.opends.server.admin.Tag; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.Configuration; |
| | | import org.forgerock.opendj.config.ConfigurationClient; |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.config.DurationUnit; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectNotFoundException; |
| | | import org.forgerock.opendj.config.ManagedObjectOption; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.ManagedObjectPathSerializer; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinition; |
| | | import org.forgerock.opendj.config.PropertyDefinitionUsageBuilder; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.SingletonRelationDefinition; |
| | | import org.forgerock.opendj.config.SizeUnit; |
| | | import org.forgerock.opendj.config.Tag; |
| | | import org.forgerock.opendj.config.client.ConcurrentModificationException; |
| | | import org.forgerock.opendj.config.client.IllegalManagedObjectNameException; |
| | | import org.forgerock.opendj.config.client.ManagedObject; |
| | | import org.forgerock.opendj.config.client.ManagedObjectDecodingException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.ldap.AuthorizationException; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.IllegalManagedObjectNameException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | |
| | | |
| | | private CommunicationException ce; |
| | | |
| | | private ErrorResultException ere; |
| | | |
| | | /** |
| | | * Any CLI exception that was caught when attempting to find the managed |
| | | * object. |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | cme = e; |
| | | result = MenuResult.quit(); |
| | | } catch (ErrorResultException e) { |
| | | ere = e; |
| | | result = MenuResult.quit(); |
| | | } catch (CommunicationException e) { |
| | | ce = e; |
| | | result = MenuResult.quit(); |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | cme = e; |
| | | result = MenuResult.quit(); |
| | | } catch (CommunicationException e) { |
| | | ce = e; |
| | | } catch (ErrorResultException e) { |
| | | ere = e; |
| | | result = MenuResult.quit(); |
| | | } |
| | | } |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | cme = e; |
| | | result = MenuResult.quit(); |
| | | } catch (ErrorResultException e) { |
| | | ere = e; |
| | | result = MenuResult.quit(); |
| | | } catch (CommunicationException e) { |
| | | ce = e; |
| | | result = MenuResult.quit(); |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | cme = e; |
| | | result = MenuResult.quit(); |
| | | } catch (CommunicationException e) { |
| | | ce = e; |
| | | } catch (ErrorResultException e) { |
| | | ere = e; |
| | | result = MenuResult.quit(); |
| | | } |
| | | } |
| | |
| | | app.println(); |
| | | |
| | | // Filter out advanced and hidden types if required. |
| | | String[] childNames; |
| | | if (r instanceof InstantiableRelationDefinition) { |
| | | childNames = |
| | | parent.listChildren((InstantiableRelationDefinition<C,S>)r, d); |
| | | } else { |
| | | childNames = parent.listChildren((SetRelationDefinition<C,S>)r, d); |
| | | String[] childNames = null; |
| | | try { |
| | | if (r instanceof InstantiableRelationDefinition) |
| | | { |
| | | childNames = |
| | | parent.listChildren((InstantiableRelationDefinition<C, S>) r, d); |
| | | } |
| | | else |
| | | { |
| | | childNames = parent.listChildren((SetRelationDefinition<C, S>) r, d); |
| | | } |
| | | } catch (ErrorResultException e) { |
| | | // FIXME check exceptions |
| | | System.out.println(String.format("An error occured %s", e.getMessage())); |
| | | } |
| | | |
| | | SortedMap<String, String> children = new TreeMap<String, String>( |
| | | String.CASE_INSENSITIVE_ORDER); |
| | | |
| | |
| | | children.put(childName, childName); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | // Skip it - the managed object has been concurrently removed. |
| | | } catch (ErrorResultException e) { |
| | | // Add it anyway: maybe the user is trying to fix the problem. |
| | | children.put(childName, childName); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.RelationDefinitionVisitor; |
| | | import org.opends.server.admin.RelationOption; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.SingletonRelationDefinition; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.Configuration; |
| | | import org.forgerock.opendj.config.ConfigurationClient; |
| | | import org.forgerock.opendj.config.InstantiableRelationDefinition; |
| | | import org.forgerock.opendj.config.ManagedObjectPath; |
| | | import org.forgerock.opendj.config.OptionalRelationDefinition; |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.RelationDefinitionVisitor; |
| | | import org.forgerock.opendj.config.RelationOption; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | import org.forgerock.opendj.config.SingletonRelationDefinition; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | |
| | | import org.opends.guitools.controlpanel.util.ControlPanelLog; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.admin.AdministrationConnector; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.cli.SecureConnectionCliArgs; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.tools.dsconfig.LDAPManagementContextFactory; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | | |
| | | import org.opends.server.util.cli.LDAPConnectionConsoleInteraction; |
| | | |
| | | import com.forgerock.opendj.cli.TableBuilder; |
| | | import com.forgerock.opendj.cli.TextTablePrinter; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | |
| | | System.arraycopy(args, 0, fullArgs, 11, args.length); |
| | | |
| | | assertEquals(DSConfig.main(fullArgs, false, System.out, System.err), 0); |
| | | assertEquals(DSConfig.main(fullArgs, System.out, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.SASL_MECHANISM_DIGEST_MD5; |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertFalse; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta. |
| | | DigestMD5SASLMechanismHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server. |
| | | DigestMD5SASLMechanismHandlerCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.meta.DigestMD5SASLMechanismHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.DigestMD5SASLMechanismHandlerCfg; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @AfterClass |
| | | @AfterClass(alwaysRun = true) |
| | | public void tearDown() throws Exception { |
| | | TestCaseUtils.dsconfig( |
| | | "set-sasl-mechanism-handler-prop", |
| | |
| | | "-X" |
| | | }; |
| | | |
| | | assertFalse(DSConfig.main(args, false, System.out, System.err) |
| | | == SUCCESS.get()); |
| | | assertFalse(DSConfig.main(args, System.out, System.err) == SUCCESS.get()); |
| | | } |
| | | |
| | | /** |
| | |
| | | "-X" |
| | | }; |
| | | |
| | | assertFalse(DSConfig.main(args, false, System.out, System.err) |
| | | == SUCCESS.get()); |
| | | assertFalse(DSConfig.main(args, System.out, System.err) == SUCCESS.get()); |
| | | } |
| | | |
| | | /** |
| | |
| | | "-X" |
| | | }; |
| | | |
| | | assertFalse(DSConfig.main(args, false, System.out, System.err) |
| | | == SUCCESS.get()); |
| | | assertFalse(DSConfig.main(args, System.out, System.err) == SUCCESS.get()); |
| | | } |
| | | |
| | | /** |
| | | * Tests list-connection-handlers with an valid password. |
| | | */ |
| | | @Test() |
| | | public void testValidBindPassword() |
| | | { |
| | | String[] args = |
| | | { |
| | | "-n", |
| | | "--noPropertiesFile", |
| | | "-Q", |
| | | "list-connection-handlers", |
| | | "-p", String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-X" |
| | | }; |
| | | |
| | | assertTrue(DSConfig.main(args, System.out, System.err) == SUCCESS.get()); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | "-X" |
| | | }; |
| | | |
| | | assertEquals(DSConfig.main(args, false, System.out, |
| | | System.err), SUCCESS.get()); |
| | | assertEquals(DSConfig.main(args, System.out, System.err), SUCCESS.get()); |
| | | } |
| | | |
| | | /** |
| | |
| | | "-X" |
| | | }; |
| | | |
| | | assertFalse(DSConfig.main(args, false, System.out, System.err) |
| | | == SUCCESS.get()); |
| | | assertFalse(DSConfig.main(args, System.out, System.err) == SUCCESS.get()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests list-connection-handlers over SSL using a trust store. |
| | | */ |
| | |
| | | "-P", trustStorePath |
| | | }; |
| | | |
| | | assertEquals(DSConfig.main(args, false, System.out, |
| | | System.err), SUCCESS.get()); |
| | | assertEquals(DSConfig.main(args, System.out, System.err), SUCCESS.get()); |
| | | } |
| | | |
| | | |
| | |
| | | public void testHelp() |
| | | { |
| | | String[] args = { "--noPropertiesFile", "--help" }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), |
| | | SUCCESS.get()); |
| | | assertEquals(DSConfig.main(args, System.out, System.err), SUCCESS.get()); |
| | | |
| | | args = new String[] { "--noPropertiesFile", "-H" }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), |
| | | SUCCESS.get()); |
| | | assertEquals(DSConfig.main(args, System.out, System.err), SUCCESS.get()); |
| | | |
| | | args = new String[] { "--noPropertiesFile", "-?" }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), |
| | | SUCCESS.get()); |
| | | assertEquals(DSConfig.main(args, System.out, System.err), SUCCESS.get()); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | } |
| | | |
| | | /** |
| | | * Ensures ADS is removed. |
| | | */ |
| | | @AfterClass() |
| | | public void afterClass() throws Exception |
| | | { |
| | | |
| | | @AfterClass(alwaysRun = true) |
| | | public void tearDown() throws Exception { |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "delete-connection-handler", |
| | | "--handler-name", "HTTP Connection Handler", |
| | | "-f"); |
| | | } |
| | | |
| | | @Test() |
| | | public void testSetEnableHTTPConnectionHandler() { |
| | | |
| | | final String[] args = |
| | | { |
| | | "set-connection-handler-prop", |
| | | "-p", String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "--trustAll", |
| | | "--bindDN","cn=Directory Manager", |
| | | "--bindPassword" , "password", |
| | | "--no-prompt", |
| | | "--handler-name", "HTTP Connection Handler", |
| | | "--set", "authentication-required:false" |
| | | }; |
| | | assertTrue(dsconfigMain(args) == SUCCESSFUL.getReturnCode()); |
| | | } |
| | | |
| | | @Test() |
| | | public void testSetSASLHandler() { |
| | | final String[] args = |
| | | { |
| | | "set-sasl-mechanism-handler-prop", |
| | | "-p", String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "--trustAll", |
| | | "--bindDN","cn=Directory Manager", |
| | | "--bindPassword" , "password", |
| | | "--no-prompt", |
| | | "--handler-name", "DIGEST-MD5", |
| | | "--set", "server-fqdn:" + "127.0.0.1" |
| | | }; |
| | | assertTrue(dsconfigMain(args) == SUCCESSFUL.getReturnCode()); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-sasl-mechanism-handler-prop", |
| | | "--handler-name", "DIGEST-MD5", |
| | | "--reset", "server-fqdn", |
| | | "--reset", "quality-of-protection"); |
| | | } |
| | | |
| | | |
| | | @Test() |
| | | public void testSetMaxAllowedClientConnections() { |
| | | final String[] args = |
| | | { |
| | | "set-global-configuration-prop", |
| | | "-p", String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "--trustAll", |
| | | "--bindDN","cn=Directory Manager", |
| | | "--bindPassword" , "password", |
| | | "--no-prompt", |
| | | "--set", "max-allowed-client-connections:32768" |
| | | }; |
| | | assertTrue(dsconfigMain(args) == SUCCESSFUL.getReturnCode()); |
| | | } |
| | | |
| | | @Test() |
| | | public void testSetReturnBindPassword() throws Exception |
| | | { |
| | | final String[] args = |
| | | { |
| | | "set-global-configuration-prop", |
| | | "-p", String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "--trustAll", |
| | | "--bindDN","cn=Directory Manager", |
| | | "--bindPassword" , "password", |
| | | "--no-prompt", |
| | | "--set", "return-bind-error-messages:true" |
| | | }; |
| | | assertTrue(dsconfigMain(args) == SUCCESSFUL.getReturnCode()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Tests that multiple "--set" option cannot be used with a singlevalued |
| | | * Tests that multiple "--set" option cannot be used with a single valued |
| | | * property |
| | | */ |
| | | @Test() |
| | | public void testMultipleSetSingleValuedProperty() throws Exception |
| | | { |
| | | String[] args = |
| | | final String[] args = |
| | | { |
| | | "set-global-configuration-prop", |
| | | "-p",String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "-p", String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "--trustAll", |
| | | "--bindDN","cn=Directory Manager", |
| | | "--bindPassword" , "password", |
| | |
| | | }; |
| | | assertTrue(dsconfigMain(args) != SUCCESSFUL.getReturnCode()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Tests that multiple "--set" option are allowed to be used with a multivalued |
| | | * property (see OPENDJ-255) |
| | |
| | | @Test() |
| | | public void testMultipleSetMultiValuedProperty() throws Exception |
| | | { |
| | | String[] args = |
| | | final String[] args = |
| | | { |
| | | "set-connection-handler-prop", |
| | | "--handler-name", "LDAP Connection Handler", |
| | | "-p",String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "-p", String.valueOf(TestCaseUtils.getServerAdminPort()), |
| | | "--trustAll", |
| | | "--bindDN","cn=Directory Manager", |
| | | "--bindPassword" , "password", |
| | |
| | | }; |
| | | assertEquals(dsconfigMain(args), SUCCESSFUL.getReturnCode()); |
| | | } |
| | | |
| | | @Test |
| | | |
| | | @Test() |
| | | public void testGenerateDoc() throws Exception |
| | | { |
| | | System.setProperty("org.forgerock.opendj.gendoc", "true"); |
| | | String[] args = { |
| | | final String[] args = { |
| | | "--no-prompt", |
| | | "-?", |
| | | }; |
| | |
| | | |
| | | private int dsconfigMain(String[] args) |
| | | { |
| | | return DSConfig.main(args, false, System.out, System.err); |
| | | return DSConfig.main(args, System.out, System.err); |
| | | } |
| | | |
| | | } |