AutoRefactored comments/javadocs on OpenDJ SDK
| | |
| | | * order to provide specific functionality. |
| | | */ |
| | | public abstract class Argument { |
| | | // Indicates whether this argument should be hidden in the usage |
| | | // information. |
| | | /** |
| | | * Indicates whether this argument should be hidden in the usage |
| | | * information. |
| | | */ |
| | | private boolean isHidden; |
| | | |
| | | // Indicates whether this argument may be specified more than once for |
| | | // multiple values. |
| | | /** |
| | | * Indicates whether this argument may be specified more than once for |
| | | * multiple values. |
| | | */ |
| | | private boolean isMultiValued; |
| | | |
| | | // Indicates whether this argument was provided in the set of |
| | | // command-line arguments. |
| | | /** |
| | | * Indicates whether this argument was provided in the set of |
| | | * command-line arguments. |
| | | */ |
| | | private boolean isPresent; |
| | | |
| | | // Indicates whether this argument is required to have a value. |
| | | /** Indicates whether this argument is required to have a value. */ |
| | | private boolean isRequired; |
| | | |
| | | // Indicates whether this argument requires a value. |
| | | /** Indicates whether this argument requires a value. */ |
| | | private boolean needsValue; |
| | | |
| | | // The single-character identifier for this argument. |
| | | /** The single-character identifier for this argument. */ |
| | | private final Character shortIdentifier; |
| | | |
| | | // The unique ID of the description for this argument. |
| | | /** The unique ID of the description for this argument. */ |
| | | private final LocalizableMessage description; |
| | | |
| | | // The set of values for this argument. |
| | | /** The set of values for this argument. */ |
| | | private final LinkedList<String> values; |
| | | |
| | | // The default value for the argument if none other is provided. |
| | | /** The default value for the argument if none other is provided. */ |
| | | private String defaultValue; |
| | | |
| | | // The long identifier for this argument. |
| | | /** The long identifier for this argument. */ |
| | | private final String longIdentifier; |
| | | |
| | | // The generic name that will be used to refer to this argument. |
| | | /** The generic name that will be used to refer to this argument. */ |
| | | private final String name; |
| | | |
| | | // The name of the property that can be used to set the default value. |
| | | /** The name of the property that can be used to set the default value. */ |
| | | private String propertyName; |
| | | |
| | | // The value placeholder for this argument, which will be used in |
| | | // usage information. |
| | | /** |
| | | * The value placeholder for this argument, which will be used in |
| | | * usage information. |
| | | */ |
| | | private LocalizableMessage valuePlaceholder; |
| | | |
| | | // Indicates whether this argument was provided in the set of |
| | | // properties found is a properties file. |
| | | /** |
| | | * Indicates whether this argument was provided in the set of |
| | | * properties found is a properties file. |
| | | */ |
| | | private boolean isValueSetByProperty; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final String OPTION_LONG_RESTART = "restart"; |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ArgumentConstants() { |
| | | |
| | | } |
| | |
| | | */ |
| | | @SuppressWarnings("serial") |
| | | public final class ArgumentException extends Exception implements LocalizableException { |
| | | // The I18N message associated with this exception. |
| | | /** The I18N message associated with this exception. */ |
| | | private final LocalizableMessage message; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public final class ArgumentGroup implements Comparable<ArgumentGroup> { |
| | | |
| | | // Description for this group of arguments |
| | | /** Description for this group of arguments. */ |
| | | private LocalizableMessage description = null; |
| | | |
| | | // List of arguments belonging to this group |
| | | /** List of arguments belonging to this group. */ |
| | | private List<Argument> args = null; |
| | | |
| | | // Governs groups position within usage statement |
| | | /** Governs groups position within usage statement. */ |
| | | private final Integer priority; |
| | | |
| | | /** |
| | |
| | | public static final String GLOBAL_ADMIN_UID = "admin"; |
| | | |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private CliConstants() { |
| | | |
| | | } |
| | |
| | | */ |
| | | public final class CommonArguments { |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private CommonArguments() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | * multiple lines, then only the first line will be read. |
| | | */ |
| | | public final class FileBasedArgument extends Argument { |
| | | // The mapping between filenames specified and the first lines read |
| | | // from those files. |
| | | /** |
| | | * The mapping between filenames specified and the first lines read |
| | | * from those files. |
| | | */ |
| | | private final LinkedHashMap<String, String> namesToValues; |
| | | |
| | | /** |
| | |
| | | * potentially only those in a given range. |
| | | */ |
| | | public final class IntegerArgument extends Argument { |
| | | // Indicates whether a lower bound will be enforced for this argument. |
| | | /** Indicates whether a lower bound will be enforced for this argument. */ |
| | | private final boolean hasLowerBound; |
| | | |
| | | // Indicates whether an upper bound will be enforced for this |
| | | // argument. |
| | | /** |
| | | * Indicates whether an upper bound will be enforced for this |
| | | * argument. |
| | | */ |
| | | private final boolean hasUpperBound; |
| | | |
| | | // The lower bound that will be enforced for this argument. |
| | | /** The lower bound that will be enforced for this argument. */ |
| | | private final int lowerBound; |
| | | |
| | | // The upper bound that will be enforced for this argument. |
| | | /** The upper bound that will be enforced for this argument. */ |
| | | private final int upperBound; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private static final class CompositeCallback<T> implements MenuCallback<T> { |
| | | |
| | | // The list of underlying call-backs. |
| | | /** The list of underlying call-backs. */ |
| | | private final Collection<MenuCallback<T>> callbacks; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private static final class MenuImpl<T> implements Menu<T> { |
| | | |
| | | // Indicates whether the menu will allow selection of multiple |
| | | // numeric options. |
| | | /** |
| | | * Indicates whether the menu will allow selection of multiple |
| | | * numeric options. |
| | | */ |
| | | private final boolean allowMultiSelect; |
| | | |
| | | // The application console. |
| | | /** The application console. */ |
| | | private final ConsoleApplication app; |
| | | |
| | | // The call-back lookup table. |
| | | /** The call-back lookup table. */ |
| | | private final Map<String, MenuCallback<T>> callbacks; |
| | | |
| | | // The char options table builder. |
| | | /** The char options table builder. */ |
| | | private final TableBuilder cbuilder; |
| | | |
| | | // The call-back for the optional default action. |
| | | /** The call-back for the optional default action. */ |
| | | private final MenuCallback<T> defaultCallback; |
| | | |
| | | // The description of the optional default action. |
| | | /** The description of the optional default action. */ |
| | | private final LocalizableMessage defaultDescription; |
| | | |
| | | // The numeric options table builder. |
| | | /** The numeric options table builder. */ |
| | | private final TableBuilder nbuilder; |
| | | |
| | | // The table printer. |
| | | /** The table printer. */ |
| | | private final TablePrinter printer; |
| | | |
| | | // The menu prompt. |
| | | /** The menu prompt. */ |
| | | private final LocalizableMessage prompt; |
| | | |
| | | // The menu title. |
| | | /** The menu title. */ |
| | | private final LocalizableMessage title; |
| | | |
| | | // The maximum number of times we display the menu if the user provides |
| | | // bad input (-1 for unlimited). |
| | | /** |
| | | * The maximum number of times we display the menu if the user provides |
| | | * bad input (-1 for unlimited). |
| | | */ |
| | | private int nMaxTries; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private MenuImpl(ConsoleApplication app, LocalizableMessage title, LocalizableMessage prompt, |
| | | TableBuilder ntable, TableBuilder ctable, TablePrinter printer, Map<String, MenuCallback<T>> callbacks, |
| | | boolean allowMultiSelect, MenuCallback<T> defaultCallback, LocalizableMessage defaultDescription, |
| | |
| | | */ |
| | | private static final class ResultCallback<T> implements MenuCallback<T> { |
| | | |
| | | // The result to be returned by this call-back. |
| | | /** The result to be returned by this call-back. */ |
| | | private final MenuResult<T> result; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ResultCallback(MenuResult<T> result) { |
| | | this.result = result; |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | // The multiple column display threshold. |
| | | /** The multiple column display threshold. */ |
| | | private int threshold = -1; |
| | | |
| | | // Indicates whether the menu will allow selection of multiple |
| | | // numeric options. |
| | | /** |
| | | * Indicates whether the menu will allow selection of multiple |
| | | * numeric options. |
| | | */ |
| | | private boolean allowMultiSelect = false; |
| | | |
| | | // The application console. |
| | | /** The application console. */ |
| | | private final ConsoleApplication app; |
| | | |
| | | // The char option call-backs. |
| | | /** The char option call-backs. */ |
| | | private final List<MenuCallback<T>> charCallbacks = new ArrayList<MenuCallback<T>>(); |
| | | |
| | | // The char option keys (must be single-character messages). |
| | | /** The char option keys (must be single-character messages). */ |
| | | private final List<LocalizableMessage> charKeys = new ArrayList<LocalizableMessage>(); |
| | | |
| | | // The synopsis of char options. |
| | | /** The synopsis of char options. */ |
| | | private final List<LocalizableMessage> charSynopsis = new ArrayList<LocalizableMessage>(); |
| | | |
| | | // Optional column headings. |
| | | /** Optional column headings. */ |
| | | private final List<LocalizableMessage> columnHeadings = new ArrayList<LocalizableMessage>(); |
| | | |
| | | // Optional column widths. |
| | | /** Optional column widths. */ |
| | | private final List<Integer> columnWidths = new ArrayList<Integer>(); |
| | | |
| | | // The call-back for the optional default action. |
| | | /** The call-back for the optional default action. */ |
| | | private MenuCallback<T> defaultCallback = null; |
| | | |
| | | // The description of the optional default action. |
| | | /** The description of the optional default action. */ |
| | | private LocalizableMessage defaultDescription = null; |
| | | |
| | | // The numeric option call-backs. |
| | | /** The numeric option call-backs. */ |
| | | private final List<MenuCallback<T>> numericCallbacks = new ArrayList<MenuCallback<T>>(); |
| | | |
| | | // The numeric option fields. |
| | | /** The numeric option fields. */ |
| | | private final List<List<LocalizableMessage>> numericFields = new ArrayList<List<LocalizableMessage>>(); |
| | | |
| | | // The menu title. |
| | | /** The menu title. */ |
| | | private LocalizableMessage title = null; |
| | | |
| | | // The menu prompt. |
| | | /** The menu prompt. */ |
| | | private LocalizableMessage prompt = null; |
| | | |
| | | // The maximum number of times that we allow the user to provide an invalid |
| | | // answer (-1 if unlimited). |
| | | /** |
| | | * The maximum number of times that we allow the user to provide an invalid |
| | | * answer (-1 if unlimited). |
| | | */ |
| | | private int nMaxTries = -1; |
| | | |
| | | /** |
| | |
| | | return success(Collections.singleton(value)); |
| | | } |
| | | |
| | | // The type of result returned from the menu. |
| | | /** The type of result returned from the menu. */ |
| | | private final Type type; |
| | | |
| | | // The menu result value(s). |
| | | /** The menu result value(s). */ |
| | | private final Collection<T> values; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private MenuResult(Type type, Collection<T> values) { |
| | | this.type = type; |
| | | this.values = values; |
| | |
| | | * The type of values returned by this argument. |
| | | */ |
| | | public final class MultiChoiceArgument<T> extends Argument { |
| | | // Indicates whether argument values should be treated in a |
| | | // case-sensitive manner. |
| | | /** |
| | | * Indicates whether argument values should be treated in a |
| | | * case-sensitive manner. |
| | | */ |
| | | private final boolean caseSensitive; |
| | | |
| | | // The set of values that will be allowed for use with this argument. |
| | | /** The set of values that will be allowed for use with this argument. */ |
| | | private final Collection<T> allowedValues; |
| | | |
| | | /** |
| | |
| | | * argument parser. The subcommand has a name, a description, and a set of arguments. |
| | | */ |
| | | public class SubCommand { |
| | | // Indicates whether this subCommand should be hidden in the usage |
| | | // information. |
| | | /** |
| | | * Indicates whether this subCommand should be hidden in the usage |
| | | * information. |
| | | */ |
| | | private boolean isHidden; |
| | | |
| | | // The mapping between the short argument IDs and the arguments for this |
| | | // subcommand. |
| | | /** |
| | | * The mapping between the short argument IDs and the arguments for this |
| | | * subcommand. |
| | | */ |
| | | private HashMap<Character, Argument> shortIDMap; |
| | | |
| | | // The mapping between the long argument IDs and the arguments for this |
| | | // subcommand. |
| | | /** |
| | | * The mapping between the long argument IDs and the arguments for this |
| | | * subcommand. |
| | | */ |
| | | private HashMap<String, Argument> longIDMap; |
| | | |
| | | // The list of arguments associated with this subcommand. |
| | | /** The list of arguments associated with this subcommand. */ |
| | | private LinkedList<Argument> arguments; |
| | | |
| | | // The description for this subcommand. |
| | | /** The description for this subcommand. */ |
| | | private LocalizableMessage description; |
| | | |
| | | // The name of this subcommand. |
| | | /** The name of this subcommand. */ |
| | | private String name; |
| | | |
| | | // The argument parser with which this subcommand is associated. |
| | | /** The argument parser with which this subcommand is associated. */ |
| | | private SubCommandArgumentParser parser; |
| | | |
| | | // Indicates whether this parser will allow additional unnamed |
| | | // arguments at the end of the list. |
| | | /** |
| | | * Indicates whether this parser will allow additional unnamed |
| | | * arguments at the end of the list. |
| | | */ |
| | | private boolean allowsTrailingArguments; |
| | | |
| | | // The maximum number of unnamed trailing arguments that may be |
| | | // provided. |
| | | /** |
| | | * The maximum number of unnamed trailing arguments that may be |
| | | * provided. |
| | | */ |
| | | private int maxTrailingArguments; |
| | | |
| | | // The minimum number of unnamed trailing arguments that may be |
| | | // provided. |
| | | /** |
| | | * The minimum number of unnamed trailing arguments that may be |
| | | * provided. |
| | | */ |
| | | private int minTrailingArguments; |
| | | |
| | | // The display name that will be used for the trailing arguments in |
| | | // the usage information. |
| | | /** |
| | | * The display name that will be used for the trailing arguments in |
| | | * the usage information. |
| | | */ |
| | | private String trailingArgsDisplayName; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public final class TableBuilder { |
| | | |
| | | // The current column number in the current row where 0 represents |
| | | // the left-most column in the table. |
| | | /** |
| | | * The current column number in the current row where 0 represents |
| | | * the left-most column in the table. |
| | | */ |
| | | private int column = 0; |
| | | |
| | | // The current with of each column. |
| | | /** The current with of each column. */ |
| | | private List<Integer> columnWidths = new ArrayList<Integer>(); |
| | | |
| | | // The list of column headings. |
| | | /** The list of column headings. */ |
| | | private List<LocalizableMessage> header = new ArrayList<LocalizableMessage>(); |
| | | |
| | | // The current number of rows in the table. |
| | | /** The current number of rows in the table. */ |
| | | private int height = 0; |
| | | |
| | | // The list of table rows. |
| | | /** The list of table rows. */ |
| | | private List<List<String>> rows = new ArrayList<List<String>>(); |
| | | |
| | | // The linked list of sort keys comparators. |
| | | /** The linked list of sort keys comparators. */ |
| | | private List<Comparator<String>> sortComparators = new ArrayList<Comparator<String>>(); |
| | | |
| | | // The linked list of sort keys. |
| | | /** The linked list of sort keys. */ |
| | | private List<Integer> sortKeys = new ArrayList<Integer>(); |
| | | |
| | | // The current number of columns in the table. |
| | | /** The current number of columns in the table. */ |
| | | private int width = 0; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private final class Serializer extends TableSerializer { |
| | | |
| | | /*The real column widths taking into account size constraints but |
| | | /**The real column widths taking into account size constraints but |
| | | not including padding or separators.*/ |
| | | private final List<Integer> columnWidths = new ArrayList<Integer>(); |
| | | |
| | | // The cells in the current row. |
| | | /** The cells in the current row. */ |
| | | private final List<String> currentRow = new ArrayList<String>(); |
| | | |
| | | // Width of the table in columns. |
| | | /** Width of the table in columns. */ |
| | | private int totalColumns = 0; |
| | | |
| | | // The padding to use for indenting the table. |
| | | /** The padding to use for indenting the table. */ |
| | | private final String indentPadding; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private Serializer() { |
| | | // Compute the indentation padding. |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | currentRow.clear(); |
| | | } |
| | | |
| | | // We need to calculate the effective width of each column. |
| | | /** We need to calculate the effective width of each column. */ |
| | | private void determineColumnWidths() { |
| | | // First calculate the minimum width so that we know how much |
| | | // expandable columns can expand. |
| | |
| | | */ |
| | | private static final int DEFAULT_PADDING = 1; |
| | | |
| | | // The string which should be used to separate one column |
| | | // from the next (not including padding). |
| | | /** |
| | | * The string which should be used to separate one column |
| | | * from the next (not including padding). |
| | | */ |
| | | private String columnSeparator = DEFAULT_COLUMN_SEPARATOR; |
| | | |
| | | // Indicates whether or not the headings should be output. |
| | | /** Indicates whether or not the headings should be output. */ |
| | | private boolean displayHeadings = true; |
| | | |
| | | // Table indicating whether or not a column is fixed width. |
| | | /** Table indicating whether or not a column is fixed width. */ |
| | | private final Map<Integer, Integer> fixedColumns = new HashMap<Integer, Integer>(); |
| | | |
| | | // The number of characters the table should be indented. |
| | | /** The number of characters the table should be indented. */ |
| | | private int indentWidth = 0; |
| | | |
| | | // The character which should be used to separate the table |
| | | // heading row from the rows beneath. |
| | | /** |
| | | * The character which should be used to separate the table |
| | | * heading row from the rows beneath. |
| | | */ |
| | | private char headingSeparator = DEFAULT_HEADING_SEPARATOR; |
| | | |
| | | // The column where the heading separator should begin. |
| | | /** The column where the heading separator should begin. */ |
| | | private int headingSeparatorStartColumn = 0; |
| | | |
| | | // The padding which will be used to separate a cell's |
| | | // contents from its adjacent column separators. |
| | | /** |
| | | * The padding which will be used to separate a cell's |
| | | * contents from its adjacent column separators. |
| | | */ |
| | | private int padding = DEFAULT_PADDING; |
| | | |
| | | // Total permitted width for the table which expandable columns |
| | | // can use up. |
| | | /** |
| | | * Total permitted width for the table which expandable columns |
| | | * can use up. |
| | | */ |
| | | private int totalWidth = MAX_LINE_WIDTH; |
| | | |
| | | // The output destination. |
| | | /** The output destination. */ |
| | | private PrintWriter writer = null; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Utils() { |
| | | // Do nothing. |
| | | } |
| | |
| | | |
| | | private SubCommandArgumentParser parser; |
| | | |
| | | // First sub-command. |
| | | /** First sub-command. */ |
| | | private SubCommand sc1; |
| | | |
| | | // Second sub-command. |
| | | /** Second sub-command. */ |
| | | private SubCommand sc2; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<String, ACIPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected ACIPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, |
| | |
| | | + "(\\s*(?i)version(?-i)\\s*(\\d\\.\\d)\\s*;\\s*(?i)acl(?-i)\\s*\"([^\"]*)" |
| | | + "\"\\s*;\\s*\\s*(\\w+)\\s*\\(([^()]+)\\)\\s*(.+?\"[)]*)\\s*;\\s*\\s*\\)\\s*$"); |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ACIPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<String> defaultBehavior) { |
| | | super(d, String.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitACI(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitACI(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(String o1, String o2) { |
| | | return o1.toString().compareTo(o2.toString()); |
| | |
| | | */ |
| | | public final class AbsoluteInheritedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | // The absolute path to the managed object containing the property. |
| | | /** The absolute path to the managed object containing the property. */ |
| | | private ManagedObjectPath<?, ?> path = null; |
| | | |
| | | // The string representation of the managed object path specifying |
| | | // the absolute location of the managed object. |
| | | /** |
| | | * The string representation of the managed object path specifying |
| | | * the absolute location of the managed object. |
| | | */ |
| | | private final String pathString; |
| | | |
| | | // The name of the property containing the inherited default values. |
| | | /** The name of the property containing the inherited default values. */ |
| | | private final String propertyName; |
| | | |
| | | /** |
| | |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitAbsoluteInherited(this, p); |
| | | } |
| | |
| | | return propertyName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | // Decode the path. |
| | |
| | | */ |
| | | public abstract class AbstractManagedObjectDefinition<C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | // The name of the definition. |
| | | /** The name of the definition. */ |
| | | private final String name; |
| | | |
| | | // The parent managed object definition if applicable. |
| | | /** The parent managed object definition if applicable. */ |
| | | private final AbstractManagedObjectDefinition<? super C, ? super S> parent; |
| | | |
| | | // The set of constraints associated with this managed object |
| | | // definition. |
| | | /** |
| | | * The set of constraints associated with this managed object |
| | | * definition. |
| | | */ |
| | | private final Collection<Constraint> constraints; |
| | | |
| | | // The set of property definitions applicable to this managed object |
| | | // definition. |
| | | /** |
| | | * The set of property definitions applicable to this managed object |
| | | * definition. |
| | | */ |
| | | private final Map<String, PropertyDefinition<?>> propertyDefinitions; |
| | | |
| | | // The set of relation definitions applicable to this managed object |
| | | // definition. |
| | | /** |
| | | * The set of relation definitions applicable to this managed object |
| | | * definition. |
| | | */ |
| | | private final Map<String, RelationDefinition<?, ?>> relationDefinitions; |
| | | |
| | | // The set of relation definitions directly referencing this managed |
| | | // object definition. |
| | | /** |
| | | * The set of relation definitions directly referencing this managed |
| | | * object definition. |
| | | */ |
| | | private final Set<RelationDefinition<C, S>> reverseRelationDefinitions; |
| | | |
| | | // The set of all property definitions associated with this managed |
| | | // object definition including inherited property definitions. |
| | | /** |
| | | * The set of all property definitions associated with this managed |
| | | * object definition including inherited property definitions. |
| | | */ |
| | | private final Map<String, PropertyDefinition<?>> allPropertyDefinitions; |
| | | |
| | | // The set of all relation definitions associated with this managed |
| | | // object definition including inherited relation definitions. |
| | | /** |
| | | * The set of all relation definitions associated with this managed |
| | | * object definition including inherited relation definitions. |
| | | */ |
| | | private final Map<String, RelationDefinition<?, ?>> allRelationDefinitions; |
| | | |
| | | // The set of aggregation property definitions applicable to this |
| | | // managed object definition. |
| | | /** |
| | | * The set of aggregation property definitions applicable to this |
| | | * managed object definition. |
| | | */ |
| | | private final Map<String, AggregationPropertyDefinition<?, ?>> aggregationPropertyDefinitions; |
| | | |
| | | // The set of aggregation property definitions directly referencing this |
| | | // managed object definition. |
| | | /** |
| | | * The set of aggregation property definitions directly referencing this |
| | | * managed object definition. |
| | | */ |
| | | private final Vector<AggregationPropertyDefinition<?, ?>> reverseAggregationPropertyDefinitions; |
| | | |
| | | // The set of all aggregation property definitions associated with this |
| | | // managed object definition including inherited relation definitions. |
| | | /** |
| | | * The set of all aggregation property definitions associated with this |
| | | * managed object definition including inherited relation definitions. |
| | | */ |
| | | private final Map<String, AggregationPropertyDefinition<?, ?>> allAggregationPropertyDefinitions; |
| | | |
| | | // The set of tags associated with this managed object. |
| | | /** The set of tags associated with this managed object. */ |
| | | private final Set<Tag> allTags; |
| | | |
| | | // Options applicable to this definition. |
| | | /** Options applicable to this definition. */ |
| | | private final Set<ManagedObjectOption> options; |
| | | |
| | | // The set of managed object definitions which inherit from this definition. |
| | | /** The set of managed object definitions which inherit from this definition. */ |
| | | private final Map<String, AbstractManagedObjectDefinition<? extends C, ? extends S>> children; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Register a relation definition in the referenced managed object |
| | | // definition's reverse lookup table. |
| | | /** |
| | | * Register a relation definition in the referenced managed object |
| | | * definition's reverse lookup table. |
| | | */ |
| | | private <C1 extends ConfigurationClient, S1 extends Configuration> void registerReverseRelationDefinition( |
| | | RelationDefinition<C1, S1> rd) { |
| | | rd.getChildDefinition().reverseRelationDefinitions.add(rd); |
| | | } |
| | | |
| | | // Register a aggregation property definition in the referenced managed |
| | | // object |
| | | // definition's reverse lookup table. |
| | | /** |
| | | * Register a aggregation property definition in the referenced managed |
| | | * object definition's reverse lookup table. |
| | | */ |
| | | private void registerReverseAggregationPropertyDefinition(AggregationPropertyDefinition<?, ?> apd) { |
| | | |
| | | apd.getRelationDefinition().getChildDefinition().reverseAggregationPropertyDefinitions.add(apd); |
| | | } |
| | | |
| | | // Recursively descend definition hierarchy to find the best match |
| | | // definition. |
| | | /** |
| | | * Recursively descend definition hierarchy to find the best match |
| | | * definition. |
| | | */ |
| | | private AbstractManagedObjectDefinition<? extends C, ? extends S> resolveManagedObjectDefinitionAux( |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d, DefinitionResolver r) { |
| | | if (!r.matches(d)) { |
| | |
| | | */ |
| | | SERVER_RESTART("server-restart"); |
| | | |
| | | // The user-friendly name of the type. |
| | | /** The user-friendly name of the type. */ |
| | | private final String name; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private Type(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | |
| | | } |
| | | |
| | | // The managed object definition associated with this administrator |
| | | // action. |
| | | /** |
| | | * The managed object definition associated with this administrator |
| | | * action. |
| | | */ |
| | | private final AbstractManagedObjectDefinition<?, ?> definition; |
| | | |
| | | // The name of the property definition associated with this |
| | | // administrator action. |
| | | /** |
| | | * The name of the property definition associated with this |
| | | * administrator action. |
| | | */ |
| | | private final String propertyName; |
| | | |
| | | // The type of administration action. |
| | | /** The type of administration action. */ |
| | | private final Type type; |
| | | |
| | | /** |
| | |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<String, AggregationPropertyDefinition<C, S>> { |
| | | |
| | | // The string representation of the managed object path specifying |
| | | // the parent of the aggregated managed objects. |
| | | /** |
| | | * The string representation of the managed object path specifying |
| | | * the parent of the aggregated managed objects. |
| | | */ |
| | | private String parentPathString = null; |
| | | |
| | | // The name of a relation in the parent managed object which |
| | | // contains the aggregated managed objects. |
| | | /** |
| | | * The name of a relation in the parent managed object which |
| | | * contains the aggregated managed objects. |
| | | */ |
| | | private String rdName = null; |
| | | |
| | | // The condition which is used to determine if a referenced |
| | | // managed object is enabled. |
| | | /** |
| | | * The condition which is used to determine if a referenced |
| | | * managed object is enabled. |
| | | */ |
| | | private Condition targetIsEnabledCondition = Conditions.TRUE; |
| | | |
| | | // The condition which is used to determine whether or not |
| | | // referenced managed objects need to be enabled. |
| | | /** |
| | | * The condition which is used to determine whether or not |
| | | * referenced managed objects need to be enabled. |
| | | */ |
| | | private Condition targetNeedsEnablingCondition = Conditions.TRUE; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | |
| | | this.targetNeedsEnablingCondition = condition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AggregationPropertyDefinition<C, S> buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | */ |
| | | private final class ReferentialIntegrityChangeListener implements ServerManagedObjectChangeListener<S> { |
| | | |
| | | // The error message which should be returned if an attempt is |
| | | // made to disable the referenced component. |
| | | /** |
| | | * The error message which should be returned if an attempt is |
| | | * made to disable the referenced component. |
| | | */ |
| | | private final LocalizableMessage message; |
| | | |
| | | // The path of the referenced component. |
| | | /** The path of the referenced component. */ |
| | | private final ManagedObjectPath<C, S> path; |
| | | |
| | | // Creates a new referential integrity delete listener. |
| | | /** Creates a new referential integrity delete listener. */ |
| | | private ReferentialIntegrityChangeListener(ManagedObjectPath<C, S> path, LocalizableMessage message) { |
| | | this.path = path; |
| | | this.message = message; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ConfigChangeResult applyConfigurationChange(ServerManagedObject<? extends S> mo) { |
| | | try { |
| | | if (targetIsEnabledCondition.evaluate(mo)) { |
| | |
| | | + relationDefinition.getChildDefinition().getUserFriendlyName()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isConfigurationChangeAcceptable(ServerManagedObject<? extends S> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | // Always prevent the referenced component from being |
| | |
| | | } |
| | | } |
| | | |
| | | // Gets the path associated with this listener. |
| | | /** Gets the path associated with this listener. */ |
| | | private ManagedObjectPath<C, S> getManagedObjectPath() { |
| | | return path; |
| | | } |
| | |
| | | */ |
| | | private final class ReferentialIntegrityDeleteListener implements ConfigurationDeleteListener<S> { |
| | | |
| | | // The DN of the referenced configuration entry. |
| | | /** The DN of the referenced configuration entry. */ |
| | | private final DN dn; |
| | | |
| | | // The error message which should be returned if an attempt is |
| | | // made to delete the referenced component. |
| | | /** |
| | | * The error message which should be returned if an attempt is |
| | | * made to delete the referenced component. |
| | | */ |
| | | private final LocalizableMessage message; |
| | | |
| | | // Creates a new referential integrity delete listener. |
| | | /** Creates a new referential integrity delete listener. */ |
| | | private ReferentialIntegrityDeleteListener(DN dn, LocalizableMessage message) { |
| | | this.dn = dn; |
| | | this.message = message; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ConfigChangeResult applyConfigurationDelete(S configuration) { |
| | | // This should not happen - the |
| | | // isConfigurationDeleteAcceptable() call-back should have |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isConfigurationDeleteAcceptable(S configuration, List<LocalizableMessage> unacceptableReasons) { |
| | | if (configuration.dn().equals(dn)) { |
| | | // Always prevent deletion of the referenced component. |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | */ |
| | | private class ServerHandler extends ServerConstraintHandler { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | return isUsable; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostAdd(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // First make sure existing listeners associated with this |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostDelete(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Remove any registered delete and change listeners. |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostModify(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Remove all the constraints associated with this managed |
| | |
| | | */ |
| | | private class SourceClientHandler extends ClientConstraintHandler { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAddAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return isAcceptable; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | */ |
| | | private class TargetClientHandler extends ClientConstraintHandler { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isDeleteAcceptable(ManagementContext context, ManagedObjectPath<?, ?> path, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return isAcceptable; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return isAcceptable; |
| | | } |
| | | |
| | | // Find all managed objects which reference the named managed |
| | | // object using this property. |
| | | /** |
| | | * Find all managed objects which reference the named managed |
| | | * object using this property. |
| | | */ |
| | | private <C1 extends ConfigurationClient> List<ManagedObject<? extends C1>> findReferences( |
| | | ManagementContext context, AbstractManagedObjectDefinition<C1, ?> mod, String name) |
| | | throws LdapException { |
| | |
| | | return instances; |
| | | } |
| | | |
| | | // Find all instances of a specific type of managed object. |
| | | /** Find all instances of a specific type of managed object. */ |
| | | @SuppressWarnings("unchecked") |
| | | private <C1 extends ConfigurationClient> List<ManagedObject<? extends C1>> findInstances( |
| | | ManagementContext context, AbstractManagedObjectDefinition<C1, ?> mod) throws LdapException { |
| | |
| | | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(AggregationPropertyDefinition.class); |
| | | |
| | | // The active server-side referential integrity change listeners |
| | | // associated with this property. |
| | | /** |
| | | * The active server-side referential integrity change listeners |
| | | * associated with this property. |
| | | */ |
| | | private final Map<DN, List<ReferentialIntegrityChangeListener>> changeListeners = |
| | | new HashMap<DN, List<ReferentialIntegrityChangeListener>>(); |
| | | |
| | | // The active server-side referential integrity delete listeners |
| | | // associated with this property. |
| | | /** |
| | | * The active server-side referential integrity delete listeners |
| | | * associated with this property. |
| | | */ |
| | | private final Map<DN, List<ReferentialIntegrityDeleteListener>> deleteListeners = |
| | | new HashMap<DN, List<ReferentialIntegrityDeleteListener>>(); |
| | | |
| | | // The name of the managed object which is the parent of the |
| | | // aggregated managed objects. |
| | | /** |
| | | * The name of the managed object which is the parent of the |
| | | * aggregated managed objects. |
| | | */ |
| | | private ManagedObjectPath<?, ?> parentPath; |
| | | |
| | | // The string representation of the managed object path specifying |
| | | // the parent of the aggregated managed objects. |
| | | /** |
| | | * The string representation of the managed object path specifying |
| | | * the parent of the aggregated managed objects. |
| | | */ |
| | | private final String parentPathString; |
| | | |
| | | // The name of a relation in the parent managed object which |
| | | // contains the aggregated managed objects. |
| | | /** |
| | | * The name of a relation in the parent managed object which |
| | | * contains the aggregated managed objects. |
| | | */ |
| | | private final String rdName; |
| | | |
| | | // The relation in the parent managed object which contains the |
| | | // aggregated managed objects. |
| | | /** |
| | | * The relation in the parent managed object which contains the |
| | | * aggregated managed objects. |
| | | */ |
| | | private InstantiableRelationDefinition<C, S> relationDefinition; |
| | | |
| | | // The source constraint. |
| | | /** The source constraint. */ |
| | | private final Constraint sourceConstraint; |
| | | |
| | | // The condition which is used to determine if a referenced managed |
| | | // object is enabled. |
| | | /** |
| | | * The condition which is used to determine if a referenced managed |
| | | * object is enabled. |
| | | */ |
| | | private final Condition targetIsEnabledCondition; |
| | | |
| | | // The condition which is used to determine whether or not |
| | | // referenced managed objects need to be enabled. |
| | | /** |
| | | * The condition which is used to determine whether or not |
| | | * referenced managed objects need to be enabled. |
| | | */ |
| | | private final Condition targetNeedsEnablingCondition; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private AggregationPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<String> defaultBehavior, String parentPathString, String rdName, |
| | |
| | | this.targetIsEnabledCondition = targetIsEnabledCondition; |
| | | this.sourceConstraint = new Constraint() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | ClientConstraintHandler handler = new SourceClientHandler(); |
| | | return Collections.singleton(handler); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | ServerConstraintHandler handler = new ServerHandler(); |
| | | return Collections.singleton(handler); |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitAggregation(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitAggregation(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return targetNeedsEnablingCondition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(String value) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | builder.append(String.valueOf(targetIsEnabledCondition)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public void initialize() throws Exception { |
| | |
| | | // for actions performed against referenced managed objects. |
| | | Constraint constraint = new Constraint() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | ClientConstraintHandler handler = new TargetClientHandler(); |
| | | return Collections.singleton(handler); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.emptyList(); |
| | | } |
| | |
| | | */ |
| | | public final class AliasDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | // The managed object definition associated with this default |
| | | // behavior. |
| | | /** |
| | | * The managed object definition associated with this default |
| | | * behavior. |
| | | */ |
| | | private final AbstractManagedObjectDefinition<?, ?> definition; |
| | | |
| | | // The name of the property definition associated with this default |
| | | // behavior. |
| | | /** |
| | | * The name of the property definition associated with this default |
| | | * behavior. |
| | | */ |
| | | private final String propertyName; |
| | | |
| | | /** |
| | |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitAlias(this, p); |
| | | } |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<AttributeType, AttributeTypePropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AttributeTypePropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private AttributeTypePropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<AttributeType> defaultBehavior) { |
| | | super(d, AttributeType.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitAttributeType(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, AttributeType value, P p) { |
| | | return v.visitAttributeType(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(AttributeType o1, AttributeType o2) { |
| | | return o1.getNameOrOID().compareToIgnoreCase(o2.getNameOrOID()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(AttributeType value) { |
| | | return value.getNameOrOID(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(AttributeType value) { |
| | | Reject.ifNull(value); |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<Boolean, BooleanPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected BooleanPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private BooleanPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Boolean> defaultBehavior) { |
| | | super(d, Boolean.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Boolean value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Boolean decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitBoolean(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Boolean value, P p) { |
| | | return v.visitBoolean(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Boolean o1, Boolean o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<String, ClassPropertyDefinition> { |
| | | |
| | | // List of interfaces which property values must implement. |
| | | /** List of interfaces which property values must implement. */ |
| | | private List<String> instanceOfInterfaces; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | |
| | |
| | | instanceOfInterfaces.add(value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected ClassPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | |
| | | } |
| | | |
| | | // Regular expression for validating class names. |
| | | /** Regular expression for validating class names. */ |
| | | private static final String CLASS_RE = "^([A-Za-z][A-Za-z0-9_]*\\.)*[A-Za-z][A-Za-z0-9_]*(\\$[A-Za-z0-9_]+)*$"; |
| | | |
| | | /** |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Load a named class. |
| | | /** Load a named class. */ |
| | | private static Class<?> loadClass(String className, boolean initialize) throws ClassNotFoundException { |
| | | return Class.forName(className, initialize, ConfigurationFramework.getInstance().getClassLoader()); |
| | | } |
| | | |
| | | // List of interfaces which property values must implement. |
| | | /** List of interfaces which property values must implement. */ |
| | | private final List<String> instanceOfInterfaces; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ClassPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<String> defaultBehavior, List<String> instanceOfInterfaces) { |
| | |
| | | this.instanceOfInterfaces = Collections.unmodifiableList(new LinkedList<String>(instanceOfInterfaces)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitClass(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitClass(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return theClass.asSubclass(instanceOf); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return value.trim(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /* |
| | | /** |
| | | * Do some basic checks to make sure the string representation is valid. |
| | | */ |
| | | private void validateClassName(String className) { |
| | |
| | | } |
| | | } |
| | | |
| | | /* |
| | | /** |
| | | * Make sure that named class implements the interfaces named by this |
| | | * definition. |
| | | */ |
| | |
| | | .getLocalizedLogger(AdminMessages.resourceName()); |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(ConfigurationFramework.class); |
| | | |
| | | // The name of the lib directory. |
| | | /** The name of the lib directory. */ |
| | | private static final String LIB_DIR = "lib"; |
| | | |
| | | // The name of the extensions directory. |
| | | /** The name of the extensions directory. */ |
| | | private static final String EXTENSIONS_DIR = "extensions"; |
| | | |
| | | // The singleton instance. |
| | | /** The singleton instance. */ |
| | | private static final ConfigurationFramework INSTANCE = new ConfigurationFramework(); |
| | | |
| | | // Attribute name in jar's MANIFEST corresponding to the revision number. |
| | | /** Attribute name in jar's MANIFEST corresponding to the revision number. */ |
| | | private static final String REVISION_NUMBER = "Revision-Number"; |
| | | |
| | | // The attribute names for build information is name, version and revision |
| | | // number |
| | | /** |
| | | * The attribute names for build information is name, version and revision |
| | | * number. |
| | | */ |
| | | private static final String[] BUILD_INFORMATION_ATTRIBUTE_NAMES = new String[] { |
| | | Attributes.Name.EXTENSION_NAME.toString(), |
| | | Attributes.Name.IMPLEMENTATION_VERSION.toString(), REVISION_NUMBER }; |
| | |
| | | return INSTANCE; |
| | | } |
| | | |
| | | // Set of registered Jar files. |
| | | /** Set of registered Jar files. */ |
| | | private Set<File> jarFiles = new HashSet<File>(); |
| | | |
| | | // Underlying class loader used to load classes and resources (null |
| | | // if disabled). |
| | | // |
| | | // We contain a reference to the URLClassLoader rather than |
| | | // sub-class it so that it is possible to replace the loader at |
| | | // run-time. For example, when removing or replacing extension Jar |
| | | // files (the URLClassLoader only supports adding new |
| | | // URLs, not removal). |
| | | /** |
| | | * Underlying class loader used to load classes and resources (null |
| | | * if disabled). |
| | | * <p> |
| | | * We contain a reference to the URLClassLoader rather than |
| | | * sub-class it so that it is possible to replace the loader at |
| | | * run-time. For example, when removing or replacing extension Jar |
| | | * files (the URLClassLoader only supports adding new |
| | | * URLs, not removal). |
| | | */ |
| | | private MyURLClassLoader loader = null; |
| | | |
| | | private boolean isClient = true; |
| | |
| | | private String instancePath; |
| | | private ClassLoader parent; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ConfigurationFramework() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public final class DNPropertyDefinition extends PropertyDefinition<DN> { |
| | | |
| | | // Optional base DN which all valid values must be immediately |
| | | // subordinate to. |
| | | /** |
| | | * Optional base DN which all valid values must be immediately |
| | | * subordinate to. |
| | | */ |
| | | private final DN baseDN; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<DN, DNPropertyDefinition> { |
| | | |
| | | // Optional base DN which all valid values must be immediately |
| | | // subordinate to. |
| | | /** |
| | | * Optional base DN which all valid values must be immediately |
| | | * subordinate to. |
| | | */ |
| | | private DN baseDN = null; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | |
| | | this.baseDN = baseDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected DNPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DNPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<DN> defaultBehavior, DN baseDN) { |
| | |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(DN value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitDN(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, DN value, P p) { |
| | | return v.visitDN(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(DN o1, DN o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | */ |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | // The default managed object's definition. |
| | | /** The default managed object's definition. */ |
| | | private final ManagedObjectDefinition<C, S> definition; |
| | | |
| | | // The string encoded default managed object's properties. |
| | | /** The string encoded default managed object's properties. */ |
| | | private final Map<String, List<String>> propertyStringValues = new HashMap<String, List<String>>(); |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | // The default managed object's definition. |
| | | /** The default managed object's definition. */ |
| | | private final ManagedObjectDefinition<C, S> definition; |
| | | |
| | | // The string encoded default managed object's properties. |
| | | /** The string encoded default managed object's properties. */ |
| | | private final Map<String, List<String>> propertyStringValues; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DefaultManagedObject(ManagedObjectDefinition<C, S> definition, |
| | | Map<String, List<String>> propertyStringValues) { |
| | | this.definition = definition; |
| | |
| | | */ |
| | | public final class DefinedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | // The collection of default values. |
| | | /** The collection of default values. */ |
| | | private final Collection<String> values; |
| | | |
| | | /** |
| | |
| | | this.values = Arrays.asList(values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitDefined(this, p); |
| | | } |
| | |
| | | */ |
| | | private static final long serialVersionUID = 3459033551415663416L; |
| | | |
| | | // Create the message. |
| | | /** Create the message. */ |
| | | private static LocalizableMessage createLocalizableMessage(AbstractManagedObjectDefinition<?, ?> d, Reason reason) { |
| | | LocalizableMessage ufn = d.getUserFriendlyName(); |
| | | switch (reason) { |
| | |
| | | } |
| | | } |
| | | |
| | | // The expected type of managed object. |
| | | /** The expected type of managed object. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> d; |
| | | |
| | | // The reason why the definition could not be determined. |
| | | /** The reason why the definition could not be determined. */ |
| | | private final Reason reason; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public final class DurationPropertyDefinition extends PropertyDefinition<Long> { |
| | | |
| | | // String used to represent unlimited durations. |
| | | /** String used to represent unlimited durations. */ |
| | | private static final String UNLIMITED = "unlimited"; |
| | | |
| | | // The base unit for this property definition. |
| | | /** The base unit for this property definition. */ |
| | | private final DurationUnit baseUnit; |
| | | |
| | | // The optional maximum unit for this property definition. |
| | | /** The optional maximum unit for this property definition. */ |
| | | private final DurationUnit maximumUnit; |
| | | |
| | | // The lower limit of the property value in milli-seconds. |
| | | /** The lower limit of the property value in milli-seconds. */ |
| | | private final long lowerLimit; |
| | | |
| | | // The optional upper limit of the property value in milli-seconds. |
| | | /** The optional upper limit of the property value in milli-seconds. */ |
| | | private final Long upperLimit; |
| | | |
| | | // Indicates whether this property allows the use of the "unlimited" |
| | | // duration value (represented using a -1L or the string |
| | | // "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the "unlimited" |
| | | * duration value (represented using a -1L or the string |
| | | * "unlimited"). |
| | | */ |
| | | private final boolean allowUnlimited; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<Long, DurationPropertyDefinition> { |
| | | |
| | | // The base unit for this property definition. |
| | | /** The base unit for this property definition. */ |
| | | private DurationUnit baseUnit = DurationUnit.SECONDS; |
| | | |
| | | // The optional maximum unit for this property definition. |
| | | /** The optional maximum unit for this property definition. */ |
| | | private DurationUnit maximumUnit = null; |
| | | |
| | | // The lower limit of the property value in milli-seconds. |
| | | /** The lower limit of the property value in milli-seconds. */ |
| | | private long lowerLimit = 0L; |
| | | |
| | | // The optional upper limit of the property value in |
| | | // milli-seconds. |
| | | /** The optional upper limit of the property value in milli-seconds. */ |
| | | private Long upperLimit = null; |
| | | |
| | | // Indicates whether this property allows the use of the |
| | | // "unlimited" duration value (represented using a -1L or the |
| | | // string "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the |
| | | * "unlimited" duration value (represented using a -1L or the |
| | | * string "unlimited"). |
| | | */ |
| | | private boolean allowUnlimited = false; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | |
| | | this.allowUnlimited = allowUnlimited; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected DurationPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DurationPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Long> defaultBehavior, DurationUnit baseUnit, DurationUnit maximumUnit, |
| | |
| | | return allowUnlimited; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Long decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return i; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitDuration(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Long value, P p) { |
| | | return v.visitDuration(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | builder.append(allowUnlimited); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Long o1, Long o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | */ |
| | | WEEKS((long) 7 * 24 * 60 * 60 * 1000, "w", "weeks"); |
| | | |
| | | // A lookup table for resolving a unit from its name. |
| | | /** A lookup table for resolving a unit from its name. */ |
| | | private static final Map<String, DurationUnit> NAME_TO_UNIT; |
| | | static { |
| | | NAME_TO_UNIT = new HashMap<String, DurationUnit>(); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | // The long name of the unit. |
| | | /** The long name of the unit. */ |
| | | private final String longName; |
| | | |
| | | // The abbreviation of the unit. |
| | | /** The abbreviation of the unit. */ |
| | | private final String shortName; |
| | | |
| | | // The size of the unit in milliseconds. |
| | | /** The size of the unit in milliseconds. */ |
| | | private final long sz; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DurationUnit(long sz, String shortName, String longName) { |
| | | this.sz = sz; |
| | | this.shortName = shortName; |
| | |
| | | */ |
| | | public final static class Builder<E extends Enum<E>> extends AbstractBuilder<E, EnumPropertyDefinition<E>> { |
| | | |
| | | // The enumeration class. |
| | | /** The enumeration class. */ |
| | | private Class<E> enumClass; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | this.enumClass = null; |
| | |
| | | this.enumClass = enumClass; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected EnumPropertyDefinition<E> buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder<E>(d, propertyName); |
| | | } |
| | | |
| | | // The enumeration class. |
| | | /** The enumeration class. */ |
| | | private final Class<E> enumClass; |
| | | |
| | | // Map used for decoding values. |
| | | /** Map used for decoding values. */ |
| | | private final Map<String, E> decodeMap; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private EnumPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<E> defaultBehavior, |
| | | Class<E> enumClass) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitEnum(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, E value, P p) { |
| | | return v.visitEnum(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public E decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(E value) { |
| | | Reject.ifNull(value); |
| | |
| | | return value.toString().trim().toLowerCase(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(E value) { |
| | | Reject.ifNull(value); |
| | |
| | | */ |
| | | private final class ClientHandler extends ClientConstraintHandler { |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ClientHandler() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAddAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | */ |
| | | private final class ServerHandler extends ServerConstraintHandler { |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ServerHandler() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | |
| | | }; |
| | | |
| | | // The client-side constraint handler. |
| | | /** The client-side constraint handler. */ |
| | | private final ClientConstraintHandler clientHandler = new ClientHandler(); |
| | | |
| | | // The condition associated with this constraint. |
| | | /** The condition associated with this constraint. */ |
| | | private final Condition condition; |
| | | |
| | | // The managed object definition associated with this constraint. |
| | | /** The managed object definition associated with this constraint. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> definition; |
| | | |
| | | // The constraint ID. |
| | | /** The constraint ID. */ |
| | | private final int id; |
| | | |
| | | // The server-side constraint handler. |
| | | /** The server-side constraint handler. */ |
| | | private final ServerConstraintHandler serverHandler = new ServerHandler(); |
| | | |
| | | /** |
| | |
| | | this.condition = condition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | return Collections.singleton(clientHandler); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.singleton(serverHandler); |
| | | } |
| | |
| | | return resource.getMessage(definition, property, locale); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | condition.initialize(definition); |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<AddressMask, IPAddressMaskPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected IPAddressMaskPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private IPAddressMaskPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<AddressMask> defaultBehavior) { |
| | | super(d, AddressMask.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(AddressMask value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AddressMask decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitIPAddressMask(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, AddressMask value, P p) { |
| | | return v.visitIPAddressMask(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(AddressMask o1, AddressMask o2) { |
| | | return o1.toString().compareTo(o2.toString()); |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<InetAddress, IPAddressPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected IPAddressPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private IPAddressPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<InetAddress> defaultBehavior) { |
| | | super(d, InetAddress.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(InetAddress value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public InetAddress decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(InetAddress value) { |
| | | // We should return the host name if it is available, or the IP |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitIPAddress(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, InetAddress value, P p) { |
| | | return v.visitIPAddress(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(InetAddress o1, InetAddress o2) { |
| | | return o1.getHostAddress().compareTo(o2.getHostAddress()); |
| | |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<C, S, InstantiableRelationDefinition<C, S>> { |
| | | |
| | | // The optional naming property definition. |
| | | /** The optional naming property definition. */ |
| | | private PropertyDefinition<?> namingPropertyDefinition = null; |
| | | |
| | | // The plural name of the relation. |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | // The optional default managed objects associated with this |
| | | // instantiable relation definition. |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * instantiable relation definition. |
| | | */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | |
| | |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected InstantiableRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new InstantiableRelationDefinition<C, S>(common, pluralName, namingPropertyDefinition, |
| | |
| | | |
| | | } |
| | | |
| | | // The optional naming property definition. |
| | | /** The optional naming property definition. */ |
| | | private final PropertyDefinition<?> namingPropertyDefinition; |
| | | |
| | | // The plural name of the relation. |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | // The optional default managed objects associated with this |
| | | // instantiable relation definition. |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * instantiable relation definition. |
| | | */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private InstantiableRelationDefinition(Common<C, S> common, String pluralName, |
| | | PropertyDefinition<?> namingPropertyDefinition, |
| | | Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects) { |
| | |
| | | this.defaultManagedObjects = defaultManagedObjects; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitInstantiable(this, p); |
| | |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(getParentDefinition(), property, locale); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | for (DefaultManagedObject<?, ?> dmo : defaultManagedObjects.values()) { |
| | |
| | | */ |
| | | public final class IntegerPropertyDefinition extends PropertyDefinition<Integer> { |
| | | |
| | | // String used to represent unlimited. |
| | | /** String used to represent unlimited. */ |
| | | private static final String UNLIMITED = "unlimited"; |
| | | |
| | | // The lower limit of the property value. |
| | | /** The lower limit of the property value. */ |
| | | private final int lowerLimit; |
| | | |
| | | // The optional upper limit of the property value. |
| | | /** The optional upper limit of the property value. */ |
| | | private final Integer upperLimit; |
| | | |
| | | // Indicates whether this property allows the use of the "unlimited" value |
| | | // (represented using a -1 or the string "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the "unlimited" value |
| | | * (represented using a -1 or the string "unlimited"). |
| | | */ |
| | | private final boolean allowUnlimited; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<Integer, IntegerPropertyDefinition> { |
| | | |
| | | // The lower limit of the property value. |
| | | /** The lower limit of the property value. */ |
| | | private int lowerLimit = 0; |
| | | |
| | | // The optional upper limit of the property value. |
| | | /** The optional upper limit of the property value. */ |
| | | private Integer upperLimit = null; |
| | | |
| | | // Indicates whether this property allows the use of the "unlimited" |
| | | // value |
| | | // (represented using a -1 or the string "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the "unlimited" value |
| | | * (represented using a -1 or the string "unlimited"). |
| | | */ |
| | | private boolean allowUnlimited = false; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | |
| | | this.allowUnlimited = allowUnlimited; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected IntegerPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private IntegerPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Integer> defaultBehavior, int lowerLimit, Integer upperLimit, boolean allowUnlimited) { |
| | |
| | | return allowUnlimited; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Integer value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(Integer value) { |
| | | Reject.ifNull(value); |
| | |
| | | return value.toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Integer decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return i; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitInteger(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Integer value, P p) { |
| | | return v.visitInteger(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | builder.append(allowUnlimited); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Integer o1, Integer o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | } |
| | | } |
| | | |
| | | // The singleton instance. |
| | | /** The singleton instance. */ |
| | | private static final LDAPProfile INSTANCE = new LDAPProfile(); |
| | | |
| | | /** |
| | |
| | | return INSTANCE; |
| | | } |
| | | |
| | | // The list of profile wrappers. |
| | | /** The list of profile wrappers. */ |
| | | private final LinkedList<Wrapper> profiles = new LinkedList<Wrapper>();; |
| | | |
| | | // The LDAP profile property table. |
| | | /** The LDAP profile property table. */ |
| | | private final ManagedObjectDefinitionResource resource = ManagedObjectDefinitionResource.createForProfile("ldap"); |
| | | |
| | | // Prevent construction. |
| | | /** Prevent construction. */ |
| | | private LDAPProfile() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public final class ManagedObjectDefinitionI18NResource { |
| | | |
| | | // Application-wide set of instances. |
| | | /** Application-wide set of instances. */ |
| | | private static final Map<String, ManagedObjectDefinitionI18NResource> INSTANCES = |
| | | new HashMap<String, ManagedObjectDefinitionI18NResource>(); |
| | | |
| | |
| | | return getInstance("config.profiles." + profile); |
| | | } |
| | | |
| | | // Get a resource instance creating it if necessary. |
| | | /** Get a resource instance creating it if necessary. */ |
| | | private synchronized static ManagedObjectDefinitionI18NResource getInstance(String prefix) { |
| | | ManagedObjectDefinitionI18NResource instance = INSTANCES.get(prefix); |
| | | |
| | |
| | | return instance; |
| | | } |
| | | |
| | | // Mapping from definition to locale-based resource bundle. |
| | | /** Mapping from definition to locale-based resource bundle. */ |
| | | private final Map<AbstractManagedObjectDefinition<?, ?>, Map<Locale, ResourceBundle>> resources; |
| | | |
| | | // The resource name prefix. |
| | | /** The resource name prefix. */ |
| | | private final String prefix; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ManagedObjectDefinitionI18NResource(String prefix) { |
| | | this.resources = new HashMap<AbstractManagedObjectDefinition<?, ?>, Map<Locale, ResourceBundle>>(); |
| | | this.prefix = prefix; |
| | |
| | | map.put(locale, resoureBundle); |
| | | } |
| | | |
| | | // Retrieve the resource bundle associated with a managed object and |
| | | // locale, lazily loading it if necessary. |
| | | /** |
| | | * Retrieve the resource bundle associated with a managed object and |
| | | * locale, lazily loading it if necessary. |
| | | */ |
| | | private synchronized ResourceBundle getResourceBundle(AbstractManagedObjectDefinition<?, ?> d, Locale locale) { |
| | | if (d.isTop()) { |
| | | throw new UnsupportedOperationException("I18n resources are not available for the " |
| | |
| | | */ |
| | | public final class ManagedObjectDefinitionResource { |
| | | |
| | | // Mapping from definition to property tables. |
| | | /** Mapping from definition to property tables. */ |
| | | private final Map<AbstractManagedObjectDefinition<?, ?>, Properties> properties; |
| | | |
| | | // The resource name prefix. |
| | | /** The resource name prefix. */ |
| | | private final String prefix; |
| | | |
| | | /** |
| | |
| | | return new ManagedObjectDefinitionResource("config.profiles." + profile); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ManagedObjectDefinitionResource(String prefix) { |
| | | this.properties = new HashMap<AbstractManagedObjectDefinition<?, ?>, Properties>(); |
| | | this.prefix = prefix; |
| | |
| | | return result; |
| | | } |
| | | |
| | | // Retrieve the properties table associated with a managed object, |
| | | // lazily loading it if necessary. |
| | | /** |
| | | * Retrieve the properties table associated with a managed object, |
| | | * lazily loading it if necessary. |
| | | */ |
| | | private synchronized Properties getProperties(AbstractManagedObjectDefinition<?, ?> d) { |
| | | Properties p = properties.get(d); |
| | | |
| | |
| | | */ |
| | | private static final class DNSerializer implements ManagedObjectPathSerializer { |
| | | |
| | | // The current DN. |
| | | /** The current DN. */ |
| | | private DN dn; |
| | | |
| | | // The LDAP profile. |
| | | /** The LDAP profile. */ |
| | | private final LDAPProfile profile; |
| | | |
| | | // Create a new DN builder. |
| | | /** Create a new DN builder. */ |
| | | private DNSerializer() { |
| | | this.dn = DN.rootDN(); |
| | | this.profile = LDAPProfile.getInstance(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | |
| | | dn = dn.child(new RDN(attrType, name)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | |
| | | dn = dn.child(new RDN(attrType, d.getName())); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | | appendManagedObjectPathElement(r); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | | appendManagedObjectPathElement(r); |
| | | } |
| | | |
| | | // Appends the RDN sequence representing the provided relation. |
| | | /** Appends the RDN sequence representing the provided relation. */ |
| | | private void appendManagedObjectPathElement(RelationDefinition<?, ?> r) { |
| | | DN localName = DN.valueOf(profile.getRelationRDNSequence(r)); |
| | | dn = dn.child(localName); |
| | | } |
| | | |
| | | // Gets the serialized DN value. |
| | | /** Gets the serialized DN value. */ |
| | | private DN toDN() { |
| | | return dn; |
| | | } |
| | |
| | | */ |
| | | private static abstract class Element<C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | // The type of managed object referenced by this element. |
| | | /** The type of managed object referenced by this element. */ |
| | | private final AbstractManagedObjectDefinition<C, S> definition; |
| | | |
| | | /** |
| | |
| | | private static final class InstantiableElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | | // Factory method. |
| | | /** Factory method. */ |
| | | private static final <C extends ConfigurationClient, S extends Configuration> InstantiableElement<C, S> create( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | | return new InstantiableElement<C, S>(r, d, name); |
| | | } |
| | | |
| | | // The name of the managed object. |
| | | /** The name of the managed object. */ |
| | | private final String name; |
| | | |
| | | // The instantiable relation. |
| | | /** The instantiable relation. */ |
| | | private final InstantiableRelationDefinition<? super C, ? super S> r; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private InstantiableElement(InstantiableRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d, String name) { |
| | | super(d); |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public InstantiableRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition(), name); |
| | |
| | | private static final class OptionalElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | | // Factory method. |
| | | /** Factory method. */ |
| | | private static final <C extends ConfigurationClient, S extends Configuration> OptionalElement<C, S> create( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | return new OptionalElement<C, S>(r, d); |
| | | } |
| | | |
| | | // The optional relation. |
| | | /** The optional relation. */ |
| | | private final OptionalRelationDefinition<? super C, ? super S> r; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private OptionalElement(OptionalRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | | super(d); |
| | | this.r = r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public OptionalRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition()); |
| | |
| | | private static final class SetElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | | // Factory method. |
| | | /** Factory method. */ |
| | | private static final <C extends ConfigurationClient, S extends Configuration> SetElement<C, S> create( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | return new SetElement<C, S>(r, d); |
| | | } |
| | | |
| | | // The set relation. |
| | | /** The set relation. */ |
| | | private final SetRelationDefinition<? super C, ? super S> r; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private SetElement(SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | super(d); |
| | | this.r = r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SetRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition()); |
| | |
| | | private static final class SingletonElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | | // Factory method. |
| | | /** Factory method. */ |
| | | private static final <C extends ConfigurationClient, S extends Configuration> SingletonElement<C, S> create( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | return new SingletonElement<C, S>(r, d); |
| | | } |
| | | |
| | | // The singleton relation. |
| | | /** The singleton relation. */ |
| | | private final SingletonRelationDefinition<? super C, ? super S> r; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private SingletonElement(SingletonRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | | super(d); |
| | | this.r = r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SingletonRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition()); |
| | |
| | | */ |
| | | private static final class StringSerializer implements ManagedObjectPathSerializer { |
| | | |
| | | // Serialize to this string builder. |
| | | /** Serialize to this string builder. */ |
| | | private final StringBuilder builder; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private StringSerializer(StringBuilder builder) { |
| | | this.builder = builder; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d, |
| | | String name) { |
| | |
| | | builder.append(name.replace("/", "//")); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | serializeElement(r, d); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | serializeElement(r, d); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | serializeElement(r, d); |
| | | } |
| | | |
| | | // Common element serialization. |
| | | /** Common element serialization. */ |
| | | private <M, N> void serializeElement(RelationDefinition<?, ?> r, AbstractManagedObjectDefinition<?, ?> d) { |
| | | // Always specify the relation name. |
| | | builder.append("/relation="); |
| | |
| | | } |
| | | } |
| | | |
| | | // Single instance of a root path. |
| | | /** Single instance of a root path. */ |
| | | private static final ManagedObjectPath<RootCfgClient, RootCfg> EMPTY_PATH = |
| | | new ManagedObjectPath<RootCfgClient, RootCfg>(new LinkedList<Element<?, ?>>(), null, |
| | | RootCfgDefn.getInstance()); |
| | | |
| | | // A regular expression used to parse path elements. |
| | | /** A regular expression used to parse path elements. */ |
| | | private static final Pattern PE_REGEXP = Pattern.compile("^\\s*relation=\\s*([^+]+)\\s*" |
| | | + "(\\+\\s*type=\\s*([^+]+)\\s*)?" + "(\\+\\s*name=\\s*([^+]+)\\s*)?$"); |
| | | |
| | |
| | | return create(elements, lastElement); |
| | | } |
| | | |
| | | // Factory method required in order to allow generic wild-card |
| | | // construction of new paths. |
| | | /** |
| | | * Factory method required in order to allow generic wild-card |
| | | * construction of new paths. |
| | | */ |
| | | private static <C extends ConfigurationClient, S extends Configuration> ManagedObjectPath<C, S> create( |
| | | LinkedList<Element<?, ?>> elements, Element<C, S> lastElement) { |
| | | return new ManagedObjectPath<C, S>(elements, lastElement.getRelationDefinition(), |
| | |
| | | } |
| | | } |
| | | |
| | | // The managed object definition in this path. |
| | | /** The managed object definition in this path. */ |
| | | private final AbstractManagedObjectDefinition<C, S> d; |
| | | |
| | | // The list of path elements in this path. |
| | | /** The list of path elements in this path. */ |
| | | private final List<Element<?, ?>> elements; |
| | | |
| | | // The last relation definition in this path. |
| | | /** The last relation definition in this path. */ |
| | | private final RelationDefinition<? super C, ? super S> r; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private ManagedObjectPath(LinkedList<Element<?, ?>> elements, RelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | | this.elements = Collections.unmodifiableList(elements); |
| | |
| | | return child(r, r.getChildDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(Object obj) { |
| | | if (obj == this) { |
| | |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return toString().hashCode(); |
| | |
| | | return serializer.toDN(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<C, S, OptionalRelationDefinition<C, S>> { |
| | | |
| | | // The optional default managed object associated with this |
| | | // optional relation. |
| | | /** |
| | | * The optional default managed object associated with this |
| | | * optional relation. |
| | | */ |
| | | private DefaultManagedObject<? extends C, ? extends S> defaultManagedObject = null; |
| | | |
| | | /** |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected OptionalRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new OptionalRelationDefinition<C, S>(common, defaultManagedObject); |
| | |
| | | |
| | | } |
| | | |
| | | // The optional default managed object associated with this |
| | | // optional relation. |
| | | /** |
| | | * The optional default managed object associated with this |
| | | * optional relation. |
| | | */ |
| | | private final DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private OptionalRelationDefinition(Common<C, S> common, |
| | | DefaultManagedObject<? extends C, ? extends S> defaultManagedObject) { |
| | | super(common); |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitOptional(this, p); |
| | |
| | | return defaultManagedObject; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | if (defaultManagedObject != null) { |
| | |
| | | */ |
| | | protected abstract static class AbstractBuilder<T, D extends PropertyDefinition<T>> { |
| | | |
| | | // The administrator action. |
| | | /** The administrator action. */ |
| | | private AdministratorAction adminAction; |
| | | |
| | | // The default behavior provider. |
| | | /** The default behavior provider. */ |
| | | private DefaultBehaviorProvider<T> defaultBehavior; |
| | | |
| | | // The abstract managed object |
| | | /** The abstract managed object. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> definition; |
| | | |
| | | // The options applicable to this definition. |
| | | /** The options applicable to this definition. */ |
| | | private final EnumSet<PropertyOption> options; |
| | | |
| | | // The name of this property definition. |
| | | /** The name of this property definition. */ |
| | | private final String propertyName; |
| | | |
| | | /** |
| | |
| | | DefaultBehaviorProvider<T> defaultBehavior); |
| | | } |
| | | |
| | | // The administrator action. |
| | | /** The administrator action. */ |
| | | private final AdministratorAction adminAction; |
| | | |
| | | // The default behavior provider. |
| | | /** The default behavior provider. */ |
| | | private final DefaultBehaviorProvider<T> defaultBehavior; |
| | | |
| | | // The abstract managed object |
| | | /** The abstract managed object. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> definition; |
| | | |
| | | // Options applicable to this definition. |
| | | /** Options applicable to this definition. */ |
| | | private final Set<PropertyOption> options; |
| | | |
| | | // The property name. |
| | | /** The property name. */ |
| | | private final String propertyName; |
| | | |
| | | // The property value class. |
| | | /** The property value class. */ |
| | | private final Class<T> theClass; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private static final class MyPropertyDefinitionVisitor extends |
| | | PropertyDefinitionVisitor<LocalizableMessage, Void> { |
| | | // Flag indicating whether detailed syntax information will be |
| | | // generated. |
| | | /** |
| | | * Flag indicating whether detailed syntax information will be |
| | | * generated. |
| | | */ |
| | | private final boolean isDetailed; |
| | | |
| | | // The formatter to use for numeric values. |
| | | /** The formatter to use for numeric values. */ |
| | | private final NumberFormat numberFormat; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private MyPropertyDefinitionVisitor(boolean isDetailed) { |
| | | this.isDetailed = isDetailed; |
| | | |
| | |
| | | this.numberFormat.setMaximumFractionDigits(2); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> LocalizableMessage visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, Void p) { |
| | | return LocalizableMessage.raw("NAME"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitAttributeType(AttributeTypePropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("OID"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitACI(ACIPropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("ACI"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitBoolean(BooleanPropertyDefinition d, Void p) { |
| | | if (isDetailed) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitClass(ClassPropertyDefinition d, Void p) { |
| | | if (isDetailed && !d.getInstanceOfInterface().isEmpty()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitDN(DNPropertyDefinition d, Void p) { |
| | | if (isDetailed && d.getBaseDN() != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitDuration(DurationPropertyDefinition d, Void p) { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <E extends Enum<E>> LocalizableMessage visitEnum(EnumPropertyDefinition<E> d, Void p) { |
| | | if (!isDetailed) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitInteger(IntegerPropertyDefinition d, Void p) { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitIPAddress(IPAddressPropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("HOST_NAME"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitIPAddressMask(IPAddressMaskPropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("IP_ADDRESS_MASK"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitSize(SizePropertyDefinition d, Void p) { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitString(StringPropertyDefinition d, Void p) { |
| | | if (d.getPattern() != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> LocalizableMessage visitUnknown(PropertyDefinition<T> d, Void p) { |
| | | return LocalizableMessage.raw("?"); |
| | | } |
| | | } |
| | | |
| | | // Underlying implementation. |
| | | /** Underlying implementation. */ |
| | | private final MyPropertyDefinitionVisitor pimpl; |
| | | |
| | | /** |
| | |
| | | pd.getName(), pd.getClass().getName())); |
| | | } |
| | | |
| | | // Create the message. |
| | | /** Create the message. */ |
| | | private static LocalizableMessage createMessage(final PropertyDefinition<?> pd, |
| | | final Object value) { |
| | | final PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder(true); |
| | |
| | | builder.getUsage(pd)); |
| | | } |
| | | |
| | | // LocalizableMessage that explains the problem. |
| | | /** LocalizableMessage that explains the problem. */ |
| | | private final LocalizableMessage message; |
| | | |
| | | // The property definition associated with the property that caused |
| | | // the exception. |
| | | /** |
| | | * The property definition associated with the property that caused |
| | | * the exception. |
| | | */ |
| | | private final PropertyDefinition<?> pd; |
| | | |
| | | private PropertyException(final PropertyDefinition<?> pd, final LocalizableMessage message) { |
| | |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public LocalizableMessage getMessageObject() { |
| | | return message; |
| | | } |
| | |
| | | */ |
| | | private static final long serialVersionUID = -895548482881819610L; |
| | | |
| | | // The name of the property that could not be found. |
| | | /** The name of the property that could not be found. */ |
| | | private final String propertyName; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final PropertyProvider DEFAULT_PROVIDER = new PropertyProvider() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) { |
| | | return Collections.<T> emptySet(); |
| | | } |
| | |
| | | return new Reference<C, S>(p, rd, s); |
| | | } |
| | | |
| | | // The name of the referenced managed object. |
| | | /** The name of the referenced managed object. */ |
| | | private final String name; |
| | | |
| | | // The path of the referenced managed object. |
| | | /** The path of the referenced managed object. */ |
| | | private final ManagedObjectPath<C, S> path; |
| | | |
| | | // The instantiable relation in the parent which contains the |
| | | // referenced managed object. |
| | | /** |
| | | * The instantiable relation in the parent which contains the |
| | | * referenced managed object. |
| | | */ |
| | | private final InstantiableRelationDefinition<C, S> relation; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private Reference(ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> relation, String name) { |
| | | this.relation = relation; |
| | | this.name = name; |
| | |
| | | return path.toDN(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String toString() { |
| | | return name; |
| | | } |
| | | |
| | | // Normalize a value using the specified naming property definition |
| | | // if defined. |
| | | /** |
| | | * Normalize a value using the specified naming property definition |
| | | * if defined. |
| | | */ |
| | | private <T> String normalizeName(PropertyDefinition<T> pd) { |
| | | if (pd != null) { |
| | | try { |
| | |
| | | protected abstract static class AbstractBuilder<C extends ConfigurationClient, S extends Configuration, |
| | | D extends RelationDefinition<C, S>> { |
| | | |
| | | // Common fields. |
| | | /** Common fields. */ |
| | | private final Common<C, S> common; |
| | | |
| | | /** |
| | |
| | | */ |
| | | protected static final class Common<C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | // The definition of the child managed object. |
| | | /** The definition of the child managed object. */ |
| | | private final AbstractManagedObjectDefinition<C, S> cd; |
| | | |
| | | // The name of the relation. |
| | | /** The name of the relation. */ |
| | | private final String name; |
| | | |
| | | // Options applicable to this definition. |
| | | /** Options applicable to this definition. */ |
| | | private final Set<RelationOption> options; |
| | | |
| | | // The definition of the parent managed object. |
| | | /** The definition of the parent managed object. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> pd; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private Common(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | this.name = name; |
| | |
| | | } |
| | | } |
| | | |
| | | // Common fields. |
| | | /** Common fields. */ |
| | | private final Common<C, S> common; |
| | | |
| | | /** |
| | |
| | | return common.options.contains(option); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | */ |
| | | public final class RelativeInheritedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | // The type of managed object expected at the relative offset. |
| | | /** The type of managed object expected at the relative offset. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> d; |
| | | |
| | | // The relative offset (where 1 = parent, 2 = grandparent) of the |
| | | // managed object containing the property. |
| | | /** |
| | | * The relative offset (where 1 = parent, 2 = grandparent) of the |
| | | * managed object containing the property. |
| | | */ |
| | | private final int offset; |
| | | |
| | | // The name of the property containing the inherited default values. |
| | | /** The name of the property containing the inherited default values. */ |
| | | private final String propertyName; |
| | | |
| | | /** |
| | |
| | | this.offset = offset; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitRelativeInherited(this, p); |
| | | } |
| | |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<C, S, SetRelationDefinition<C, S>> { |
| | | |
| | | // The plural name of the relation. |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | // The optional default managed objects associated with this |
| | | // set relation definition. |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * set relation definition. |
| | | */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | |
| | |
| | | defaultManagedObject); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SetRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new SetRelationDefinition<C, S>(common, pluralName, defaultManagedObjects); |
| | |
| | | |
| | | } |
| | | |
| | | // The plural name of the relation. |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | // The optional default managed objects associated with this |
| | | // set relation definition. |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * set relation definition. |
| | | */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private SetRelationDefinition(Common<C, S> common, String pluralName, |
| | | Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects) { |
| | | super(common); |
| | |
| | | this.defaultManagedObjects = defaultManagedObjects; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSet(this, p); |
| | |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(getParentDefinition(), property, locale); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | for (DefaultManagedObject<?, ?> dmo : defaultManagedObjects.values()) { |
| | |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<C, S, SingletonRelationDefinition<C, S>> { |
| | | |
| | | // The optional default managed object associated with this |
| | | // singleton relation. |
| | | /** |
| | | * The optional default managed object associated with this |
| | | * singleton relation. |
| | | */ |
| | | private DefaultManagedObject<? extends C, ? extends S> defaultManagedObject = null; |
| | | |
| | | /** |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SingletonRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new SingletonRelationDefinition<C, S>(common, defaultManagedObject); |
| | |
| | | |
| | | } |
| | | |
| | | // The optional default managed object associated with this |
| | | // singleton relation. |
| | | /** |
| | | * The optional default managed object associated with this |
| | | * singleton relation. |
| | | */ |
| | | private final DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private SingletonRelationDefinition(Common<C, S> common, |
| | | DefaultManagedObject<? extends C, ? extends S> defaultManagedObject) { |
| | | super(common); |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSingleton(this, p); |
| | |
| | | return defaultManagedObject; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | if (defaultManagedObject != null) { |
| | |
| | | */ |
| | | public final class SizePropertyDefinition extends PropertyDefinition<Long> { |
| | | |
| | | // String used to represent unlimited memory sizes. |
| | | /** String used to represent unlimited memory sizes. */ |
| | | private static final String UNLIMITED = "unlimited"; |
| | | |
| | | // The lower limit of the property value in bytes. |
| | | /** The lower limit of the property value in bytes. */ |
| | | private final long lowerLimit; |
| | | |
| | | // The optional upper limit of the property value in bytes. |
| | | /** The optional upper limit of the property value in bytes. */ |
| | | private final Long upperLimit; |
| | | |
| | | // Indicates whether this property allows the use of the "unlimited" memory |
| | | // size value (represented using a -1L or the string "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the "unlimited" memory |
| | | * size value (represented using a -1L or the string "unlimited"). |
| | | */ |
| | | private final boolean allowUnlimited; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<Long, SizePropertyDefinition> { |
| | | |
| | | // The lower limit of the property value in bytes. |
| | | /** The lower limit of the property value in bytes. */ |
| | | private long lowerLimit = 0L; |
| | | |
| | | // The optional upper limit of the property value in bytes. |
| | | /** The optional upper limit of the property value in bytes. */ |
| | | private Long upperLimit = null; |
| | | |
| | | // Indicates whether this property allows the use of the "unlimited" |
| | | // memory |
| | | // size value (represented using a -1L or the string "unlimited"). |
| | | /** |
| | | * Indicates whether this property allows the use of the "unlimited" memory |
| | | * size value (represented using a -1L or the string "unlimited"). |
| | | */ |
| | | private boolean allowUnlimited = false; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | |
| | | this.allowUnlimited = allowUnlimited; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SizePropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private SizePropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Long> defaultBehavior, Long lowerLimit, Long upperLimit, boolean allowUnlimited) { |
| | |
| | | return allowUnlimited; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Long decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return i; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSize(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Long value, P p) { |
| | | return v.visitSize(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Long o1, Long o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | */ |
| | | TERA_BYTES((long) 1000 * 1000 * 1000 * 1000, "tb", "terabytes"); |
| | | |
| | | // A lookup table for resolving a unit from its name. |
| | | /** A lookup table for resolving a unit from its name. */ |
| | | private static final Map<String, SizeUnit> NAME_TO_UNIT; |
| | | static { |
| | | NAME_TO_UNIT = new HashMap<String, SizeUnit>(); |
| | |
| | | return unit.toBytes(d); |
| | | } |
| | | |
| | | // The long name of the unit. |
| | | /** The long name of the unit. */ |
| | | private final String longName; |
| | | |
| | | // The abbreviation of the unit. |
| | | /** The abbreviation of the unit. */ |
| | | private final String shortName; |
| | | |
| | | // The size of the unit in bytes. |
| | | /** The size of the unit in bytes. */ |
| | | private final long sz; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private SizeUnit(long sz, String shortName, String longName) { |
| | | this.sz = sz; |
| | | this.shortName = shortName; |
| | |
| | | */ |
| | | public static final class Builder extends AbstractBuilder<String, StringPropertyDefinition> { |
| | | |
| | | // Flag indicating whether values of this property are |
| | | // case-insensitive. |
| | | /** |
| | | * Flag indicating whether values of this property are |
| | | * case-insensitive. |
| | | */ |
| | | private boolean isCaseInsensitive = true; |
| | | |
| | | // Optional pattern which values of this property must match. |
| | | /** Optional pattern which values of this property must match. */ |
| | | private Pattern pattern = null; |
| | | |
| | | // Pattern usage which provides a user-friendly summary of the |
| | | // pattern if present. |
| | | /** |
| | | * Pattern usage which provides a user-friendly summary of the |
| | | * pattern if present. |
| | | */ |
| | | private String patternUsage = null; |
| | | |
| | | // Private constructor |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected StringPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | // Flag indicating whether values of this property are |
| | | // case-insensitive. |
| | | /** |
| | | * Flag indicating whether values of this property are |
| | | * case-insensitive. |
| | | */ |
| | | private final boolean isCaseInsensitive; |
| | | |
| | | // Optional pattern which values of this property must match. |
| | | /** Optional pattern which values of this property must match. */ |
| | | private final Pattern pattern; |
| | | |
| | | // Pattern usage which provides a user-friendly summary of the |
| | | // pattern if present. |
| | | /** |
| | | * Pattern usage which provides a user-friendly summary of the |
| | | * pattern if present. |
| | | */ |
| | | private final String patternUsage; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private StringPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<String> defaultBehavior, boolean isCaseInsensitive, Pattern pattern, |
| | |
| | | this.patternUsage = patternUsage; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitString(this, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitString(this, value, p); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return isCaseInsensitive; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | */ |
| | | public final class TopCfgDefn extends AbstractManagedObjectDefinition<ConfigurationClient, Configuration> { |
| | | |
| | | // The singleton configuration definition instance. |
| | | /** The singleton configuration definition instance. */ |
| | | private static final TopCfgDefn INSTANCE = new TopCfgDefn(); |
| | | |
| | | /** |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitUndefined(this, p); |
| | | } |
| | |
| | | */ |
| | | private static final long serialVersionUID = -4268510652395945357L; |
| | | |
| | | // Create the message. |
| | | /** Create the message. */ |
| | | private static LocalizableMessage createMessage(ManagedObject<?> partialManagedObject, |
| | | Collection<PropertyException> causes) { |
| | | Reject.ifNull(causes); |
| | |
| | | } |
| | | } |
| | | |
| | | // The exception(s) that caused this decoding exception. |
| | | /** The exception(s) that caused this decoding exception. */ |
| | | private final Collection<PropertyException> causes; |
| | | |
| | | // The partially created managed object. |
| | | /** The partially created managed object. */ |
| | | private final ManagedObject<?> partialManagedObject; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private static final long serialVersionUID = 6342522125252055588L; |
| | | |
| | | // Create the message. |
| | | /** Create the message. */ |
| | | private static LocalizableMessage createMessage(Collection<PropertyException> causes) { |
| | | Reject.ifNull(causes); |
| | | Reject.ifFalse(!causes.isEmpty(), "causes should not be empty"); |
| | |
| | | } |
| | | } |
| | | |
| | | // The causes of this exception. |
| | | /** The causes of this exception. */ |
| | | private final Collection<PropertyException> causes; |
| | | |
| | | // Indicates whether the exception occurred during managed object |
| | | // creation. |
| | | /** |
| | | * Indicates whether the exception occurred during managed object |
| | | * creation. |
| | | */ |
| | | private final boolean isCreate; |
| | | |
| | | // The user friendly name of the component that caused this |
| | | // exception. |
| | | /** |
| | | * The user friendly name of the component that caused this |
| | | * exception. |
| | | */ |
| | | private final LocalizableMessage ufn; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private static final long serialVersionUID = 8547688890613079044L; |
| | | |
| | | // Gets the default message. |
| | | /** Gets the default message. */ |
| | | private static LocalizableMessage getDefaultMessage(Collection<LocalizableMessage> messages) { |
| | | Reject.ifNull(messages); |
| | | Reject.ifFalse(!messages.isEmpty(), "Messages should not be empty"); |
| | |
| | | } |
| | | } |
| | | |
| | | // Merge the messages into a single message. |
| | | /** Merge the messages into a single message. */ |
| | | private static LocalizableMessage getSingleMessage(Collection<LocalizableMessage> messages) { |
| | | if (messages.size() == 1) { |
| | | return messages.iterator().next(); |
| | |
| | | } |
| | | } |
| | | |
| | | // The messages describing the constraint violations that occurred. |
| | | /** The messages describing the constraint violations that occurred. */ |
| | | private final Collection<LocalizableMessage> messages; |
| | | |
| | | // The type of operation that caused this exception. |
| | | /** The type of operation that caused this exception. */ |
| | | private final OperationType type; |
| | | |
| | | // The user friendly name of the component that caused this |
| | | // exception. |
| | | /** |
| | | * The user friendly name of the component that caused this |
| | | * exception. |
| | | */ |
| | | private final LocalizableMessage ufn; |
| | | |
| | | /** |
| | |
| | | this.profile = profile; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d, String name) { |
| | |
| | | return rdnsOfDn; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | appendManagedObjectPathElement(r); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | appendManagedObjectPathElement(r); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | |
| | | return pd.castValue(pd.accept(new ValueDecoder(), s)); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ValueDecoder() { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Object visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, String p) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) { |
| | | // By default the property definition's decoder will do. |
| | |
| | | |
| | | private final Connection connection; |
| | | |
| | | // The LDAP profile which should be used to construct LDAP |
| | | // requests and decode LDAP responses. |
| | | /** |
| | | * The LDAP profile which should be used to construct LDAP |
| | | * requests and decode LDAP responses. |
| | | */ |
| | | private final LDAPProfile profile; |
| | | |
| | | /** |
| | |
| | | this.context = context; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() { |
| | | connection.close(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject( |
| | | ManagedObjectPath<C, S> path) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration, P> SortedSet<P> getPropertyValues( |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ManagedObject<RootCfgClient> getRootConfigurationManagedObject() { |
| | | return new LDAPManagedObject<RootCfgClient>(this, RootCfgDefn.getInstance(), ManagedObjectPath.emptyPath(), |
| | | new PropertySet(), true, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | |
| | | return children.toArray(new String[children.size()]); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, |
| | |
| | | return children.toArray(new String[children.size()]); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean managedObjectExists(ManagedObjectPath<?, ?> path) throws ManagedObjectNotFoundException, |
| | | LdapException { |
| | |
| | | return entryExists(dn); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected <C extends ConfigurationClient, S extends Configuration> void deleteManagedObject( |
| | | ManagedObjectPath<C, S> path) throws OperationRejectedException, LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected LDAPManagementContext getManagementContext() { |
| | | return context; |
| | |
| | | return profile; |
| | | } |
| | | |
| | | // Create a managed object which already exists on the server. |
| | | /** Create a managed object which already exists on the server. */ |
| | | private <M extends ConfigurationClient, N extends Configuration> ManagedObject<M> createExistingManagedObject( |
| | | ManagedObjectDefinition<M, N> d, ManagedObjectPath<? super M, ? super N> p, PropertySet properties) { |
| | | RelationDefinition<?, ?> rd = p.getRelationDefinition(); |
| | |
| | | return new LDAPManagedObject<M>(this, d, p.asSubType(d), properties, true, pd); |
| | | } |
| | | |
| | | // Create a property using the provided string values. |
| | | /** Create a property using the provided string values. */ |
| | | private <P> void decodeProperty(PropertySet newProperties, ManagedObjectPath<?, ?> path, |
| | | PropertyDefinition<P> propertyDef, Attribute attribute) { |
| | | PropertyException exception = null; |
| | |
| | | return d.resolveManagedObjectDefinition(resolver); |
| | | } |
| | | |
| | | /* |
| | | /** |
| | | * Delete a subtree of entries. We cannot use the subtree delete control because it is not supported by the config |
| | | * backend. |
| | | */ |
| | |
| | | */ |
| | | private static final class ValueEncoder extends PropertyValueVisitor<Object, Void> { |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ValueEncoder() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Object visitAggregation( |
| | | AggregationPropertyDefinition<C, S> pd, String v, Void p) { |
| | |
| | | return reference.toDN().toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <P> Object visitUnknown(PropertyDefinition<P> propertyDef, P value, Void p) { |
| | | return propertyDef.encodeValue(value); |
| | | } |
| | | } |
| | | |
| | | // The LDAP management driver associated with this managed object. |
| | | /** The LDAP management driver associated with this managed object. */ |
| | | private final LDAPDriver driver; |
| | | |
| | | /** |
| | |
| | | this.driver = driver; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void addNewManagedObject() throws LdapException, OperationRejectedException, |
| | | ConcurrentModificationException, ManagedObjectAlreadyExistsException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Driver getDriver() { |
| | | return driver; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void modifyExistingManagedObject() throws ConcurrentModificationException, OperationRejectedException, |
| | | LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected <M extends ConfigurationClient> ManagedObject<M> newInstance(ManagedObjectDefinition<M, ?> d, |
| | | ManagedObjectPath<M, ?> path, PropertySet properties, boolean existsOnServer, |
| | |
| | | return new LDAPManagedObject<M>(driver, d, path, properties, existsOnServer, namingPropertyDefinition); |
| | | } |
| | | |
| | | // Encode a property into LDAP string values. |
| | | /** Encode a property into LDAP string values. */ |
| | | private <P> void encodeProperty(Attribute attribute, PropertyDefinition<P> propertyDef) { |
| | | PropertyValueVisitor<Object, Void> visitor = new ValueEncoder(); |
| | | Property<P> property = getProperty(propertyDef); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isModified() { |
| | | ManagedObjectDefinition<?, ?> d = getManagedObjectDefinition(); |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | |
| | | */ |
| | | private final class DefaultManagedObjectFactory implements RelationDefinitionVisitor<Void, Void> { |
| | | |
| | | // Possible exceptions. |
| | | /** Possible exceptions. */ |
| | | private ManagedObjectAlreadyExistsException moaee = null; |
| | | |
| | | private MissingMandatoryPropertiesException mmpe = null; |
| | |
| | | |
| | | private LdapException ere = null; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitInstantiable( |
| | | InstantiableRelationDefinition<C, S> rd, Void p) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, Void p) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSingleton( |
| | | SingletonRelationDefinition<C, S> rd, Void p) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSet(SetRelationDefinition<C, S> rd, |
| | | Void p) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | // Create the child managed object. |
| | | /** Create the child managed object. */ |
| | | private void createDefaultManagedObject(ManagedObjectDefinition<?, ?> d, ManagedObject<?> child, |
| | | DefaultManagedObject<?, ?> dmo) { |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | |
| | | } |
| | | } |
| | | |
| | | // Set property values. |
| | | /** Set property values. */ |
| | | private <P> void setPropertyValues(ManagedObject<?> mo, PropertyDefinition<P> pd, |
| | | DefaultManagedObject<?, ?> dmo) { |
| | | mo.setPropertyValues(pd, dmo.getPropertyValues(pd)); |
| | | } |
| | | } |
| | | |
| | | // The managed object definition associated with this managed |
| | | // object. |
| | | /** |
| | | * The managed object definition associated with this managed |
| | | * object. |
| | | */ |
| | | private final ManagedObjectDefinition<T, ? extends Configuration> definition; |
| | | |
| | | // Indicates whether or not this managed object exists on the server |
| | | // (false means the managed object is new and has not been |
| | | // committed). |
| | | /** |
| | | * Indicates whether or not this managed object exists on the server |
| | | * (false means the managed object is new and has not been |
| | | * committed). |
| | | */ |
| | | private boolean existsOnServer; |
| | | |
| | | // Optional naming property definition. |
| | | /** Optional naming property definition. */ |
| | | private final PropertyDefinition<?> namingPropertyDefinition; |
| | | |
| | | // The path associated with this managed object. |
| | | /** The path associated with this managed object. */ |
| | | private ManagedObjectPath<T, ? extends Configuration> path; |
| | | |
| | | // The managed object's properties. |
| | | /** The managed object's properties. */ |
| | | private final PropertySet properties; |
| | | |
| | | /** |
| | |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | InstantiableRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, String name, |
| | |
| | | return createNewManagedObject(d, childPath, pd, name, exceptions); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | OptionalRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, |
| | |
| | | return createNewManagedObject(d, childPath, null, null, exceptions); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | SetRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, |
| | |
| | | return createNewManagedObject(d, childPath, null, null, exceptions); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws DefinitionDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r, name)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | OptionalRelationDefinition<C, S> r) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SingletonRelationDefinition<C, S> r) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SetRelationDefinition<C, S> r, String name) throws DefinitionDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r, cd)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final T getConfiguration() { |
| | | return definition.createClientConfiguration(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final ManagedObjectDefinition<T, ? extends Configuration> getManagedObjectDefinition() { |
| | | return definition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final ManagedObjectPath<T, ? extends Configuration> getManagedObjectPath() { |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyDefaultValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<P>(getProperty(pd).getDefaultValues()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> P getPropertyValue(PropertyDefinition<P> pd) { |
| | | Set<P> values = getProperty(pd).getEffectiveValues(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<P>(getProperty(pd).getEffectiveValues()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean hasChild( |
| | | OptionalRelationDefinition<C, S> r) throws ConcurrentModificationException, LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean isPropertyPresent(PropertyDefinition<?> pd) { |
| | | return !getProperty(pd).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r) throws ConcurrentModificationException, LdapException { |
| | | return listChildren(r, r.getChildDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | SetRelationDefinition<C, S> r) throws ConcurrentModificationException, LdapException { |
| | | return listChildren(r, r.getChildDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | SetRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws ManagedObjectNotFoundException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | OptionalRelationDefinition<C, S> r) throws ManagedObjectNotFoundException, OperationRejectedException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | SetRelationDefinition<C, S> r, String name) throws ManagedObjectNotFoundException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> void setPropertyValue(PropertyDefinition<P> pd, P value) { |
| | | if (value == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> void setPropertyValues(PropertyDefinition<P> pd, Collection<P> values) { |
| | | if (pd.hasOption(PropertyOption.MONITORING)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | ManagedObjectPath<M, ?> path, PropertySet properties, boolean existsOnServer, |
| | | PropertyDefinition<?> namingPropertyDefinition); |
| | | |
| | | // Creates a new managed object with no active values, just default |
| | | // values. |
| | | /** |
| | | * Creates a new managed object with no active values, just default |
| | | * values. |
| | | */ |
| | | private <M extends ConfigurationClient, P> ManagedObject<M> createNewManagedObject( |
| | | ManagedObjectDefinition<M, ?> d, ManagedObjectPath<M, ?> p, PropertyDefinition<P> namingPropertyDefinition, |
| | | String name, Collection<PropertyException> exceptions) { |
| | |
| | | return newInstance(d, p, childProperties, false, namingPropertyDefinition); |
| | | } |
| | | |
| | | // Create an empty property. |
| | | /** Create an empty property. */ |
| | | private <P> void createProperty(PropertySet properties, ManagedObjectPath<?, ?> p, PropertyDefinition<P> pd) { |
| | | try { |
| | | Driver context = getDriver(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Makes sure that this managed object exists. |
| | | /** Makes sure that this managed object exists. */ |
| | | private void ensureThisManagedObjectExists() throws ConcurrentModificationException, LdapException { |
| | | if (!path.isEmpty()) { |
| | | Driver ctx = getDriver(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Validate that a relation definition belongs to this managed |
| | | // object. |
| | | /** |
| | | * Validate that a relation definition belongs to this managed |
| | | * object. |
| | | */ |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) { |
| | | ManagedObjectDefinition<T, ?> d = getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = d.getRelationDefinition(rd.getName()); |
| | |
| | | */ |
| | | private final class DefaultValueFinder<T> implements DefaultBehaviorProviderVisitor<T, Collection<T>, Void> { |
| | | |
| | | // Any exception that occurred whilst retrieving inherited default |
| | | // values. |
| | | /** |
| | | * Any exception that occurred whilst retrieving inherited default |
| | | * values. |
| | | */ |
| | | private PropertyException exception = null; |
| | | |
| | | // The path of the managed object containing the first property. |
| | | /** The path of the managed object containing the first property. */ |
| | | private final ManagedObjectPath<?, ?> firstPath; |
| | | |
| | | // Indicates whether the managed object has been created yet. |
| | | /** Indicates whether the managed object has been created yet. */ |
| | | private final boolean isCreate; |
| | | |
| | | // The path of the managed object containing the next property. |
| | | /** The path of the managed object containing the next property. */ |
| | | private ManagedObjectPath<?, ?> nextPath = null; |
| | | |
| | | // The next property whose default values were required. |
| | | /** The next property whose default values were required. */ |
| | | private PropertyDefinition<T> nextProperty = null; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DefaultValueFinder(ManagedObjectPath<?, ?> p, boolean isCreate) { |
| | | this.firstPath = p; |
| | | this.isCreate = isCreate; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitAlias(AliasDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | Collection<String> stringValues = d.getDefaultValues(); |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | // Find the default values for the next path/property. |
| | | /** Find the default values for the next path/property. */ |
| | | private Collection<T> find(ManagedObjectPath<?, ?> p, PropertyDefinition<T> pd) { |
| | | this.nextPath = p; |
| | | this.nextProperty = pd; |
| | |
| | | return values; |
| | | } |
| | | |
| | | // Get an inherited property value. |
| | | /** Get an inherited property value. */ |
| | | @SuppressWarnings("unchecked") |
| | | private Collection<T> getInheritedProperty(ManagedObjectPath<?, ?> target, |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | |
| | | } |
| | | } |
| | | |
| | | // Remove a managed object, first ensuring that the parent exists, |
| | | // then ensuring that the child exists, before ensuring that any |
| | | // constraints are satisfied. |
| | | /** |
| | | * Remove a managed object, first ensuring that the parent exists, |
| | | * then ensuring that the child exists, before ensuring that any |
| | | * constraints are satisfied. |
| | | */ |
| | | private <C extends ConfigurationClient, S extends Configuration> boolean doDeleteManagedObject( |
| | | ManagedObjectPath<C, S> path) throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | LdapException { |
| | |
| | | */ |
| | | private static final class MyProperty<T> implements Property<T> { |
| | | |
| | | // The active set of values. |
| | | /** The active set of values. */ |
| | | private final SortedSet<T> activeValues; |
| | | |
| | | // The definition associated with this property. |
| | | /** The definition associated with this property. */ |
| | | private final PropertyDefinition<T> d; |
| | | |
| | | // The default set of values (read-only). |
| | | /** The default set of values (read-only). */ |
| | | private final SortedSet<T> defaultValues; |
| | | |
| | | // The pending set of values. |
| | | /** The pending set of values. */ |
| | | private final SortedSet<T> pendingValues; |
| | | |
| | | /** |
| | |
| | | activeValues.addAll(pendingValues); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<T> getActiveValues() { |
| | | return Collections.unmodifiableSortedSet(activeValues); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<T> getDefaultValues() { |
| | | return defaultValues; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<T> getEffectiveValues() { |
| | | SortedSet<T> values = getPendingValues(); |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<T> getPendingValues() { |
| | | return Collections.unmodifiableSortedSet(pendingValues); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PropertyDefinition<T> getPropertyDefinition() { |
| | | return d; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isEmpty() { |
| | | return pendingValues.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModified() { |
| | | if (activeValues.size() == pendingValues.size() && activeValues.containsAll(pendingValues)) { |
| | |
| | | pendingValues.addAll(c); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return getEffectiveValues().toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean wasEmpty() { |
| | | return activeValues.isEmpty(); |
| | | } |
| | | } |
| | | |
| | | // The properties. |
| | | /** The properties. */ |
| | | private final Map<PropertyDefinition<?>, MyProperty<?>> properties; |
| | | |
| | | /** |
| | |
| | | return (Property<T>) properties.get(d); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | */ |
| | | public final class ANDCondition implements Condition { |
| | | |
| | | // The list of sub-conditions. |
| | | /** The list of sub-conditions. */ |
| | | private final List<Condition> conditions; |
| | | |
| | | /** |
| | |
| | | this.conditions = Arrays.asList(conditions); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | for (Condition condition : conditions) { |
| | | if (!condition.evaluate(context, managedObject)) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | for (Condition condition : conditions) { |
| | | if (!condition.evaluate(managedObject)) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | for (Condition condition : conditions) { |
| | | condition.initialize(d); |
| | |
| | | */ |
| | | public static final Condition FALSE = new Condition() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public static final Condition TRUE = new Condition() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // No implementation required. |
| | | } |
| | |
| | | return new ORCondition(conditions); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Conditions() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | private static final class Impl<T> implements Condition { |
| | | |
| | | // The property. |
| | | /** The property. */ |
| | | final PropertyDefinition<T> pd; |
| | | |
| | | // The required property value. |
| | | /** The required property value. */ |
| | | final T value; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private Impl(PropertyDefinition<T> pd, T value) { |
| | | this.pd = pd; |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | SortedSet<T> values = managedObject.getPropertyValues(pd); |
| | | return values.contains(value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | SortedSet<T> values = managedObject.getPropertyValues(pd); |
| | | return values.contains(value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // Not used. |
| | | } |
| | | |
| | | // Private implementation of fix() method. |
| | | /** Private implementation of fix() method. */ |
| | | private void setPropertyValue(ManagedObject<?> managedObject) { |
| | | managedObject.setPropertyValue(pd, value); |
| | | } |
| | | |
| | | } |
| | | |
| | | // The strongly typed private implementation. |
| | | /** The strongly typed private implementation. */ |
| | | private Impl<?> impl = null; |
| | | |
| | | // The property name. |
| | | /** The property name. */ |
| | | private final String propertyName; |
| | | |
| | | // The string representation of the required property value. |
| | | /** The string representation of the required property value. */ |
| | | private final String propertyStringValue; |
| | | |
| | | /** |
| | |
| | | this.propertyStringValue = stringValue; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return impl.evaluate(context, managedObject); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return impl.evaluate(managedObject); |
| | | } |
| | |
| | | impl.setPropertyValue(managedObject); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // Decode the property. |
| | | buildImpl(d.getPropertyDefinition(propertyName)); |
| | | } |
| | | |
| | | // Creates the new private implementation. |
| | | /** Creates the new private implementation. */ |
| | | private <T> void buildImpl(PropertyDefinition<T> pd) { |
| | | T value = pd.decodeValue(propertyStringValue); |
| | | this.impl = new Impl<T>(pd, value); |
| | |
| | | */ |
| | | public final class IsPresentCondition implements Condition { |
| | | |
| | | // The property name. |
| | | /** The property name. */ |
| | | private final String propertyName; |
| | | |
| | | // The property definition. |
| | | /** The property definition. */ |
| | | private PropertyDefinition<?> pd; |
| | | |
| | | /** |
| | |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | SortedSet<?> values = managedObject.getPropertyValues(pd); |
| | | return !values.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | SortedSet<?> values = managedObject.getPropertyValues(pd); |
| | | return !values.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // Decode the property. |
| | | this.pd = d.getPropertyDefinition(propertyName); |
| | |
| | | */ |
| | | public final class NOTCondition implements Condition { |
| | | |
| | | // The single sub-condition. |
| | | /** The single sub-condition. */ |
| | | private final Condition condition; |
| | | |
| | | /** |
| | |
| | | this.condition = condition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return !condition.evaluate(context, managedObject); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return !condition.evaluate(managedObject); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | condition.initialize(d); |
| | | } |
| | |
| | | */ |
| | | public final class ORCondition implements Condition { |
| | | |
| | | // The list of sub-conditions. |
| | | /** The list of sub-conditions. */ |
| | | private final List<Condition> conditions; |
| | | |
| | | /** |
| | |
| | | this.conditions = Arrays.asList(conditions); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | for (Condition condition : conditions) { |
| | | if (condition.evaluate(context, managedObject)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | for (Condition condition : conditions) { |
| | | if (condition.evaluate(managedObject)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | for (Condition condition : conditions) { |
| | | condition.initialize(d); |
| | |
| | | return new ClientException(ReturnCode.ERROR_USER_DATA, msg); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ArgumentExceptionFactory() { |
| | | // No implementation required. |
| | | } |
| | |
| | | return new GetPropSubCommandHandler(parser, path.child(r), r); |
| | | } |
| | | |
| | | // The sub-commands naming arguments. |
| | | /** The sub-commands naming arguments. */ |
| | | private final List<StringArgument> namingArgs; |
| | | |
| | | // The path of the managed object. |
| | | /** The path of the managed object. */ |
| | | private final ManagedObjectPath<?, ?> path; |
| | | |
| | | // The sub-command associated with this handler. |
| | | /** The sub-command associated with this handler. */ |
| | | private final SubCommand subCommand; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private GetPropSubCommandHandler(SubCommandArgumentParser parser, ManagedObjectPath<?, ?> path, |
| | | RelationDefinition<?, ?> r) throws ArgumentException { |
| | | this.path = path; |
| | |
| | | return path.getRelationDefinition(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SubCommand getSubCommand() { |
| | | return subCommand; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, LDAPManagementContextFactory factory) |
| | | throws ArgumentException, ClientException { |
| | |
| | | return MenuResult.success(0); |
| | | } |
| | | |
| | | // Display the set of values associated with a property. |
| | | /** Display the set of values associated with a property. */ |
| | | private <T> void displayProperty(final ConsoleApplication app, TableBuilder builder, ManagedObject<?> mo, |
| | | PropertyDefinition<T> pd, PropertyValuePrinter valuePrinter) { |
| | | SortedSet<T> values = mo.getPropertyValues(pd); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * /** {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Void> visitBoolean(BooleanPropertyDefinition d, Void p) { |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<Boolean>(app); |
| | |
| | | |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | |
| | | private MenuResult<ManagedObject<?>> result; |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | if (result.isSuccess()) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | if (result.isSuccess()) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | if (result.isSuccess()) { |
| | |
| | | this.dde = null; |
| | | this.mode = null; |
| | | this.monfe = null; |
| | | this.ere = null; |
| | | |
| | | path.serialize(this); |
| | | |
| | |
| | | /** |
| | | * A path serializer which is used to register a sub-command's naming arguments. |
| | | */ |
| | | protected static final class NamingArgumentBuilder implements ManagedObjectPathSerializer { |
| | | private static final class NamingArgumentBuilder implements ManagedObjectPathSerializer { |
| | | |
| | | /** |
| | | * Creates the naming arguments for a given path. |
| | |
| | | * @throws ArgumentException |
| | | * If one or more naming arguments could not be registered. |
| | | */ |
| | | public static List<StringArgument> create(SubCommand subCommand, ManagedObjectPath<?, ?> path, boolean isCreate) |
| | | throws ArgumentException { |
| | | private static List<StringArgument> create(SubCommand subCommand, ManagedObjectPath<?, ?> path, |
| | | boolean isCreate) throws ArgumentException { |
| | | NamingArgumentBuilder builder = new NamingArgumentBuilder(subCommand, path.size(), isCreate); |
| | | path.serialize(builder); |
| | | |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | sz--; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | sz--; |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | sz--; |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int compareTo(SubCommandHandler o) { |
| | | String s1 = getSubCommand().getName(); |
| | | String s2 = o.getSubCommand().getName(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds one or more tags to this sub-command handler. |
| | | * |
| | | * @param tags |
| | | * The tags to be added to this sub-command handler. |
| | | */ |
| | | protected final void addTags(Tag... tags) { |
| | | addTags(Arrays.asList(tags)); |
| | | } |
| | | |
| | | /** |
| | | * Creates the naming arguments for a given path and registers them. |
| | | * |
| | | * @param subCommand |
| | |
| | | final String value = arg.getValue(); |
| | | if (value == null && !app.isInteractive()) { |
| | | throw ArgumentExceptionFactory.missingMandatoryNonInteractiveArgument(arg); |
| | | } else { |
| | | values.add(value); |
| | | } |
| | | values.add(value); |
| | | } |
| | | return values; |
| | | } |
| | |
| | | * the type of the property to be retrieved. |
| | | * @return the String value to be displayed in the equivalent command-line. |
| | | */ |
| | | protected static <T> String castAndGetArgumentValue(PropertyDefinition<T> propertyDefinition, Object o) { |
| | | static <T> String castAndGetArgumentValue(PropertyDefinition<T> propertyDefinition, Object o) { |
| | | return propertyDefinition.encodeValue(propertyDefinition.castValue(o)); |
| | | } |
| | | |
| | |
| | | * the type of the property to be retrieved. |
| | | * @return the String value to be displayed in the equivalent command-line. |
| | | */ |
| | | protected static <T> String getArgumentValue(PropertyDefinition<T> propertyDefinition, T o) { |
| | | static <T> String getArgumentValue(PropertyDefinition<T> propertyDefinition, T o) { |
| | | return propertyDefinition.encodeValue(o); |
| | | } |
| | | |
| | |
| | | * The managed object definition. |
| | | * @return A mapping of managed object type argument values to their corresponding managed object definitions. |
| | | */ |
| | | protected static <C extends ConfigurationClient, S extends Configuration> SortedMap<String, |
| | | static <C extends ConfigurationClient, S extends Configuration> SortedMap<String, |
| | | ManagedObjectDefinition<? extends C, ? extends S>> getSubTypes( |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | | SortedMap<String, ManagedObjectDefinition<? extends C, ? extends S>> map; |
| | |
| | | * The child definition. |
| | | * @return The type short name. |
| | | */ |
| | | protected static <C extends ConfigurationClient, S extends Configuration> String getShortTypeName( |
| | | private static <C extends ConfigurationClient, S extends Configuration> String getShortTypeName( |
| | | AbstractManagedObjectDefinition<C, S> d, AbstractManagedObjectDefinition<?, ?> c) { |
| | | if (c == d) { |
| | | // This is the top-level definition, so use the value "generic" or |
| | |
| | | * The managed object definition. |
| | | * @return A usage string representing the list of possible types for the provided managed object definition. |
| | | */ |
| | | protected static String getSubTypesUsage(AbstractManagedObjectDefinition<?, ?> d) { |
| | | static String getSubTypesUsage(AbstractManagedObjectDefinition<?, ?> d) { |
| | | // Build the -t option usage. |
| | | SortedMap<String, ?> types = getSubTypes(d); |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(ConfigAddListenerAdaptor.class); |
| | | |
| | | // Cached managed object between accept/apply callbacks. |
| | | /** Cached managed object between accept/apply callbacks. */ |
| | | private ServerManagedObject<? extends S> cachedManagedObject; |
| | | |
| | | // The instantiable relation. |
| | | /** The instantiable relation. */ |
| | | private final InstantiableRelationDefinition<?, S> instantiableRelation; |
| | | |
| | | // The set relation. |
| | | /** The set relation. */ |
| | | private final SetRelationDefinition<?, S> setRelation; |
| | | |
| | | // The underlying add listener. |
| | | /** The underlying add listener. */ |
| | | private final ServerManagedObjectAddListener<S> listener; |
| | | |
| | | // The optional relation. |
| | | /** The optional relation. */ |
| | | private final OptionalRelationDefinition<?, S> optionalRelation; |
| | | |
| | | // The managed object path of the parent. |
| | | /** The managed object path of the parent. */ |
| | | private final ManagedObjectPath<?, ?> path; |
| | | |
| | | private final ServerManagementContext serverContext; |
| | |
| | | this.cachedManagedObject = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ConfigChangeResult applyConfigurationAdd(Entry configEntry) { |
| | | if (optionalRelation != null) { |
| | | // Optional managed objects are located directly beneath the |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean configAddIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getName(); |
| | | String name = dn.rdn().getFirstAVA().getAttributeValue().toString().trim(); |
| | |
| | | db.accept(v, path); |
| | | } |
| | | |
| | | // The names of entries that this change listener depends on. |
| | | /** The names of entries that this change listener depends on. */ |
| | | private final Collection<DN> dependencies; |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Visitor(Collection<DN> dependencies) { |
| | | this.dependencies = dependencies; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Void visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, ManagedObjectPath<?, ?> p) { |
| | | ManagedObjectPath<?, ?> next = d.getManagedObjectPath(); |
| | | dependencies.add(DNBuilder.create(next)); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Void visitAlias(AliasDefaultBehaviorProvider<T> d, ManagedObjectPath<?, ?> p) { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Void visitDefined(DefinedDefaultBehaviorProvider<T> d, ManagedObjectPath<?, ?> p) { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Void visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, ManagedObjectPath<?, ?> p) { |
| | | ManagedObjectPath<?, ?> next = d.getManagedObjectPath(p); |
| | | dependencies.add(DNBuilder.create(next)); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Void visitUndefined(UndefinedDefaultBehaviorProvider<T> d, ManagedObjectPath<?, ?> p) { |
| | | return null; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ConfigChangeResult applyConfigurationChange(Entry configEntry) { |
| | | // Looking at the ConfigFileHandler implementation reveals |
| | | // that this ConfigEntry will actually be a different object to |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean configChangeIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | return configChangeIsAcceptable(configEntry, unacceptableReason, configEntry); |
| | | } |
| | |
| | | return listener; |
| | | } |
| | | |
| | | // Returns the named configuration entry or null if it could not be |
| | | // retrieved. |
| | | /** |
| | | * Returns the named configuration entry or null if it could not be |
| | | * retrieved. |
| | | */ |
| | | private Entry getConfigEntry(DN dn) { |
| | | try { |
| | | if (configRepository.hasEntry(dn)) { |
| | |
| | | * about the result of processing a configuration change. |
| | | */ |
| | | public final class ConfigChangeResult { |
| | | // A set of messages describing the changes that were made, any |
| | | // action that may be required, or any problems that were |
| | | // encountered. |
| | | /** |
| | | * A set of messages describing the changes that were made, any |
| | | * action that may be required, or any problems that were encountered. |
| | | */ |
| | | private List<LocalizableMessage> messages; |
| | | |
| | | // Indicates whether one or more of the changes requires |
| | | // administrative action in order to take effect. |
| | | /** |
| | | * Indicates whether one or more of the changes requires |
| | | * administrative action in order to take effect. |
| | | */ |
| | | private boolean adminActionRequired; |
| | | |
| | | // The result code to return to the client from this configuration |
| | | // change. |
| | | /** |
| | | * The result code to return to the client from this configuration change. |
| | | */ |
| | | private ResultCode resultCode; |
| | | |
| | | /** |
| | |
| | | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(ConfigDeleteListenerAdaptor.class); |
| | | |
| | | // Cached managed object between accept/apply callbacks. |
| | | /** Cached managed object between accept/apply callbacks. */ |
| | | private ServerManagedObject<? extends S> cachedManagedObject; |
| | | |
| | | // The instantiable relation. |
| | | /** The instantiable relation. */ |
| | | private final InstantiableRelationDefinition<?, S> instantiableRelation; |
| | | |
| | | // The set relation. |
| | | /** The set relation. */ |
| | | private final SetRelationDefinition<?, S> setRelation; |
| | | |
| | | // The underlying delete listener. |
| | | /** The underlying delete listener. */ |
| | | private final ServerManagedObjectDeleteListener<S> listener; |
| | | |
| | | // The optional relation. |
| | | /** The optional relation. */ |
| | | private final OptionalRelationDefinition<?, S> optionalRelation; |
| | | |
| | | // The managed object path of the parent. |
| | | /** The managed object path of the parent. */ |
| | | private final ManagedObjectPath<?, ?> path; |
| | | |
| | | private final ServerManagementContext serverContext; |
| | |
| | | this.cachedManagedObject = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(Entry configEntry) { |
| | | if (optionalRelation != null) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean configDeleteIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getName(); |
| | | String name = dn.rdn().getFirstAVA().getAttributeValue().toString().trim(); |
| | |
| | | */ |
| | | final class ConfigExceptionFactory { |
| | | |
| | | // The singleton instance. |
| | | /** The singleton instance. */ |
| | | private static final ConfigExceptionFactory INSTANCE = new ConfigExceptionFactory(); |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ConfigExceptionFactory() { |
| | | // Do nothing. |
| | | } |
| | |
| | | */ |
| | | private static final long serialVersionUID = -4902443848460011875L; |
| | | |
| | | // The server managed object. |
| | | /** The server managed object. */ |
| | | private final ServerManagedObject<?> managedObject; |
| | | |
| | | // Gets the default message. |
| | | /** Gets the default message. */ |
| | | private static LocalizableMessage getDefaultMessage(Collection<LocalizableMessage> messages) { |
| | | Reject.ifNull(messages); |
| | | Reject.ifFalse(!messages.isEmpty(), "messages should not be empty"); |
| | |
| | | } |
| | | } |
| | | |
| | | // Merge the messages into a single message. |
| | | /** Merge the messages into a single message. */ |
| | | private static LocalizableMessage getSingleMessage(Collection<LocalizableMessage> messages) { |
| | | if (messages.size() == 1) { |
| | | return messages.iterator().next(); |
| | |
| | | } |
| | | } |
| | | |
| | | // The messages describing the constraint violations that occurred. |
| | | /** The messages describing the constraint violations that occurred. */ |
| | | private final Collection<LocalizableMessage> messages; |
| | | |
| | | /** |
| | |
| | | return dn.child(localName); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private DNBuilder() { |
| | | // No implementation required. |
| | | } |
| | |
| | | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(DelayedConfigAddListener.class); |
| | | |
| | | // The name of the parent entry. |
| | | /** The name of the parent entry. */ |
| | | private final DN parent; |
| | | |
| | | // The name of the subordinate entry which should have an add or |
| | | // delete listener registered with it when it is created. |
| | | /** |
| | | * The name of the subordinate entry which should have an add or |
| | | * delete listener registered with it when it is created. |
| | | */ |
| | | private final DN child; |
| | | |
| | | // The add listener to be registered with the subordinate entry when |
| | | // it is added (or null if a delete listener should be registered). |
| | | /** |
| | | * The add listener to be registered with the subordinate entry when |
| | | * it is added (or null if a delete listener should be registered). |
| | | */ |
| | | private final ConfigAddListener delayedAddListener; |
| | | |
| | | // The delete listener to be registered with the subordinate entry |
| | | // when it is added (or null if an add listener should be |
| | | // registered). |
| | | /** |
| | | * The delete listener to be registered with the subordinate entry |
| | | * when it is added (or null if an add listener should be registered). |
| | | */ |
| | | private final ConfigDeleteListener delayedDeleteListener; |
| | | |
| | | private final ConfigurationRepository configRepository; |
| | |
| | | this.delayedDeleteListener = deleteListener; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(Entry configEntry) { |
| | | if (configEntry.getName().equals(child)) { |
| | |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean configAddIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | // Always acceptable. |
| | |
| | | registerDeleteListener(baseDN, adaptor); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | this.configDN = configDN; |
| | | } |
| | | |
| | | // Deregister an add listener. |
| | | /** Deregister an add listener. */ |
| | | private <M extends Configuration> void deregisterAddListener(DN baseDN, ConfigurationAddListener<M> listener) { |
| | | try { |
| | | if (configRepository.hasEntry(baseDN)) { |
| | |
| | | } |
| | | } |
| | | |
| | | // Deregister an add listener. |
| | | /** Deregister an add listener. */ |
| | | private <M extends Configuration> void deregisterAddListener(DN baseDN, |
| | | ServerManagedObjectAddListener<M> listener) { |
| | | try { |
| | |
| | | return Pair.empty(); |
| | | } |
| | | |
| | | // Deregister a delete listener. |
| | | /** Deregister a delete listener. */ |
| | | private <M extends Configuration> void deregisterDeleteListener(DN baseDN, |
| | | ConfigurationDeleteListener<M> listener) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | // Deregister a delete listener. |
| | | /** Deregister a delete listener. */ |
| | | private <M extends Configuration> void deregisterDeleteListener(DN baseDN, |
| | | ServerManagedObjectDeleteListener<M> listener) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | // Register an instantiable or optional relation add listener. |
| | | /** Register an instantiable or optional relation add listener. */ |
| | | private void registerAddListener(DN baseDN, ConfigAddListener adaptor) throws |
| | | ConfigException { |
| | | if (configRepository.hasEntry(baseDN)) { |
| | |
| | | } |
| | | } |
| | | |
| | | // Register a delayed listener with the nearest existing parent |
| | | // entry to the provided base DN. |
| | | /** |
| | | * Register a delayed listener with the nearest existing parent |
| | | * entry to the provided base DN. |
| | | */ |
| | | private void registerDelayedListener(DN baseDN, ConfigAddListener delayedListener) throws ConfigException { |
| | | DN currentDN = baseDN.parent(); |
| | | DN previousDN = currentDN; |
| | |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | // Deregister a delayed listener with the nearest existing parent |
| | | // entry to the provided base DN. |
| | | /** |
| | | * Deregister a delayed listener with the nearest existing parent |
| | | * entry to the provided base DN. |
| | | */ |
| | | private <M extends Configuration> void deregisterDelayedAddListener(DN baseDN, |
| | | ConfigurationAddListener<M> listener) throws ConfigException { |
| | | DN parentDN = baseDN.parent(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Deregister a delayed listener with the nearest existing parent |
| | | // entry to the provided base DN. |
| | | /** |
| | | * Deregister a delayed listener with the nearest existing parent |
| | | * entry to the provided base DN. |
| | | */ |
| | | private <M extends Configuration> void deregisterDelayedDeleteListener(DN baseDN, |
| | | ConfigurationDeleteListener<M> listener) throws ConfigException { |
| | | DN parentDN = baseDN.parent(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Deregister a delayed listener with the nearest existing parent |
| | | // entry to the provided base DN. |
| | | /** |
| | | * Deregister a delayed listener with the nearest existing parent |
| | | * entry to the provided base DN. |
| | | */ |
| | | private <M extends Configuration> void deregisterDelayedAddListener(DN baseDN, |
| | | ServerManagedObjectAddListener<M> listener) throws ConfigException { |
| | | DN parentDN = baseDN.parent(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Deregister a delayed listener with the nearest existing parent |
| | | // entry to the provided base DN. |
| | | /** |
| | | * Deregister a delayed listener with the nearest existing parent |
| | | * entry to the provided base DN. |
| | | */ |
| | | private <M extends Configuration> void deregisterDelayedDeleteListener(DN baseDN, |
| | | ServerManagedObjectDeleteListener<M> listener) throws ConfigException { |
| | | DN parentDN = baseDN.parent(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Register an instantiable or optional relation delete listener. |
| | | /** Register an instantiable or optional relation delete listener. */ |
| | | private void registerDeleteListener(DN baseDN, ConfigDeleteListener adaptor) throws ConfigException { |
| | | if (configRepository.hasEntry(baseDN)) { |
| | | configRepository.registerDeleteListener(baseDN, adaptor); |
| | |
| | | } |
| | | } |
| | | |
| | | // Validate that a relation definition belongs to this managed |
| | | // object. |
| | | /** Validate that a relation definition belongs to this managed object. */ |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) { |
| | | RelationDefinition<?, ?> tmp = definition.getRelationDefinition(rd.getName()); |
| | | if (tmp != rd) { |
| | |
| | | final class ServerManagedObjectAddListenerAdaptor<T extends Configuration> implements |
| | | ServerManagedObjectAddListener<T> { |
| | | |
| | | // The underlying add listener. |
| | | /** The underlying add listener. */ |
| | | private final ConfigurationAddListener<T> listener; |
| | | |
| | | /** |
| | |
| | | this.listener = listener; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ConfigChangeResult applyConfigurationAdd(ServerManagedObject<? extends T> mo) { |
| | | return listener.applyConfigurationAdd(mo.getConfiguration()); |
| | | } |
| | |
| | | return listener; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isConfigurationAddAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return listener.isConfigurationAddAcceptable(mo.getConfiguration(), unacceptableReasons); |
| | |
| | | final class ServerManagedObjectChangeListenerAdaptor<T extends Configuration> implements |
| | | ServerManagedObjectChangeListener<T> { |
| | | |
| | | // The underlying change listener. |
| | | /** The underlying change listener. */ |
| | | private final ConfigurationChangeListener<? super T> listener; |
| | | |
| | | /** |
| | |
| | | this.listener = listener; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(ServerManagedObject<? extends T> mo) { |
| | | return listener.applyConfigurationChange(mo.getConfiguration()); |
| | |
| | | return listener; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | |
| | | */ |
| | | private static final long serialVersionUID = 1598401431084729853L; |
| | | |
| | | // Create the message. |
| | | /** Create the message. */ |
| | | private static LocalizableMessage createMessage(ServerManagedObject<?> partialManagedObject, |
| | | Collection<PropertyException> causes) { |
| | | Reject.ifNull(causes); |
| | |
| | | } |
| | | } |
| | | |
| | | // The exception(s) that caused this decoding exception. |
| | | /** The exception(s) that caused this decoding exception. */ |
| | | private final Collection<PropertyException> causes; |
| | | |
| | | // The partially created server managed object. |
| | | /** The partially created server managed object. */ |
| | | private final ServerManagedObject<?> partialManagedObject; |
| | | |
| | | /** |
| | |
| | | final class ServerManagedObjectDeleteListenerAdaptor<T extends Configuration> implements |
| | | ServerManagedObjectDeleteListener<T> { |
| | | |
| | | // The underlying delete listener. |
| | | /** The underlying delete listener. */ |
| | | private final ConfigurationDeleteListener<T> listener; |
| | | |
| | | /** |
| | |
| | | this.listener = listener; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ConfigChangeResult applyConfigurationDelete(ServerManagedObject<? extends T> mo) { |
| | | return listener.applyConfigurationDelete(mo.getConfiguration()); |
| | | } |
| | |
| | | return listener; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isConfigurationDeleteAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return listener.isConfigurationDeleteAcceptable(mo.getConfiguration(), unacceptableReasons); |
| | |
| | | */ |
| | | private final class DefaultValueFinder<T> implements DefaultBehaviorProviderVisitor<T, Collection<T>, Void> { |
| | | |
| | | // Any exception that occurred whilst retrieving inherited default |
| | | // values. |
| | | /** |
| | | * Any exception that occurred whilst retrieving inherited default |
| | | * values. |
| | | */ |
| | | private PropertyException exception = null; |
| | | |
| | | // Optional new configuration entry which does not yet exist in |
| | | // the configuration back-end. |
| | | /** |
| | | * Optional new configuration entry which does not yet exist in |
| | | * the configuration back-end. |
| | | */ |
| | | private final Entry newConfigEntry; |
| | | |
| | | // The path of the managed object containing the next property. |
| | | /** The path of the managed object containing the next property. */ |
| | | private ManagedObjectPath<?, ?> nextPath = null; |
| | | |
| | | // The next property whose default values were required. |
| | | /** The next property whose default values were required. */ |
| | | private PropertyDefinition<T> nextProperty = null; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DefaultValueFinder(Entry newConfigEntry) { |
| | | this.newConfigEntry = newConfigEntry; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<T> visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(), d.getManagedObjectDefinition(), |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<T> visitAlias(AliasDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | Collection<String> stringValues = d.getDefaultValues(); |
| | | List<T> values = new ArrayList<T>(stringValues.size()); |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<T> visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(nextPath), d.getManagedObjectDefinition(), |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | // Find the default values for the next path/property. |
| | | /** Find the default values for the next path/property. */ |
| | | private Collection<T> find(ManagedObjectPath<?, ?> path, PropertyDefinition<T> propertyDef) { |
| | | nextPath = path; |
| | | nextProperty = propertyDef; |
| | |
| | | return values; |
| | | } |
| | | |
| | | // Get an inherited property value. |
| | | /** Get an inherited property value. */ |
| | | @SuppressWarnings("unchecked") |
| | | private Collection<T> getInheritedProperty(ManagedObjectPath<?, ?> target, |
| | | AbstractManagedObjectDefinition<?, ?> definition, String propertyName) { |
| | |
| | | */ |
| | | private static final class MyDefinitionResolver implements DefinitionResolver { |
| | | |
| | | // The config entry. |
| | | /** The config entry. */ |
| | | private final Entry entry; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private MyDefinitionResolver(Entry entry) { |
| | | this.entry = entry; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean matches(AbstractManagedObjectDefinition<?, ?> d) { |
| | | String oc = LDAPProfile.getInstance().getObjectClass(d); |
| | | // TODO : use the schema to get object class and check it in the entry |
| | |
| | | return propertyDef.castValue(propertyDef.accept(new ValueDecoder(), value)); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ValueDecoder() { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Object visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, String p) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) { |
| | | // By default the property definition's decoder will do. |
| | |
| | | } |
| | | } |
| | | |
| | | // Decode helper method required to avoid generics warning. |
| | | /** Decode helper method required to avoid generics warning. */ |
| | | private <C extends ConfigurationClient, S extends Configuration> ServerManagedObject<S> decodeAux( |
| | | ManagedObjectPath<? super C, ? super S> path, ManagedObjectDefinition<C, S> d, |
| | | Map<PropertyDefinition<?>, SortedSet<?>> properties, DN configDN) { |
| | |
| | | return values; |
| | | } |
| | | |
| | | // Get the default values for the specified property. |
| | | /** Get the default values for the specified property. */ |
| | | private <T> Collection<T> getDefaultValues(ManagedObjectPath<?, ?> p, PropertyDefinition<T> pd, |
| | | Entry newConfigEntry) { |
| | | DefaultValueFinder<T> v = new DefaultValueFinder<T>(newConfigEntry); |
| | |
| | | return configRepository; |
| | | } |
| | | |
| | | // Gets a config entry required for a managed object and throws a |
| | | // config exception on failure. |
| | | /** |
| | | * Gets a config entry required for a managed object and throws a |
| | | * config exception on failure. |
| | | */ |
| | | private Entry getManagedObjectConfigEntry(DN dn) throws ConfigException { |
| | | Entry configEntry; |
| | | try { |
| | |
| | | return configEntry; |
| | | } |
| | | |
| | | // Validate that a relation definition belongs to the path. |
| | | /** Validate that a relation definition belongs to the path. */ |
| | | private void validateRelationDefinition(ManagedObjectPath<?, ?> path, RelationDefinition<?, ?> rd) { |
| | | AbstractManagedObjectDefinition<?, ?> d = path.getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = d.getRelationDefinition(rd.getName()); |
| | |
| | | return configRepository; |
| | | } |
| | | |
| | | /** Returns the name used for the provided entry (the value of the cn attribute) */ |
| | | /** Returns the name used for the provided entry (the value of the cn attribute). */ |
| | | protected final String entryName(final Entry entry) { |
| | | return entry.getName().rdn().getFirstAVA().getAttributeValue().toString(); |
| | | } |
| | | |
| | | /** Gets the named parent configuration corresponding to the provided entry */ |
| | | /** Gets the named parent configuration corresponding to the provided entry. */ |
| | | protected final TestParentCfg getParentCfg(final Entry entry, final ServerManagementContext serverContext) |
| | | throws Exception { |
| | | return getParentCfg(entryName(entry), serverContext); |
| | |
| | | assertEquals(type.getNameOrOID(), value); |
| | | } |
| | | |
| | | // Create a new definition. |
| | | /** Create a new definition. */ |
| | | private AttributeTypePropertyDefinition createPropertyDefinition() { |
| | | AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder( |
| | | RootCfgDefn.getInstance(), "test-property"); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class ClassPropertyDefinitionTest extends ConfigTestCase { |
| | | |
| | | // Dummy class used in tests. |
| | | /** Dummy class used in tests. */ |
| | | public static final class Dummy { |
| | | public class X { |
| | | // no implementation |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates data for testing string-based limit values |
| | | * Creates data for testing string-based limit values. |
| | | * |
| | | * @return data |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates data for testing limit values |
| | | * Creates data for testing limit values. |
| | | * |
| | | * @return data |
| | | */ |
| | |
| | | assertEquals(def.encodeValue(valueToEncode), expectedValue); |
| | | } |
| | | |
| | | /** Test that accept doesn't throw and exception */ |
| | | /** Test that accept doesn't throw and exception. */ |
| | | @Test |
| | | public void testAccept() { |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | |
| | | assertEquals((boolean) def.accept(v, null), true); |
| | | } |
| | | |
| | | /** Make sure toString doesn't barf */ |
| | | /** Make sure toString doesn't barf. */ |
| | | @Test |
| | | public void testToString() { |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | |
| | | def.toString(); |
| | | } |
| | | |
| | | /** Make sure toString doesn't barf */ |
| | | /** Make sure toString doesn't barf. */ |
| | | @Test |
| | | public void testToString2() { |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Tests that exception thrown when no enum class specified by builder |
| | | * Tests that exception thrown when no enum class specified by builder. |
| | | */ |
| | | @Test |
| | | public void testBuildInstance() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Tests that exception thrown when no enum class specified by builder |
| | | * Tests that exception thrown when no enum class specified by builder. |
| | | */ |
| | | @Test(expectedExceptions = { IllegalStateException.class }) |
| | | public void testBuildInstanceWithoutEnumClassSpecified() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates data decodeValue test |
| | | * Creates data decodeValue test. |
| | | * |
| | | * @return data |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Tests decodeValue() |
| | | * Tests decodeValue(). |
| | | * |
| | | * @param value |
| | | * to decode |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates illegal data for decode value test |
| | | * Creates illegal data for decode value test. |
| | | * |
| | | * @return data |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Tests decodeValue() |
| | | * Tests decodeValue(). |
| | | * |
| | | * @param value |
| | | * to decode |
| | |
| | | def.decodeValue(value); |
| | | } |
| | | |
| | | /** |
| | | * Tests normalization |
| | | */ |
| | | /** Tests normalization. */ |
| | | @Test |
| | | public void testNormalizeValue() { |
| | | EnumPropertyDefinition<TestEnum> def = builder.getInstance(); |
| | | assertEquals(def.normalizeValue(TestEnum.ONE), "one"); |
| | | } |
| | | |
| | | /** |
| | | * Tests validation |
| | | */ |
| | | /** Tests validation. */ |
| | | @Test |
| | | public void testValidateValue() { |
| | | EnumPropertyDefinition<TestEnum> def = builder.getInstance(); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class LDAPProfileTest extends ConfigTestCase { |
| | | |
| | | /** Makes sure the returned list contains "top" */ |
| | | /** Makes sure the returned list contains "top". */ |
| | | @Test |
| | | public void testGetObjectClasses() { |
| | | LDAPProfile ldapProfile = LDAPProfile.getInstance(); |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getAttributeName(AbstractManagedObjectDefinition<?, ?> d, PropertyDefinition<?> pd) { |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getRelationChildRDNType(InstantiableRelationDefinition<?, ?> r) { |
| | | if (r == TestCfg.getTestOneToManyParentRelationDefinition() |
| | | || r == TestParentCfgDefn.getInstance().getTestChildrenRelationDefinition()) { |
| | | return "cn"; |
| | | } else { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getObjectClass(AbstractManagedObjectDefinition<?, ?> d) { |
| | | if (d == TestParentCfgDefn.getInstance()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getRelationRDNSequence(RelationDefinition<?, ?> r) { |
| | | if (r == TestCfg.getTestOneToManyParentRelationDefinition()) { |
| | |
| | | d.decodeValue("abc123"); |
| | | } |
| | | |
| | | // Create a string property definition. |
| | | /** Create a string property definition. */ |
| | | private StringPropertyDefinition getDefinition(boolean isCaseInsensitive, String pattern) { |
| | | StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(RootCfgDefn.getInstance(), |
| | | "test-property"); |
| | |
| | | RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT; |
| | | // @Checkstyle:on |
| | | |
| | | // Create a one-to-many relation for test-parent components. |
| | | /** Create a one-to-many relation for test-parent components. */ |
| | | static { |
| | | InstantiableRelationDefinition.Builder<TestParentCfgClient, TestParentCfg> builder = |
| | | new InstantiableRelationDefinition.Builder<TestParentCfgClient, TestParentCfg>( |
| | |
| | | RD_TEST_ONE_TO_MANY_PARENT = builder.getInstance(); |
| | | } |
| | | |
| | | // Create a one-to-many relation for test-parent components. |
| | | /** Create a one-to-many relation for test-parent components. */ |
| | | static { |
| | | OptionalRelationDefinition.Builder<TestParentCfgClient, TestParentCfg> builder = |
| | | new OptionalRelationDefinition.Builder<TestParentCfgClient, TestParentCfg>( |
| | |
| | | TestChildCfgDefn.getInstance().deregisterConstraint(constraint); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private TestCfg() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public final class TestChildCfgDefn extends ManagedObjectDefinition<TestChildCfgClient, TestChildCfg> { |
| | | |
| | | // The singleton configuration definition instance. |
| | | /** The singleton configuration definition instance. */ |
| | | private static final TestChildCfgDefn INSTANCE = new TestChildCfgDefn(); |
| | | |
| | | // The "aggregation-property" property definition. |
| | | // @Checkstyle:off |
| | | /** The "aggregation-property" property definition. */ |
| | | private static final AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> |
| | | PROPDEF_AGGREGATION_PROPERTY; |
| | | // @Checkstyle:on |
| | | |
| | | // The "mandatory-boolean-property" property definition. |
| | | /** The "mandatory-boolean-property" property definition. */ |
| | | private static final BooleanPropertyDefinition PROPDEF_MANDATORY_BOOLEAN_PROPERTY; |
| | | |
| | | // The "mandatory-class-property" property definition. |
| | | /** The "mandatory-class-property" property definition. */ |
| | | private static final ClassPropertyDefinition PROPDEF_MANDATORY_CLASS_PROPERTY; |
| | | |
| | | // The "mandatory-read-only-attribute-type-property" property definition. |
| | | /** The "mandatory-read-only-attribute-type-property" property definition. */ |
| | | private static final AttributeTypePropertyDefinition PROPDEF_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY; |
| | | |
| | | // The "optional-multi-valued-dn-property1" property definition. |
| | | /** The "optional-multi-valued-dn-property1" property definition. */ |
| | | private static final DNPropertyDefinition PROPDEF_OPTIONAL_MULTI_VALUED_DN_PROPERTY1; |
| | | |
| | | // The "optional-multi-valued-dn-property2" property definition. |
| | | /** The "optional-multi-valued-dn-property2" property definition. */ |
| | | private static final DNPropertyDefinition PROPDEF_OPTIONAL_MULTI_VALUED_DN_PROPERTY2; |
| | | |
| | | // Build the "aggregation-property" property definition. |
| | | /** Build the "aggregation-property" property definition. */ |
| | | static { |
| | | AggregationPropertyDefinition.Builder<ConnectionHandlerCfgClient, ConnectionHandlerCfg> builder = |
| | | AggregationPropertyDefinition.createBuilder(INSTANCE, "aggregation-property"); |
| | |
| | | INSTANCE.registerConstraint(PROPDEF_AGGREGATION_PROPERTY.getSourceConstraint()); |
| | | } |
| | | |
| | | // Build the "mandatory-boolean-property" property definition. |
| | | /** Build the "mandatory-boolean-property" property definition. */ |
| | | static { |
| | | BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-boolean-property"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PROPDEF_MANDATORY_BOOLEAN_PROPERTY); |
| | | } |
| | | |
| | | // Build the "mandatory-class-property" property definition. |
| | | /** Build the "mandatory-class-property" property definition. */ |
| | | static { |
| | | ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-class-property"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PROPDEF_MANDATORY_CLASS_PROPERTY); |
| | | } |
| | | |
| | | // Build the "mandatory-read-only-attribute-type-property" property |
| | | // definition. |
| | | /** |
| | | * Build the "mandatory-read-only-attribute-type-property" property |
| | | * definition. |
| | | */ |
| | | static { |
| | | AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-read-only-attribute-type-property"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PROPDEF_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY); |
| | | } |
| | | |
| | | // Build the "optional-multi-valued-dn-property1" property definition. |
| | | /** Build the "optional-multi-valued-dn-property1" property definition. */ |
| | | static { |
| | | DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, |
| | | "optional-multi-valued-dn-property1"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PROPDEF_OPTIONAL_MULTI_VALUED_DN_PROPERTY1); |
| | | } |
| | | |
| | | // Build the "optional-multi-valued-dn-property2" property definition. |
| | | /** Build the "optional-multi-valued-dn-property2" property definition. */ |
| | | static { |
| | | DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, |
| | | "optional-multi-valued-dn-property2"); |
| | |
| | | super("test-child", null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestChildCfgClient createClientConfiguration(ManagedObject<? extends TestChildCfgClient> impl) { |
| | | return new TestChildCfgClientImpl(impl); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestChildCfg createServerConfiguration(ServerManagedObject<? extends TestChildCfg> impl) { |
| | | return new TestChildCfgServerImpl(impl); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Class<TestChildCfg> getServerConfigurationClass() { |
| | | return TestChildCfg.class; |
| | | } |
| | |
| | | */ |
| | | private static class TestChildCfgClientImpl implements TestChildCfgClient { |
| | | |
| | | // Private implementation. |
| | | /** Private implementation. */ |
| | | private ManagedObject<? extends TestChildCfgClient> impl; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private TestChildCfgClientImpl(ManagedObject<? extends TestChildCfgClient> impl) { |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<String> getAggregationProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getAggregationPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setAggregationProperty(Collection<String> values) { |
| | | impl.setPropertyValues(INSTANCE.getAggregationPropertyPropertyDefinition(), values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setMandatoryBooleanProperty(boolean value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setMandatoryClassProperty(String value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty1() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setOptionalMultiValuedDNProperty1(Collection<DN> values) { |
| | | impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition(), values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty2() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setOptionalMultiValuedDNProperty2(Collection<DN> values) { |
| | | impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition(), values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ManagedObjectDefinition<? extends TestChildCfgClient, ? extends TestChildCfg> definition() { |
| | | return INSTANCE; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public PropertyProvider properties() { |
| | | return impl; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | | impl.commit(); |
| | |
| | | */ |
| | | private static class TestChildCfgServerImpl implements TestChildCfg { |
| | | |
| | | // Private implementation. |
| | | /** Private implementation. */ |
| | | private ServerManagedObject<? extends TestChildCfg> impl; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private TestChildCfgServerImpl(ServerManagedObject<? extends TestChildCfg> impl) { |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addChangeListener(ConfigurationChangeListener<TestChildCfg> listener) { |
| | | impl.registerChangeListener(listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeChangeListener(ConfigurationChangeListener<TestChildCfg> listener) { |
| | | impl.deregisterChangeListener(listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<String> getAggregationProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getAggregationPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty1() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty2() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Class<? extends TestChildCfg> configurationClass() { |
| | | return TestChildCfg.class; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public DN dn() { |
| | | return impl.getDN(); |
| | | } |
| | |
| | | */ |
| | | public final class TestParentCfgDefn extends ManagedObjectDefinition<TestParentCfgClient, TestParentCfg> { |
| | | |
| | | // The singleton configuration definition instance. |
| | | /** The singleton configuration definition instance. */ |
| | | private static final TestParentCfgDefn INSTANCE = new TestParentCfgDefn(); |
| | | |
| | | // The "mandatory-boolean-property" property definition. |
| | | /** The "mandatory-boolean-property" property definition. */ |
| | | private static final BooleanPropertyDefinition PD_MANDATORY_BOOLEAN_PROPERTY; |
| | | |
| | | // The "mandatory-class-property" property definition. |
| | | /** The "mandatory-class-property" property definition. */ |
| | | private static final ClassPropertyDefinition PD_MANDATORY_CLASS_PROPERTY; |
| | | |
| | | // The "mandatory-read-only-attribute-type-property" property definition. |
| | | /** The "mandatory-read-only-attribute-type-property" property definition. */ |
| | | private static final AttributeTypePropertyDefinition PD_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY; |
| | | |
| | | // The "optional-multi-valued-dn-property" property definition. |
| | | /** The "optional-multi-valued-dn-property" property definition. */ |
| | | private static final DNPropertyDefinition PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY; |
| | | |
| | | // The "test-children" relation definition. |
| | | /** The "test-children" relation definition. */ |
| | | private static final InstantiableRelationDefinition<TestChildCfgClient, TestChildCfg> RD_TEST_CHILDREN; |
| | | |
| | | // The "optional-test-child" relation definition. |
| | | /** The "optional-test-child" relation definition. */ |
| | | private static final OptionalRelationDefinition<TestChildCfgClient, TestChildCfg> RD_OPTIONAL_TEST_CHILD; |
| | | |
| | | // Build the "mandatory-boolean-property" property definition. |
| | | /** Build the "mandatory-boolean-property" property definition. */ |
| | | static { |
| | | BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-boolean-property"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PD_MANDATORY_BOOLEAN_PROPERTY); |
| | | } |
| | | |
| | | // Build the "mandatory-class-property" property definition. |
| | | /** Build the "mandatory-class-property" property definition. */ |
| | | static { |
| | | ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-class-property"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PD_MANDATORY_CLASS_PROPERTY); |
| | | } |
| | | |
| | | // Build the "mandatory-read-only-attribute-type-property" property |
| | | // definition. |
| | | /** |
| | | * Build the "mandatory-read-only-attribute-type-property" property |
| | | * definition. |
| | | */ |
| | | static { |
| | | AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-read-only-attribute-type-property"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PD_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY); |
| | | } |
| | | |
| | | // Build the "optional-multi-valued-dn-property" property definition. |
| | | /** Build the "optional-multi-valued-dn-property" property definition. */ |
| | | static { |
| | | DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, |
| | | "optional-multi-valued-dn-property"); |
| | |
| | | INSTANCE.registerPropertyDefinition(PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY); |
| | | } |
| | | |
| | | // Build the "test-children" relation definition. |
| | | /** Build the "test-children" relation definition. */ |
| | | static { |
| | | InstantiableRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = |
| | | new InstantiableRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | |
| | | INSTANCE.registerRelationDefinition(RD_TEST_CHILDREN); |
| | | } |
| | | |
| | | // Build the "optional-test-child" relation definition. |
| | | /** Build the "optional-test-child" relation definition. */ |
| | | static { |
| | | OptionalRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = |
| | | new OptionalRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | |
| | | super("test-parent", null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestParentCfgClient createClientConfiguration(ManagedObject<? extends TestParentCfgClient> impl) { |
| | | return new TestParentCfgClientImpl(impl); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestParentCfg createServerConfiguration(ServerManagedObject<? extends TestParentCfg> impl) { |
| | | return new TestParentCfgServerImpl(impl); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Class<TestParentCfg> getServerConfigurationClass() { |
| | | return TestParentCfg.class; |
| | | } |
| | |
| | | */ |
| | | private static class TestParentCfgClientImpl implements TestParentCfgClient { |
| | | |
| | | // Private implementation. |
| | | /** Private implementation. */ |
| | | private ManagedObject<? extends TestParentCfgClient> impl; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private TestParentCfgClientImpl(ManagedObject<? extends TestParentCfgClient> impl) { |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setMandatoryBooleanProperty(boolean value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setMandatoryClassProperty(String value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void setOptionalMultiValuedDNProperty(Collection<DN> values) { |
| | | impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNPropertyPropertyDefinition(), values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String[] listTestChildren() throws ConcurrentModificationException, LdapException { |
| | | return impl.listChildren(INSTANCE.getTestChildrenRelationDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestChildCfgClient getTestChild(String name) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | LdapException { |
| | | return impl.getChild(INSTANCE.getTestChildrenRelationDefinition(), name).getConfiguration(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <M extends TestChildCfgClient> M createTestChild(ManagedObjectDefinition<M, ? extends TestChildCfg> d, |
| | | String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException { |
| | | return impl.createChild(INSTANCE.getTestChildrenRelationDefinition(), d, name, exceptions) |
| | | .getConfiguration(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeTestChild(String name) throws ManagedObjectNotFoundException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | | impl.removeChild(INSTANCE.getTestChildrenRelationDefinition(), name); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasOptionalTestChild() throws ConcurrentModificationException, LdapException { |
| | | return impl.hasChild(INSTANCE.getOptionalTestChildRelationDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestChildCfgClient getOptionalChild() throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | LdapException { |
| | | return impl.getChild(INSTANCE.getOptionalTestChildRelationDefinition()).getConfiguration(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <M extends TestChildCfgClient> M createOptionalTestChild( |
| | | ManagedObjectDefinition<M, ? extends TestChildCfg> d, Collection<PropertyException> exceptions) { |
| | | return impl.createChild(INSTANCE.getOptionalTestChildRelationDefinition(), d, exceptions) |
| | | .getConfiguration(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeOptionalTestChild() throws ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | OperationRejectedException, LdapException { |
| | | impl.removeChild(INSTANCE.getOptionalTestChildRelationDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ManagedObjectDefinition<? extends TestParentCfgClient, ? extends TestParentCfg> definition() { |
| | | return INSTANCE; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public PropertyProvider properties() { |
| | | return impl; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | | impl.commit(); |
| | |
| | | */ |
| | | private static class TestParentCfgServerImpl implements TestParentCfg { |
| | | |
| | | // Private implementation. |
| | | /** Private implementation. */ |
| | | private ServerManagedObject<? extends TestParentCfg> impl; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private TestParentCfgServerImpl(ServerManagedObject<? extends TestParentCfg> impl) { |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addChangeListener(ConfigurationChangeListener<TestParentCfg> listener) { |
| | | impl.registerChangeListener(listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeChangeListener(ConfigurationChangeListener<TestParentCfg> listener) { |
| | | impl.deregisterChangeListener(listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String[] listTestChildren() { |
| | | return impl.listChildren(INSTANCE.getTestChildrenRelationDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestChildCfg getTestChild(String name) throws ConfigException { |
| | | return impl.getChild(INSTANCE.getTestChildrenRelationDefinition(), name).getConfiguration(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) throws ConfigException { |
| | | impl.registerAddListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) { |
| | | impl.deregisterAddListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addTestChildDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) |
| | | throws ConfigException { |
| | | impl.registerDeleteListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeTestChildDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) { |
| | | impl.deregisterDeleteListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasOptionalTestChild() { |
| | | return impl.hasChild(INSTANCE.getOptionalTestChildRelationDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public TestChildCfg getOptionalTestChild() throws ConfigException { |
| | | return impl.getChild(INSTANCE.getOptionalTestChildRelationDefinition()).getConfiguration(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addOptionalTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) |
| | | throws ConfigException { |
| | | impl.registerAddListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeOptionalTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) { |
| | | impl.deregisterAddListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addOptionalChildTestDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) |
| | | throws ConfigException { |
| | | impl.registerDeleteListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void removeOptionalTestChildDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) { |
| | | impl.deregisterDeleteListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Class<? extends TestParentCfg> configurationClass() { |
| | | return TestParentCfg.class; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public DN dn() { |
| | | return impl.getDN(); |
| | | } |
| | |
| | | return params; |
| | | } |
| | | |
| | | // Exceptions to config objects having a different objectclass |
| | | /** Exceptions to config objects having a different objectclass. */ |
| | | private static final List<String> CLASS_OBJECT_CLASS_EXCEPTIONS = Arrays.asList(new String[] { |
| | | "org.forgerock.opendj.config.std.meta.RootCfgDefn", "org.forgerock.opendj.config.std.meta.GlobalCfgDefn", }); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // Exceptions to properties ending in -class being exactly 'java-class'. |
| | | /** Exceptions to properties ending in -class being exactly 'java-class'. */ |
| | | private static final List<String> CLASS_PROPERTY_EXCEPTIONS = Arrays.asList(new String[] { |
| | | // e.g. "prop-name-ending-with-class" |
| | | }); |
| | | |
| | | // Exceptions to properties ending in -enabled being exactly 'enabled'. |
| | | /** Exceptions to properties ending in -enabled being exactly 'enabled'. */ |
| | | private static final List<String> ENABLED_PROPERTY_EXCEPTIONS = Arrays.asList(new String[] { |
| | | "index-filter-analyzer-enabled", "subordinate-indexes-enabled" |
| | | // e.g. "prop-name-ending-with-enabled" |
| | | }); |
| | | |
| | | // Exceptions to properties not starting with the name of their config |
| | | // object |
| | | /** |
| | | * Exceptions to properties not starting with the name of their config |
| | | * object. |
| | | */ |
| | | private static final List<String> OBJECT_PREFIX_PROPERTY_EXCEPTIONS = Arrays.asList(new String[] { "backend-id", |
| | | "plugin-type", "replication-server-id", "network-group-id", "workflow-id", "workflow-element-id", |
| | | "workflow-element" |
| | |
| | | @Test(singleThreaded = true) |
| | | public class AggregationClientTest extends AdminTestCase { |
| | | |
| | | // Test LDIF. |
| | | /** Test LDIF. */ |
| | | private static final String[] TEST_LDIF = new String[] { |
| | | // @formatter:off |
| | | // Base entries. |
| | |
| | | "cn=JMX Connection Handler,cn=connection handlers, cn=config"); |
| | | } |
| | | |
| | | // Retrieve the named test parent managed object. |
| | | /** Retrieve the named test parent managed object. */ |
| | | private TestParentCfgClient getTestParent(ManagementContext context, String name) |
| | | throws Exception { |
| | | ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject(); |
| | |
| | | .getConfiguration(); |
| | | } |
| | | |
| | | // Asserts that the actual set of DNs contains the expected values. |
| | | /** Asserts that the actual set of DNs contains the expected values. */ |
| | | private void assertSetEquals(SortedSet<String> actual, String... expected) { |
| | | SortedSet<String> values = |
| | | new TreeSet<String>(TestChildCfgDefn.getInstance() |
| | |
| | | } |
| | | } |
| | | |
| | | // Asserts that the actual set of DNs contains the expected values. |
| | | /** Asserts that the actual set of DNs contains the expected values. */ |
| | | private void assertDNSetEquals(SortedSet<DN> actual, String... expected) { |
| | | String[] actualStrings = new String[actual.size()]; |
| | | int i = 0; |
| | |
| | | Assert.assertEqualsNoOrder(actualStrings, expected); |
| | | } |
| | | |
| | | // Create the named test parent managed object. |
| | | /** Create the named test parent managed object. */ |
| | | private TestParentCfgClient createTestParent(ManagementContext context, String name) |
| | | throws Exception { |
| | | ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject(); |
| | |
| | | TestParentCfgDefn.getInstance(), name, null).getConfiguration(); |
| | | } |
| | | |
| | | // Retrieve the named test parent managed object. |
| | | /** Retrieve the named test parent managed object. */ |
| | | private TestParentCfgClient getTestParent(ManagementContext context, String name) |
| | | throws Exception { |
| | | ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject(); |
| | |
| | | .getConfiguration(); |
| | | } |
| | | |
| | | // List test parent managed objects. |
| | | /** List test parent managed objects. */ |
| | | private String[] listTestParents(ManagementContext context) throws Exception { |
| | | ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject(); |
| | | return root.listChildren(TestCfg.getTestOneToManyParentRelationDefinition()); |
| | | } |
| | | |
| | | // Remove the named test parent managed object. |
| | | /** Remove the named test parent managed object. */ |
| | | private void removeTestParent(ManagementContext context, String name) throws Exception { |
| | | ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject(); |
| | | root.removeChild(TestCfg.getTestOneToManyParentRelationDefinition(), name); |
| | |
| | | */ |
| | | private class Handler extends ClientConstraintHandler { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAddAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return allowAdds; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isDeleteAcceptable(ManagementContext context, ManagedObjectPath<?, ?> path, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return allowDeletes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | |
| | | } |
| | | |
| | | // Determines if add operations are allowed. |
| | | /** Determines if add operations are allowed. */ |
| | | private final boolean allowAdds; |
| | | |
| | | // Determines if modify operations are allowed. |
| | | /** Determines if modify operations are allowed. */ |
| | | private final boolean allowModifies; |
| | | |
| | | // Determines if delete operations are allowed. |
| | | /** Determines if delete operations are allowed. */ |
| | | private final boolean allowDeletes; |
| | | |
| | | /** |
| | |
| | | this.allowDeletes = allowDeletes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | return Collections.<ClientConstraintHandler> singleton(new Handler()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | */ |
| | | public final class AdminTestCaseUtils { |
| | | |
| | | // The relation name which will be used for dummy configurations. A |
| | | // deliberately obfuscated name is chosen to avoid clashes. |
| | | /** |
| | | * The relation name which will be used for dummy configurations. A |
| | | * deliberately obfuscated name is chosen to avoid clashes. |
| | | */ |
| | | private static final String DUMMY_TEST_RELATION = "*dummy*test*relation*"; |
| | | |
| | | // Indicates if the dummy relation profile has been registered. |
| | | /** Indicates if the dummy relation profile has been registered. */ |
| | | private static boolean isProfileRegistered = false; |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private AdminTestCaseUtils() { |
| | | // No implementation required. |
| | | } |
| | |
| | | "objectclass: ds-cfg-branch", |
| | | "cn: test children"); |
| | | |
| | | /** this handler is disabled - see ds-cfg-enabled property */ |
| | | /** This handler is disabled - see ds-cfg-enabled property. */ |
| | | protected static final Entry TEST_CONNECTION_HANDLER_ENTRY_DISABLED = LDIF.makeEntry( |
| | | "dn: cn=" + "Test Connection Handler" + ",cn=Connection Handlers,cn=config", |
| | | "objectClass: top", |
| | |
| | | "ds-cfg-enabled: false", |
| | | "ds-cfg-listen-address: 0.0.0.0", "ds-cfg-listen-port: 389"); |
| | | |
| | | /** this handler is enabled - see ds-cfg-enabled property */ |
| | | /** This handler is enabled - see ds-cfg-enabled property. */ |
| | | protected static final Entry TEST_CONNECTION_HANDLER_ENTRY_ENABLED = LDIF.makeEntry( |
| | | "dn: cn=" + "Test Connection Handler" + ",cn=Connection Handlers,cn=config", |
| | | "objectClass: top", |
| | |
| | | "objectclass: ds-cfg-branch", |
| | | "cn: test children"); |
| | | |
| | | // Parent 1 - uses default values for |
| | | // optional-multi-valued-dn-property. |
| | | /** |
| | | * Parent 1 - uses default values for |
| | | * optional-multi-valued-dn-property. |
| | | */ |
| | | private static final Entry TEST_PARENT_1 = LDIF.makeEntry( |
| | | "dn: cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | |
| | | "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | | "ds-cfg-attribute-type: description", |
| | | "ds-cfg-conflict-behavior: virtual-overrides-real"); |
| | | |
| | | // @Checkstyle:on |
| | | |
| | | @BeforeClass |
| | |
| | | TestCfg.cleanup(); |
| | | } |
| | | |
| | | /** Success just ensure there is no exception raised */ |
| | | /** Success just ensure there is no exception raised. */ |
| | | @Test |
| | | public void testGetManagedObjectSuccess() throws Exception { |
| | | // arrange |
| | |
| | | "objectclass: ds-cfg-branch", |
| | | "cn: test parents"); |
| | | |
| | | // Parent 1 - uses default values for optional-multi-valued-dn-property. |
| | | /** Parent 1 - uses default values for optional-multi-valued-dn-property. */ |
| | | static final List<String> LDIF_TEST_PARENT_1 = Arrays.asList( |
| | | "dn: cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | |
| | | |
| | | static final Entry TEST_PARENT_1 = makeEntry(LDIF_TEST_PARENT_1); |
| | | |
| | | // Parent 2 - overrides default values for optional-multi-valued-dn-property. |
| | | /** Parent 2 - overrides default values for optional-multi-valued-dn-property. */ |
| | | static final Entry TEST_PARENT_2 = makeEntry( |
| | | "dn: cn=test parent 2,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | |
| | | "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | | "ds-cfg-attribute-type: description", |
| | | "ds-cfg-conflict-behavior: virtual-overrides-real"); |
| | | |
| | | // @Checkstyle:on |
| | | |
| | | @BeforeClass |
| | |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), dnProperty2); |
| | | } |
| | | |
| | | /** Asserts that the actual set of DNs contains the expected values */ |
| | | /** Asserts that the actual set of DNs contains the expected values. */ |
| | | private void assertDNSetEquals(SortedSet<DN> actualDNs, List<String> expectedDNs) { |
| | | String[] actualStrings = new String[actualDNs.size()]; |
| | | int i = 0; |
| | |
| | | assertThat(actualStrings).containsOnly(expectedDNs.toArray(new Object[expectedDNs.size()])); |
| | | } |
| | | |
| | | /** Make an entry by combining two lists */ |
| | | /** Make an entry by combining two lists. */ |
| | | static Entry makeEntryFrom(List<String> base, List<String> attrs) { |
| | | List<String> ldif = new ArrayList<String>(base); |
| | | ldif.addAll(attrs); |
| | |
| | | |
| | | /** |
| | | * Register a listener for test parent entry and return the actual |
| | | * registered listener |
| | | * registered listener. |
| | | */ |
| | | private ConfigAddListener registerAddListenerForTestParent(ConfigurationRepository configRepository, |
| | | ServerManagedObject<RootCfg> root, ConfigurationAddListener<TestParentCfg> parentListener) throws Exception { |
| | |
| | | |
| | | /** |
| | | * Register a listener for test parent entry in delayed scenario and return |
| | | * the actual registered listener |
| | | * the actual registered listener. |
| | | */ |
| | | private DelayedConfigAddListener registerAddListenerForTestParentDelayed( |
| | | ConfigurationRepository configRepository, ServerManagedObject<RootCfg> root, |
| | |
| | | */ |
| | | private class MockConstraintHandler extends ServerConstraintHandler { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isDeleteAllowed(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | return isDeleteAllowed; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | return isUsable; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostAdd(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Make sure that the associated config entry exists. |
| | |
| | | Assert.assertTrue(configRepository.hasEntry(targetDN)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostDelete(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Make sure that the associated config entry does not exist. |
| | |
| | | Assert.assertTrue(configRepository.hasEntry(targetDN)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostModify(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Make sure that the associated config entry exists. |
| | |
| | | |
| | | } |
| | | |
| | | // Determines if delete operations are allowed. |
| | | /** Determines if delete operations are allowed. */ |
| | | private final boolean isDeleteAllowed; |
| | | |
| | | // Determines if configurations can be decoded. |
| | | /** Determines if configurations can be decoded. */ |
| | | private final boolean isUsable; |
| | | |
| | | private final ConfigurationRepository configRepository; |
| | |
| | | this.configRepository = configRepository; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.<ServerConstraintHandler> singleton(new MockConstraintHandler()); |
| | | } |
| | |
| | | return isCritical ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE; |
| | | } |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private AccountUsabilityRequestControl(final boolean isCritical) { |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | secondsBeforeExpiration); |
| | | } |
| | | |
| | | // Indicates whether the user's account is usable. |
| | | /** Indicates whether the user's account is usable. */ |
| | | private final boolean isUsable; |
| | | |
| | | // Indicates whether the user's password is expired. |
| | | /** Indicates whether the user's password is expired. */ |
| | | private final boolean isExpired; |
| | | |
| | | // Indicates whether the user's account is inactive. |
| | | /** Indicates whether the user's account is inactive. */ |
| | | private final boolean isInactive; |
| | | |
| | | // Indicates whether the user's account is currently locked. |
| | | /** Indicates whether the user's account is currently locked. */ |
| | | private final boolean isLocked; |
| | | |
| | | // Indicates whether the user's password has been reset and must be |
| | | // changed before anything else can be done. |
| | | /** |
| | | * Indicates whether the user's password has been reset and must be |
| | | * changed before anything else can be done. |
| | | */ |
| | | private final boolean isReset; |
| | | |
| | | // The number of remaining grace logins, if available. |
| | | /** The number of remaining grace logins, if available. */ |
| | | private final int remainingGraceLogins; |
| | | |
| | | // The length of time in seconds before the user's password expires, |
| | | // if available. |
| | | /** |
| | | * The length of time in seconds before the user's password expires, |
| | | * if available. |
| | | */ |
| | | private final int secondsBeforeExpiration; |
| | | |
| | | // The length of time before the user's account is unlocked, if |
| | | // available. |
| | | /** |
| | | * The length of time before the user's account is unlocked, if |
| | | * available. |
| | | */ |
| | | private final int secondsBeforeUnlock; |
| | | |
| | | private final boolean isCritical; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private AccountUsabilityResponseControl(final boolean isCritical, final boolean isUsable, |
| | | final boolean isInactive, final boolean isReset, final boolean isExpired, |
| | | final int remainingGraceLogins, final boolean isLocked, final int secondsBeforeUnlock, |
| | |
| | | this.secondsBeforeExpiration = secondsBeforeExpiration; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | |
| | | return secondsBeforeUnlock; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | |
| | | return isUsable; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | |
| | | private static final class ResultDecoder extends |
| | | AbstractExtendedResultDecoder<GetConnectionIDExtendedResult> { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public GetConnectionIDExtendedResult newExtendedErrorResult(final ResultCode resultCode, |
| | | final String matchedDN, final String diagnosticMessage) { |
| | | if (!resultCode.isExceptional()) { |
| | |
| | | */ |
| | | public static final String OID = "1.3.6.1.4.1.26027.1.6.2"; |
| | | |
| | | // Singleton. |
| | | /** Singleton. */ |
| | | private static final GetConnectionIDExtendedRequest INSTANCE = |
| | | new GetConnectionIDExtendedRequest(); |
| | | |
| | |
| | | */ |
| | | public static final RequestDecoder REQUEST_DECODER = new RequestDecoder(); |
| | | |
| | | // No need to expose this. |
| | | /** No need to expose this. */ |
| | | private static final ResultDecoder RESULT_DECODER = new ResultDecoder(); |
| | | |
| | | /** |
| | |
| | | return INSTANCE; |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private GetConnectionIDExtendedRequest() { |
| | | // Nothing to do. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ExtendedResultDecoder<GetConnectionIDExtendedResult> getResultDecoder() { |
| | | return RESULT_DECODER; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return connectionID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return GetConnectionIDExtendedRequest.OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(6); |
| | |
| | | return buffer.toByteString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | */ |
| | | public static final RequestDecoder REQUEST_DECODER = new RequestDecoder(); |
| | | |
| | | // No need to expose this. |
| | | /** No need to expose this. */ |
| | | private static final ResultDecoder RESULT_DECODER = new ResultDecoder(); |
| | | |
| | | /** |
| | |
| | | |
| | | private String instanceKeyID = null; |
| | | |
| | | // Instantiation via factory. |
| | | /** Instantiation via factory. */ |
| | | private GetSymmetricKeyExtendedRequest() { |
| | | |
| | | } |
| | |
| | | return instanceKeyID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | |
| | | return requestSymmetricKey; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ExtendedResultDecoder<ExtendedResult> getResultDecoder() { |
| | | return RESULT_DECODER; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | |
| | | return buffer.toByteString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return property.toString() + ": " + values; |
| | |
| | | private static final class ResultDecoder extends |
| | | AbstractExtendedResultDecoder<PasswordPolicyStateExtendedResult> { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public PasswordPolicyStateExtendedResult newExtendedErrorResult( |
| | | final ResultCode resultCode, final String matchedDN, final String diagnosticMessage) { |
| | | if (!resultCode.isExceptional()) { |
| | |
| | | */ |
| | | public static final RequestDecoder REQUEST_DECODER = new RequestDecoder(); |
| | | |
| | | // No need to expose this. |
| | | /** No need to expose this. */ |
| | | private static final ResultDecoder RESULT_DECODER = new ResultDecoder(); |
| | | |
| | | static ByteString encode(final String targetUser, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addOperation(final PasswordPolicyStateOperation operation) { |
| | | operations.add(operation); |
| | | } |
| | |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_RESET_STATE); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Iterable<PasswordPolicyStateOperation> getOperations() { |
| | | return operations; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ExtendedResultDecoder<PasswordPolicyStateExtendedResult> getResultDecoder() { |
| | | return RESULT_DECODER; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getTargetUser() { |
| | | return targetUser; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | return encode(targetUser, operations); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | |
| | | .valueOf(String.valueOf(state)))); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setTargetUser(String targetUser) { |
| | | this.targetUser = targetUser != null ? targetUser : ""; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | super(resultCode); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void addOperation(final PasswordPolicyStateOperation operation) { |
| | | operations.add(operation); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | // No response name defined. |
| | | return PasswordPolicyStateExtendedRequest.OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Iterable<PasswordPolicyStateOperation> getOperations() { |
| | | return operations; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getTargetUser() { |
| | | return targetUser; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | return PasswordPolicyStateExtendedRequest.encode(targetUser, operations); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setTargetUser(String targetUser) { |
| | | this.targetUser = targetUser != null ? targetUser : ""; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public PasswordPolicyStateOperationType getOperationType() { |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Iterable<ByteString> getValues() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return propertyName; |
| | |
| | | return c; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int compareTo(final ASCIICharProp o) { |
| | | return c - o.c; |
| | | } |
| | |
| | | return decimalValue; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | return this == obj; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return c; |
| | |
| | | return lowerCaseChar; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return stringValue; |
| | |
| | | private static final class ArrayIterable<M> extends AbstractIterable<M> { |
| | | private final M[] a; |
| | | |
| | | // Constructed via factory methods. |
| | | /** Constructed via factory methods. */ |
| | | private ArrayIterable(final M[] a) { |
| | | this.a = a; |
| | | } |
| | |
| | | private final P parameter; |
| | | private final Predicate<? super M, P> predicate; |
| | | |
| | | // Constructed via factory methods. |
| | | /** Constructed via factory methods. */ |
| | | private FilteredIterable(final Iterable<M> iterable, |
| | | final Predicate<? super M, P> predicate, final P p) { |
| | | this.iterable = iterable; |
| | |
| | | private static final class SingletonIterable<M> extends AbstractIterable<M> { |
| | | private final M value; |
| | | |
| | | // Constructed via factory methods. |
| | | /** Constructed via factory methods. */ |
| | | private SingletonIterable(final M value) { |
| | | this.value = value; |
| | | } |
| | |
| | | private final Function<? super M, ? extends N, NeverThrowsException> function; |
| | | private final Iterable<M> iterable; |
| | | |
| | | // Constructed via factory methods. |
| | | /** Constructed via factory methods. */ |
| | | private TransformedIterable(final Iterable<M> iterable, |
| | | final Function<? super M, ? extends N, NeverThrowsException> function) { |
| | | this.iterable = iterable; |
| | |
| | | private static final class UnmodifiableIterable<M> extends AbstractIterable<M> { |
| | | private final Iterable<M> iterable; |
| | | |
| | | // Constructed via factory methods. |
| | | /** Constructed via factory methods. */ |
| | | private UnmodifiableIterable(final Iterable<M> iterable) { |
| | | this.iterable = iterable; |
| | | } |
| | |
| | | return new UnmodifiableIterable<M>(iterable); |
| | | } |
| | | |
| | | // Prevent instantiation |
| | | /** Prevent instantiation. */ |
| | | private Iterables() { |
| | | // Do nothing. |
| | | } |
| | |
| | | */ |
| | | UNKNOWN("Unknown", false, false, false); |
| | | |
| | | // The human-readable name for this operating system. |
| | | /** The human-readable name for this operating system. */ |
| | | private String osName; |
| | | |
| | | private boolean isWindows; |
| | |
| | | * released during garbage collection. |
| | | */ |
| | | public final class Reference { |
| | | /* |
| | | /** |
| | | * The value will be accessed by the finalizer thread so it needs to be |
| | | * volatile in order to ensure that updates are published. |
| | | */ |
| | |
| | | this.readLimit = readLimit; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int available() throws IOException { |
| | | final int streamAvail = parentStream.available(); |
| | |
| | | return limitedAvail < streamAvail ? limitedAvail : streamAvail; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | parentStream.close(); |
| | |
| | | return readLimit; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public synchronized void mark(final int readlimit) { |
| | | parentStream.mark(readlimit); |
| | | markBytesRead = bytesRead; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean markSupported() { |
| | | return parentStream.markSupported(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int read() throws IOException { |
| | | if (bytesRead >= readLimit) { |
| | |
| | | return b; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int read(final byte[] b, final int off, int len) throws IOException { |
| | | if (off < 0 || len < 0 || off + len > b.length) { |
| | |
| | | return readLen; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public synchronized void reset() throws IOException { |
| | | parentStream.reset(); |
| | | bytesRead = markBytesRead; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long skip(long n) throws IOException { |
| | | if (bytesRead + n > readLimit) { |
| | |
| | | return ' '; |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private StaticUtils() { |
| | | // No implementation required. |
| | | } |
| | |
| | | * A sub-string reader. |
| | | */ |
| | | public class SubstringReader { |
| | | // The source string. |
| | | /** The source string. */ |
| | | private final String source; |
| | | // The current position. |
| | | /** The current position. */ |
| | | private int pos; |
| | | // The marked position. |
| | | /** The marked position. */ |
| | | private int mark; |
| | | // The length of the source. |
| | | /** The length of the source. */ |
| | | private final int length; |
| | | |
| | | /** |
| | |
| | | return new ASN1OutputStreamWriter(stream, maxBufferSize); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ASN1() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | this.maxElementSize = maxElementSize; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void close() throws IOException { |
| | | readerStack.clear(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean elementAvailable() throws IOException { |
| | | if ((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false)) { |
| | | return false; |
| | |
| | | return peekLength <= reader.remaining(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasNextElement() throws IOException { |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(false); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int peekLength() throws IOException { |
| | | peekType(); |
| | | |
| | |
| | | return peekLength; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public byte peekType() throws IOException { |
| | | if (state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) { |
| | | // Read just the type. |
| | |
| | | return peekType; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean readBoolean() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return readByte != 0x00; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readEndSequence() throws IOException { |
| | | if (readerStack.isEmpty()) { |
| | | final LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | |
| | | readEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readEndSet() throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | | readEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int readEnumerated() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return (int) readInteger(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public long readInteger() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readNull() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | state = ASN1.ELEMENT_READ_STATE_NEED_TYPE; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString readOctetString() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return reader.getByteString(peekLength); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteStringBuilder readOctetString(final ByteStringBuilder builder) throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return builder; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String readOctetStringAsString() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return reader.getString(peekLength); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSequence() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | readStartSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSet() throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | | readStartSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Reader skipElement() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | this.maxElementSize = maxElementSize; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void close() throws IOException { |
| | | // Calling close of SizeLimitInputStream should close the parent |
| | | // stream. |
| | |
| | | streamStack.clear(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean elementAvailable() throws IOException { |
| | | if ((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false, false)) { |
| | | return false; |
| | |
| | | return peekLength <= in.available(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasNextElement() throws IOException { |
| | | if (!streamStack.isEmpty()) { |
| | | // We are reading a sub sequence. Return true as long as we |
| | |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true, false); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int peekLength() throws IOException { |
| | | peekType(); |
| | | switch (state) { |
| | |
| | | return peekLength; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public byte peekType() throws IOException { |
| | | if (state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) { |
| | | needTypeState(true, true); |
| | |
| | | return peekType; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean readBoolean() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return readByte != 0x00; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readEndSequence() throws IOException { |
| | | if (streamStack.isEmpty()) { |
| | | final LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | |
| | | readEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readEndSet() throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | | readEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int readEnumerated() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return (int) readInteger(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public long readInteger() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readNull() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | state = ASN1.ELEMENT_READ_STATE_NEED_TYPE; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString readOctetString() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return ByteString.wrap(value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteStringBuilder readOctetString(final ByteStringBuilder builder) throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return builder; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String readOctetStringAsString() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSequence() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | readStartSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSet() throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | | readStartSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Reader skipElement() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | this.stackDepth = -1; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | while (stackDepth >= 0) { |
| | |
| | | rootStream.close(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void flush() throws IOException { |
| | | rootStream.flush(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeBoolean(final byte type, final boolean booleanValue) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeEndSequence() throws IOException { |
| | | if (stackDepth < 0) { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeEndSet() throws IOException { |
| | | return writeEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeEnumerated(final byte type, final int intValue) throws IOException { |
| | | return writeInteger(type, intValue); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeInteger(final byte type, final int intValue) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeInteger(final byte type, final long longValue) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeNull(final byte type) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeOctetString(final byte type, final byte[] value, final int offset, |
| | | final int length) throws IOException { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeOctetString(final byte type, final ByteSequence value) |
| | | throws IOException { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeOctetString(final byte type, final String value) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeStartSequence(final byte type) throws IOException { |
| | | // Write the type in current stream switch to next sub-stream |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeStartSet(final byte type) throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean readBoolean(byte type) throws IOException { |
| | | if (type == 0x00) { |
| | | type = ASN1.UNIVERSAL_BOOLEAN_TYPE; |
| | |
| | | return readBoolean(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int readEnumerated(byte type) throws IOException { |
| | | if (type == 0x00) { |
| | | type = ASN1.UNIVERSAL_ENUMERATED_TYPE; |
| | |
| | | return readEnumerated(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public long readInteger(byte type) throws IOException { |
| | | if (type == 0x00) { |
| | | type = ASN1.UNIVERSAL_INTEGER_TYPE; |
| | |
| | | return readInteger(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readNull(byte type) throws IOException { |
| | | if (type == 0x00) { |
| | | type = ASN1.UNIVERSAL_NULL_TYPE; |
| | |
| | | readNull(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString readOctetString(byte type) throws IOException { |
| | | if (type == 0x00) { |
| | | type = ASN1.UNIVERSAL_OCTET_STRING_TYPE; |
| | |
| | | return readOctetString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteStringBuilder readOctetString(byte type, final ByteStringBuilder builder) |
| | | throws IOException { |
| | | if (type == 0x00) { |
| | |
| | | return builder; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String readOctetStringAsString(byte type) throws IOException { |
| | | // We could cache the UTF-8 CharSet if performance proves to be an |
| | | // issue. |
| | |
| | | return readOctetStringAsString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartExplicitTag(byte type) throws IOException { |
| | | if (type == 0x00) { |
| | | type = (ASN1.TYPE_MASK_CONTEXT | ASN1.TYPE_MASK_CONSTRUCTED); |
| | |
| | | readStartExplicitTag(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSequence(byte type) throws IOException { |
| | | if (type == 0x00) { |
| | | type = ASN1.UNIVERSAL_SEQUENCE_TYPE; |
| | |
| | | readStartSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSet(byte type) throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | |
| | | readStartSet(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Reader skipElement(final byte expectedType) throws IOException { |
| | | if (peekType() != expectedType) { |
| | | final LocalizableMessage message = |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeBoolean(final boolean value) throws IOException { |
| | | return writeBoolean(ASN1.UNIVERSAL_BOOLEAN_TYPE, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeEnumerated(final int value) throws IOException { |
| | | return writeEnumerated(ASN1.UNIVERSAL_ENUMERATED_TYPE, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeInteger(final int value) throws IOException { |
| | | return writeInteger(ASN1.UNIVERSAL_INTEGER_TYPE, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeInteger(final long value) throws IOException { |
| | | return writeInteger(ASN1.UNIVERSAL_INTEGER_TYPE, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeNull() throws IOException { |
| | | return writeNull(ASN1.UNIVERSAL_NULL_TYPE); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(byte type, byte[] value) throws IOException { |
| | | return writeOctetString(type, value, 0, value.length); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(byte[] value) throws IOException { |
| | | return writeOctetString(value, 0, value.length); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(final byte[] value, final int offset, final int length) |
| | | throws IOException { |
| | | return writeOctetString(ASN1.UNIVERSAL_OCTET_STRING_TYPE, value, offset, length); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(final ByteSequence value) throws IOException { |
| | | return writeOctetString(ASN1.UNIVERSAL_OCTET_STRING_TYPE, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(final String value) throws IOException { |
| | | return writeOctetString(ASN1.UNIVERSAL_OCTET_STRING_TYPE, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeStartSequence() throws IOException { |
| | | return writeStartSequence(ASN1.UNIVERSAL_SEQUENCE_TYPE); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeStartSet() throws IOException { |
| | | return writeStartSet(ASN1.UNIVERSAL_SET_TYPE); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private LDAP() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | * The type of ASN.1 writer used for encoding elements. |
| | | */ |
| | | public final class LDAPWriter<W extends ASN1Writer> { |
| | | // @Checkstyle:ignore AvoidNestedBlocks |
| | | /** @Checkstyle:ignore AvoidNestedBlocks */ |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | private final W writer; |
| | |
| | | |
| | | private final ByteString attributeValue; |
| | | |
| | | // Cached normalized value using equality matching rule. |
| | | /** Cached normalized value using equality matching rule. */ |
| | | private ByteString equalityNormalizedAttributeValue = null; |
| | | |
| | | // Cached normalized value using ordering matching rule. |
| | | /** Cached normalized value using ordering matching rule. */ |
| | | private ByteString orderingNormalizedAttributeValue = null; |
| | | |
| | | /** |
| | |
| | | this.attributeValue = ByteString.valueOf(attributeValue); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final AVA ava) { |
| | | final int result = attributeType.compareTo(ava.attributeType); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return attributeValue; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return attributeType.hashCode() * 31 + getEqualityNormalizedValue().hashCode(); |
| | |
| | | return new LinkedAttribute(ad, attributeValue); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Handle thread interruption. |
| | | /** Handle thread interruption. */ |
| | | private LdapException interrupted(InterruptedException e) { |
| | | return newLdapException(ResultCode.CLIENT_SIDE_USER_CANCELLED, e); |
| | | } |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract boolean add(ByteString value); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean add(final Object... values) { |
| | | Reject.ifNull(values); |
| | | boolean modified = false; |
| | |
| | | return modified; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean addAll(final Collection<? extends ByteString> values) { |
| | | return addAll(values, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <T> boolean addAll(final Collection<T> values, |
| | | final Collection<? super T> duplicateValues) { |
| | | boolean modified = false; |
| | |
| | | return modified; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract boolean contains(Object value); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean containsAll(final Collection<?> values) { |
| | | for (final Object value : values) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | return equals(this, object); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString firstValue() { |
| | | return iterator().next(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String firstValueAsString() { |
| | | return firstValue().toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public abstract AttributeDescription getAttributeDescription(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getAttributeDescriptionAsString() { |
| | | return getAttributeDescription().toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return hashCode(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public AttributeParser parse() { |
| | | return AttributeParser.parseAttribute(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract Iterator<ByteString> iterator(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract boolean remove(Object value); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean removeAll(final Collection<?> values) { |
| | | return removeAll(values, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <T> boolean removeAll(final Collection<T> values, |
| | | final Collection<? super T> missingValues) { |
| | | boolean modified = false; |
| | |
| | | return modified; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean retainAll(final Collection<?> values) { |
| | | return retainAll(values, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <T> boolean retainAll(final Collection<T> values, |
| | | final Collection<? super T> missingValues) { |
| | | if (values.isEmpty()) { |
| | |
| | | return modified; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract int size(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString[] toArray() { |
| | | return toArray(new ByteString[size()]); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return toString(this); |
| | |
| | | */ |
| | | public abstract class AbstractEntry implements Entry { |
| | | |
| | | // Predicate used for findAttributes. |
| | | /** Predicate used for findAttributes. */ |
| | | private static final Predicate<Attribute, AttributeDescription> FIND_ATTRIBUTES_PREDICATE = |
| | | new Predicate<Attribute, AttributeDescription>() { |
| | | |
| | |
| | | */ |
| | | abstract int getInitialConnectionFactoryIndex(); |
| | | |
| | | // Return the first factory after index which is operational. |
| | | /** Return the first factory after index which is operational. */ |
| | | private MonitoredConnectionFactory getMonitoredConnectionFactory(final int initialIndex) throws LdapException { |
| | | int index = initialIndex; |
| | | final int maxIndex = monitoredFactories.size(); |
| | |
| | | this.attributes = attributes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean addAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Entry clearAttributes() { |
| | | attributes.clear(); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Iterable<Attribute> getAllAttributes() { |
| | | return attributes.values(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Attribute getAttribute(final AttributeDescription attributeDescription) { |
| | | final Attribute attribute = attributes.get(attributeDescription); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int getAttributeCount() { |
| | | return attributes.size(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final DN getName() { |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean removeAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Entry setName(final DN dn) { |
| | | Reject.ifNull(dn); |
| | |
| | | ALLWILDCARD, HOST, HOSTPATTERN, IPv4, IPv6 |
| | | } |
| | | |
| | | // IPv4 values for number of bytes and max CIDR prefix |
| | | /** IPv4 values for number of bytes and max CIDR prefix. */ |
| | | private static final int IN4ADDRSZ = 4; |
| | | private static final int IPV4MAXPREFIX = 32; |
| | | |
| | | // IPv6 values for number of bytes and max CIDR prefix |
| | | /** IPv6 values for number of bytes and max CIDR prefix. */ |
| | | private static final int IN6ADDRSZ = 16; |
| | | private static final int IPV6MAXPREFIX = 128; |
| | | |
| | |
| | | return new AddressMask(mask); |
| | | } |
| | | |
| | | // Array that holds each component of a hostname. |
| | | /** Array that holds each component of a hostname. */ |
| | | private String[] hostName; |
| | | |
| | | // Holds a hostname pattern (ie, rule that begins with '.');' |
| | | /** Holds a hostname pattern (ie, rule that begins with '.');'. */ |
| | | private String hostPattern; |
| | | |
| | | // Holds binary representations of rule and mask respectively. |
| | | /** Holds binary representations of rule and mask respectively. */ |
| | | private byte[] ruleMask, prefixMask; |
| | | |
| | | // Holds string passed into the constructor. |
| | | /** Holds string passed into the constructor. */ |
| | | private final String ruleString; |
| | | |
| | | // Type of rule determined |
| | | /** Type of rule determined. */ |
| | | private RuleType ruleType; |
| | | |
| | | // Bit array that holds wildcard info for above binary arrays. |
| | | /** Bit array that holds wildcard info for above binary arrays. */ |
| | | private final BitSet wildCard = new BitSet(); |
| | | |
| | | private AddressMask(final String rule) { |
| | |
| | | private static final ThreadLocal<WeakHashMap<Schema, Map<String, AttributeDescription>>> CACHE = |
| | | new ThreadLocal<WeakHashMap<Schema, Map<String, AttributeDescription>>>() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected WeakHashMap<Schema, Map<String, AttributeDescription>> initialValue() { |
| | | return new WeakHashMap<Schema, Map<String, AttributeDescription>>(); |
| | |
| | | |
| | | }; |
| | | |
| | | // Object class attribute description. |
| | | /** Object class attribute description. */ |
| | | private static final ZeroOptionImpl ZERO_OPTION_IMPL = new ZeroOptionImpl(); |
| | | |
| | | private static final AttributeDescription OBJECT_CLASS; |
| | |
| | | ZERO_OPTION_IMPL); |
| | | } |
| | | |
| | | // This is the size of the per-thread per-schema attribute description |
| | | // cache. We should be conservative here in case there are many |
| | | // threads. |
| | | /** |
| | | * This is the size of the per-thread per-schema attribute description |
| | | * cache. We should be conservative here in case there are many |
| | | * threads. |
| | | */ |
| | | private static final int ATTRIBUTE_DESCRIPTION_CACHE_SIZE = 512; |
| | | |
| | | /** |
| | |
| | | return i; |
| | | } |
| | | |
| | | // Uncached valueOf implementation. |
| | | /** Uncached valueOf implementation. */ |
| | | private static AttributeDescription valueOf0(final String attributeDescription, |
| | | final Schema schema) { |
| | | final boolean allowMalformedNamesAndOptions = schema.allowMalformedNamesAndOptions(); |
| | |
| | | |
| | | private final Impl pimpl; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private AttributeDescription(final String attributeDescription, |
| | | final AttributeType attributeType, final Impl pimpl) { |
| | | this.attributeDescription = attributeDescription; |
| | |
| | | public final class AttributeFilter { |
| | | // TODO: exclude specific attributes, matched values, custom predicates, etc. |
| | | private boolean includeAllOperationalAttributes = false; |
| | | private boolean includeAllUserAttributes; // Depends on constructor. |
| | | /** Depends on constructor. */ |
| | | private boolean includeAllUserAttributes; |
| | | private boolean typesOnly = false; |
| | | |
| | | /** |
| | |
| | | return 1; |
| | | } |
| | | |
| | | // Lazily computes the normalized single value. |
| | | /** Lazily computes the normalized single value. */ |
| | | private ByteString normalizedSingleValue() { |
| | | if (normalizedValue == null) { |
| | | normalizedValue = normalizeValue(this, value); |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Attributes() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | */ |
| | | public final class ByteString implements ByteSequence { |
| | | |
| | | // Singleton empty byte string. |
| | | /** Singleton empty byte string. */ |
| | | private static final ByteString EMPTY = wrap(new byte[0]); |
| | | |
| | | /** |
| | |
| | | // These are package private so that compression and crypto |
| | | // functionality may directly access the fields. |
| | | |
| | | // The buffer where data is stored. |
| | | /** The buffer where data is stored. */ |
| | | final byte[] buffer; |
| | | |
| | | // The number of bytes to expose from the buffer. |
| | | /** The number of bytes to expose from the buffer. */ |
| | | final int length; |
| | | |
| | | // The start index of the range of bytes to expose through this byte |
| | | // string. |
| | | /** |
| | | * The start index of the range of bytes to expose through this byte |
| | | * string. |
| | | */ |
| | | final int offset; |
| | | |
| | | /** |
| | |
| | | return new ByteSequenceReader(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public byte byteAt(final int index) { |
| | | if (index >= length || index < 0) { |
| | | throw new IndexOutOfBoundsException(); |
| | |
| | | return buffer[offset + index]; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int compareTo(final byte[] bytes, final int offset, final int length) { |
| | | checkArrayBounds(bytes, offset, length); |
| | | return compareTo(this.buffer, this.offset, this.length, bytes, offset, length); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int compareTo(final ByteSequence o) { |
| | | if (this == o) { |
| | | return 0; |
| | |
| | | return -o.compareTo(buffer, offset, length); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public byte[] copyTo(final byte[] bytes) { |
| | | copyTo(bytes, 0); |
| | | return bytes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public byte[] copyTo(final byte[] bytes, final int offset) { |
| | | if (offset < 0) { |
| | | throw new IndexOutOfBoundsException(); |
| | |
| | | return bytes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteStringBuilder copyTo(final ByteStringBuilder builder) { |
| | | builder.append(buffer, offset, length); |
| | | return builder; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public OutputStream copyTo(final OutputStream stream) throws IOException { |
| | | stream.write(buffer, offset, length); |
| | | return stream; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean equals(final byte[] bytes, final int offset, final int length) { |
| | | checkArrayBounds(bytes, offset, length); |
| | | return equals(this.buffer, this.offset, this.length, bytes, offset, length); |
| | |
| | | return length == 0; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int length() { |
| | | return length; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString subSequence(final int start, final int end) { |
| | | if (start < 0 || start > end || end > length) { |
| | | throw new IndexOutOfBoundsException(); |
| | |
| | | return new ByteString(buffer, offset + start, end - start); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String toBase64String() { |
| | | return Base64.encode(this); |
| | | } |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public byte[] toByteArray() { |
| | | return copyTo(new byte[length]); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString toByteString() { |
| | | return this; |
| | | } |
| | |
| | | return v; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return toString(buffer, offset, length); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | // Checks that this pooled connection has not been closed. |
| | | /** Checks that this pooled connection has not been closed. */ |
| | | private Connection checkState() { |
| | | if (isClosed()) { |
| | | throw new IllegalStateException(); |
| | |
| | | close(); |
| | | } |
| | | |
| | | // Package private for unit testing. |
| | | /** Package private for unit testing. */ |
| | | int currentPoolSize() { |
| | | return maxPoolSize - availableConnections.availablePermits(); |
| | | } |
| | |
| | | * Common options for LDAP clients and listeners. |
| | | */ |
| | | abstract class CommonLDAPOptions<T extends CommonLDAPOptions<T>> { |
| | | // Default values for options taken from Java properties. |
| | | /** Default values for options taken from Java properties. */ |
| | | private static final boolean DEFAULT_TCP_NO_DELAY; |
| | | private static final boolean DEFAULT_REUSE_ADDRESS; |
| | | private static final boolean DEFAULT_KEEPALIVE; |
| | |
| | | */ |
| | | TRUE("true"); |
| | | |
| | | // Boolean -> ConditionResult map. |
| | | /** Boolean -> ConditionResult map. */ |
| | | private static final boolean[] BOOLEAN_MAP = { false, false, true }; |
| | | |
| | | // AND truth table. |
| | | /** AND truth table. */ |
| | | private static final ConditionResult[][] LOGICAL_AND = { { FALSE, FALSE, FALSE }, |
| | | { FALSE, UNDEFINED, UNDEFINED }, { FALSE, UNDEFINED, TRUE }, }; |
| | | |
| | | // NOT truth table. |
| | | /** NOT truth table. */ |
| | | private static final ConditionResult[] LOGICAL_NOT = { TRUE, UNDEFINED, FALSE }; |
| | | |
| | | // OR truth table. |
| | | /** OR truth table. */ |
| | | private static final ConditionResult[][] LOGICAL_OR = { { FALSE, UNDEFINED, TRUE }, |
| | | { UNDEFINED, UNDEFINED, TRUE }, { TRUE, TRUE, TRUE }, }; |
| | | |
| | |
| | | return b ? TRUE : FALSE; |
| | | } |
| | | |
| | | // The human-readable name for this result. |
| | | /** The human-readable name for this result. */ |
| | | private final String resultName; |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private ConditionResult(final String resultName) { |
| | | this.resultName = resultName; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Connections() { |
| | | // Do nothing. |
| | | } |
| | |
| | | public final class DN implements Iterable<RDN>, Comparable<DN> { |
| | | private static final DN ROOT_DN = new DN(null, null, ""); |
| | | |
| | | // This is the size of the per-thread per-schema DN cache. We should |
| | | // be conservative here in case there are many threads. We will only |
| | | // cache parent DNs, so there's no need for it to be big. |
| | | /** |
| | | * This is the size of the per-thread per-schema DN cache. We should |
| | | * be conservative here in case there are many threads. We will only |
| | | * cache parent DNs, so there's no need for it to be big. |
| | | */ |
| | | private static final int DN_CACHE_SIZE = 32; |
| | | |
| | | private static final ThreadLocal<WeakHashMap<Schema, Map<String, DN>>> CACHE = |
| | | new ThreadLocal<WeakHashMap<Schema, Map<String, DN>>>() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected WeakHashMap<Schema, Map<String, DN>> initialValue() { |
| | | return new WeakHashMap<Schema, Map<String, DN>>(); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | // Decodes a DN using the provided reader and schema. |
| | | /** Decodes a DN using the provided reader and schema. */ |
| | | private static DN decode(final String dnString, final SubstringReader reader, |
| | | final Schema schema, final Map<String, DN> cache) { |
| | | reader.skipWhitespaces(); |
| | |
| | | |
| | | private final int size; |
| | | |
| | | // We need to store the original string value if provided in order to |
| | | // preserve the original whitespace. |
| | | /** |
| | | * We need to store the original string value if provided in order to |
| | | * preserve the original whitespace. |
| | | */ |
| | | private String stringValue; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DN(final DN parent, final RDN rdn, final String stringValue) { |
| | | this(parent, rdn, stringValue, parent != null ? parent.size + 1 : 0); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private DN(final DN parent, final RDN rdn, final String stringValue, final int size) { |
| | | this.parent = parent; |
| | | this.rdn = rdn; |
| | |
| | | return child(new RDN(attributeType, attributeValue)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int compareTo(final DN dn) { |
| | | return compareTo(this, dn); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | if (size == 0) { |
| | |
| | | |
| | | private final boolean isFatal; |
| | | |
| | | // Construction is provided via factory methods. |
| | | /** Construction is provided via factory methods. */ |
| | | private DecodeException(final LocalizableMessage message, final boolean isFatal, |
| | | final Throwable cause) { |
| | | super(message.toString(), cause); |
| | |
| | | this.schema = schema; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public Schema resolveSchema(final String dn) { |
| | | return schema; |
| | | } |
| | |
| | | |
| | | private final String name; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private DereferenceAliasesPolicy(final int intValue, final String name) { |
| | | this.intValue = intValue; |
| | | this.name = name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | this.entry = entry; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry addAttribute(final String attributeDescription, final Object... values) { |
| | | throw new UnsupportedOperationException(); |
| | |
| | | return entry.containsAttribute(attributeDescription, values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | return (object == this || entry.equals(object)); |
| | |
| | | .getAllAttributes(attributeDescription), UNMODIFIABLE_ATTRIBUTE_FUNCTION)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes(final String attributeDescription) { |
| | | return Iterables.unmodifiableIterable(Iterables.transformedIterable(entry |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Attribute getAttribute(final String attributeDescription) { |
| | | final Attribute attribute = entry.getAttribute(attributeDescription); |
| | |
| | | return entry.getAttributeCount(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN getName() { |
| | | return entry.getName(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return entry.hashCode(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeParser parseAttribute(final AttributeDescription attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeParser parseAttribute(final String attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry removeAttribute(final String attributeDescription, final Object... values) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean replaceAttribute(final Attribute attribute) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry replaceAttribute(final String attributeDescription, final Object... values) { |
| | | throw new UnsupportedOperationException(); |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry setName(final String dn) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return entry.toString(); |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Entries() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | this(factories, null, interval, unit, scheduler); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | String getAlgorithmName() { |
| | | return "Failover"; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | int getInitialConnectionFactoryIndex() { |
| | | // Always start with the first connection factory. |
| | |
| | | |
| | | } |
| | | |
| | | // RFC 4526 - FALSE filter. |
| | | /** RFC 4526 - FALSE filter. */ |
| | | private static final Filter FALSE = new Filter(new OrImpl(Collections.<Filter> emptyList())); |
| | | |
| | | // Heavily used (objectClass=*) filter. |
| | | /** Heavily used (objectClass=*) filter. */ |
| | | private static final Filter OBJECT_CLASS_PRESENT = new Filter(new PresentImpl("objectClass")); |
| | | |
| | | private static final FilterVisitor<StringBuilder, StringBuilder> TO_STRING_VISITOR = |
| | |
| | | } |
| | | }; |
| | | |
| | | // RFC 4526 - TRUE filter. |
| | | /** RFC 4526 - TRUE filter. */ |
| | | private static final Filter TRUE = new Filter(new AndImpl(Collections.<Filter> emptyList())); |
| | | |
| | | /** |
| | |
| | | return valueOf(filterString); |
| | | } |
| | | |
| | | // Converts an assertion value to a substring filter. |
| | | /** Converts an assertion value to a substring filter. */ |
| | | private static Filter assertionValue2SubstringFilter(final String filterString, |
| | | final String attrType, final int equalPos, final int endPos) { |
| | | // Get a binary representation of the value. |
| | |
| | | return BYTESTRING_TO_STRING; |
| | | } |
| | | |
| | | // Prevent instantiation |
| | | /** Prevent instantiation. */ |
| | | private Functions() { |
| | | // Do nothing. |
| | | } |
| | |
| | | */ |
| | | public final class GeneralizedTime implements Comparable<GeneralizedTime> { |
| | | |
| | | // UTC TimeZone is assumed to never change over JVM lifetime |
| | | /** UTC TimeZone is assumed to never change over JVM lifetime. */ |
| | | private static final TimeZone TIME_ZONE_UTC_OBJ = TimeZone.getTimeZone("UTC"); |
| | | |
| | | /** |
| | |
| | | return TimeZone.getTimeZone("GMT" + offSetStr); |
| | | } |
| | | |
| | | // Lazily constructed internal representations. |
| | | /** Lazily constructed internal representations. */ |
| | | private volatile Calendar calendar; |
| | | private volatile Date date; |
| | | private volatile String stringValue; |
| | |
| | | this.stringValue = stringValue; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final GeneralizedTime o) { |
| | | final Long timeMS1 = getTimeInMillis(); |
| | |
| | | return timeMS1.compareTo(timeMS2); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return tmpTimeMS; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return ((Long) getTimeInMillis()).hashCode(); |
| | |
| | | return (Date) tmpDate.clone(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | String tmpString = stringValue; |
| | |
| | | this.serverConnection = serverConnection; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Void> abandonAsync(final AbandonRequest request) { |
| | | final int i = messageID.getAndIncrement(); |
| | |
| | | return newSuccessfulLdapPromise((Void) null, i); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> addAsync(final AddRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addConnectionEventListener(final ConnectionEventListener listener) { |
| | | Reject.ifNull(listener); |
| | | listeners.add(listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<BindResult> bindAsync(final BindRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close(final UnbindRequest request, final String reason) { |
| | | final int i = messageID.getAndIncrement(); |
| | | serverConnection.handleConnectionClosed(i, request); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<CompareResult> compareAsync(final CompareRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> deleteAsync(final DeleteRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> LdapPromise<R> extendedRequestAsync(final ExtendedRequest<R> request, |
| | | final IntermediateResponseHandler intermediateResponseHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isClosed() { |
| | | // FIXME: this should be true after close has been called. |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isValid() { |
| | | // FIXME: this should be false if this connection is disconnected. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> modifyAsync(final ModifyRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> modifyDNAsync(final ModifyDNRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeConnectionEventListener(final ConnectionEventListener listener) { |
| | | Reject.ifNull(listener); |
| | | listeners.remove(listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> searchAsync(final SearchRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler) { |
| | |
| | | return promise; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | this.alias = alias; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String chooseClientAlias(final String[] keyType, final Principal[] issuers, |
| | | final Socket socket) { |
| | | for (final String type : keyType) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String chooseEngineClientAlias(final String[] keyType, final Principal[] issuers, |
| | | final SSLEngine engine) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String chooseEngineServerAlias(final String keyType, final Principal[] issuers, |
| | | final SSLEngine engine) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String chooseServerAlias(final String keyType, final Principal[] issuers, |
| | | final Socket socket) { |
| | | final String[] serverAliases = keyManager.getServerAliases(keyType, issuers); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public X509Certificate[] getCertificateChain(final String alias) { |
| | | return keyManager.getCertificateChain(alias); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String[] getClientAliases(final String keyType, final Principal[] issuers) { |
| | | return keyManager.getClientAliases(keyType, issuers); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public PrivateKey getPrivateKey(final String alias) { |
| | | return keyManager.getPrivateKey(alias); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String[] getServerAliases(final String keyType, final Principal[] issuers) { |
| | | return keyManager.getServerAliases(keyType, issuers); |
| | | } |
| | |
| | | return new SelectCertificate(keyManager, alias); |
| | | } |
| | | |
| | | // Prevent insantiation. |
| | | /** Prevent insantiation. */ |
| | | private KeyManagers() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | * Server. |
| | | */ |
| | | public final class LDAPConnectionFactory implements ConnectionFactory { |
| | | /* |
| | | /** |
| | | * We implement the factory using the pimpl idiom in order to avoid making |
| | | * too many implementation classes public. |
| | | */ |
| | | private final LDAPConnectionFactoryImpl impl; |
| | | |
| | | /* |
| | | /** |
| | | * Transport provider that provides the implementation of this factory. |
| | | */ |
| | | private final TransportProvider provider; |
| | |
| | | */ |
| | | public final class LDAPListener implements Closeable { |
| | | |
| | | // We implement the factory using the pimpl idiom in order have |
| | | // cleaner Javadoc which does not expose implementation methods. |
| | | /** |
| | | * We implement the factory using the pimpl idiom in order have |
| | | * cleaner Javadoc which does not expose implementation methods. |
| | | */ |
| | | private final LDAPListenerImpl impl; |
| | | |
| | | /* |
| | | /** |
| | | * Transport provider that provides the implementation of this listener. |
| | | */ |
| | | private TransportProvider provider; |
| | |
| | | * </pre> |
| | | */ |
| | | public final class LDAPOptions extends CommonLDAPOptions<LDAPOptions> { |
| | | // Default values for options taken from Java properties. |
| | | /** Default values for options taken from Java properties. */ |
| | | private static final long DEFAULT_TIMEOUT; |
| | | private static final long DEFAULT_CONNECT_TIMEOUT; |
| | | static { |
| | |
| | | return request; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | |
| | | return scope; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | final String s = toNormalizedString(); |
| | |
| | | return isSecured; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return urlString; |
| | |
| | | add(values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean add(final ByteString value) { |
| | | Reject.ifNull(value); |
| | | return pimpl.add(this, value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void clear() { |
| | | pimpl.clear(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean contains(final Object value) { |
| | | Reject.ifNull(value); |
| | | return pimpl.contains(this, ByteString.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean containsAll(final Collection<?> values) { |
| | | Reject.ifNull(values); |
| | | return pimpl.containsAll(this, values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString firstValue() { |
| | | return pimpl.firstValue(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeDescription getAttributeDescription() { |
| | | return attributeDescription; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterator<ByteString> iterator() { |
| | | return pimpl.iterator(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean remove(final Object value) { |
| | | Reject.ifNull(value); |
| | | return pimpl.remove(this, ByteString.valueOf(value)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> boolean retainAll(final Collection<T> values, |
| | | final Collection<? super T> missingValues) { |
| | |
| | | return pimpl.retainAll(this, values, missingValues); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int size() { |
| | | return pimpl.size(this); |
| | | } |
| | | |
| | | // Lazily computes the normalized single value. |
| | | /** Lazily computes the normalized single value. */ |
| | | private ByteString normalizedSingleValue() { |
| | | if (normalizedSingleValue == null) { |
| | | normalizedSingleValue = normalizeValue(this, singleValue); |
| | |
| | | return modificationType; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | |
| | | private final Enum modificationTypeEnum; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private ModificationType(final int intValue, final String name, final Enum modificationTypeEnum) { |
| | | this.intValue = intValue; |
| | | this.name = name; |
| | | this.modificationTypeEnum = modificationTypeEnum; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | */ |
| | | public final class RDN implements Iterable<AVA>, Comparable<RDN> { |
| | | |
| | | // A constant holding a special RDN having zero AVAs and which always |
| | | // compares greater than any other RDN other than itself. |
| | | /** |
| | | * A constant holding a special RDN having zero AVAs and which always |
| | | * compares greater than any other RDN other than itself. |
| | | */ |
| | | private static final RDN MAX_VALUE = new RDN(new AVA[0], ""); |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | // In original order. |
| | | /** In original order. */ |
| | | private final AVA[] avas; |
| | | |
| | | // We need to store the original string value if provided in order to |
| | | // preserve the original whitespace. |
| | | /** |
| | | * We need to store the original string value if provided in order to |
| | | * preserve the original whitespace. |
| | | */ |
| | | private String stringValue; |
| | | |
| | | /** |
| | |
| | | this.stringValue = stringValue; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int compareTo(final RDN rdn) { |
| | | // Identity. |
| | | if (this == rdn) { |
| | |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return avas[0]; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | // Avoid an algorithm that requires the AVAs to be sorted. |
| | |
| | | private static class RequestContextImpl<S extends Result, H extends ResultHandler<S>> |
| | | implements RequestContext, ResultHandler<S> { |
| | | |
| | | /* |
| | | /** |
| | | * Adapter class which invokes cancel result handlers with correct |
| | | * result type. |
| | | */ |
| | |
| | | } |
| | | |
| | | private static enum RequestState { |
| | | // Request active, cancel requested |
| | | /** Request active, cancel requested. */ |
| | | CANCEL_REQUESTED, |
| | | |
| | | // Result sent, was cancelled |
| | | /** Result sent, was cancelled. */ |
| | | CANCELLED, |
| | | |
| | | // Request active |
| | | /** Request active. */ |
| | | PENDING, |
| | | |
| | | // Result sent, not cancelled |
| | | /** Result sent, not cancelled. */ |
| | | RESULT_SENT, |
| | | |
| | | // Request active, too late to cancel |
| | | /** Request active, too late to cancel. */ |
| | | TOO_LATE; |
| | | } |
| | | |
| | | protected final H resultHandler; |
| | | |
| | | // These should be notified when a cancel request arrives, at most once. |
| | | /** These should be notified when a cancel request arrives, at most once. */ |
| | | private List<CancelRequestListener> cancelRequestListeners = null; |
| | | |
| | | private LocalizableMessage cancelRequestReason = null; |
| | | |
| | | // These should be notified when the result is set. |
| | | /** These should be notified when the result is set. */ |
| | | private List<ExtendedResultHandlerHolder<?>> cancelResultHandlers = null; |
| | | |
| | | private final ServerConnectionImpl clientConnection; |
| | |
| | | |
| | | private RequestState state = RequestState.PENDING; |
| | | |
| | | // Cancellation state guarded by lock. |
| | | /** Cancellation state guarded by lock. */ |
| | | private final Object stateLock = new Object(); |
| | | |
| | | protected RequestContextImpl(final ServerConnectionImpl clientConnection, |
| | |
| | | this.isCancelSupported = isCancelSupported; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addCancelRequestListener(final CancelRequestListener listener) { |
| | | Reject.ifNull(listener); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void checkIfCancelled(final boolean signalTooLate) throws CancelledResultException { |
| | | synchronized (stateLock) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int getMessageID() { |
| | | return messageID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleError(final LdapException error) { |
| | | if (clientConnection.removePendingRequest(this)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleResult(final S result) { |
| | | if (clientConnection.removePendingRequest(this)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeCancelRequestListener(final CancelRequestListener listener) { |
| | | Reject.ifNull(listener); |
| | |
| | | this.entryHandler = entryHandler; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean handleEntry(final SearchResultEntry entry) { |
| | | return entryHandler.handleEntry(entry); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean handleReference(final SearchResultReference reference) { |
| | | return entryHandler.handleReference(reference); |
| | |
| | | this.requestHandler = requestHandler; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAbandon(final Integer messageID, final AbandonRequest request) { |
| | | final RequestContextImpl<?, ?> abandonedRequest = |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAdd(final Integer messageID, final AddRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer messageID, final int version, |
| | | final BindRequest request, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleCompare(final Integer messageID, final CompareRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionClosed(final Integer messageID, final UnbindRequest request) { |
| | | final LocalizableMessage cancelReason = INFO_CANCELED_BY_CLIENT_DISCONNECT.get(); |
| | | doClose(cancelReason); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionDisconnected(final ResultCode resultCode, final String message) { |
| | | final LocalizableMessage cancelReason = INFO_CANCELED_BY_SERVER_DISCONNECT.get(); |
| | | doClose(cancelReason); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionError(final Throwable error) { |
| | | final LocalizableMessage cancelReason = INFO_CANCELED_BY_CLIENT_ERROR.get(); |
| | | doClose(cancelReason); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleDelete(final Integer messageID, final DeleteRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> void handleExtendedRequest(final Integer messageID, |
| | | final ExtendedRequest<R> request, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModify(final Integer messageID, final ModifyRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModifyDN(final Integer messageID, final ModifyDNRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleSearch(final Integer messageID, final SearchRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler, |
| | |
| | | this.factory = factory; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ServerConnection<Integer> handleAccept(final C clientContext) throws LdapException { |
| | | return adaptRequestHandler(factory.handleAccept(clientContext)); |
| | |
| | | |
| | | private final Enum resultCodeEnum; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private ResultCode(final int intValue, final LocalizableMessage name, final boolean exceptional, |
| | | final Enum resultCodeEnum) { |
| | | this.intValue = intValue; |
| | |
| | | this.resultCodeEnum = resultCodeEnum; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | this(factories, null, interval, unit, scheduler); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | String getAlgorithmName() { |
| | | return "RoundRobin"; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | int getInitialConnectionFactoryIndex() { |
| | | // A round robin pool of one connection factories is unlikely in |
| | |
| | | private String protocol = PROTOCOL_TLS1; |
| | | private SecureRandom random = null; |
| | | |
| | | // These are mutually exclusive. |
| | | /** These are mutually exclusive. */ |
| | | private Provider provider = null; |
| | | private String providerName = null; |
| | | |
| | |
| | | |
| | | private final Enum searchScopeEnum; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private SearchScope(final int intValue, final String name, Enum searchScopeEnum) { |
| | | this.intValue = intValue; |
| | | this.name = name; |
| | | this.searchScopeEnum = searchScopeEnum; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | this.hostNamePattern = hostNamePattern; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkClientTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | verifyHostName(chain); |
| | | trustManager.checkClientTrusted(chain, authType); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkServerTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | verifyHostName(chain); |
| | | trustManager.checkServerTrusted(chain, authType); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public X509Certificate[] getAcceptedIssuers() { |
| | | return trustManager.getAcceptedIssuers(); |
| | | } |
| | |
| | | this.trustManager = trustManager; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkClientTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | verifyExpiration(chain); |
| | | trustManager.checkClientTrusted(chain, authType); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkServerTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | verifyExpiration(chain); |
| | | trustManager.checkServerTrusted(chain, authType); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public X509Certificate[] getAcceptedIssuers() { |
| | | return trustManager.getAcceptedIssuers(); |
| | | } |
| | |
| | | * An X509TrustManager which does not trust any certificates. |
| | | */ |
| | | private static final class DistrustAll implements X509TrustManager { |
| | | // Single instance. |
| | | /** Single instance. */ |
| | | private static final DistrustAll INSTANCE = new DistrustAll(); |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private DistrustAll() { |
| | | // Nothing to do. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkClientTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | throw new CertificateException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkServerTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | throw new CertificateException(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public X509Certificate[] getAcceptedIssuers() { |
| | | return new X509Certificate[0]; |
| | | } |
| | |
| | | */ |
| | | private static final class TrustAll implements X509TrustManager { |
| | | |
| | | // Single instance. |
| | | /** Single instance. */ |
| | | private static final TrustAll INSTANCE = new TrustAll(); |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private TrustAll() { |
| | | // Nothing to do. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkClientTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void checkServerTrusted(final X509Certificate[] chain, final String authType) |
| | | throws CertificateException { |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public X509Certificate[] getAcceptedIssuers() { |
| | | return new X509Certificate[0]; |
| | | } |
| | |
| | | return TrustAll.INSTANCE; |
| | | } |
| | | |
| | | // Prevent insantiation. |
| | | /** Prevent insantiation. */ |
| | | private TrustManagers() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | return new ADNotificationRequestControl(isCritical); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return new AssertionRequestControl(isCritical, filter); |
| | | } |
| | | |
| | | // The assertion filter. |
| | | /** The assertion filter. */ |
| | | private final Filter filter; |
| | | |
| | | private final boolean isCritical; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private AssertionRequestControl(final boolean isCritical, final Filter filter) { |
| | | Reject.ifNull(filter); |
| | | this.isCritical = isCritical; |
| | |
| | | return filter; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return isCritical ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE; |
| | | } |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private AuthorizationIdentityRequestControl(final boolean isCritical) { |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return new AuthorizationIdentityResponseControl(false, authorizationID); |
| | | } |
| | | |
| | | // The authorization ID for this control. |
| | | /** The authorization ID for this control. */ |
| | | private final String authorizationID; |
| | | |
| | | private final boolean isCritical; |
| | |
| | | } |
| | | }; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private AuthorizationIdentityResponseControl(final boolean isCritical, |
| | | final String authorizationID) { |
| | | Reject.ifNull(authorizationID); |
| | |
| | | return authorizationID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return ByteString.valueOf(authorizationID); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | changeNumber); |
| | | } |
| | | |
| | | // The previous DN for this change notification control. |
| | | /** The previous DN for this change notification control. */ |
| | | private final DN previousName; |
| | | |
| | | // The change number for this change notification control. |
| | | /** The change number for this change notification control. */ |
| | | private final long changeNumber; |
| | | |
| | | // The change type for this change notification control. |
| | | /** The change type for this change notification control. */ |
| | | private final PersistentSearchChangeType changeType; |
| | | |
| | | private final boolean isCritical; |
| | |
| | | return changeType; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | |
| | | return previousName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | |
| | | private final ByteString value; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private GenericControl(final String oid, final boolean isCritical, final ByteString value) { |
| | | Reject.ifNull(oid); |
| | | this.oid = oid; |
| | |
| | | this.value = value; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return oid; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return value != null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return new GetEffectiveRightsRequestControl(isCritical, dn, copyOfAttributes); |
| | | } |
| | | |
| | | // The DN representing the authzId (may be null meaning use the client's |
| | | // DN). |
| | | /** The DN representing the authzId (may be null meaning use the client's DN). */ |
| | | private final DN authorizationName; |
| | | |
| | | // The unmodifiable list of attributes to be queried (may be empty). |
| | | /** The unmodifiable list of attributes to be queried (may be empty). */ |
| | | private final Collection<AttributeType> attributes; |
| | | |
| | | private final boolean isCritical; |
| | |
| | | return authorizationName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return authorizationName != null || !attributes.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return filters; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return CONTROL_VALUE; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return new PasswordExpiringResponseControl(false, secondsUntilExpiration); |
| | | } |
| | | |
| | | // The length of time in seconds until the password actually expires. |
| | | /** The length of time in seconds until the password actually expires. */ |
| | | private final int secondsUntilExpiration; |
| | | |
| | | private final boolean isCritical; |
| | |
| | | this.secondsUntilExpiration = secondsUntilExpiration; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | |
| | | return secondsUntilExpiration; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return ByteString.valueOf(String.valueOf(secondsUntilExpiration)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return errorType; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | return warningValue; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.intValue = intValue; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | return newControl(isCritical, changesOnly, returnECs, Arrays.asList(changeTypes)); |
| | | } |
| | | |
| | | // Indicates whether to only return entries that have been updated |
| | | // since the beginning of the search. |
| | | /** |
| | | * Indicates whether to only return entries that have been updated |
| | | * since the beginning of the search. |
| | | */ |
| | | private final boolean changesOnly; |
| | | |
| | | // Indicates whether entries returned as a result of changes to |
| | | // directory data should include the entry change notification control. |
| | | /** |
| | | * Indicates whether entries returned as a result of changes to |
| | | * directory data should include the entry change notification control. |
| | | */ |
| | | private final boolean returnECs; |
| | | |
| | | // The logical OR of change types associated with this control. |
| | | /** The logical OR of change types associated with this control. */ |
| | | private final Set<PersistentSearchChangeType> changeTypes; |
| | | |
| | | private final boolean isCritical; |
| | |
| | | return changeTypes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | |
| | | return changesOnly; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | |
| | | return returnECs; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | */ |
| | | public static final String OID = "1.3.6.1.1.13.2"; |
| | | |
| | | // The list of raw attributes to return in the entry. |
| | | /** The list of raw attributes to return in the entry. */ |
| | | private final List<String> attributes; |
| | | |
| | | private final boolean isCritical; |
| | |
| | | return attributes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | throw DecodeException.error(message, le); |
| | | } |
| | | |
| | | /** |
| | | /* |
| | | * FIXME: the RFC states that the control contains a |
| | | * SearchResultEntry rather than an Entry. Can we assume |
| | | * that the response will not contain a nested set of |
| | |
| | | * If {@code entry} was {@code null}. |
| | | */ |
| | | public static PostReadResponseControl newControl(final Entry entry) { |
| | | /** |
| | | /* |
| | | * FIXME: all other control implementations are fully immutable. We |
| | | * should really do a defensive copy here in order to be consistent, |
| | | * rather than just wrap it. Also, the RFC states that the control |
| | |
| | | return entry; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | try { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | */ |
| | | public static final String OID = "1.3.6.1.1.13.1"; |
| | | |
| | | // The list of raw attributes to return in the entry. |
| | | /** The list of raw attributes to return in the entry. */ |
| | | private final List<String> attributes; |
| | | |
| | | private final boolean isCritical; |
| | |
| | | return attributes; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | throw DecodeException.error(message, le); |
| | | } |
| | | |
| | | /** |
| | | /* |
| | | * FIXME: the RFC states that the control contains a |
| | | * SearchResultEntry rather than an Entry. Can we assume |
| | | * that the response will not contain a nested set of |
| | |
| | | * If {@code entry} was {@code null}. |
| | | */ |
| | | public static PreReadResponseControl newControl(final Entry entry) { |
| | | /** |
| | | /* |
| | | * FIXME: all other control implementations are fully immutable. We |
| | | * should really do a defensive copy here in order to be consistent, |
| | | * rather than just wrap it. Also, the RFC states that the control |
| | |
| | | return entry; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | try { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return authorizationName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder buffer = new StringBuilder(); |
| | |
| | | return new ProxiedAuthV2RequestControl(authorizationID); |
| | | } |
| | | |
| | | // The authorization ID from the control value. |
| | | /** The authorization ID from the control value. */ |
| | | private final String authorizationID; |
| | | |
| | | private ProxiedAuthV2RequestControl(final String authorizationID) { |
| | |
| | | return authorizationID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return ByteString.valueOf(authorizationID); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.sortKeys = keys; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | |
| | | return sortKeys; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder buffer = new StringBuilder(); |
| | |
| | | return attributeDescription; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return cookie; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | |
| | | return size; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.visibility = visibility; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | return visibility; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | this.isCritical = isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return offset; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | return assertionValue != null ? false : true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return contextID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | |
| | | return targetPosition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | | final ASN1Writer writer = ASN1.getWriter(buffer); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | */ |
| | | abstract class AbstractRequestImpl<R extends Request> implements Request { |
| | | |
| | | // Used by unmodifiable implementations as well. |
| | | /** Used by unmodifiable implementations as well. */ |
| | | static Control getControl(final List<Control> controls, final String oid) { |
| | | // Avoid creating an iterator if possible. |
| | | if (!controls.isEmpty()) { |
| | |
| | | } |
| | | } |
| | | |
| | | // No need to expose this. |
| | | /** No need to expose this. */ |
| | | private static final ExtendedResultDecoder<ExtendedResult> RESULT_DECODER = new ResultDecoder(); |
| | | |
| | | private int requestID; |
| | |
| | | this.requestID = cancelExtendedRequest.getRequestID(); |
| | | } |
| | | |
| | | // Instantiation via factory. |
| | | /** Instantiation via factory. */ |
| | | CancelExtendedRequestImpl(final int requestID) { |
| | | this.requestID = requestID; |
| | | } |
| | |
| | | private byte[] password; |
| | | private final List<String> qopValues = new LinkedList<String>(); |
| | | private String realm = null; |
| | | /* |
| | | * Don't use primitives for these so that we can distinguish between default |
| | | /** |
| | | * Do not use primitives for these so that we can distinguish between default |
| | | * settings (null) and values set by the caller. |
| | | */ |
| | | private Boolean serverAuth = null; |
| | |
| | | |
| | | private final Map<String, String> additionalAuthParams = new LinkedHashMap<String, String>(); |
| | | |
| | | // Ignored if subject is non-null. |
| | | /** Ignored if subject is non-null. */ |
| | | private String authenticationID = null; |
| | | // Optional authorization ID. |
| | | /** Optional authorization ID. */ |
| | | private String authorizationID = null; |
| | | private String kdcAddress = null; |
| | | |
| | |
| | | private final List<String> qopValues = new LinkedList<String>(); |
| | | |
| | | private String realm = null; |
| | | // Don't use primitives for these so that we can distinguish between default |
| | | // settings (null) and values set by the caller. |
| | | /** |
| | | * Don't use primitives for these so that we can distinguish between default |
| | | * settings (null) and values set by the caller. |
| | | */ |
| | | private Boolean serverAuth = null; |
| | | // If null then authenticationID and password must be present. |
| | | /** If null then authenticationID and password must be present. */ |
| | | private Subject subject = null; |
| | | |
| | | GSSAPISASLBindRequestImpl(final GSSAPISASLBindRequest gssapiSASLBindRequest) { |
| | |
| | | |
| | | private ByteString userIdentity = null; |
| | | |
| | | // Instantiation via factory. |
| | | /** Instantiation via factory. */ |
| | | PasswordModifyExtendedRequestImpl() { |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // No need to expose this. |
| | | /** No need to expose this. */ |
| | | private static final ExtendedResultDecoder<ExtendedResult> RESULT_DECODER = new ResultDecoder(); |
| | | |
| | | /** |
| | | * The list of cipher suite. |
| | | */ |
| | | /** The list of cipher suite. */ |
| | | private final List<String> enabledCipherSuites = new LinkedList<String>(); |
| | | |
| | | /** |
| | | * the list of protocols. |
| | | */ |
| | | /** The list of protocols. */ |
| | | private final List<String> enabledProtocols = new LinkedList<String>(); |
| | | |
| | | private SSLContext sslContext; |
| | |
| | | this.enabledProtocols.addAll(startTLSExtendedRequest.getEnabledProtocols()); |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private StartTLSExtendedRequestImpl() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // No need to expose this. |
| | | /** No need to expose this. */ |
| | | private static final ExtendedResultDecoder<WhoAmIExtendedResult> RESULT_DECODER = |
| | | new ResultDecoder(); |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | WhoAmIExtendedRequestImpl() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | * The type of response. |
| | | */ |
| | | abstract class AbstractResponseImpl<S extends Response> implements Response { |
| | | // Used by unmodifiable implementations as well. |
| | | /** Used by unmodifiable implementations as well. */ |
| | | static Control getControl(final List<Control> controls, final String oid) { |
| | | // Avoid creating an iterator if possible. |
| | | if (!controls.isEmpty()) { |
| | |
| | | */ |
| | | abstract class AbstractResultImpl<S extends Result> extends AbstractResponseImpl<S> implements |
| | | Result { |
| | | // For local errors caused by internal exceptions. |
| | | /** For local errors caused by internal exceptions. */ |
| | | private Throwable cause = null; |
| | | private String diagnosticMessage = ""; |
| | | private String matchedDN = ""; |
| | |
| | | this.password = passwordModifyExtendedResult.getGeneratedPassword(); |
| | | } |
| | | |
| | | // Instantiation via factory. |
| | | /** Instantiation via factory. */ |
| | | PasswordModifyExtendedResultImpl(final ResultCode resultCode) { |
| | | super(resultCode); |
| | | } |
| | |
| | | return new UnmodifiableWhoAmIExtendedResultImpl(result); |
| | | } |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private Responses() { |
| | | // Prevent instantiation. |
| | | } |
| | |
| | | final class WhoAmIExtendedResultImpl extends AbstractExtendedResult<WhoAmIExtendedResult> implements |
| | | WhoAmIExtendedResult { |
| | | |
| | | // The authorization ID. |
| | | /** The authorization ID. */ |
| | | private String authorizationID = null; |
| | | |
| | | // Instantiation via factory. |
| | | /** Instantiation via factory. */ |
| | | WhoAmIExtendedResultImpl(final ResultCode resultCode) { |
| | | super(resultCode); |
| | | } |
| | |
| | | */ |
| | | public final class AttributeType extends SchemaElement implements Comparable<AttributeType> { |
| | | |
| | | // The approximate matching rule for this attribute type. |
| | | /** The approximate matching rule for this attribute type. */ |
| | | private final String approximateMatchingRuleOID; |
| | | |
| | | // The attribute usage for this attribute type. |
| | | /** The attribute usage for this attribute type. */ |
| | | private final AttributeUsage attributeUsage; |
| | | |
| | | // The equality matching rule for this attribute type. |
| | | /** The equality matching rule for this attribute type. */ |
| | | private final String equalityMatchingRuleOID; |
| | | |
| | | // Indicates whether this attribute type is declared "collective". |
| | | /** Indicates whether this attribute type is declared "collective". */ |
| | | private final boolean isCollective; |
| | | |
| | | // Indicates whether this attribute type is declared |
| | | // "no-user-modification". |
| | | /** |
| | | * Indicates whether this attribute type is declared "no-user-modification". |
| | | */ |
| | | private final boolean isNoUserModification; |
| | | |
| | | // Indicates whether this definition is declared "obsolete". |
| | | /** Indicates whether this definition is declared "obsolete". */ |
| | | private final boolean isObsolete; |
| | | |
| | | // Indicates whether this definition is a temporary place-holder. |
| | | /** Indicates whether this definition is a temporary place-holder. */ |
| | | private final boolean isPlaceHolder; |
| | | |
| | | // Indicates whether this attribute type is declared "single-value". |
| | | /** Indicates whether this attribute type is declared "single-value". */ |
| | | private final boolean isSingleValue; |
| | | |
| | | // The set of user defined names for this definition. |
| | | /** The set of user defined names for this definition. */ |
| | | private final List<String> names; |
| | | |
| | | // The OID that may be used to reference this definition. |
| | | /** The OID that may be used to reference this definition. */ |
| | | private final String oid; |
| | | |
| | | // The ordering matching rule for this attribute type. |
| | | /** The ordering matching rule for this attribute type. */ |
| | | private final String orderingMatchingRuleOID; |
| | | |
| | | // The substring matching rule for this attribute type. |
| | | /** The substring matching rule for this attribute type. */ |
| | | private final String substringMatchingRuleOID; |
| | | |
| | | // The superior attribute type from which this attribute type |
| | | // inherits. |
| | | /** The superior attribute type from which this attribute type inherits. */ |
| | | private final String superiorTypeOID; |
| | | |
| | | // The syntax for this attribute type. |
| | | /** The syntax for this attribute type. */ |
| | | private final String syntaxOID; |
| | | |
| | | // True if this type has OID 2.5.4.0. |
| | | /** True if this type has OID 2.5.4.0. */ |
| | | private final boolean isObjectClassType; |
| | | |
| | | // The normalized name of this attribute type. |
| | | /** The normalized name of this attribute type. */ |
| | | private final String normalizedName; |
| | | |
| | | // The superior attribute type from which this attribute type |
| | | // inherits. |
| | | /** The superior attribute type from which this attribute type inherits. */ |
| | | private AttributeType superiorType; |
| | | |
| | | // The equality matching rule for this attribute type. |
| | | /** The equality matching rule for this attribute type. */ |
| | | private MatchingRule equalityMatchingRule; |
| | | |
| | | // The ordering matching rule for this attribute type. |
| | | /** The ordering matching rule for this attribute type. */ |
| | | private MatchingRule orderingMatchingRule; |
| | | |
| | | // The substring matching rule for this attribute type. |
| | | /** The substring matching rule for this attribute type. */ |
| | | private MatchingRule substringMatchingRule; |
| | | |
| | | // The approximate matching rule for this attribute type. |
| | | /** The approximate matching rule for this attribute type. */ |
| | | private MatchingRule approximateMatchingRule; |
| | | |
| | | // The syntax for this attribute type. |
| | | /** The syntax for this attribute type. */ |
| | | private Syntax syntax; |
| | | |
| | | // Indicates whether or not validation has been performed. |
| | | /** Indicates whether or not validation has been performed. */ |
| | | private boolean needsValidating = true; |
| | | |
| | | // The indicates whether or not validation failed. |
| | | /** The indicates whether or not validation failed. */ |
| | | private boolean isValid = false; |
| | | |
| | | AttributeType(final String oid, final List<String> names, final String description, |
| | |
| | | */ |
| | | DSA_OPERATION("dSAOperation", true); |
| | | |
| | | // The string representation of this attribute usage. |
| | | /** The string representation of this attribute usage. */ |
| | | private final String usageString; |
| | | |
| | | // Flag indicating whether or not the usage should be categorized as |
| | | // operational. |
| | | /** |
| | | * Flag indicating whether or not the usage should be categorized as |
| | | * operational. |
| | | */ |
| | | private final boolean isOperational; |
| | | |
| | | /** |
| | |
| | | */ |
| | | final class CertificateExactAssertionSyntaxImpl extends AbstractSyntaxImpl { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String getName() { |
| | | return SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean valueIsAcceptable(final Schema schema, final ByteSequence value, |
| | | final LocalizableMessageBuilder invalidReason) { |
| | | // This method will never be called because this syntax is only used |
| | |
| | | return createEncodedValue(serialNumber, certificateIssuer); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Assertion getAssertion(final Schema schema, final ByteSequence value) |
| | | throws DecodeException { |
| | |
| | | * accept only X.509 certificates. |
| | | */ |
| | | final class CertificateSyntaxImpl extends AbstractSyntaxImpl { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getEqualityMatchingRule() { |
| | | return EMR_CERTIFICATE_EXACT_OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() { |
| | | return SYNTAX_CERTIFICATE_NAME; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOrderingMatchingRule() { |
| | | return OMR_OCTET_STRING_OID; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(final Schema schema, final ByteSequence value, |
| | | final LocalizableMessageBuilder invalidReason) { |
| | |
| | | return substringMatchingRule.getSubstringAssertion(schema, subInitial, subAnyElements, subFinal); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Collection<? extends Indexer> getIndexers() { |
| | | return Arrays.asList(subIndexer, indexer); |
| | |
| | | * the entry. |
| | | */ |
| | | public final class DITContentRule extends SchemaElement { |
| | | // The structural objectclass for this DIT content rule. |
| | | |
| | | /** The structural objectclass for this DIT content rule. */ |
| | | private final String structuralClassOID; |
| | | |
| | | // The set of user defined names for this definition. |
| | | /** The set of user defined names for this definition. */ |
| | | private final List<String> names; |
| | | |
| | | // Indicates whether this definition is declared "obsolete". |
| | | /** Indicates whether this definition is declared "obsolete". */ |
| | | private final boolean isObsolete; |
| | | |
| | | // The set of auxiliary objectclasses that entries with this content |
| | | // rule may contain, in a mapping between the objectclass and the |
| | | // user-defined name for that class. |
| | | /** |
| | | * The set of auxiliary objectclasses that entries with this content |
| | | * rule may contain, in a mapping between the objectclass and the |
| | | * user-defined name for that class. |
| | | */ |
| | | private final Set<String> auxiliaryClassOIDs; |
| | | |
| | | // The set of optional attribute types for this DIT content rule. |
| | | /** The set of optional attribute types for this DIT content rule. */ |
| | | private final Set<String> optionalAttributeOIDs; |
| | | |
| | | // The set of prohibited attribute types for this DIT content rule. |
| | | /** The set of prohibited attribute types for this DIT content rule. */ |
| | | private final Set<String> prohibitedAttributeOIDs; |
| | | |
| | | // The set of required attribute types for this DIT content rule. |
| | | /** The set of required attribute types for this DIT content rule. */ |
| | | private final Set<String> requiredAttributeOIDs; |
| | | |
| | | private ObjectClass structuralClass; |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean valueIsAcceptable(final Schema schema, final ByteSequence value, |
| | | final LocalizableMessageBuilder invalidReason) { |
| | | // We'll use the decodeDITContentRule method to determine if the |
| | |
| | | * of children that entries may have. |
| | | */ |
| | | public final class DITStructureRule extends SchemaElement { |
| | | // The rule ID for this DIT structure rule. |
| | | /** The rule ID for this DIT structure rule. */ |
| | | private final Integer ruleID; |
| | | |
| | | // The set of user defined names for this definition. |
| | | /** The set of user defined names for this definition. */ |
| | | private final List<String> names; |
| | | |
| | | // Indicates whether this definition is declared "obsolete". |
| | | /** Indicates whether this definition is declared "obsolete". */ |
| | | private final boolean isObsolete; |
| | | |
| | | // The name form for this DIT structure rule. |
| | | /** The name form for this DIT structure rule. */ |
| | | private final String nameFormOID; |
| | | |
| | | // The set of superior DIT structure rules. |
| | | /** The set of superior DIT structure rules. */ |
| | | private final Set<Integer> superiorRuleIDs; |
| | | |
| | | private NameForm nameForm; |
| | | private Set<DITStructureRule> superiorRules = Collections.emptySet(); |
| | | |
| | | // Indicates whether or not validation has been performed. |
| | | /** Indicates whether or not validation has been performed. */ |
| | | private boolean needsValidating = true; |
| | | |
| | | // The indicates whether or not validation failed. |
| | | /** The indicates whether or not validation failed. */ |
| | | private boolean isValid = false; |
| | | |
| | | DITStructureRule(final Integer ruleID, final List<String> names, final String description, |
| | |
| | | */ |
| | | final class DistinguishedNameEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) |
| | | throws DecodeException { |
| | | try { |
| | |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) { |
| | | String valueString = value.toString(); |
| | | final int length = valueString.length(); |
| | |
| | | */ |
| | | final class EnumSyntaxImpl extends AbstractSyntaxImpl { |
| | | private final String oid; |
| | | // Set of read-only enum entries. |
| | | /** Set of read-only enum entries. */ |
| | | private final List<String> entries; |
| | | |
| | | EnumSyntaxImpl(final String oid, final List<String> entries) { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) { |
| | | return value.toByteString(); |
| | |
| | | * attribute types that may be used for a given matching rule. |
| | | */ |
| | | public final class MatchingRuleUse extends SchemaElement { |
| | | // The OID of the matching rule associated with this matching rule |
| | | // use definition. |
| | | /** |
| | | * The OID of the matching rule associated with this matching rule |
| | | * use definition. |
| | | */ |
| | | private final String oid; |
| | | |
| | | // The set of user defined names for this definition. |
| | | /** The set of user defined names for this definition. */ |
| | | private final List<String> names; |
| | | |
| | | // Indicates whether this definition is declared "obsolete". |
| | | /** Indicates whether this definition is declared "obsolete". */ |
| | | private final boolean isObsolete; |
| | | |
| | | // The set of attribute types with which this matching rule use is |
| | | // associated. |
| | | /** |
| | | * The set of attribute types with which this matching rule use is |
| | | * associated. |
| | | */ |
| | | private final Set<String> attributeOIDs; |
| | | |
| | | private MatchingRule matchingRule; |
| | |
| | | } |
| | | } |
| | | |
| | | // Indicates whether this definition is declared "obsolete". |
| | | /** Indicates whether this definition is declared "obsolete". */ |
| | | private final boolean isObsolete; |
| | | |
| | | // The set of user defined names for this definition. |
| | | /** The set of user defined names for this definition. */ |
| | | private final List<String> names; |
| | | |
| | | // The OID that may be used to reference this definition. |
| | | /** The OID that may be used to reference this definition. */ |
| | | private final String oid; |
| | | |
| | | // The set of optional attribute types for this name form. |
| | | /** The set of optional attribute types for this name form. */ |
| | | private final Set<String> optionalAttributeOIDs; |
| | | private Set<AttributeType> optionalAttributes = Collections.emptySet(); |
| | | |
| | | // The set of required attribute types for this name form. |
| | | /** The set of required attribute types for this name form. */ |
| | | private final Set<String> requiredAttributeOIDs; |
| | | private Set<AttributeType> requiredAttributes = Collections.emptySet(); |
| | | |
| | | // The reference to the structural objectclass for this name form. |
| | | /** The reference to the structural objectclass for this name form. */ |
| | | private ObjectClass structuralClass; |
| | | private final String structuralClassOID; |
| | | |
| | |
| | | * accessed via their getters or via the {@link #toString()} methods. |
| | | */ |
| | | public final class ObjectClass extends SchemaElement { |
| | | // The OID that may be used to reference this definition. |
| | | /** The OID that may be used to reference this definition. */ |
| | | private final String oid; |
| | | |
| | | // The set of user defined names for this definition. |
| | | /** The set of user defined names for this definition. */ |
| | | private final List<String> names; |
| | | |
| | | // Indicates whether this definition is declared "obsolete". |
| | | /** Indicates whether this definition is declared "obsolete". */ |
| | | private final boolean isObsolete; |
| | | |
| | | // The reference to the superior objectclasses. |
| | | /** The reference to the superior objectclasses. */ |
| | | private final Set<String> superiorClassOIDs; |
| | | |
| | | // The objectclass type for this objectclass. |
| | | /** The objectclass type for this objectclass. */ |
| | | private final ObjectClassType objectClassType; |
| | | |
| | | // The set of required attribute types for this objectclass. |
| | | /** The set of required attribute types for this objectclass. */ |
| | | private final Set<String> requiredAttributeOIDs; |
| | | |
| | | // The set of optional attribute types for this objectclass. |
| | | /** The set of optional attribute types for this objectclass. */ |
| | | private final Set<String> optionalAttributeOIDs; |
| | | |
| | | private Set<ObjectClass> superiorClasses = Collections.emptySet(); |
| | |
| | | private Set<AttributeType> declaredOptionalAttributes = Collections.emptySet(); |
| | | private Set<AttributeType> optionalAttributes = Collections.emptySet(); |
| | | |
| | | // Indicates whether or not validation has been performed. |
| | | /** Indicates whether or not validation has been performed. */ |
| | | private boolean needsValidating = true; |
| | | |
| | | // The indicates whether or not validation failed. |
| | | /** The indicates whether or not validation failed. */ |
| | | private boolean isValid = false; |
| | | |
| | | ObjectClass(final String oid, final List<String> names, final String description, |
| | |
| | | */ |
| | | AUXILIARY("AUXILIARY"); |
| | | |
| | | // The string representation of this objectclass type. |
| | | /** The string representation of this objectclass type. */ |
| | | private final String typeString; |
| | | |
| | | /** |
| | |
| | | * LDAPSyntaxDescriptionSyntax with X-PATTERN extension. |
| | | */ |
| | | final class RegexSyntaxImpl extends AbstractSyntaxImpl { |
| | | // The Pattern associated with the regex. |
| | | /** The Pattern associated with the regex. */ |
| | | private final Pattern pattern; |
| | | |
| | | RegexSyntaxImpl(final Pattern pattern) { |
| | |
| | | */ |
| | | public static final String DATE_FORMAT_UTC_TIME = "yyMMddHHmmss'Z'"; |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private SchemaConstants() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | */ |
| | | private String definition; |
| | | |
| | | // The description for this definition. |
| | | /** The description for this definition. */ |
| | | private final String description; |
| | | |
| | | // The set of additional name-value pairs. |
| | | /** The set of additional name-value pairs. */ |
| | | private final Map<String, List<String>> extraProperties; |
| | | |
| | | SchemaElement() { |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract boolean equals(Object obj); |
| | | |
| | |
| | | return extraProperties; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract int hashCode(); |
| | | |
| | |
| | | */ |
| | | @SuppressWarnings("serial") |
| | | final class SchemaException extends Exception implements LocalizableException { |
| | | // The I18N message associated with this exception. |
| | | /** The I18N message associated with this exception. */ |
| | | private final LocalizableMessage message; |
| | | |
| | | /** |
| | |
| | | this.message = message; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public LocalizableMessage getMessageObject() { |
| | | return this.message; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private SchemaUtils() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | private Action checkAttributeValues = Action.REJECT; |
| | | private EntryResolver checkDITStructureRulesEntryResolver = null; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private SchemaValidationPolicy() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | .asNonStrictSchema(); |
| | | } |
| | | |
| | | // Assigns the provided options to this set of options. |
| | | /** Assigns the provided options to this set of options. */ |
| | | SchemaValidationPolicy assign(final SchemaValidationPolicy policy) { |
| | | this.checkAttributeValues = policy.checkAttributeValues; |
| | | this.checkNameForms = policy.checkNameForms; |
| | |
| | | return ldifLine; |
| | | } |
| | | |
| | | /* |
| | | * Determine whether the provided line is a continuation line. Note that |
| | | /** |
| | | * Determines whether the provided line is a continuation line. Note that |
| | | * while RFC 2849 technically only allows a space in this position, both |
| | | * OpenLDAP and the Sun Java System Directory Server allow a tab as well, so |
| | | * we will too for compatibility reasons. See issue #852 for details. |
| | |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * Regular expression used for splitting comments on line-breaks. |
| | | */ |
| | | /** Regular expression used for splitting comments on line-breaks. */ |
| | | private static final Pattern SPLIT_NEWLINE = Pattern.compile("\\r?\\n"); |
| | | boolean addUserFriendlyComments = false; |
| | | final LDIFWriterImpl impl; |
| | |
| | | */ |
| | | // ChangeRecord setName(String dn); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | Request addControl(Control control); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options) |
| | | throws DecodeException; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | List<Control> getControls(); |
| | | } |
| | |
| | | */ |
| | | final class ChangeRecordVisitorWriter implements |
| | | ChangeRecordVisitor<IOException, ChangeRecordWriter> { |
| | | // Visitor used for writing generic change records. |
| | | /** Visitor used for writing generic change records. */ |
| | | private static final ChangeRecordVisitorWriter VISITOR = new ChangeRecordVisitorWriter(); |
| | | |
| | | /** |
| | |
| | | promise.cancel(true); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasNext() throws LdapException { |
| | | // Poll for the next response if needed. |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private LDIF() { |
| | | // Do nothing. |
| | | } |
| | |
| | | private static final Pattern CONTROL_REGEX = Pattern |
| | | .compile("^\\s*(\\d+(.\\d+)*)(\\s+((true)|(false)))?\\s*(:(:)?\\s*?\\S+)?\\s*$"); |
| | | |
| | | // Poison used to indicate end of LDIF. |
| | | /** Poison used to indicate end of LDIF. */ |
| | | private static final ChangeRecord EOF = Requests.newAddRequest(DN.rootDN()); |
| | | |
| | | /** |
| | |
| | | super(Arrays.asList(ldifLines)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | close0(); |
| | |
| | | super(writer); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | close0(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void flush() throws IOException { |
| | | flush0(); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final AddRequest change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ChangeRecord change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | final IOException e = change.accept(ChangeRecordVisitorWriter.getInstance(), this); |
| | | if (e != null) { |
| | | throw e; |
| | | } else { |
| | | return this; |
| | | } |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final DeleteRequest change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ModifyDNRequest change) |
| | | throws IOException { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ModifyRequest change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeComment(final CharSequence comment) throws IOException { |
| | | writeComment0(comment); |
| | |
| | | * Interchange Format (LDIF) - Technical Specification </a> |
| | | */ |
| | | public final class LDIFEntryReader extends AbstractLDIFReader implements EntryReader { |
| | | // Poison used to indicate end of LDIF. |
| | | /** Poison used to indicate end of LDIF. */ |
| | | private static final Entry EOF = new LinkedHashMapEntry(); |
| | | |
| | | /** |
| | |
| | | super(Arrays.asList(ldifLines)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | close0(); |
| | |
| | | super(writer); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | close0(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void flush() throws IOException { |
| | | flush0(); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFEntryWriter writeComment(final CharSequence comment) throws IOException { |
| | | writeComment0(comment); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFEntryWriter writeEntry(final Entry entry) throws IOException { |
| | | Reject.ifNull(entry); |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** parent DN of entries to generate for this template. */ |
| | | /** Parent DN of entries to generate for this template. */ |
| | | private DN parentDN; |
| | | |
| | | /** |
| | |
| | | /** The decimal format used to format numeric values. */ |
| | | private DecimalFormat decimalFormat; |
| | | |
| | | /** The number of characters between the minimum and maximum length */ |
| | | /** (inclusive). */ |
| | | /** The number of characters between the minimum and maximum length (inclusive). */ |
| | | private int lengthRange = 1; |
| | | |
| | | /** The maximum number of characters to include in the value. */ |
| | |
| | | assertEquals(result, liveResult); |
| | | } |
| | | |
| | | // Generates data for case exact matching rules. |
| | | /** Generates data for case exact matching rules. */ |
| | | @DataProvider(name = "exactRuleData") |
| | | public Object[][] createExactRuleData() { |
| | | return new Object[][] { { "12345678", "12345678", ConditionResult.TRUE }, |
| | |
| | | { "foo\u070Fbar", "foobar", ConditionResult.TRUE }, }; |
| | | } |
| | | |
| | | // Generates data for case ignore matching rules. |
| | | /** Generates data for case ignore matching rules. */ |
| | | @DataProvider(name = "caseFoldRuleData") |
| | | public Object[][] createIgnoreRuleData() { |
| | | return new Object[][] { { "12345678", "12345678", ConditionResult.TRUE }, |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * Test class for ASN1ByteSequenceReaderTestCase |
| | | * Test class for ASN1ByteSequenceReaderTestCase. |
| | | */ |
| | | public class ASN1ByteSequenceReaderTestCase extends ASN1ReaderTestCase { |
| | | @Override |
| | |
| | | import java.io.ByteArrayInputStream; |
| | | |
| | | /** |
| | | * Test class for ASN1InputStreamReader |
| | | * Test class for ASN1InputStreamReader. |
| | | */ |
| | | public class ASN1InputStreamReaderTestCase extends ASN1ReaderTestCase { |
| | | @Override |
| | |
| | | import java.io.ByteArrayOutputStream; |
| | | |
| | | /** |
| | | * Test class for ASN1OutputStreamWriter |
| | | * Test class for ASN1OutputStreamWriter. |
| | | */ |
| | | public class ASN1OutputStreamWriterTestCase extends ASN1WriterTestCase { |
| | | private final ByteArrayOutputStream outStream = new ByteArrayOutputStream(); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public abstract class ASN1WriterTestCase extends ForgeRockTestCase { |
| | | |
| | | // Create an array with a selection of the valid single-byte types. We don't |
| | | // support multi-byte types, so this should be a comprehensive data set. |
| | | /** |
| | | * Create an array with a selection of the valid single-byte types. We don't |
| | | * support multi-byte types, so this should be a comprehensive data set. |
| | | */ |
| | | private final byte[] testTypes = { 0x00, 0x7f, (byte) 0x80, (byte) 0xff }; |
| | | |
| | | /** |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public abstract class LDAPReaderWriterTestCase extends SdkTestCase { |
| | | |
| | | // message ID is used in all tests |
| | | /** Message ID is used in all tests. */ |
| | | private static final int MESSAGE_ID = 0; |
| | | |
| | | // DN used is several tests |
| | | /** DN used is several tests. */ |
| | | private static final String TEST_DN = "cn=test"; |
| | | |
| | | interface LDAPWrite { |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class AddressMaskTestCase extends SdkTestCase { |
| | | |
| | | /* These are all valid rules -- should all pass. */ |
| | | /** These are all valid rules -- should all pass. */ |
| | | @DataProvider(name = "validRules") |
| | | public Object[][] validData() { |
| | | return new Object[][] { { "129.34.55.67" }, { "129.*.78.55" }, { ".central.sun.com" }, |
| | |
| | | * IPV6 data and tests. |
| | | */ |
| | | |
| | | //Invalid IPv6 expressions. |
| | | /** Invalid IPv6 expressions. */ |
| | | @DataProvider(name = "invalid6Rules") |
| | | public Object[][] inValid6Data() { |
| | | return new Object[][] { { "2001:feca:ba23:cd1f:dcb1:1010:9234:4088///124" }, |
| | |
| | | { "1080::8:800:*:417A/66" }, { "2001:fecd:ba23:cd1ff:dcb1:1010:202.45.66.20" }, }; |
| | | } |
| | | |
| | | //Valid IPv6 expressions. |
| | | /** Valid IPv6 expressions. */ |
| | | @DataProvider(name = "valid6Rules") |
| | | public Object[][] valid6Data() { |
| | | return new Object[][] { { "2001:fecd:ba23:cd1f:dcb1:1010:9234:4088/124" }, |
| | |
| | | assertFalse(iterator.hasNext()); |
| | | } |
| | | |
| | | // FIXME: none of these pass! The valueOf method is far to lenient. |
| | | /** FIXME: none of these pass! The valueOf method is far to lenient. */ |
| | | @Test(dataProvider = "dataForValueOfInvalidAttributeDescriptions", |
| | | expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testValueOfInvalidAttributeDescriptions(final String ad) { |
| | |
| | | e.parseAttribute("type").requireValue().asByteString(); |
| | | } |
| | | |
| | | // Smoke test for set of methods: use one type only since the code is common |
| | | // and we've already tested the parsing. |
| | | /** |
| | | * Smoke test for set of methods: use one type only since the code is common |
| | | * and we've already tested the parsing. |
| | | */ |
| | | @Test |
| | | public void testAsSetOfDN() { |
| | | Entry e = |
| | |
| | | { "cn;bar" }, { "cn;BAR" }, { "cn;foo;bar" }, { "cn;FOO;bar" }, }; |
| | | } |
| | | |
| | | /** |
| | | * Data provider for old and new attributes |
| | | * |
| | | * @return |
| | | */ |
| | | /** Data provider for old and new attributes. */ |
| | | @DataProvider(name = "dataForAttributeRename") |
| | | public Object[][] dataForAttributeRename() { |
| | | return new Object[][] { { "cn", "cn", true }, { "CN", "cn", true }, |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test class for ByteSequenceReader |
| | | * Test class for ByteSequenceReader. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class ByteSequenceReaderTest extends SdkTestCase { |
| | |
| | | |
| | | @Test(expectedExceptions = IndexOutOfBoundsException.class) |
| | | public void testUndersizedGetBERLength() { |
| | | ByteSequenceReader reader = ByteString.wrap(new byte[0]).asReader(); |
| | | ByteSequenceReader reader = ByteString.empty().asReader(); |
| | | |
| | | // Shouldn't be able to reader over a 4 byte length. |
| | | reader.getBERLength(); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class DNTestCase extends SdkTestCase { |
| | | /** |
| | | * child DN test data provider. |
| | | * Child DN test data provider. |
| | | * |
| | | * @return The array of test data. |
| | | */ |
| | |
| | | { "cn=hello world\\ ,dc=com", "cn=hello world,dc=com", 0 }, |
| | | { "cn=HELLO WORLD,dc=com", "cn=hello world,dc=com", 0 }, |
| | | { "cn=HELLO+sn=WORLD,dc=com", "sn=world+cn=hello,dc=com", 0 }, |
| | | /** |
| | | /* |
| | | * { "x-test-integer-type=10,dc=com", |
| | | * "x-test-integer-type=9,dc=com", 1 }, { |
| | | * "x-test-integer-type=999,dc=com", |
| | |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class LDAPServer implements ServerConnectionFactory<LDAPClientContext, Integer> { |
| | | // Creates an abandonable request from the ordinary requests. |
| | | /** Creates an abandonable request from the ordinary requests. */ |
| | | private static class AbandonableRequest implements Request { |
| | | // the request. |
| | | /** The request. */ |
| | | private final Request request; |
| | | |
| | | // whether is has been cancelled. |
| | | /** Whether is has been cancelled. */ |
| | | private final AtomicBoolean isCanceled; |
| | | |
| | | // Ctor. |
| | | /** Ctor. */ |
| | | AbandonableRequest(final Request request) { |
| | | this.request = request; |
| | | this.isCanceled = new AtomicBoolean(false); |
| | |
| | | } |
| | | } |
| | | |
| | | // The singleton instance. |
| | | /** The singleton instance. */ |
| | | private static final LDAPServer INSTANCE = new LDAPServer(); |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | // The mapping between entry DNs and the corresponding entries. |
| | | /** The mapping between entry DNs and the corresponding entries. */ |
| | | private final ConcurrentHashMap<DN, Entry> entryMap = new ConcurrentHashMap<DN, Entry>(); |
| | | |
| | | // The LDAP listener. |
| | | /** The LDAP listener. */ |
| | | private LDAPListener listener = null; |
| | | |
| | | // whether the server is running. |
| | | /** Whether the server is running. */ |
| | | private volatile boolean isRunning; |
| | | |
| | | // The mapping between the message id and the requests the server is |
| | | // currently handling. |
| | | /** |
| | | * The mapping between the message id and the requests the server is |
| | | * currently handling. |
| | | */ |
| | | private final ConcurrentHashMap<Integer, AbandonableRequest> requestsInProgress = |
| | | new ConcurrentHashMap<Integer, AbandonableRequest>(); |
| | | |
| | |
| | | private ExtendedResult notification = null; |
| | | private final AtomicInteger invocationCount = new AtomicInteger(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionClosed() { |
| | | invocationCount.incrementAndGet(); |
| | | closedLatch.countDown(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionError(boolean isDisconnectNotification, LdapException error) { |
| | | this.isDisconnectNotification = isDisconnectNotification; |
| | |
| | | errorLatch.countDown(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleUnsolicitedNotification(ExtendedResult notification) { |
| | | this.notification = notification; |
| | |
| | | |
| | | } |
| | | |
| | | // Saved scheduled tasks. |
| | | /** Saved scheduled tasks. */ |
| | | private final List<Callable<?>> tasks = new CopyOnWriteArrayList<Callable<?>>(); |
| | | |
| | | MockScheduler() { |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public final class RDNTestCase extends SdkTestCase { |
| | | |
| | | // Domain component attribute type. |
| | | /** Domain component attribute type. */ |
| | | private static final AttributeType ATTR_TYPE_DC; |
| | | |
| | | // Common name attribute type. |
| | | /** Common name attribute type. */ |
| | | private static final AttributeType ATTR_TYPE_CN; |
| | | |
| | | // Test attribute value. |
| | | /** Test attribute value. */ |
| | | private static final AVA ATTR_VALUE_DC_ORG; |
| | | |
| | | static { |
| | |
| | | ATTR_VALUE_DC_ORG = new AVA(ATTR_TYPE_DC, ByteString.valueOf("org")); |
| | | } |
| | | |
| | | // org bytestring. |
| | | /** "org" bytestring. */ |
| | | private static final ByteString ORG = ByteString.valueOf("org"); |
| | | |
| | | /** |
| | |
| | | private static final GenericControl NEW_CONTROL3 = GenericControl.newControl("6.7.8".intern()); |
| | | private static final GenericControl NEW_CONTROL4 = GenericControl.newControl("8.9.0".intern()); |
| | | |
| | | // Dummy decoder which does nothing. |
| | | /** Dummy decoder which does nothing. */ |
| | | private static class MyDecoder implements ControlDecoder<Control> { |
| | | public Control decodeControl(final Control control, final DecodeOptions options) throws DecodeException { |
| | | // do nothing. |
| | |
| | | * Attribute type syntax tests. |
| | | */ |
| | | public class AttributeTypeSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | + " NO-USER-MODIFICATION USAGE userApplications", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | |
| | | * Test the BitStringEqualityMatchingRule. |
| | | */ |
| | | public class BitStringEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | { "\'1010\'A" }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "\'0\'B", "\'1\'B", ConditionResult.FALSE }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_BIT_STRING_OID); |
| | |
| | | * Bit string syntax tests. |
| | | */ |
| | | public class BitStringSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "invalid", false }, { "1", false }, { "'010100000111111010101000'B", true }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_BIT_STRING_OID); |
| | |
| | | */ |
| | | public class BooleanEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { { "garbage" }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "0", "false", ConditionResult.TRUE }, { "TRUE", "false", ConditionResult.FALSE }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_BOOLEAN_OID); |
| | |
| | | */ |
| | | public class CaseExactEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "ABC45678", "abc45678", ConditionResult.FALSE }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_EXACT_OID); |
| | |
| | | */ |
| | | public class CaseExactIA5EqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { { "12345678\uFFFD" }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_EXACT_IA5_OID); |
| | |
| | | */ |
| | | public class CaseExactOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | { "abcdef", "abcdef", 0 }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_CASE_EXACT_OID); |
| | |
| | | * Test the CaseIgnoreEqualityMatchingRule. |
| | | */ |
| | | public class CaseIgnoreEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_IGNORE_OID); |
| | |
| | | */ |
| | | public class CaseIgnoreIA5EqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { { "12345678\uFFFD" }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "ABC45678", "abc45678", ConditionResult.TRUE }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_IGNORE_IA5_OID); |
| | |
| | | */ |
| | | public class CaseIgnoreOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | { "a", "\u00f8", -1 }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_CASE_IGNORE_OID); |
| | |
| | | @Test |
| | | public class CollationEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | // Note that oid and names are not used by the test (ie, they could be any value, test should pass anyway) |
| | |
| | | @Test |
| | | public class CollationGreaterThanMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | // Note that oid and names are not used by the test (ie, they could be any value, test should pass anyway) |
| | |
| | | @Test |
| | | public class CollationGreaterThanOrEqualMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | // Note that oid and names are not used by the test (ie, they could be any value, test should pass anyway) |
| | |
| | | @Test |
| | | public class CollationLessThanMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | // Note that oid and names are not used by the test (ie, they could be any value, test should pass anyway) |
| | |
| | | @Test |
| | | public class CollationLessThanOrEqualMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | // Note that oid and names are not used by the test (ie, they could be any value, test should pass anyway) |
| | |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "substringFinalMatchData") |
| | | public Object[][] createSubstringFinalMatchData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "substringInitialMatchData") |
| | | public Object[][] createSubstringInitialMatchData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "substringMiddleMatchData") |
| | | public Object[][] createSubstringMiddleMatchData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | // Note that oid and names are not used by the test (ie, they could be any value, test should pass anyway) |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Core schema tests |
| | | * Core schema tests. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class CoreSchemaTest extends AbstractSchemaTestCase { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_COUNTRY_STRING_OID); |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_DIT_CONTENT_RULE_OID); |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the DistinguishedNameEqualityMatchingRule |
| | | * Test the DistinguishedNameEqualityMatchingRule. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class DistinguishedNameEqualityMatchingRuleTest extends MatchingRuleTest { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Test the normalized values |
| | | * Test the normalized values. |
| | | */ |
| | | @Test(dataProvider = "testDNs") |
| | | public void testNormalization(final String value1, final String value2) throws Exception { |
| | |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class EnumSyntaxTestCase extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | builder.toSchema(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() throws SchemaException, DecodeException { |
| | | final SchemaBuilder builder = new SchemaBuilder(Schema.getCoreSchema()); |
| | |
| | | { "200612-1235959Z", false }, { "20061231#35959Z", false }, { "2006", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_GENERALIZED_TIME_OID); |
| | |
| | | * Guide syntax tests. |
| | | */ |
| | | public class GuideSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "sn$EQ|(cn$APPROX&?false)", true }, { "sn$EQ|(cn$APPROX&|?false)", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_GUIDE_OID); |
| | |
| | | * IA5 string syntax tests. |
| | | */ |
| | | public class IA5StringSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | | return new Object[][] { { "12345678", true }, { "12345678\u2163", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_IA5_STRING_OID); |
| | |
| | | * LDAP syntax tests. |
| | | */ |
| | | public class LDAPSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "(2.5.4.3 DESC 'syntax description' ", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_LDAP_SYNTAX_OID); |
| | |
| | | * Matching rule syntax tests. |
| | | */ |
| | | public class MatchingRuleSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | + " X-name ( 'this is an extension' ) ", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_MATCHING_RULE_OID); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Removes all the extra properties |
| | | * Removes all the extra properties. |
| | | */ |
| | | @Test() |
| | | public final void testBuilderRemoveExtraProperties() { |
| | |
| | | * Matching rule use syntax tests. |
| | | */ |
| | | public class MatchingRuleUseSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | + " X-name ( 'this is an extension' ) ", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_MATCHING_RULE_USE_OID); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Remove functions uses on names / required attribute / |
| | | * Remove functions uses on names / required attribute. |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | |
| | | * Other mailbox syntax tests. |
| | | */ |
| | | public class OtherMailboxSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | | return new Object[][] { { "MyMail$Mymailbox", true }, { "MyMailMymailbox", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_OTHER_MAILBOX_OID); |
| | |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class RegexSyntaxTestCase extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | Assert.assertFalse(builder.toSchema().getWarnings().isEmpty()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | final SchemaBuilder builder = new SchemaBuilder(Schema.getCoreSchema()); |
| | |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class SubstitutionSyntaxTestCase extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | Assert.assertFalse(builder.toSchema().getWarnings().isEmpty()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | // Use IA5String syntax as our substitute. |
| | |
| | | * Telex syntax tests. |
| | | */ |
| | | public class TelexSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "abcdefghijk$lmnopqr$stuvwxyz", true }, { "12345$67890$()+,-./:? ", true }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_TELEX_OID); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_UTC_TIME_OID); |
| | |
| | | * UUID syntax tests. |
| | | */ |
| | | public class UUIDSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "12345678-9abc-def0-1234-1234567890a", false }, }; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_UUID_OID); |
| | |
| | | |
| | | /** |
| | | * ConnectionChangeRecordWriter write a change record (in this example the |
| | | * ChangeRecord is an AddRequest) |
| | | * ChangeRecord is an AddRequest). |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | |
| | | /** |
| | | * ConnectionChangeRecordWriter write a change record (in this example the |
| | | * ChangeRecord is a DeleteRequest) |
| | | * ChangeRecord is a DeleteRequest). |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Test for parsing escaped character in templates |
| | | */ |
| | | /** Test for parsing escaped character in templates. */ |
| | | @Test(dataProvider = "validTemplates") |
| | | public void testParsingEscapeCharInTemplate(String testName, String[] lines) throws Exception { |
| | | TemplateFile templateFile = new TemplateFile(schema, null, resourcePath); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Test for escaped characters in templates |
| | | * Test for escaped characters in templates. |
| | | */ |
| | | @Test(dataProvider = "templatesToTestEscapeChars", dependsOnMethods = { "testParsingEscapeCharInTemplate" }) |
| | | public void testEscapeCharsFromTemplate(String testName, String[] lines, String attrName, String expectedValue) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Test template that combines escaped characters and variables |
| | | * Test template that combines escaped characters and variables. |
| | | */ |
| | | @Test(dependsOnMethods = { "testParsingEscapeCharInTemplate" }) |
| | | public void testCombineEscapeCharInTemplate() throws Exception { |
| | |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | | import static org.fest.assertions.Assertions.assertThat; |
| | | import static org.mockito.Matchers.any; |
| | | import static org.mockito.Matchers.anyListOf; |
| | | import static org.mockito.Matchers.eq; |
| | | import static org.mockito.Mockito.doThrow; |
| | | import static org.mockito.Mockito.mock; |
| | | import static org.mockito.Mockito.times; |
| | | import static org.mockito.Mockito.verify; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | |
| | | import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.Action; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.fest.assertions.Assertions.*; |
| | | import static org.mockito.Matchers.*; |
| | | import static org.mockito.Mockito.*; |
| | | |
| | | /** |
| | | * This class tests the LDIFChangeRecordReader functionality. |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * valueOfLDIFChangeRecord cause an exception due to the presence of |
| | | * multiple change record. |
| | | * |
| | | * @throws Exception |
| | | * {@link LDIFChangeRecordReader#valueOfLDIFChangeRecord(String...)} cause |
| | | * an exception due to the presence of multiple change record. |
| | | */ |
| | | @Test(expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testValueOfLDIFChangeRecordDoesntAllowMultipleChangeRecords() throws Exception { |
| | |
| | | } |
| | | |
| | | /** |
| | | * valueOfLDIFChangeRecord cause an exception due to badly formed ldif. In |
| | | * this case, DN is missing. |
| | | * |
| | | * @throws Exception |
| | | * {@link LDIFChangeRecordReader#valueOfLDIFChangeRecord(String...)} cause |
| | | * an exception due to badly formed ldif. In this case, DN is missing. |
| | | */ |
| | | @Test(expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testValueOfLDIFChangeRecordMalformedLDIFDNIsMissing() throws Exception { |
| | |
| | | } |
| | | |
| | | /** |
| | | * setExcludeAttributeDoesn't allow null. |
| | | * {@link LDIFEntryReader#setExcludeAttribute(AttributeDescription)} |
| | | * does not allow null. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Test to read an entry excluding all operational attributes |
| | | * setExcludeAllOperationalAttributes is forced to true |
| | | * setExcludeAllOperationalAttributes is forced to true. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Test to read an entry containing spaces before the attribute |
| | | * |
| | | * @throws Exception |
| | | * Test to read an entry containing spaces before the attribute. |
| | | */ |
| | | @Test() |
| | | public void testReadEntryWithAttributesSpacesAtStart() throws Exception { |
| | |
| | | /** |
| | | * Test to read an entry containing duplicates values |
| | | * ERR_LDIF_MULTI_VALUED_SINGLE_VALUED_ATTRIBUTE && |
| | | * WARN_LDIF_DUPLICATE_ATTRIBUTE_VALUE |
| | | * WARN_LDIF_DUPLICATE_ATTRIBUTE_VALUE. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | tagWithArguments(new AttributeValueTag(), templateWithNoAttribute(), "dc"); |
| | | } |
| | | |
| | | /** Helper method to initialize tags with template having any attribute and some arguments*/ |
| | | /** Helper method to initialize tags with template having any attribute and some arguments. */ |
| | | private void tagWithArguments(TemplateTag tag, String... arguments) throws DecodeException { |
| | | tagWithArguments(tag, templateWithAnyAttribute(), arguments); |
| | | } |
| | | |
| | | /** Helper method to initialize tags with template and some arguments*/ |
| | | /** Helper method to initialize tags with template and some arguments. */ |
| | | private void tagWithArguments(TemplateTag tag, Template template, String... arguments) |
| | | throws DecodeException { |
| | | tag.initializeForTemplate(Schema.getDefaultSchema(), NULL_TEMPLATE_FILE, template, |
| | |
| | | return templateVal; |
| | | } |
| | | |
| | | /** Helper method to build a template that always return true on attribute type check */ |
| | | /** Helper method to build a template that always return true on attribute type check. */ |
| | | private Template templateWithAnyAttribute() { |
| | | Template template = mock(Template.class); |
| | | when(template.hasAttribute(any(AttributeType.class))).thenReturn(true); |
| | | return template; |
| | | } |
| | | |
| | | /** Helper method to build a template that always return false on attribute type check */ |
| | | /** Helper method to build a template that always return false on attribute type check. */ |
| | | private Template templateWithNoAttribute() { |
| | | Template template = mock(Template.class); |
| | | when(template.hasAttribute(any(AttributeType.class))).thenReturn(false); |
| | |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int peekLength() throws IOException { |
| | | peekType(); |
| | | |
| | |
| | | return peekLength; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public byte peekType() throws IOException { |
| | | if (state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) { |
| | | needTypeState(false); |
| | |
| | | return peekType; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public boolean readBoolean() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return readByte != 0x00; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readEndSequence() throws IOException { |
| | | readLimiter = readLimiter.endSequence(); |
| | | |
| | |
| | | readEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readEndSet() throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | | readEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public int readEnumerated() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return (int) readInteger(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public long readInteger() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readNull() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | state = ASN1.ELEMENT_READ_STATE_NEED_TYPE; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteString readOctetString() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return ByteString.wrap(value); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ByteStringBuilder readOctetString(final ByteStringBuilder builder) throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return builder; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public String readOctetStringAsString() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSequence() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | readStartSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void readStartSet() throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | | readStartSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Reader skipElement() throws IOException { |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | |
| | | outBuffer.clear(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeBoolean(final byte type, final boolean booleanValue) throws IOException { |
| | | sequenceBuffer.writeByte(type); |
| | | writeLength(sequenceBuffer, 1); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeEndSequence() throws IOException { |
| | | sequenceBuffer = sequenceBuffer.endSequence(); |
| | | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeEndSet() throws IOException { |
| | | return writeEndSequence(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeEnumerated(final byte type, final int intValue) throws IOException { |
| | | return writeInteger(type, intValue); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeInteger(final byte type, final int intValue) throws IOException { |
| | | sequenceBuffer.writeByte(type); |
| | | if (((intValue < 0) && ((intValue & 0xFFFFFF80) == 0xFFFFFF80)) |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeInteger(final byte type, final long longValue) throws IOException { |
| | | sequenceBuffer.writeByte(type); |
| | | if (((longValue < 0) && ((longValue & 0xFFFFFFFFFFFFFF80L) == 0xFFFFFFFFFFFFFF80L)) |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeNull(final byte type) throws IOException { |
| | | sequenceBuffer.writeByte(type); |
| | | writeLength(sequenceBuffer, 0); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(final byte type, final byte[] value, final int offset, |
| | | final int length) throws IOException { |
| | | sequenceBuffer.writeByte(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(final byte type, final ByteSequence value) |
| | | throws IOException { |
| | | sequenceBuffer.writeByte(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeOctetString(final byte type, final String value) throws IOException { |
| | | sequenceBuffer.writeByte(type); |
| | | |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeStartSequence(final byte type) throws IOException { |
| | | // Get a child sequence buffer |
| | | sequenceBuffer = sequenceBuffer.startSequence(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public ASN1Writer writeStartSet(final byte type) throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | | // sequence. |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private GrizzlyUtils() { |
| | | // No implementation required. |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // Needed in order to expose type information. |
| | | /** Needed in order to expose type information. */ |
| | | private <R extends ExtendedResult> void handleExtendedResult0( |
| | | final GrizzlyLDAPConnection conn, final ExtendedResultLdapPromiseImpl<R> promise, |
| | | final ExtendedResult result) throws DecodeException { |
| | |
| | | |
| | | package org.forgerock.opendj.grizzly; |
| | | |
| | | import static org.forgerock.opendj.grizzly.GrizzlyUtils.configureConnection; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.InetSocketAddress; |
| | | import java.security.GeneralSecurityException; |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConnectionSecurityLayer; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.IntermediateResponseHandler; |
| | | import org.forgerock.opendj.ldap.LDAPClientContext; |
| | | import org.forgerock.opendj.ldap.LDAPListenerOptions; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ResultHandler; |
| | | import org.forgerock.opendj.ldap.SSLContextBuilder; |
| | |
| | | import org.forgerock.opendj.ldap.responses.Result; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | import org.forgerock.util.Reject; |
| | | import org.glassfish.grizzly.Connection; |
| | | import org.glassfish.grizzly.Grizzly; |
| | | import org.glassfish.grizzly.attributes.Attribute; |
| | |
| | | import org.glassfish.grizzly.ssl.SSLEngineConfigurator; |
| | | import org.glassfish.grizzly.ssl.SSLFilter; |
| | | import org.glassfish.grizzly.ssl.SSLUtils; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import static org.forgerock.opendj.grizzly.GrizzlyUtils.*; |
| | | |
| | | /** |
| | | * Grizzly filter implementation for decoding LDAP requests and handling server |
| | |
| | | */ |
| | | private static final LDAPWrite<IntermediateResponse> INTERMEDIATE = |
| | | new LDAPWrite<IntermediateResponse>() { |
| | | @Override |
| | | public void perform(LDAPWriter<ASN1BufferWriter> writer, int messageID, |
| | | IntermediateResponse resp) throws IOException { |
| | | writer.writeIntermediateResponse(messageID, resp); |
| | |
| | | */ |
| | | private void defaultHandleResult(final R result) { |
| | | writeMessage(new LDAPWrite<R>() { |
| | | @Override |
| | | public void perform(LDAPWriter<ASN1BufferWriter> writer, int messageID, R res) |
| | | throws IOException { |
| | | writeResult(writer, res); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | @Override |
| | | public void handleResult(final ExtendedResult result) { |
| | | writeMessage(new LDAPWrite<ExtendedResult>() { |
| | | @Override |
| | | public void perform(LDAPWriter<ASN1BufferWriter> writer, int messageID, |
| | | ExtendedResult message) throws IOException { |
| | | writer.writeExtendedResult(messageID, message); |
| | |
| | | @Override |
| | | public boolean handleEntry(final SearchResultEntry entry) { |
| | | writeMessage(new LDAPWrite<SearchResultEntry>() { |
| | | @Override |
| | | public void perform(LDAPWriter<ASN1BufferWriter> writer, int messageID, |
| | | SearchResultEntry sre) throws IOException { |
| | | writer.writeSearchResultEntry(messageID, sre); |
| | |
| | | @Override |
| | | public boolean handleReference(final SearchResultReference reference) { |
| | | writeMessage(new LDAPWrite<SearchResultReference>() { |
| | | @Override |
| | | public void perform(LDAPWriter<ASN1BufferWriter> writer, int messageID, |
| | | SearchResultReference ref) throws IOException { |
| | | writer.writeSearchResultReference(messageID, ref); |
| | |
| | | writer.writeSearchResult(messageID, result); |
| | | } |
| | | } |
| | | |
| | | // Map of cipher phrases to effective key size (bits). Taken from the |
| | | // following RFCs: 5289, 4346, 3268,4132 and 4162. |
| | | // @formatter:off |
| | | |
| | | /** |
| | | * Map of cipher phrases to effective key size (bits). Taken from the |
| | | * following RFCs: 5289, 4346, 3268,4132 and 4162. |
| | | */ |
| | | private static final Object[][] CIPHER_KEY_SIZES = { |
| | | { "_WITH_AES_256_CBC_", 256 }, |
| | | { "_WITH_CAMELLIA_256_CBC_", 256 }, |
| | |
| | | { "_WITH_DES40_CBC_", 40 }, |
| | | { "_WITH_NULL_", 0 }, |
| | | }; |
| | | // @formatter:on |
| | | |
| | | // Default maximum request size for incoming requests. |
| | | // @formatter:on |
| | | /** |
| | | * Default maximum request size for incoming requests. |
| | | */ |
| | | private static final int DEFAULT_MAX_REQUEST_SIZE = 5 * 1024 * 1024; |
| | | |
| | | private static final Attribute<ClientContextImpl> LDAP_CONNECTION_ATTR = |
| | |
| | | * |
| | | * @return the reader to read incoming LDAP messages |
| | | */ |
| | | @Override |
| | | public LDAPReader<ASN1BufferReader> getReader() { |
| | | return reader; |
| | | } |
| | |
| | | */ |
| | | @SuppressWarnings({ "javadoc", "unchecked" }) |
| | | public class GrizzlyLDAPConnectionFactoryTestCase extends SdkTestCase { |
| | | /* |
| | | /** |
| | | * The number of test iterations for unit tests which attempt to expose |
| | | * potential race conditions. Manual testing has gone up to 10000 |
| | | * iterations. |
| | | */ |
| | | private static final int ITERATIONS = 100; |
| | | |
| | | // Test timeout for tests which need to wait for network events. |
| | | /** Test timeout for tests which need to wait for network events. */ |
| | | private static final long TEST_TIMEOUT = 30L; |
| | | |
| | | /* |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAbandon(final Integer requestContext, final AbandonRequest request) |
| | | throws UnsupportedOperationException { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAdd(final Integer requestContext, final AddRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer requestContext, final int version, |
| | | final BindRequest request, |
| | |
| | | resultHandler.handleResult(Responses.newBindResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleCompare(final Integer requestContext, final CompareRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newCompareResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionClosed(final Integer requestContext, final UnbindRequest request) { |
| | | isClosed.countDown(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionDisconnected(final ResultCode resultCode, final String message) { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionError(final Throwable error) { |
| | | connectionError.handleResult(error); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleDelete(final Integer requestContext, final DeleteRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> void handleExtendedRequest(final Integer requestContext, |
| | | final ExtendedRequest<R> request, |
| | |
| | | "Extended operation " + request.getOID() + " not supported"))); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModify(final Integer requestContext, final ModifyRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModifyDN(final Integer requestContext, final ModifyDNRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleSearch(final Integer requestContext, final SearchRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler, |
| | |
| | | this.serverConnection = serverConnection; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ServerConnection<Integer> handleAccept(final LDAPClientContext clientContext) throws LdapException { |
| | | serverConnection.context.handleResult(clientContext); |
| | |
| | | |
| | | final MockServerConnection proxyServerConnection = new MockServerConnection() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer requestContext, final int version, |
| | | final BindRequest request, |
| | |
| | | try { |
| | | final MockServerConnection proxyServerConnection = new MockServerConnection() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer requestContext, final int version, |
| | | final BindRequest request, |
| | |
| | | * Demonstrates accessing server information about capabilities and schema. |
| | | */ |
| | | public final class GetInfo { |
| | | // Connection information |
| | | /** Connection information. */ |
| | | private static String host; |
| | | private static int port; |
| | | // The kind of server information to request (all, controls, extops) |
| | | /** The kind of server information to request (all, controls, extops). */ |
| | | private static String infoType; |
| | | |
| | | /** |
| | |
| | | connectionFactoryProvider = new ConnectionFactoryProvider(argParser, app); |
| | | } |
| | | |
| | | /** Issue OPENDJ-734. */ |
| | | @Test |
| | | /** Issue OPENDJ-734 */ |
| | | public void getConnectionFactoryShouldAllowNullTrustStorePassword() throws Exception { |
| | | // provide a trustStorePath but no password |
| | | String trustStorePath = new File(getClass().getClassLoader().getResource("dummy-truststore").toURI()) |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Simple integration tests to check the ldapsearch command |
| | | * Simple integration tests to check the ldapsearch command. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class LDAPSearchITCase extends ToolsITCase { |
| | |
| | | } |
| | | } |
| | | |
| | | /** Arguments passed to the command */ |
| | | /** Arguments passed to the command. */ |
| | | private String[] args(String...arguments) { |
| | | return arguments; |
| | | } |
| | |
| | | import static com.forgerock.opendj.cli.Utils.wrapText; |
| | | import static org.fest.assertions.Assertions.assertThat; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.TestCaseUtils; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | |
| | | /** |
| | | * Class used for the toolkit integration tests |
| | | * Class used for the toolkit integration tests. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public abstract class ToolsITCase extends ForgeRockTestCase { |
| | | |
| | | @BeforeClass |
| | |
| | | } |
| | | |
| | | /** |
| | | * Check both out and err outputs streams |
| | | * Check both out and err outputs streams. |
| | | * |
| | | * @param out |
| | | * output stream from the toolkit application |
| | |
| | | * String or LocalizedMessage expected on output |
| | | * @param expectedError |
| | | * String or LocalizedMessage expected on error output |
| | | * @throws UnsupportedEncodingException |
| | | * @throws Exception |
| | | */ |
| | | protected void checkOuputStreams(ByteStringBuilder out, ByteStringBuilder err, Object expectedOutput, |
| | | Object expectedError) throws Exception { |
| | |
| | | |
| | | } |
| | | |
| | | /** Arguments passed to the command */ |
| | | /** Arguments passed to the command. */ |
| | | protected String[] args(String... arguments) { |
| | | return arguments; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /* |
| | | /** |
| | | * Get a bind connection and then perform the bind operation, setting the |
| | | * cached connection and authorization credentials on completion. |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Rest2LDAPConnectionFactoryProvider() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | public static final String ATTRIBUTE_AUTHN_CONNECTION = |
| | | "org.forgerock.opendj.rest2ldap.authn-connection"; |
| | | |
| | | // Singleton instance. |
| | | /** Singleton instance. */ |
| | | private static final Rest2LDAPContextFactory INSTANCE = new Rest2LDAPContextFactory(); |
| | | |
| | | /** |
| | |
| | | throw new InternalServerErrorException(i18n("Cached LDAP connections cannot be restored")); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void saveToJson(final JsonValue savedContext, final PersistenceConfig config) |
| | | throws ResourceException { |
| | |
| | | */ |
| | | final class Context implements Closeable { |
| | | |
| | | /* |
| | | /** |
| | | * A cached read request - see cachedReads for more information. |
| | | */ |
| | | private static final class CachedRead implements SearchResultHandler, ResultHandler<Result> { |
| | |
| | | |
| | | } |
| | | |
| | | /* |
| | | /** |
| | | * An LRU cache of recent reads requests. This is used in order to reduce |
| | | * the number of repeated read operations performed when resolving DN |
| | | * references. |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() { |
| | | connection.close(); |
| | |
| | | } |
| | | } |
| | | |
| | | /* |
| | | /** |
| | | * Adds read caching support to the provided connection as well |
| | | * functionality which automatically adds the proxied authorization control |
| | | * if needed. |
| | |
| | | connection.removeConnectionEventListener(listener); |
| | | } |
| | | |
| | | /* |
| | | * Try and re-use a cached result if possible. |
| | | */ |
| | | /** Try and re-use a cached result if possible. */ |
| | | @Override |
| | | public LdapPromise<Result> searchAsync(final SearchRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler) { |
| | |
| | | }, h)); |
| | | } |
| | | |
| | | /* |
| | | /** |
| | | * Fail immediately if the JSON value has the wrong type or contains unknown |
| | | * attributes. |
| | | */ |
| | |
| | | * The type of result. |
| | | */ |
| | | private static final class AccumulatingResultHandler<V> implements ResultHandler<V> { |
| | | private ResourceException exception; // Guarded by latch. |
| | | /** Guarded by latch. */ |
| | | private ResourceException exception; |
| | | private final ResultHandler<List<V>> handler; |
| | | private final AtomicInteger latch; |
| | | private final List<V> results; |
| | |
| | | } |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Utils() { |
| | | // No implementation required. |
| | | } |
| | |
| | | assertThat(resource.getContent().get("_rev").asString()).isNull(); |
| | | } |
| | | |
| | | // Disabled - see CREST-86 (Should JSON resource fields be case insensitive?) |
| | | /** Disabled - see CREST-86 (Should JSON resource fields be case insensitive?) */ |
| | | @Test(enabled = false) |
| | | public void testReadSelectPartialInsensitive() throws Exception { |
| | | final Resource resource = |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(final ExamplePluginCfg config) { |
| | | // The new configuration has already been validated. |
| | |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(final ExamplePluginCfg config, |
| | | final List<LocalizableMessage> messages) { |
| | |
| | | public abstract class AbstractDataProvider implements DataProvider { |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(AbstractDataProvider.class); |
| | | |
| | | // The list of event listeners associated with this data provider. |
| | | /** The list of event listeners associated with this data provider. */ |
| | | private final List<DataProviderEventListener> eventListeners = |
| | | new CopyOnWriteArrayList<DataProviderEventListener>(); |
| | | |
| | |
| | | return getEntry(dn) != null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void deregisterEventListener(final DataProviderEventListener listener) { |
| | | eventListeners.remove(listener); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void registerEventListener(final DataProviderEventListener listener) { |
| | | eventListeners.add(listener); |
| | |
| | | SUPPORTED_FEATURES; |
| | | } |
| | | |
| | | // A message describing this event. |
| | | /** A message describing this event. */ |
| | | private final LocalizableMessage reason; |
| | | |
| | | // the types of event that have occurred in the data provider. |
| | | /** The types of event that have occurred in the data provider. */ |
| | | private final Set<Type> types; |
| | | |
| | | /** |
| | |
| | | return new DataProviderID(name, false /* user */); |
| | | } |
| | | |
| | | // Flag indicating whether or not this ID represents an internal |
| | | // data provider. |
| | | /** |
| | | * Flag indicating whether or not this ID represents an internal |
| | | * data provider. |
| | | */ |
| | | private final boolean isInternal; |
| | | |
| | | // The data provider name. |
| | | /** The data provider name. */ |
| | | private final String name; |
| | | |
| | | // The normalized name. |
| | | /** The normalized name. */ |
| | | private final String normalizedName; |
| | | |
| | | // Prevent direct instantiation. |
| | | /** Prevent direct instantiation. */ |
| | | private DataProviderID(final String name, final boolean isInternal) { |
| | | this.name = name; |
| | | this.normalizedName = name.trim().toLowerCase(Locale.ENGLISH); |
| | | this.isInternal = isInternal; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final DataProviderID o) { |
| | | if (isInternal != o.isInternal) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return normalizedName.hashCode(); |
| | |
| | | return isInternal; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | if (isInternal) { |
| | |
| | | */ |
| | | WRITE_INTERNAL_ONLY("write-internal-only"); |
| | | |
| | | // The human-readable name for this status. |
| | | /** The human-readable name for this status. */ |
| | | private String name; |
| | | |
| | | /** |
| | |
| | | private IntegerArgument connectTimeout; |
| | | private BooleanArgument acceptLicense; |
| | | |
| | | // Sub-commands |
| | | /** Sub-commands. */ |
| | | private SubCommand createDirectoryServer; |
| | | private SubCommand createProxy; |
| | | |
| | | // Register the global arguments. |
| | | /** Register the global arguments. */ |
| | | private BooleanArgument noPrompt; |
| | | private BooleanArgument quietMode; |
| | | private BooleanArgument verbose; |
| | |
| | | // Nothing to do. |
| | | } |
| | | |
| | | // To allow tests |
| | | /** To allow tests. */ |
| | | SetupCli(PrintStream out, PrintStream err) { |
| | | super(out, err); |
| | | } |
| | |
| | | * execution of the checking. |
| | | */ |
| | | private void checkProvidedPorts(final Collection<LocalizableMessage> errorMessages) { |
| | | /** |
| | | /* |
| | | * Check that the provided ports do not match. |
| | | */ |
| | | try { |
| | |
| | | /** Default port number for the replication port. */ |
| | | static final int DEFAULT_REPLICATION_PORT = 389; |
| | | |
| | | // First in topology |
| | | /** First in topology. */ |
| | | private int replicationPort; |
| | | private boolean isSecure; |
| | | |
| | | // Part of topology |
| | | /** Part of topology. */ |
| | | private String hostName; |
| | | private int hostPort; |
| | | private String administrator; |
| | |
| | | this.additionalArguments = additionalArguments; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean equals(Object o) { |
| | | if (o == this) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public int hashCode() { |
| | | int hashCode = 44 + initialMemory + maximumMemory; |
| | |
| | | return hashCode; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public String toString() { |
| | | final StringBuilder sb = new StringBuilder(); |
| | |
| | | import org.forgerock.testng.ForgeRockTestCase; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * This test class verifies that the product information has been generated |
| | | * and can be loaded at runtime. It does not attempt to exhaustively check |
| | | * all methods. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class ProductInformationTest extends ForgeRockTestCase { |
| | | /* |
| | | * This test class verifies that the product information has been generated |
| | | * and can be loaded at runtime. It does not attempt to exhaustively check |
| | | * all methods. |
| | | */ |
| | | |
| | | @Test |
| | | public void testProductName() { |
| | |
| | | assertThat(resultCode).isEqualTo(ReturnCode.SUCCESS.get()); |
| | | } else { |
| | | assertThat(resultCode).isNotEqualTo(ReturnCode.SUCCESS.get()); |
| | | /** |
| | | /* |
| | | * If an application is interactive, all messages should be redirect to the stdout. (info, warnings, |
| | | * errors). Otherwise, standard messages should be displayed in the stdout(info) and errors to the |
| | | * stderr (warnings, errors). |
| | |
| | | } |
| | | } |
| | | |
| | | /** Arguments passed to the command */ |
| | | /** Arguments passed to the command. */ |
| | | private String[] args(String... arguments) { |
| | | return arguments; |
| | | } |
| | |
| | | */ |
| | | public final class Converters { |
| | | |
| | | // Prevent instantiation. |
| | | /** Prevent instantiation. */ |
| | | private Converters() { |
| | | throw new AssertionError(); |
| | | } |