Move Message/MessageBuilder/LocalizableException/LocalizableIllegalArgumentException to public API since other public API elements reference them. Prefix Message/MessageBuilder with Localizable to emphasize that these classes are I18N related and not protocol messages. Keep MessageDescriptor private since users should not need access to it for now.
2 files deleted
2 files added
3 files renamed
178 files modified
| | |
| | | .compile(SPECIFIER_REGEX); |
| | | |
| | | /** |
| | | * Message giving formatting rules for string keys. |
| | | * LocalizableMessage giving formatting rules for string keys. |
| | | */ |
| | | static public String KEY_FORM_MSG; |
| | | |
| | |
| | | StringBuilder sb = new StringBuilder(); |
| | | if (useGenericMessageTypeClass()) |
| | | { |
| | | sb.append("MessageDescriptor"); |
| | | sb.append("LocalizableMessageDescriptor"); |
| | | sb.append("."); |
| | | sb.append(DESCRIPTOR_CLASS_BASE_NAME); |
| | | sb.append("N"); |
| | | } |
| | | else |
| | | { |
| | | sb.append("MessageDescriptor"); |
| | | sb.append("LocalizableMessageDescriptor"); |
| | | sb.append("."); |
| | | sb.append(DESCRIPTOR_CLASS_BASE_NAME); |
| | | sb.append(classTypes.size()); |
| | |
| | | } |
| | | } |
| | | |
| | | log(" Message Generated:" + keyMap.size(), |
| | | log(" LocalizableMessage Generated:" + keyMap.size(), |
| | | Project.MSG_VERBOSE); |
| | | log(" MessageDescriptor.ArgN:" + usesOfGenericDescriptor, |
| | | log(" LocalizableMessageDescriptor.ArgN:" + usesOfGenericDescriptor, |
| | | Project.MSG_VERBOSE); |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Gets the name of the MessageDescriptor as it should appear in the |
| | | * Gets the name of the LocalizableMessageDescriptor as it should appear in the |
| | | * messages file. |
| | | * |
| | | * @return name of message descriptor |
| | |
| | | |
| | | package ${PACKAGE}; |
| | | |
| | | import com.sun.opends.sdk.util.MessageDescriptor; |
| | | import com.sun.opends.sdk.util.LocalizableMessageDescriptor; |
| | | |
| | | /** |
| | | * This file contains a number of constants that are used throughout the |
| | |
| | | import java.util.Iterator; |
| | | import java.util.LinkedList; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | private Character shortIdentifier; |
| | | |
| | | // The unique ID of the description for this argument. |
| | | private Message description; |
| | | private LocalizableMessage description; |
| | | |
| | | // The set of values for this argument. |
| | | private LinkedList<String> values; |
| | |
| | | // The value placeholder for this argument, which will be used in |
| | | // usage |
| | | // information. |
| | | private Message valuePlaceholder; |
| | | private LocalizableMessage valuePlaceholder; |
| | | |
| | | // Indicates whether this argument was provided in the set of |
| | | // properties |
| | |
| | | * used to override the default value but will be overridden |
| | | * by a command-line argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | protected Argument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | boolean needsValue, Message valuePlaceholder, |
| | | String defaultValue, String propertyName, Message description) |
| | | boolean needsValue, LocalizableMessage valuePlaceholder, |
| | | String defaultValue, String propertyName, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | this.name = name; |
| | |
| | | |
| | | if ((shortIdentifier == null) && (longIdentifier == null)) |
| | | { |
| | | Message message = ERR_ARG_NO_IDENTIFIER.get(name); |
| | | LocalizableMessage message = ERR_ARG_NO_IDENTIFIER.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | | if (needsValue && (valuePlaceholder == null)) |
| | | { |
| | | Message message = ERR_ARG_NO_VALUE_PLACEHOLDER.get(name); |
| | | LocalizableMessage message = ERR_ARG_NO_VALUE_PLACEHOLDER.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | |
| | | * argument in the generated usage information, or |
| | | * <CODE>null</CODE> if there is none. |
| | | */ |
| | | public Message getValuePlaceholder() |
| | | public LocalizableMessage getValuePlaceholder() |
| | | { |
| | | return valuePlaceholder; |
| | | } |
| | |
| | | * The value placeholder that will be displayed for this |
| | | * argument in the generated usage information. |
| | | */ |
| | | public void setValuePlaceholder(Message valuePlaceholder) |
| | | public void setValuePlaceholder(LocalizableMessage valuePlaceholder) |
| | | { |
| | | this.valuePlaceholder = valuePlaceholder; |
| | | } |
| | |
| | | * |
| | | * @return The human-readable description for this argument. |
| | | */ |
| | | public Message getDescription() |
| | | public LocalizableMessage getDescription() |
| | | { |
| | | return description != null ? description : Message.EMPTY; |
| | | return description != null ? description : LocalizableMessage.EMPTY; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (values.isEmpty()) |
| | | { |
| | | Message message = ERR_ARG_NO_INT_VALUE.get(name); |
| | | LocalizableMessage message = ERR_ARG_NO_INT_VALUE.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name); |
| | | throw new ArgumentException(message, e); |
| | | } |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | Message message = ERR_ARG_INT_MULTIPLE_VALUES.get(name); |
| | | LocalizableMessage message = ERR_ARG_INT_MULTIPLE_VALUES.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | else |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name); |
| | | throw new ArgumentException(message, e); |
| | | } |
| | |
| | | { |
| | | if (values.isEmpty()) |
| | | { |
| | | Message message = ERR_ARG_NO_INT_VALUE.get(name); |
| | | LocalizableMessage message = ERR_ARG_NO_INT_VALUE.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name); |
| | | throw new ArgumentException(message, e); |
| | | } |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | Message message = ERR_ARG_INT_MULTIPLE_VALUES.get(name); |
| | | LocalizableMessage message = ERR_ARG_INT_MULTIPLE_VALUES.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | else |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name); |
| | | throw new ArgumentException(message, e); |
| | | } |
| | |
| | | { |
| | | if (values.isEmpty()) |
| | | { |
| | | Message message = ERR_ARG_NO_BOOLEAN_VALUE.get(name); |
| | | LocalizableMessage message = ERR_ARG_NO_BOOLEAN_VALUE.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_ARG_CANNOT_DECODE_AS_BOOLEAN.get(valueString, name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | Message message = ERR_ARG_BOOLEAN_MULTIPLE_VALUES.get(name); |
| | | LocalizableMessage message = ERR_ARG_BOOLEAN_MULTIPLE_VALUES.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | else |
| | |
| | | * <CODE>false</CODE> if it is not. |
| | | */ |
| | | public abstract boolean valueIsAcceptable(String valueString, |
| | | MessageBuilder invalidReason); |
| | | LocalizableMessageBuilder invalidReason); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import com.sun.opends.sdk.util.LocalizableException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | private static final long serialVersionUID = 5623155045312160730L; |
| | | |
| | | // The I18N message associated with this exception. |
| | | private final Message message; |
| | | private final LocalizableMessage message; |
| | | |
| | | |
| | | |
| | |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | */ |
| | | ArgumentException(Message message) |
| | | ArgumentException(LocalizableMessage message) |
| | | { |
| | | super(String.valueOf(message)); |
| | | this.message = message; |
| | |
| | | * @param cause |
| | | * The exception that was caught to trigger this exception. |
| | | */ |
| | | ArgumentException(Message message, Throwable cause) |
| | | ArgumentException(LocalizableMessage message, Throwable cause) |
| | | { |
| | | super(String.valueOf(message), cause); |
| | | this.message = message; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getMessageObject() |
| | | public LocalizableMessage getMessageObject() |
| | | { |
| | | return this.message; |
| | | } |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | |
| | | // Description for this group of arguments |
| | | private Message description = null; |
| | | private LocalizableMessage description = null; |
| | | |
| | | // List of arguments belonging to this group |
| | | private List<Argument> args = null; |
| | |
| | | * usage statement. Groups with higher priority values appear |
| | | * before groups with lower priority. |
| | | */ |
| | | ArgumentGroup(Message description, int priority) |
| | | ArgumentGroup(LocalizableMessage description, int priority) |
| | | { |
| | | this.description = description; |
| | | this.priority = priority; |
| | |
| | | * |
| | | * @return description for this argument group |
| | | */ |
| | | Message getDescription() |
| | | LocalizableMessage getDescription() |
| | | { |
| | | return this.description; |
| | | } |
| | |
| | | * @param description |
| | | * for this argument group |
| | | */ |
| | | void setDescription(Message description) |
| | | void setDescription(LocalizableMessage description) |
| | | { |
| | | this.description = description; |
| | | } |
| | |
| | | import java.io.OutputStream; |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | // A human-readable description for the tool, which will be included |
| | | // when |
| | | // displaying usage information. |
| | | private Message toolDescription; |
| | | private LocalizableMessage toolDescription; |
| | | |
| | | // The display name that will be used for the trailing arguments in |
| | | // the usage |
| | |
| | | * will appear at the top of the usage statement without a header. |
| | | */ |
| | | private ArgumentGroup defaultArgGroup = new ArgumentGroup( |
| | | Message.EMPTY, Integer.MAX_VALUE); |
| | | LocalizableMessage.EMPTY, Integer.MAX_VALUE); |
| | | |
| | | /** |
| | | * Group for arguments that are related to connection through LDAP. |
| | |
| | | * Indicates whether long arguments should be treated in a |
| | | * case-sensitive manner. |
| | | */ |
| | | ArgumentParser(String mainClassName, Message toolDescription, |
| | | ArgumentParser(String mainClassName, LocalizableMessage toolDescription, |
| | | boolean longArgumentsCaseSensitive) |
| | | { |
| | | this.mainClassName = mainClassName; |
| | |
| | | * unnamed trailing arguments in the generated usage |
| | | * information. |
| | | */ |
| | | ArgumentParser(String mainClassName, Message toolDescription, |
| | | ArgumentParser(String mainClassName, LocalizableMessage toolDescription, |
| | | boolean longArgumentsCaseSensitive, |
| | | boolean allowsTrailingArguments, int minTrailingArguments, |
| | | int maxTrailingArguments, String trailingArgsDisplayName) |
| | |
| | | * @return A human-readable description for this tool, or {@code null} |
| | | * if none is available. |
| | | */ |
| | | Message getToolDescription() |
| | | LocalizableMessage getToolDescription() |
| | | { |
| | | return toolDescription; |
| | | } |
| | |
| | | * @param description |
| | | * for the default group |
| | | */ |
| | | void setDefaultArgumentGroupDescription(Message description) |
| | | void setDefaultArgumentGroupDescription(LocalizableMessage description) |
| | | { |
| | | this.defaultArgGroup.setDescription(description); |
| | | } |
| | |
| | | * @param description |
| | | * for the LDAP group |
| | | */ |
| | | void setLdapArgumentGroupDescription(Message description) |
| | | void setLdapArgumentGroupDescription(LocalizableMessage description) |
| | | { |
| | | this.ldapArgGroup.setDescription(description); |
| | | } |
| | |
| | | * @param description |
| | | * for the input/output group |
| | | */ |
| | | void setInputOutputArgumentGroupDescription(Message description) |
| | | void setInputOutputArgumentGroupDescription(LocalizableMessage description) |
| | | { |
| | | this.ioArgGroup.setDescription(description); |
| | | } |
| | |
| | | * @param description |
| | | * for the general group |
| | | */ |
| | | void setGeneralArgumentGroupDescription(Message description) |
| | | void setGeneralArgumentGroupDescription(LocalizableMessage description) |
| | | { |
| | | this.generalArgGroup.setDescription(description); |
| | | } |
| | |
| | | { |
| | | String conflictingName = shortIDMap.get(shortID).getName(); |
| | | |
| | | Message message = ERR_ARGPARSER_DUPLICATE_SHORT_ID.get(argument |
| | | LocalizableMessage message = ERR_ARGPARSER_DUPLICATE_SHORT_ID.get(argument |
| | | .getName(), String.valueOf(shortID), conflictingName); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | { |
| | | String conflictingName = longIDMap.get(longID).getName(); |
| | | |
| | | Message message = ERR_ARGPARSER_DUPLICATE_LONG_ID.get(argument |
| | | LocalizableMessage message = ERR_ARGPARSER_DUPLICATE_LONG_ID.get(argument |
| | | .getName(), argument.getLongIdentifier(), conflictingName); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if (requirePropertiesFile) |
| | | { |
| | | Message message = ERR_ARGPARSER_CANNOT_READ_PROPERTIES_FILE |
| | | LocalizableMessage message = ERR_ARGPARSER_CANNOT_READ_PROPERTIES_FILE |
| | | .get(String.valueOf(propertiesFile), getExceptionMessage(e)); |
| | | throw new ArgumentException(message, e); |
| | | } |
| | |
| | | if ((maxTrailingArguments > 0) |
| | | && (trailingArguments.size() > maxTrailingArguments)) |
| | | { |
| | | Message message = ERR_ARGPARSER_TOO_MANY_TRAILING_ARGS |
| | | LocalizableMessage message = ERR_ARGPARSER_TOO_MANY_TRAILING_ARGS |
| | | .get(maxTrailingArguments); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | else if (equalPos == 0) |
| | | { |
| | | // The argument starts with "--=", which is not acceptable. |
| | | Message message = ERR_ARGPARSER_LONG_ARG_WITHOUT_NAME |
| | | LocalizableMessage message = ERR_ARGPARSER_LONG_ARG_WITHOUT_NAME |
| | | .get(arg); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | else |
| | | { |
| | | // There is no such argument registered. |
| | | Message message = ERR_ARGPARSER_NO_ARGUMENT_WITH_LONG_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_NO_ARGUMENT_WITH_LONG_ID |
| | | .get(origArgName); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if ((i + 1) == numArguments) |
| | | { |
| | | Message message = ERR_ARGPARSER_NO_VALUE_FOR_ARGUMENT_WITH_LONG_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_NO_VALUE_FOR_ARGUMENT_WITH_LONG_ID |
| | | .get(origArgName); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | argValue = rawArguments[++i]; |
| | | } |
| | | |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | if (!a.valueIsAcceptable(argValue, invalidReason)) |
| | | { |
| | | Message message = ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_LONG_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_LONG_ID |
| | | .get(argValue, origArgName, invalidReason.toString()); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | // acceptable to have more than one. |
| | | if (a.hasValue() && (!a.isMultiValued())) |
| | | { |
| | | Message message = ERR_ARGPARSER_NOT_MULTIVALUED_FOR_LONG_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_NOT_MULTIVALUED_FOR_LONG_ID |
| | | .get(origArgName); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if (argValue != null) |
| | | { |
| | | Message message = ERR_ARGPARSER_ARG_FOR_LONG_ID_DOESNT_TAKE_VALUE |
| | | LocalizableMessage message = ERR_ARGPARSER_ARG_FOR_LONG_ID_DOESNT_TAKE_VALUE |
| | | .get(origArgName); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | // -n value |
| | | if (arg.equals("-")) |
| | | { |
| | | Message message = ERR_ARGPARSER_INVALID_DASH_AS_ARGUMENT |
| | | LocalizableMessage message = ERR_ARGPARSER_INVALID_DASH_AS_ARGUMENT |
| | | .get(); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | else |
| | | { |
| | | // There is no such argument registered. |
| | | Message message = ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID |
| | | .get(String.valueOf(argCharacter)); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if ((i + 1) == numArguments) |
| | | { |
| | | Message message = ERR_ARGPARSER_NO_VALUE_FOR_ARGUMENT_WITH_SHORT_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_NO_VALUE_FOR_ARGUMENT_WITH_SHORT_ID |
| | | .get(String.valueOf(argCharacter)); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | argValue = rawArguments[++i]; |
| | | } |
| | | |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | if (!a.valueIsAcceptable(argValue, invalidReason)) |
| | | { |
| | | Message message = ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_SHORT_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_SHORT_ID |
| | | .get(argValue, String.valueOf(argCharacter), |
| | | invalidReason.toString()); |
| | | throw new ArgumentException(message); |
| | |
| | | // acceptable to have more than one. |
| | | if (a.hasValue() && (!a.isMultiValued())) |
| | | { |
| | | Message message = ERR_ARGPARSER_NOT_MULTIVALUED_FOR_SHORT_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_NOT_MULTIVALUED_FOR_SHORT_ID |
| | | .get(String.valueOf(argCharacter)); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | if (b == null) |
| | | { |
| | | // There is no such argument registered. |
| | | Message message = ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID |
| | | LocalizableMessage message = ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID |
| | | .get(String.valueOf(argCharacter)); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | // a |
| | | // valid argument that takes a value. We don't support |
| | | // that. |
| | | Message message = ERR_ARGPARSER_CANT_MIX_ARGS_WITH_VALUES |
| | | LocalizableMessage message = ERR_ARGPARSER_CANT_MIX_ARGS_WITH_VALUES |
| | | .get(String.valueOf(argCharacter), argValue, String |
| | | .valueOf(c)); |
| | | throw new ArgumentException(message); |
| | |
| | | // It doesn't start with a dash and we don't allow trailing |
| | | // arguments, |
| | | // so this is illegal. |
| | | Message message = ERR_ARGPARSER_DISALLOWED_TRAILING_ARGUMENT |
| | | LocalizableMessage message = ERR_ARGPARSER_DISALLOWED_TRAILING_ARGUMENT |
| | | .get(arg); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if (trailingArguments.size() < minTrailingArguments) |
| | | { |
| | | Message message = ERR_ARGPARSER_TOO_FEW_TRAILING_ARGUMENTS |
| | | LocalizableMessage message = ERR_ARGPARSER_TOO_FEW_TRAILING_ARGUMENTS |
| | | .get(minTrailingArguments); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | { |
| | | String value = argumentProperties.getProperty(a |
| | | .getPropertyName().toLowerCase()); |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | if (value != null) |
| | | { |
| | | Boolean addValue = true; |
| | |
| | | // a problem. |
| | | if ((!a.hasValue()) && a.isRequired()) |
| | | { |
| | | Message message = ERR_ARGPARSER_NO_VALUE_FOR_REQUIRED_ARG |
| | | LocalizableMessage message = ERR_ARGPARSER_NO_VALUE_FOR_REQUIRED_ARG |
| | | .get(a.getName()); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_ARGPARSER_CANNOT_READ_PROPERTIES_FILE.get( |
| | | LocalizableMessage message = ERR_ARGPARSER_CANNOT_READ_PROPERTIES_FILE.get( |
| | | String.valueOf(propertiesFilePath), getExceptionMessage(e)); |
| | | throw new ArgumentException(message, e); |
| | | } |
| | |
| | | if (argGroup.containsArguments() && printHeaders) |
| | | { |
| | | // Print the groups description if any |
| | | Message groupDesc = argGroup.getDescription(); |
| | | if (groupDesc != null && !Message.EMPTY.equals(groupDesc)) |
| | | LocalizableMessage groupDesc = argGroup.getDescription(); |
| | | if (groupDesc != null && !LocalizableMessage.EMPTY.equals(groupDesc)) |
| | | { |
| | | buffer.append(EOL); |
| | | buffer.append(wrapText(groupDesc.toString(), MAX_LENGTH - 1)); |
| | |
| | | * @return A string containing usage information based on the defined |
| | | * arguments. |
| | | */ |
| | | Message getUsageMessage() |
| | | LocalizableMessage getUsageMessage() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | getUsage(buffer); |
| | | |
| | | // TODO: rework getUsage(OutputStream) to work with messages |
| | | // framework |
| | | return Message.raw(buffer.toString()); |
| | | return LocalizableMessage.raw(buffer.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | // indent the description five characters and try our best to wrap |
| | | // at or |
| | | // before column 79 so it will be friendly to 80-column displays. |
| | | Message description = a.getDescription(); |
| | | LocalizableMessage description = a.getDescription(); |
| | | int descMaxLength = MAX_LENGTH - indentLength - 1; |
| | | if (description.length() <= descMaxLength) |
| | | { |
| | |
| | | import org.opends.sdk.requests.Requests; |
| | | import org.opends.sdk.sasl.*; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.SSLUtils; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | |
| | | hostNameArg.setPropertyName(OPTION_LONG_HOST); |
| | | argumentParser.addLdapConnectionArgument(hostNameArg); |
| | | |
| | | Message portDescription = INFO_DESCRIPTION_PORT.get(); |
| | | LocalizableMessage portDescription = INFO_DESCRIPTION_PORT.get(); |
| | | if (alwaysSSL) |
| | | { |
| | | portDescription = INFO_DESCRIPTION_ADMIN_PORT.get(); |
| | |
| | | // Couldn't have at the same time bindPassword and bindPasswordFile |
| | | if (bindPasswordArg.isPresent() && bindPasswordFileArg.isPresent()) |
| | | { |
| | | Message message = ERR_TOOL_CONFLICTING_ARGS |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS |
| | | .get(bindPasswordArg.getLongIdentifier(), bindPasswordFileArg |
| | | .getLongIdentifier()); |
| | | throw new ArgumentException(message); |
| | |
| | | // trustStore related arg |
| | | if (trustAllArg.isPresent() && trustStorePathArg.isPresent()) |
| | | { |
| | | Message message = ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg |
| | | .getLongIdentifier(), trustStorePathArg.getLongIdentifier()); |
| | | throw new ArgumentException(message); |
| | | } |
| | | if (trustAllArg.isPresent() && trustStorePasswordArg.isPresent()) |
| | | { |
| | | Message message = ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg |
| | | .getLongIdentifier(), trustStorePasswordArg |
| | | .getLongIdentifier()); |
| | | throw new ArgumentException(message); |
| | |
| | | if (trustAllArg.isPresent() |
| | | && trustStorePasswordFileArg.isPresent()) |
| | | { |
| | | Message message = ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg |
| | | .getLongIdentifier(), trustStorePasswordFileArg |
| | | .getLongIdentifier()); |
| | | throw new ArgumentException(message); |
| | |
| | | if (trustStorePasswordArg.isPresent() |
| | | && trustStorePasswordFileArg.isPresent()) |
| | | { |
| | | Message message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | trustStorePasswordArg.getLongIdentifier(), |
| | | trustStorePasswordFileArg.getLongIdentifier()); |
| | | throw new ArgumentException(message); |
| | |
| | | String value = trustStorePathArg.getValue(); |
| | | if (!canRead(trustStorePathArg.getValue())) |
| | | { |
| | | Message message = ERR_CANNOT_READ_TRUSTSTORE.get(value); |
| | | LocalizableMessage message = ERR_CANNOT_READ_TRUSTSTORE.get(value); |
| | | throw new ArgumentException(message); |
| | | } |
| | | } |
| | |
| | | String value = keyStorePathArg.getValue(); |
| | | if (!canRead(trustStorePathArg.getValue())) |
| | | { |
| | | Message message = ERR_CANNOT_READ_KEYSTORE.get(value); |
| | | LocalizableMessage message = ERR_CANNOT_READ_KEYSTORE.get(value); |
| | | throw new ArgumentException(message); |
| | | } |
| | | } |
| | |
| | | // useSSLArg |
| | | if (useStartTLSArg.isPresent() && useSSLArg.isPresent()) |
| | | { |
| | | Message message = ERR_TOOL_CONFLICTING_ARGS.get(useStartTLSArg |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(useStartTLSArg |
| | | .getLongIdentifier(), useSSLArg.getLongIdentifier()); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | } |
| | | catch (CLIException e) |
| | | { |
| | | throw new ArgumentException(Message.raw("Error reading input: " |
| | | throw new ArgumentException(LocalizableMessage.raw("Error reading input: " |
| | | + e.toString())); |
| | | } |
| | | if (bindRequest != null) |
| | |
| | | } |
| | | catch (LoginException e) |
| | | { |
| | | Message message = ERR_LDAPAUTH_GSSAPI_LOCAL_AUTHENTICATION_FAILED |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_LOCAL_AUTHENTICATION_FAILED |
| | | .get(StaticUtils.getExceptionMessage(e)); |
| | | throw new ArgumentException(message, e); |
| | | } |
| | |
| | | { |
| | | if (sslContext == null) |
| | | { |
| | | Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get(); |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get(); |
| | | throw new ArgumentException(message); |
| | | } |
| | | if (!keyStorePathArg.isPresent() && getKeyStore() == null) |
| | | { |
| | | Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | throw new ArgumentException(message); |
| | | } |
| | | return new ExternalSASLBindRequest(getAuthzID()); |
| | |
| | | } |
| | | else if (app.isInteractive()) |
| | | { |
| | | value = app.readInput(Message.raw("Bind DN:"), bindDnArg |
| | | value = app.readInput(LocalizableMessage.raw("Bind DN:"), bindDnArg |
| | | .getDefaultValue() == null ? value : bindDnArg |
| | | .getDefaultValue()); |
| | | } |
| | |
| | | } |
| | | if (value == null && app.isInteractive()) |
| | | { |
| | | value = app.readInput(Message.raw("Authentication ID:"), |
| | | value = app.readInput(LocalizableMessage.raw("Authentication ID:"), |
| | | bindDnArg.getDefaultValue() == null ? null : "dn: " |
| | | + bindDnArg.getDefaultValue()); |
| | | } |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(mech); |
| | | LocalizableMessage message = ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(mech); |
| | | throw new ArgumentException(message); |
| | | } |
| | | return value; |
| | |
| | | } |
| | | if (value.length() == 0 && app.isInteractive()) |
| | | { |
| | | value = app.readLineOfInput(Message.raw("Bind Password:")); |
| | | value = app.readLineOfInput(LocalizableMessage.raw("Bind Password:")); |
| | | } |
| | | |
| | | return ByteString.valueOf(value); |
| | |
| | | int equalPos = option.indexOf('='); |
| | | if (equalPos <= 0) |
| | | { |
| | | Message message = ERR_LDAP_CONN_CANNOT_PARSE_SASL_OPTION |
| | | LocalizableMessage message = ERR_LDAP_CONN_CANNOT_PARSE_SASL_OPTION |
| | | .get(option); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | |
| | | import static com.sun.opends.sdk.messages.Messages.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * The long identifier for this argument, or |
| | | * <CODE>null</CODE> if there is none. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public BooleanArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, Message description) |
| | | String longIdentifier, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, false, false, false, |
| | |
| | | * <CODE>false</CODE> if it is not. |
| | | */ |
| | | public boolean valueIsAcceptable(String valueString, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // This argument type should never have a value, so any value |
| | | // provided will |
| | |
| | | |
| | | |
| | | |
| | | import org.opends.sdk.LocalizableException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.messages.Messages; |
| | | import com.sun.opends.sdk.util.LocalizableException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | * @param message |
| | | * The message explaining the problem that occurred. |
| | | */ |
| | | CLIException(Message message) |
| | | CLIException(LocalizableMessage message) |
| | | { |
| | | super(message.toString()); |
| | | this.message = message; |
| | |
| | | * @param cause |
| | | * The cause of this exception. |
| | | */ |
| | | CLIException(Message message, Throwable cause) |
| | | CLIException(LocalizableMessage message, Throwable cause) |
| | | { |
| | | super(message.toString(), cause); |
| | | this.message = message; |
| | |
| | | |
| | | |
| | | |
| | | private final Message message; |
| | | private final LocalizableMessage message; |
| | | |
| | | |
| | | |
| | | public Message getMessageObject() |
| | | public LocalizableMessage getMessageObject() |
| | | { |
| | | return message; |
| | | } |
| | |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | final void pressReturnToContinue() |
| | | { |
| | | Message msg = INFO_MENU_PROMPT_RETURN_TO_CONTINUE.get(); |
| | | LocalizableMessage msg = INFO_MENU_PROMPT_RETURN_TO_CONTINUE.get(); |
| | | try |
| | | { |
| | | readLineOfInput(msg); |
| | |
| | | * @param msg |
| | | * The message. |
| | | */ |
| | | final void println(Message msg) |
| | | final void println(LocalizableMessage msg) |
| | | { |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | } |
| | |
| | | * @param msg |
| | | * The message. |
| | | */ |
| | | final void print(Message msg) |
| | | final void print(LocalizableMessage msg) |
| | | { |
| | | err.print(wrapText(msg, MAX_LINE_WIDTH)); |
| | | } |
| | |
| | | * @param msg |
| | | * The message. |
| | | */ |
| | | final void printProgress(Message msg) |
| | | final void printProgress(LocalizableMessage msg) |
| | | { |
| | | if (!isQuiet()) |
| | | { |
| | |
| | | * @param indent |
| | | * The number of columns to indent. |
| | | */ |
| | | final void println(Message msg, int indent) |
| | | final void println(LocalizableMessage msg, int indent) |
| | | { |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH, indent)); |
| | | } |
| | |
| | | * @param msg |
| | | * The verbose message. |
| | | */ |
| | | final void printVerboseMessage(Message msg) |
| | | final void printVerboseMessage(LocalizableMessage msg) |
| | | { |
| | | if (isVerbose() || isInteractive()) |
| | | { |
| | |
| | | * If the line of input could not be retrieved for some |
| | | * reason. |
| | | */ |
| | | final String readLineOfInput(Message prompt) throws CLIException |
| | | final String readLineOfInput(LocalizableMessage prompt) throws CLIException |
| | | { |
| | | if (prompt != null) |
| | | { |
| | |
| | | * reason. |
| | | * @return The string value read from the user. |
| | | */ |
| | | final String readInput(Message prompt, String defaultValue) |
| | | final String readInput(LocalizableMessage prompt, String defaultValue) |
| | | throws CLIException |
| | | { |
| | | while (true) |
| | |
| | | * the Logger to be used to log the error message. |
| | | * @return The string value read from the user. |
| | | */ |
| | | final String readInput(Message prompt, String defaultValue, |
| | | final String readInput(LocalizableMessage prompt, String defaultValue, |
| | | Logger logger) |
| | | { |
| | | String s = defaultValue; |
| | |
| | | import java.io.FileReader; |
| | | import java.util.LinkedHashMap; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * displayed in usage information, or <CODE>null</CODE> if |
| | | * this argument does not require a value. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public FileBasedArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, |
| | | Message valuePlaceholder, Message description) |
| | | LocalizableMessage valuePlaceholder, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, false, |
| | |
| | | * used to override the default value but will be overridden |
| | | * by a command-line argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public FileBasedArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | Message valuePlaceholder, String defaultValue, |
| | | String propertyName, Message description) |
| | | LocalizableMessage valuePlaceholder, String defaultValue, |
| | | String propertyName, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, |
| | |
| | | * <CODE>false</CODE> if it is not. |
| | | */ |
| | | public boolean valueIsAcceptable(String valueString, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // First, make sure that the specified file exists. |
| | | File valueFile; |
| | |
| | | |
| | | import static com.sun.opends.sdk.messages.Messages.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * displayed in usage information, or <CODE>null</CODE> if |
| | | * this argument does not require a value. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public IntegerArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean needsValue, |
| | | Message valuePlaceholder, Message description) |
| | | LocalizableMessage valuePlaceholder, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, false, |
| | |
| | | * The upper bound that should be enforced for values of this |
| | | * argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public IntegerArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean needsValue, |
| | | Message valuePlaceholder, boolean hasLowerBound, |
| | | LocalizableMessage valuePlaceholder, boolean hasLowerBound, |
| | | double lowerBound, boolean hasUpperBound, double upperBound, |
| | | Message description) throws ArgumentException |
| | | LocalizableMessage description) throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, false, |
| | | needsValue, valuePlaceholder, null, null, description); |
| | |
| | | |
| | | if (hasLowerBound && hasUpperBound && (lowerBound > upperBound)) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_INTARG_LOWER_BOUND_ABOVE_UPPER_BOUND.get(name, |
| | | lowerBound, upperBound); |
| | | throw new ArgumentException(message); |
| | |
| | | * used to override the default value but will be overridden |
| | | * by a command-line argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public IntegerArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | boolean needsValue, Message valuePlaceholder, int defaultValue, |
| | | String propertyName, Message description) |
| | | boolean needsValue, LocalizableMessage valuePlaceholder, int defaultValue, |
| | | String propertyName, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, |
| | |
| | | * used to override the default value but will be overridden |
| | | * by a command-line argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public IntegerArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | boolean needsValue, Message valuePlaceholder, |
| | | double defaultValue, String propertyName, Message description) |
| | | boolean needsValue, LocalizableMessage valuePlaceholder, |
| | | double defaultValue, String propertyName, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, |
| | |
| | | * The upper bound that should be enforced for values of this |
| | | * argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public IntegerArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | boolean needsValue, Message valuePlaceholder, int defaultValue, |
| | | boolean needsValue, LocalizableMessage valuePlaceholder, int defaultValue, |
| | | String propertyName, boolean hasLowerBound, double lowerBound, |
| | | boolean hasUpperBound, double upperBound, Message description) |
| | | boolean hasUpperBound, double upperBound, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, |
| | |
| | | |
| | | if (hasLowerBound && hasUpperBound && (lowerBound > upperBound)) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_INTARG_LOWER_BOUND_ABOVE_UPPER_BOUND.get(name, |
| | | lowerBound, upperBound); |
| | | throw new ArgumentException(message); |
| | |
| | | * The upper bound that should be enforced for values of this |
| | | * argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public IntegerArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | boolean needsValue, Message valuePlaceholder, |
| | | boolean needsValue, LocalizableMessage valuePlaceholder, |
| | | double defaultValue, String propertyName, boolean hasLowerBound, |
| | | double lowerBound, boolean hasUpperBound, double upperBound, |
| | | Message description) throws ArgumentException |
| | | LocalizableMessage description) throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, |
| | | isMultiValued, needsValue, valuePlaceholder, String |
| | |
| | | |
| | | if (hasLowerBound && hasUpperBound && (lowerBound > upperBound)) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_INTARG_LOWER_BOUND_ABOVE_UPPER_BOUND.get(name, |
| | | lowerBound, upperBound); |
| | | throw new ArgumentException(message); |
| | |
| | | * <CODE>false</CODE> if it is not. |
| | | */ |
| | | public boolean valueIsAcceptable(String valueString, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // First, the value must be decodable as an integer. |
| | | double intValue; |
| | |
| | | import org.opends.sdk.responses.Result; |
| | | |
| | | import com.sun.opends.sdk.util.Base64; |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | Message toolDescription = INFO_LDAPCOMPARE_TOOL_DESCRIPTION.get(); |
| | | LocalizableMessage toolDescription = INFO_LDAPCOMPARE_TOOL_DESCRIPTION.get(); |
| | | ArgumentParser argParser = |
| | | new ArgumentParser(LDAPCompare.class.getName(), |
| | | toolDescription, false, true, 1, 0, |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | println(argParser.getUsageMessage()); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | |
| | | if (attrAndDNStrings.isEmpty()) |
| | | { |
| | | Message message = ERR_LDAPCOMPARE_NO_ATTR.get(); |
| | | LocalizableMessage message = ERR_LDAPCOMPARE_NO_ATTR.get(); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | int idx = attributeString.indexOf(":"); |
| | | if (idx == -1) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_LDAPCOMPARE_INVALID_ATTR_STRING.get(attributeString); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (DecodeException de) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString); |
| | | println(message); |
| | | ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (LocalizedIllegalArgumentException le) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (ErrorResultException ere) |
| | | { |
| | | println(Message.raw(ere.getMessage())); |
| | | println(LocalizableMessage.raw(ere.getMessage())); |
| | | return ere.getResult().getResultCode().intValue(); |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (ErrorResultException ere) |
| | | { |
| | | Message msg = INFO_OPERATION_FAILED.get("COMPARE"); |
| | | LocalizableMessage msg = INFO_OPERATION_FAILED.get("COMPARE"); |
| | | println(msg); |
| | | Result r = ere.getResult(); |
| | | println(ERR_TOOL_RESULT_CODE.get(r.getResultCode().intValue(), |
| | |
| | | if ((r.getDiagnosticMessage() != null) |
| | | && (r.getDiagnosticMessage().length() > 0)) |
| | | { |
| | | println(Message.raw(r.getDiagnosticMessage())); |
| | | println(LocalizableMessage.raw(r.getDiagnosticMessage())); |
| | | } |
| | | if (r.getMatchedDN() != null && r.getMatchedDN().length() > 0) |
| | | { |
| | |
| | | import org.opends.sdk.responses.Responses; |
| | | import org.opends.sdk.responses.Result; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | Message toolDescription = INFO_LDAPMODIFY_TOOL_DESCRIPTION.get(); |
| | | LocalizableMessage toolDescription = INFO_LDAPMODIFY_TOOL_DESCRIPTION.get(); |
| | | ArgumentParser argParser = new ArgumentParser(LDAPModify.class |
| | | .getName(), toolDescription, false); |
| | | ArgumentParserConnectionFactory connectionFactory; |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | println(argParser.getUsageMessage()); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (DecodeException de) |
| | | { |
| | | Message message = ERR_TOOL_INVALID_CONTROL_STRING |
| | | LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING |
| | | .get(ctrlString); |
| | | println(message); |
| | | ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (LocalizedIllegalArgumentException le) |
| | | { |
| | | Message message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(le |
| | | LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(le |
| | | .getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ.get( |
| | | LocalizableMessage message = ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ.get( |
| | | filename.getValue(), e.getLocalizedMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | Message message = ERR_LDIF_FILE_READ_ERROR.get(filename |
| | | LocalizableMessage message = ERR_LDIF_FILE_READ_ERROR.get(filename |
| | | .getValue(), ioe.getLocalizedMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue(); |
| | |
| | | if (r.getResultCode() != ResultCode.SUCCESS |
| | | && r.getResultCode() != ResultCode.REFERRAL) |
| | | { |
| | | Message msg = INFO_OPERATION_FAILED.get(operationType); |
| | | LocalizableMessage msg = INFO_OPERATION_FAILED.get(operationType); |
| | | println(msg); |
| | | println(ERR_TOOL_RESULT_CODE.get(r.getResultCode().intValue(), |
| | | r.getResultCode().toString())); |
| | | if ((r.getDiagnosticMessage() != null) |
| | | && (r.getDiagnosticMessage().length() > 0)) |
| | | { |
| | | println(Message.raw(r.getDiagnosticMessage())); |
| | | println(LocalizableMessage.raw(r.getDiagnosticMessage())); |
| | | } |
| | | if (r.getMatchedDN() != null && r.getMatchedDN().length() > 0) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | Message msg = INFO_OPERATION_SUCCESSFUL |
| | | LocalizableMessage msg = INFO_OPERATION_SUCCESSFUL |
| | | .get(operationType, name); |
| | | println(msg); |
| | | if ((r.getDiagnosticMessage() != null) |
| | | && (r.getDiagnosticMessage().length() > 0)) |
| | | { |
| | | println(Message.raw(r.getDiagnosticMessage())); |
| | | println(LocalizableMessage.raw(r.getDiagnosticMessage())); |
| | | } |
| | | if (r.getReferralURIs() != null) |
| | | { |
| | | for (String uri : r.getReferralURIs()) |
| | | { |
| | | println(Message.raw(uri)); |
| | | println(LocalizableMessage.raw(uri)); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.opends.sdk.extensions.PasswordModifyRequest; |
| | | import org.opends.sdk.extensions.PasswordModifyResult; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | Message toolDescription = INFO_LDAPPWMOD_TOOL_DESCRIPTION.get(); |
| | | LocalizableMessage toolDescription = INFO_LDAPPWMOD_TOOL_DESCRIPTION.get(); |
| | | ArgumentParser argParser = |
| | | new ArgumentParser(LDAPPasswordModify.class.getName(), toolDescription, |
| | | false); |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | println(argParser.getUsageMessage()); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (DecodeException de) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString); |
| | | println(message); |
| | | ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | |
| | | if (newPW.isPresent() && newPWFile.isPresent()) |
| | | { |
| | | Message message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | newPW.getLongIdentifier(), |
| | | newPWFile.getLongIdentifier()); |
| | | println(message); |
| | |
| | | |
| | | if (currentPW.isPresent() && currentPWFile.isPresent()) |
| | | { |
| | | Message message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | currentPW.getLongIdentifier(), |
| | | currentPWFile.getLongIdentifier()); |
| | | println(message); |
| | |
| | | } |
| | | catch (ErrorResultException e) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_LDAPPWMOD_FAILED.get(e.getResult().getResultCode().intValue(), |
| | | e.getResult().getResultCode().toString()); |
| | | println(message); |
| | |
| | | return e.getResult().getResultCode().intValue(); |
| | | } |
| | | |
| | | Message message = INFO_LDAPPWMOD_SUCCESSFUL.get(); |
| | | LocalizableMessage message = INFO_LDAPPWMOD_SUCCESSFUL.get(); |
| | | println(message); |
| | | |
| | | String additionalInfo = result.getDiagnosticMessage(); |
| | |
| | | import org.opends.sdk.responses.SearchResultEntry; |
| | | import org.opends.sdk.responses.SearchResultReference; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | if (dc.getSecondsBeforeExpiration() > 0) |
| | | { |
| | | int timeToExp = dc.getSecondsBeforeExpiration(); |
| | | Message timeToExpStr = Utils.secondsToTimeString(timeToExp); |
| | | LocalizableMessage timeToExpStr = Utils.secondsToTimeString(timeToExp); |
| | | |
| | | println(INFO_LDAPSEARCH_ACCTUSABLE_TIME_UNTIL_EXPIRATION |
| | | .get(timeToExpStr)); |
| | |
| | | if (dc.getSecondsBeforeUnlock() > 0) |
| | | { |
| | | int timeToUnlock = dc.getSecondsBeforeUnlock(); |
| | | Message timeToUnlockStr = Utils |
| | | LocalizableMessage timeToUnlockStr = Utils |
| | | .secondsToTimeString(timeToUnlock); |
| | | |
| | | println(INFO_LDAPSEARCH_ACCTUSABLE_TIME_UNTIL_UNLOCK |
| | |
| | | */ |
| | | public void handleReference(Void p, SearchResultReference reference) |
| | | { |
| | | println(Message.raw(reference.toString())); |
| | | println(LocalizableMessage.raw(reference.toString())); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | Message toolDescription = INFO_LDAPSEARCH_TOOL_DESCRIPTION.get(); |
| | | LocalizableMessage toolDescription = INFO_LDAPSEARCH_TOOL_DESCRIPTION.get(); |
| | | ArgumentParser argParser = new ArgumentParser(LDAPSearch.class |
| | | .getName(), toolDescription, false, true, 0, 0, |
| | | "[filter] [attributes ...]"); |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | println(argParser.getUsageMessage()); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | println(Message.raw(e.toString())); |
| | | println(LocalizableMessage.raw(e.toString())); |
| | | return ResultCode.CLIENT_SIDE_FILTER_ERROR.intValue(); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (DecodeException de) |
| | | { |
| | | Message message = ERR_TOOL_INVALID_CONTROL_STRING |
| | | LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING |
| | | .get(ctrlString); |
| | | println(message); |
| | | ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | String authzID = effectiveRightsUser.getValue(); |
| | | if (!authzID.startsWith("dn:")) |
| | | { |
| | | Message message = ERR_EFFECTIVERIGHTS_INVALID_AUTHZID |
| | | LocalizableMessage message = ERR_EFFECTIVERIGHTS_INVALID_AUTHZID |
| | | .get(authzID); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | |
| | | if (!tokenizer.hasMoreTokens()) |
| | | { |
| | | Message message = ERR_PSEARCH_MISSING_DESCRIPTOR.get(); |
| | | LocalizableMessage message = ERR_PSEARCH_MISSING_DESCRIPTOR.get(); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | String token = tokenizer.nextToken(); |
| | | if (!token.equals("ps")) |
| | | { |
| | | Message message = ERR_PSEARCH_DOESNT_START_WITH_PS.get(String |
| | | LocalizableMessage message = ERR_PSEARCH_DOESNT_START_WITH_PS.get(String |
| | | .valueOf(infoString)); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | else |
| | | { |
| | | Message message = ERR_PSEARCH_INVALID_CHANGE_TYPE |
| | | LocalizableMessage message = ERR_PSEARCH_INVALID_CHANGE_TYPE |
| | | .get(String.valueOf(token)); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | else |
| | | { |
| | | Message message = ERR_PSEARCH_INVALID_CHANGESONLY.get(String |
| | | LocalizableMessage message = ERR_PSEARCH_INVALID_CHANGESONLY.get(String |
| | | .valueOf(token)); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | else |
| | | { |
| | | Message message = ERR_PSEARCH_INVALID_RETURN_ECS.get(String |
| | | LocalizableMessage message = ERR_PSEARCH_INVALID_RETURN_ECS.get(String |
| | | .valueOf(token)); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (LocalizedIllegalArgumentException le) |
| | | { |
| | | Message message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(le |
| | | LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(le |
| | | .getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (LocalizedIllegalArgumentException le) |
| | | { |
| | | Message message = ERR_LDAP_MATCHEDVALUES_INVALID_FILTER |
| | | LocalizableMessage message = ERR_LDAP_MATCHEDVALUES_INVALID_FILTER |
| | | .get(le.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (DecodeException le) |
| | | { |
| | | Message message = ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(le |
| | | LocalizableMessage message = ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(le |
| | | .getMessageObject()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | { |
| | | if (!sortOrder.isPresent()) |
| | | { |
| | | Message message = ERR_LDAPSEARCH_VLV_REQUIRES_SORT.get( |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_REQUIRES_SORT.get( |
| | | vlvDescriptor.getLongIdentifier(), sortOrder |
| | | .getLongIdentifier()); |
| | | println(message); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Message message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | { |
| | | if (filters.size() > 1) |
| | | { |
| | | Message message = ERR_PAGED_RESULTS_REQUIRES_SINGLE_FILTER |
| | | LocalizableMessage message = ERR_PAGED_RESULTS_REQUIRES_SINGLE_FILTER |
| | | .get(); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | /* |
| | | * if(connectionOptions.useSASLExternal()) { |
| | | * if(!connectionOptions.useSSL() && |
| | | * !connectionOptions.useStartTLS()) { Message message = |
| | | * !connectionOptions.useStartTLS()) { LocalizableMessage message = |
| | | * ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get(); |
| | | * err.println(wrapText(message, MAX_LINE_WIDTH)); return |
| | | * CLIENT_SIDE_PARAM_ERROR; } if(keyStorePathValue == null) { |
| | | * Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | * LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | * err.println(wrapText(message, MAX_LINE_WIDTH)); return |
| | | * CLIENT_SIDE_PARAM_ERROR; } } |
| | | * connectionOptions.setVerbose(verbose.isPresent()); |
| | |
| | | ServerSideSortControl.Response dc = (ServerSideSortControl.Response) control; |
| | | if (dc.getSortResult() != SortResult.SUCCESS) |
| | | { |
| | | Message msg = WARN_LDAPSEARCH_SORT_ERROR.get(dc |
| | | LocalizableMessage msg = WARN_LDAPSEARCH_SORT_ERROR.get(dc |
| | | .getSortResult().toString()); |
| | | println(msg); |
| | | } |
| | |
| | | VLVControl.Response dc = (VLVControl.Response) control; |
| | | if (dc.getVLVResult() == VLVResult.SUCCESS) |
| | | { |
| | | Message msg = INFO_LDAPSEARCH_VLV_TARGET_OFFSET.get(dc |
| | | LocalizableMessage msg = INFO_LDAPSEARCH_VLV_TARGET_OFFSET.get(dc |
| | | .getTargetPosition()); |
| | | println(msg); |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | Message msg = WARN_LDAPSEARCH_VLV_ERROR.get(dc |
| | | LocalizableMessage msg = WARN_LDAPSEARCH_VLV_ERROR.get(dc |
| | | .getVLVResult().toString()); |
| | | println(msg); |
| | | } |
| | |
| | | if ((result.getDiagnosticMessage() != null) |
| | | && (result.getDiagnosticMessage().length() > 0)) |
| | | { |
| | | println(Message.raw(result.getDiagnosticMessage())); |
| | | println(LocalizableMessage.raw(result.getDiagnosticMessage())); |
| | | } |
| | | if (result.getMatchedDN() != null |
| | | && result.getMatchedDN().length() > 0) |
| | |
| | | } |
| | | if (countEntries.isPresent() && !isQuiet()) |
| | | { |
| | | Message message = INFO_LDAPSEARCH_MATCHING_ENTRY_COUNT |
| | | LocalizableMessage message = INFO_LDAPSEARCH_MATCHING_ENTRY_COUNT |
| | | .get(resultHandler.entryCount); |
| | | println(message); |
| | | println(); |
| | |
| | | import org.opends.sdk.requests.Requests; |
| | | import org.opends.sdk.responses.Result; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | Message toolDescription = |
| | | Message.raw("This utility can be used to " |
| | | LocalizableMessage toolDescription = |
| | | LocalizableMessage.raw("This utility can be used to " |
| | | + "measure modify performance"); |
| | | // TODO: correct usage |
| | | ArgumentParser argParser = |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | println(argParser.getUsageMessage()); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (Exception ex1) |
| | | { |
| | | println(Message.raw("Error formatting filter or base DN: " |
| | | println(LocalizableMessage.raw("Error formatting filter or base DN: " |
| | | + ex1.toString())); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | |
| | | import java.util.Collection; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * Indicates whether the set of allowed values should be |
| | | * treated in a case-sensitive manner. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public MultiChoiceArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean needsValue, |
| | | Message valuePlaceholder, Collection<T> allowedValues, |
| | | boolean caseSensitive, Message description) |
| | | LocalizableMessage valuePlaceholder, Collection<T> allowedValues, |
| | | boolean caseSensitive, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, false, |
| | |
| | | * Indicates whether the set of allowed values should be |
| | | * treated in a case-sensitive manner. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public MultiChoiceArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | boolean needsValue, Message valuePlaceholder, |
| | | boolean needsValue, LocalizableMessage valuePlaceholder, |
| | | String defaultValue, String propertyName, |
| | | Collection<T> allowedValues, boolean caseSensitive, |
| | | Message description) throws ArgumentException |
| | | LocalizableMessage description) throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, |
| | | isMultiValued, needsValue, valuePlaceholder, defaultValue, |
| | |
| | | * <CODE>false</CODE> if it is not. |
| | | */ |
| | | public boolean valueIsAcceptable(String valueString, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | for (T o : allowedValues) |
| | | { |
| | |
| | | import org.opends.sdk.AuthenticatedConnectionFactory.AuthenticatedAsynchronousConnection; |
| | | import org.opends.sdk.responses.Result; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | this.app = app; |
| | | numThreadsArgument = new IntegerArgument("numThreads", 't', |
| | | "numThreads", false, false, true, Message.raw("{numThreads}"), |
| | | 1, null, true, 1, false, 0, Message |
| | | "numThreads", false, false, true, LocalizableMessage.raw("{numThreads}"), |
| | | 1, null, true, 1, false, 0, LocalizableMessage |
| | | .raw("number of search threads per connection")); |
| | | numThreadsArgument.setPropertyName("numThreads"); |
| | | argParser.addArgument(numThreadsArgument); |
| | | |
| | | numConnectionsArgument = new IntegerArgument("numConnections", 'c', |
| | | "numConnections", false, false, true, Message |
| | | "numConnections", false, false, true, LocalizableMessage |
| | | .raw("{numConnections}"), 1, null, true, 1, false, 0, |
| | | Message.raw("number of connections")); |
| | | LocalizableMessage.raw("number of connections")); |
| | | numThreadsArgument.setPropertyName("numConnections"); |
| | | argParser.addArgument(numConnectionsArgument); |
| | | |
| | | maxIterationsArgument = new IntegerArgument("maxIterations", 'm', |
| | | "maxIterations", false, false, true, Message |
| | | .raw("{maxIterations}"), 0, null, Message |
| | | "maxIterations", false, false, true, LocalizableMessage |
| | | .raw("{maxIterations}"), 0, null, LocalizableMessage |
| | | .raw("max searches per thread, 0 for unlimited")); |
| | | numThreadsArgument.setPropertyName("maxIterations"); |
| | | argParser.addArgument(maxIterationsArgument); |
| | | |
| | | statsIntervalArgument = new IntegerArgument("statInterval", 'i', |
| | | "statInterval", false, false, true, Message |
| | | .raw("{statInterval}"), 5, null, true, 1, false, 0, Message |
| | | "statInterval", false, false, true, LocalizableMessage |
| | | .raw("{statInterval}"), 5, null, true, 1, false, 0, LocalizableMessage |
| | | .raw("Display results each specified number of seconds")); |
| | | numThreadsArgument.setPropertyName("statInterval"); |
| | | argParser.addArgument(statsIntervalArgument); |
| | | |
| | | targetThroughputArgument = new IntegerArgument("targetThroughput", |
| | | 'M', "targetThroughput", false, false, true, Message |
| | | .raw("{targetThroughput}"), 0, null, Message |
| | | 'M', "targetThroughput", false, false, true, LocalizableMessage |
| | | .raw("{targetThroughput}"), 0, null, LocalizableMessage |
| | | .raw("Target average throughput to achieve")); |
| | | targetThroughputArgument.setPropertyName("targetThroughput"); |
| | | argParser.addArgument(targetThroughputArgument); |
| | | |
| | | percentilesArgument = new IntegerArgument("percentile", 'e', |
| | | "percentile", false, true, Message.raw("{percentile}"), true, |
| | | 50, true, 100, Message.raw("Calculate max response time for a " |
| | | "percentile", false, true, LocalizableMessage.raw("{percentile}"), true, |
| | | 50, true, 100, LocalizableMessage.raw("Calculate max response time for a " |
| | | + "percentile of operations")); |
| | | percentilesArgument.setPropertyName("percentile"); |
| | | argParser.addArgument(percentilesArgument); |
| | | |
| | | keepConnectionsOpen = new BooleanArgument("keepConnectionsOpen", |
| | | 'f', "keepConnectionsOpen", Message |
| | | 'f', "keepConnectionsOpen", LocalizableMessage |
| | | .raw("keep connections open")); |
| | | keepConnectionsOpen.setPropertyName("keepConnectionsOpen"); |
| | | argParser.addArgument(keepConnectionsOpen); |
| | | |
| | | noRebindArgument = new BooleanArgument("noRebind", 'F', "noRebind", |
| | | Message.raw("keep connections open and don't rebind")); |
| | | LocalizableMessage.raw("keep connections open and don't rebind")); |
| | | keepConnectionsOpen.setPropertyName("noRebind"); |
| | | argParser.addArgument(noRebindArgument); |
| | | |
| | | asyncArgument = new BooleanArgument("asynchronous", 'A', |
| | | "asynchronous", Message.raw("asynch, don't wait for results")); |
| | | "asynchronous", LocalizableMessage.raw("asynch, don't wait for results")); |
| | | keepConnectionsOpen.setPropertyName("asynchronous"); |
| | | argParser.addArgument(asyncArgument); |
| | | |
| | |
| | | false, |
| | | true, |
| | | true, |
| | | Message.raw("{arguments}"), |
| | | LocalizableMessage.raw("{arguments}"), |
| | | null, |
| | | null, |
| | | Message |
| | | LocalizableMessage |
| | | .raw("arguments for variables in the filter and/or base DN")); |
| | | arguments.setPropertyName("arguments"); |
| | | argParser.addArgument(arguments); |
| | |
| | | |
| | | if (!noRebindArgument.isPresent() && this.numThreads > 1) |
| | | { |
| | | throw new ArgumentException(Message.raw("--" |
| | | throw new ArgumentException(LocalizableMessage.raw("--" |
| | | + noRebindArgument.getLongIdentifier() |
| | | + " must be used if --" |
| | | + numThreadsArgument.getLongIdentifier() + " is > 1")); |
| | |
| | | |
| | | if (!noRebindArgument.isPresent() && asyncArgument.isPresent()) |
| | | { |
| | | throw new ArgumentException(Message.raw("--" |
| | | throw new ArgumentException(LocalizableMessage.raw("--" |
| | | + noRebindArgument.getLongIdentifier() |
| | | + " must be used when using --" |
| | | + asyncArgument.getLongIdentifier())); |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | throw new ArgumentException(Message |
| | | throw new ArgumentException(LocalizableMessage |
| | | .raw("Error occured while parsing arguments: " |
| | | + ioe.toString())); |
| | | } |
| | |
| | | catch (ErrorResultException e) |
| | | { |
| | | stopRequested = true; |
| | | app.println(Message.raw(e.getResult().getDiagnosticMessage())); |
| | | app.println(LocalizableMessage.raw(e.getResult().getDiagnosticMessage())); |
| | | } |
| | | |
| | | return 0; |
| | |
| | | public void handleErrorResult(Void p, ErrorResultException error) |
| | | { |
| | | failedRecentCount.getAndIncrement(); |
| | | app.println(Message.raw(error.getResult().toString())); |
| | | app.println(LocalizableMessage.raw(error.getResult().toString())); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (ErrorResultException e) |
| | | { |
| | | app.println(Message.raw(e.getResult() |
| | | app.println(LocalizableMessage.raw(e.getResult() |
| | | .getDiagnosticMessage())); |
| | | if (e.getCause() != null && app.isVerbose()) |
| | | { |
| | |
| | | } |
| | | catch (ErrorResultException e) |
| | | { |
| | | app.println(Message.raw(e.getResult().toString())); |
| | | app.println(LocalizableMessage.raw(e.getResult().toString())); |
| | | if (e.getCause() != null && app.isVerbose()) |
| | | { |
| | | e.getCause().printStackTrace(app.getErrorStream()); |
| | |
| | | import javax.net.ssl.TrustManagerFactory; |
| | | import javax.net.ssl.X509TrustManager; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | private Integer choice; |
| | | |
| | | private Message msg; |
| | | private LocalizableMessage msg; |
| | | |
| | | |
| | | |
| | |
| | | * @param msg |
| | | * the message message. |
| | | */ |
| | | private TrustOption(int i, Message msg) |
| | | private TrustOption(int i, LocalizableMessage msg) |
| | | { |
| | | choice = i; |
| | | this.msg = msg; |
| | |
| | | * |
| | | * @return the menu message. |
| | | */ |
| | | Message getMenuMessage() |
| | | LocalizableMessage getMenuMessage() |
| | | { |
| | | return msg; |
| | | } |
| | |
| | | { |
| | | menuOptions.put(t.getChoice().toString(), t); |
| | | |
| | | MessageBuilder builder = new MessageBuilder(); |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | | builder.append(t.getChoice()); |
| | | builder.append(") "); |
| | | builder.append(t.getMenuMessage()); |
| | |
| | | } |
| | | |
| | | TrustOption defaultTrustMethod = TrustOption.SESSION; |
| | | Message promptMsg = INFO_MENU_PROMPT_SINGLE_DEFAULT |
| | | LocalizableMessage promptMsg = INFO_MENU_PROMPT_SINGLE_DEFAULT |
| | | .get(defaultTrustMethod.getChoice().toString()); |
| | | |
| | | while (true) |
| | |
| | | import org.opends.sdk.responses.SearchResultEntry; |
| | | import org.opends.sdk.responses.SearchResultReference; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | Message toolDescription = Message |
| | | LocalizableMessage toolDescription = LocalizableMessage |
| | | .raw("This utility can be used to " |
| | | + "measure search performance"); |
| | | // TODO: correct usage |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | println(message); |
| | | println(argParser.getUsageMessage()); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | |
| | | } |
| | | catch (Exception ex1) |
| | | { |
| | | println(Message.raw("Error formatting filter or base DN: " |
| | | println(LocalizableMessage.raw("Error formatting filter or base DN: " |
| | | + ex1.toString())); |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * displayed in usage information, or <CODE>null</CODE> if |
| | | * this argument does not require a value. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public StringArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean needsValue, |
| | | Message valuePlaceholder, Message description) |
| | | LocalizableMessage valuePlaceholder, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, false, |
| | |
| | | * used to override the default value but will be overridden |
| | | * by a command-line argument. |
| | | * @param description |
| | | * Message for the description of this argument. |
| | | * LocalizableMessage for the description of this argument. |
| | | * @throws ArgumentException |
| | | * If there is a problem with any of the parameters used to |
| | | * create this argument. |
| | | */ |
| | | public StringArgument(String name, Character shortIdentifier, |
| | | String longIdentifier, boolean isRequired, boolean isMultiValued, |
| | | boolean needsValue, Message valuePlaceholder, |
| | | String defaultValue, String propertyName, Message description) |
| | | boolean needsValue, LocalizableMessage valuePlaceholder, |
| | | String defaultValue, String propertyName, LocalizableMessage description) |
| | | throws ArgumentException |
| | | { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, |
| | |
| | | * <CODE>false</CODE> if it is not. |
| | | */ |
| | | public boolean valueIsAcceptable(String valueString, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for this argument. |
| | | return true; |
| | |
| | | import java.io.IOException; |
| | | import java.util.StringTokenizer; |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.Connection; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.ErrorResultException; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.AuthenticatedConnectionFactory.AuthenticatedConnection; |
| | | import org.opends.sdk.controls.*; |
| | | import org.opends.sdk.responses.BindResult; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | * there is a suitable breaking point. |
| | | * @return The wrapped text. |
| | | */ |
| | | static String wrapText(Message message, int width) |
| | | static String wrapText(LocalizableMessage message, int width) |
| | | { |
| | | return wrapText(Message.toString(message), width, 0); |
| | | return wrapText(message.toString(), width, 0); |
| | | } |
| | | |
| | | |
| | |
| | | * The number of columns to indent each line. |
| | | * @return The wrapped text. |
| | | */ |
| | | static String wrapText(Message message, int width, int indent) |
| | | static String wrapText(LocalizableMessage message, int width, int indent) |
| | | { |
| | | return wrapText(Message.toString(message), width, indent); |
| | | return wrapText(message.toString(), width, indent); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | // TODO: I18N |
| | | throw DecodeException.error(Message |
| | | throw DecodeException.error(LocalizableMessage |
| | | .raw("Invalid format for criticality value:" + remainder)); |
| | | } |
| | | return new GenericControl(controlOID, controlCriticality); |
| | |
| | | else |
| | | { |
| | | // TODO: I18N |
| | | throw DecodeException.error(Message |
| | | throw DecodeException.error(LocalizableMessage |
| | | .raw("Invalid format for criticality value:" + critical)); |
| | | } |
| | | |
| | |
| | | // if ((ere.getMessage() != null) && (ere.getMessage().length() > |
| | | // 0)) |
| | | // { |
| | | // app.println(Message.raw(ere.getMessage())); |
| | | // app.println(LocalizableMessage.raw(ere.getMessage())); |
| | | // } |
| | | |
| | | if (ere.getResult().getResultCode().intValue() >= 0) |
| | |
| | | * @return The user-friendly representation of the specified number of |
| | | * seconds. |
| | | */ |
| | | static Message secondsToTimeString(int numSeconds) |
| | | static LocalizableMessage secondsToTimeString(int numSeconds) |
| | | { |
| | | if (numSeconds < 60) |
| | | { |
| | |
| | | if (control != null) |
| | | { |
| | | AuthorizationIdentityControl.Response dc = (AuthorizationIdentityControl.Response) control; |
| | | Message message = INFO_BIND_AUTHZID_RETURNED.get(dc |
| | | LocalizableMessage message = INFO_BIND_AUTHZID_RETURNED.get(dc |
| | | .getAuthorizationID()); |
| | | app.println(message); |
| | | } |
| | |
| | | .getControl(PasswordExpiredControl.OID_NS_PASSWORD_EXPIRED); |
| | | if (control != null) |
| | | { |
| | | Message message = INFO_BIND_PASSWORD_EXPIRED.get(); |
| | | LocalizableMessage message = INFO_BIND_PASSWORD_EXPIRED.get(); |
| | | app.println(message); |
| | | } |
| | | control = result |
| | |
| | | if (control != null) |
| | | { |
| | | PasswordExpiringControl dc = (PasswordExpiringControl) control; |
| | | Message timeString = Utils.secondsToTimeString(dc |
| | | LocalizableMessage timeString = Utils.secondsToTimeString(dc |
| | | .getSecondsUntilExpiration()); |
| | | Message message = INFO_BIND_PASSWORD_EXPIRING.get(timeString); |
| | | LocalizableMessage message = INFO_BIND_PASSWORD_EXPIRING.get(timeString); |
| | | app.println(message); |
| | | } |
| | | control = result |
| | |
| | | PasswordPolicyErrorType errorType = dc.getErrorType(); |
| | | if (errorType == PasswordPolicyErrorType.PASSWORD_EXPIRED) |
| | | { |
| | | Message message = INFO_BIND_PASSWORD_EXPIRED.get(); |
| | | LocalizableMessage message = INFO_BIND_PASSWORD_EXPIRED.get(); |
| | | app.println(message); |
| | | } |
| | | else if (errorType == PasswordPolicyErrorType.ACCOUNT_LOCKED) |
| | | { |
| | | Message message = INFO_BIND_ACCOUNT_LOCKED.get(); |
| | | LocalizableMessage message = INFO_BIND_ACCOUNT_LOCKED.get(); |
| | | app.println(message); |
| | | } |
| | | else if (errorType == PasswordPolicyErrorType.CHANGE_AFTER_RESET) |
| | | { |
| | | |
| | | Message message = INFO_BIND_MUST_CHANGE_PASSWORD.get(); |
| | | LocalizableMessage message = INFO_BIND_MUST_CHANGE_PASSWORD.get(); |
| | | app.println(message); |
| | | } |
| | | |
| | | PasswordPolicyWarningType warningType = dc.getWarningType(); |
| | | if (warningType == PasswordPolicyWarningType.TIME_BEFORE_EXPIRATION) |
| | | { |
| | | Message timeString = Utils.secondsToTimeString(dc |
| | | LocalizableMessage timeString = Utils.secondsToTimeString(dc |
| | | .getWarningValue()); |
| | | Message message = INFO_BIND_PASSWORD_EXPIRING.get(timeString); |
| | | LocalizableMessage message = INFO_BIND_PASSWORD_EXPIRING.get(timeString); |
| | | app.println(message); |
| | | } |
| | | else if (warningType == PasswordPolicyWarningType.GRACE_LOGINS_REMAINING) |
| | | { |
| | | Message message = INFO_BIND_GRACE_LOGINS_REMAINING.get(dc |
| | | LocalizableMessage message = INFO_BIND_GRACE_LOGINS_REMAINING.get(dc |
| | | .getWarningValue()); |
| | | app.println(message); |
| | | } |
| | |
| | | import static com.sun.opends.sdk.messages.Messages.*; |
| | | import static com.sun.opends.sdk.util.Validator.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.*; |
| | | |
| | | |
| | | |
| | |
| | | int length = base64.length(); |
| | | if ((length % 4) != 0) |
| | | { |
| | | Message message = ERR_BASE64_DECODE_INVALID_LENGTH.get(base64); |
| | | LocalizableMessage message = ERR_BASE64_DECODE_INVALID_LENGTH.get(base64); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | } |
| | | break; |
| | | default: |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_BASE64_DECODE_INVALID_CHARACTER.get(base64, base64 |
| | | .charAt(i + j)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| File was renamed from sdk/src/com/sun/opends/sdk/util/MessageDescriptor.java |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.sun.opends.sdk.util; |
| | | |
| | | |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | | import java.util.ResourceBundle; |
| | | |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Base class for all Message descriptor classes. |
| | | * An opaque handle to a localizable message. |
| | | */ |
| | | public abstract class MessageDescriptor |
| | | public abstract class LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | | * ID for messages that don't have a real ID. |
| | | */ |
| | | public static final int NULL_ID = -1; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Subclass for creating messages with no arguments. |
| | | */ |
| | | static public final class Arg0 extends MessageDescriptor |
| | | public static final class Arg0 extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * away with this for the zero argument message because it is |
| | | * immutable. |
| | | */ |
| | | private Message message; |
| | | private final LocalizableMessage message; |
| | | |
| | | private boolean requiresFormat; |
| | | private final boolean requiresFormat; |
| | | |
| | | |
| | | |
| | |
| | | public Arg0(String rbBase, String key, ClassLoader classLoader) |
| | | { |
| | | super(rbBase, key, classLoader); |
| | | message = new Message(this); |
| | | message = newMessage(this); |
| | | requiresFormat = containsArgumentLiterals(getFormatString()); |
| | | } |
| | | |
| | |
| | | /** |
| | | * Creates a message. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | */ |
| | | public Message get() |
| | | public LocalizableMessage get() |
| | | { |
| | | return message; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return requiresFormat; |
| | | } |
| | |
| | | * @param <T1> |
| | | * The type of the first message argument. |
| | | */ |
| | | static public final class Arg1<T1> extends MessageDescriptor |
| | | public static final class Arg1<T1> extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1) |
| | | public LocalizableMessage get(T1 a1) |
| | | { |
| | | return new Message(this, a1); |
| | | return newMessage(this, a1); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T2> |
| | | * The type of the second message argument. |
| | | */ |
| | | static public final class Arg2<T1, T2> extends MessageDescriptor |
| | | public static final class Arg2<T1, T2> extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2) |
| | | public LocalizableMessage get(T1 a1, T2 a2) |
| | | { |
| | | return new Message(this, a1, a2); |
| | | return newMessage(this, a1, a2); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T3> |
| | | * The type of the third message argument. |
| | | */ |
| | | static public final class Arg3<T1, T2, T3> extends MessageDescriptor |
| | | public static final class Arg3<T1, T2, T3> extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | |
| | | * @param a3 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3) |
| | | public LocalizableMessage get(T1 a1, T2 a2, T3 a3) |
| | | { |
| | | return new Message(this, a1, a2, a3); |
| | | return newMessage(this, a1, a2, a3); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T4> |
| | | * The type of the fourth message argument. |
| | | */ |
| | | static public final class Arg4<T1, T2, T3, T4> extends |
| | | MessageDescriptor |
| | | public static final class Arg4<T1, T2, T3, T4> extends |
| | | LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | |
| | | * @param a4 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4) |
| | | public LocalizableMessage get(T1 a1, T2 a2, T3 a3, T4 a4) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4); |
| | | return newMessage(this, a1, a2, a3, a4); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T5> |
| | | * The type of the fifth message argument. |
| | | */ |
| | | static public final class Arg5<T1, T2, T3, T4, T5> extends |
| | | MessageDescriptor |
| | | public static final class Arg5<T1, T2, T3, T4, T5> extends |
| | | LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | |
| | | * @param a5 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
| | | public LocalizableMessage get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4, a5); |
| | | return newMessage(this, a1, a2, a3, a4, a5); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T6> |
| | | * The type of the sixth message argument. |
| | | */ |
| | | static public final class Arg6<T1, T2, T3, T4, T5, T6> extends |
| | | MessageDescriptor |
| | | public static final class Arg6<T1, T2, T3, T4, T5, T6> extends |
| | | LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | |
| | | * @param a6 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) |
| | | public LocalizableMessage get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4, a5, a6); |
| | | return newMessage(this, a1, a2, a3, a4, a5, a6); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T7> |
| | | * The type of the seventh message argument. |
| | | */ |
| | | static public final class Arg7<T1, T2, T3, T4, T5, T6, T7> extends |
| | | MessageDescriptor |
| | | public static final class Arg7<T1, T2, T3, T4, T5, T6, T7> extends |
| | | LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | |
| | | * @param a7 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) |
| | | public LocalizableMessage get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4, a5, a6, a7); |
| | | return newMessage(this, a1, a2, a3, a4, a5, a6, a7); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T8> |
| | | * The type of the eighth message argument. |
| | | */ |
| | | static public final class Arg8<T1, T2, T3, T4, T5, T6, T7, T8> |
| | | extends MessageDescriptor |
| | | public static final class Arg8<T1, T2, T3, T4, T5, T6, T7, T8> |
| | | extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | |
| | | * @param a8 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, |
| | | public LocalizableMessage get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, |
| | | T8 a8) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4, a5, a6, a7, a8); |
| | | return newMessage(this, a1, a2, a3, a4, a5, a6, a7, a8); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * @param <T9> |
| | | * The type of the ninth message argument. |
| | | */ |
| | | static public final class Arg9<T1, T2, T3, T4, T5, T6, T7, T8, T9> |
| | | extends MessageDescriptor |
| | | public static final class Arg9<T1, T2, T3, T4, T5, T6, T7, T8, T9> |
| | | extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | |
| | | * @param a9 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, |
| | | public LocalizableMessage get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, |
| | | T8 a8, T9 a9) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| | | return newMessage(this, a1, a2, a3, a4, a5, a6, a7, a8, a9); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Subclass for creating messages with ten arguments. |
| | | * |
| | | * @param <T1> |
| | | * The type of the first message argument. |
| | | * @param <T2> |
| | | * The type of the second message argument. |
| | | * @param <T3> |
| | | * The type of the third message argument. |
| | | * @param <T4> |
| | | * The type of the fourth message argument. |
| | | * @param <T5> |
| | | * The type of the fifth message argument. |
| | | * @param <T6> |
| | | * The type of the sixth message argument. |
| | | * @param <T7> |
| | | * The type of the seventh message argument. |
| | | * @param <T8> |
| | | * The type of the eighth message argument. |
| | | * @param <T9> |
| | | * The type of the ninth message argument. |
| | | * @param <T10> |
| | | * The type of the tenth message argument. |
| | | */ |
| | | static public final class Arg10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> |
| | | extends MessageDescriptor |
| | | { |
| | | |
| | | /** |
| | | * Creates a parameterized instance. |
| | | * |
| | | * @param rbBase |
| | | * base of the backing resource bundle |
| | | * @param key |
| | | * for accessing the format string from the resource bundle |
| | | * @param classLoader |
| | | * the class loader to be used to get the ResourceBundle |
| | | */ |
| | | public Arg10(String rbBase, String key, ClassLoader classLoader) |
| | | { |
| | | super(rbBase, key, classLoader); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a message with arguments that will replace format |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | | * message argument |
| | | * @param a3 |
| | | * message argument |
| | | * @param a4 |
| | | * message argument |
| | | * @param a5 |
| | | * message argument |
| | | * @param a6 |
| | | * message argument |
| | | * @param a7 |
| | | * message argument |
| | | * @param a8 |
| | | * message argument |
| | | * @param a9 |
| | | * message argument |
| | | * @param a10 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, |
| | | T8 a8, T9 a9, T10 a10) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Subclass for creating messages with eleven arguments. |
| | | * |
| | | * @param <T1> |
| | | * The type of the first message argument. |
| | | * @param <T2> |
| | | * The type of the second message argument. |
| | | * @param <T3> |
| | | * The type of the third message argument. |
| | | * @param <T4> |
| | | * The type of the fourth message argument. |
| | | * @param <T5> |
| | | * The type of the fifth message argument. |
| | | * @param <T6> |
| | | * The type of the sixth message argument. |
| | | * @param <T7> |
| | | * The type of the seventh message argument. |
| | | * @param <T8> |
| | | * The type of the eighth message argument. |
| | | * @param <T9> |
| | | * The type of the ninth message argument. |
| | | * @param <T10> |
| | | * The type of the tenth message argument. |
| | | * @param <T11> |
| | | * The type of the eleventh message argument. |
| | | */ |
| | | static public final class Arg11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> |
| | | extends MessageDescriptor |
| | | { |
| | | |
| | | /** |
| | | * Creates a parameterized instance. |
| | | * |
| | | * @param rbBase |
| | | * base of the backing resource bundle |
| | | * @param key |
| | | * for accessing the format string from the resource bundle |
| | | * @param classLoader |
| | | * the class loader to be used to get the ResourceBundle |
| | | */ |
| | | public Arg11(String rbBase, String key, ClassLoader classLoader) |
| | | { |
| | | super(rbBase, key, classLoader); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a message with arguments that will replace format |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @param a1 |
| | | * message argument |
| | | * @param a2 |
| | | * message argument |
| | | * @param a3 |
| | | * message argument |
| | | * @param a4 |
| | | * message argument |
| | | * @param a5 |
| | | * message argument |
| | | * @param a6 |
| | | * message argument |
| | | * @param a7 |
| | | * message argument |
| | | * @param a8 |
| | | * message argument |
| | | * @param a9 |
| | | * message argument |
| | | * @param a10 |
| | | * message argument |
| | | * @param a11 |
| | | * message argument |
| | | */ |
| | | public Message get(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7, |
| | | T8 a8, T9 a9, T10 a10, T11 a11) |
| | | { |
| | | return new Message(this, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, |
| | | a11); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * defined with more arguments that can be handled with the current |
| | | * number of subclasses |
| | | */ |
| | | static public final class ArgN extends MessageDescriptor |
| | | public static final class ArgN extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | /** |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param args |
| | | * message arguments |
| | | */ |
| | | public Message get(Object... args) |
| | | public LocalizableMessage get(Object... args) |
| | | { |
| | | return new Message(this, args); |
| | | return newMessage(this, args); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * plugins may want to use the mechanism to create messages without |
| | | * storing their strings in resource bundles. |
| | | */ |
| | | static final class Raw extends MessageDescriptor |
| | | public static final class Raw extends LocalizableMessageDescriptor |
| | | { |
| | | |
| | | private String formatString; |
| | | private final String formatString; |
| | | |
| | | private boolean requiresFormatter; |
| | | private final boolean requiresFormatter; |
| | | |
| | | |
| | | |
| | |
| | | * @param formatString |
| | | * for created messages |
| | | */ |
| | | Raw(CharSequence formatString) |
| | | public Raw(CharSequence formatString) |
| | | { |
| | | super(null, null, null); |
| | | this.formatString = formatString != null ? formatString |
| | |
| | | * specifiers in the assocated format string when the message is |
| | | * rendered to string representation. |
| | | * |
| | | * @return Message object |
| | | * @return LocalizableMessage object |
| | | * @param args |
| | | * message arguments |
| | | */ |
| | | public Message get(Object... args) |
| | | public LocalizableMessage get(Object... args) |
| | | { |
| | | return new Message(this, args); |
| | | return newMessage(this, args); |
| | | } |
| | | |
| | | |
| | |
| | | * ignored |
| | | * @return format string |
| | | */ |
| | | @Override |
| | | String getFormatString(Locale locale) |
| | | public String getFormatString(Locale locale) |
| | | { |
| | | return this.formatString; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean requiresFormatter() |
| | | public boolean requiresFormatter() |
| | | { |
| | | return this.requiresFormatter; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | /** String for accessing backing resource bundle. */ |
| | | private final String rbBase; |
| | | |
| | | /** Used for accessing format string from the resource bundle. */ |
| | | private final String key; |
| | | |
| | | /** |
| | | * The class loader to be used to retrieve the ResourceBundle. If null |
| | | * the default class loader will be used. |
| | | */ |
| | | private final ClassLoader classLoader; |
| | | |
| | | private final Map<Locale, String> formatStrMap = new HashMap<Locale, String>(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the key for accessing the message template in a resource |
| | | * bundle. May be null for raw messages. |
| | | * |
| | | * @return key of this message |
| | | */ |
| | | public final String getKey() |
| | | // Container for caching the last locale specific format string. |
| | | private static final class CachedFormatString |
| | | { |
| | | return this.key; |
| | | } |
| | | private final Locale locale; |
| | | |
| | | private final String formatString; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Obtains the resource bundle base string used to access the resource |
| | | * bundle containing created message's format string. May be null for |
| | | * raw messages. |
| | | * |
| | | * @return string base |
| | | */ |
| | | public final String getBase() |
| | | { |
| | | return this.rbBase; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether or not this descriptor format string should be |
| | | * processed by Formatter during string rendering. |
| | | * |
| | | * @return boolean where true means Formatter should be used; false |
| | | * otherwise |
| | | * @see java.util.Formatter |
| | | */ |
| | | abstract boolean requiresFormatter(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Obtains the format string for constructing the string value of this |
| | | * message according to the default locale. |
| | | * |
| | | * @return format string |
| | | */ |
| | | final String getFormatString() |
| | | { |
| | | return getFormatString(Locale.getDefault()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Obtains the format string for constructing the string value of this |
| | | * message according to the requested locale. |
| | | * |
| | | * @param locale |
| | | * for the returned format string |
| | | * @return format string |
| | | */ |
| | | String getFormatString(Locale locale) |
| | | { |
| | | String fmtStr = formatStrMap.get(locale); |
| | | if (fmtStr == null) |
| | | private CachedFormatString(Locale locale, String formatString) |
| | | { |
| | | ResourceBundle bundle = getBundle(locale); |
| | | fmtStr = bundle.getString(this.key); |
| | | formatStrMap.put(locale, fmtStr); |
| | | this.locale = locale; |
| | | this.formatString = formatString; |
| | | } |
| | | return fmtStr; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Factory interface for creating messages. Only LocalizableMessage should |
| | | * implement this. |
| | | */ |
| | | public static interface MessageFactory |
| | | { |
| | | /** |
| | | * Creates a new parameterized message instance. |
| | | * |
| | | * @param descriptor |
| | | * The message descriptor. |
| | | * @param args |
| | | * The message parameters. |
| | | * @return The new message. |
| | | */ |
| | | LocalizableMessage newMessage(LocalizableMessageDescriptor descriptor, Object... args); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * We use a factory for creating LocalizableMessage objects in order to avoid |
| | | * exposing this class in the public API. |
| | | */ |
| | | public static MessageFactory MESSAGE_FACTORY; |
| | | |
| | | // Force MESSAGE_FACTORY to be set. |
| | | static |
| | | { |
| | | try |
| | | { |
| | | Class.forName("org.opends.sdk.LocalizableMessage"); |
| | | } |
| | | catch (ClassNotFoundException e) |
| | | { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | * not replaced by arguments. |
| | | * |
| | | * @param s |
| | | * candiate for formatting |
| | | * candidate for formatting |
| | | * @return boolean where true indicates that the format string |
| | | * requires formatting |
| | | */ |
| | | protected final boolean containsArgumentLiterals(String s) |
| | | private static final boolean containsArgumentLiterals(String s) |
| | | { |
| | | return s.matches(".*%[n|%].*"); // match Formatter literals |
| | | } |
| | | |
| | | |
| | | |
| | | private ResourceBundle getBundle(Locale locale) |
| | | private static LocalizableMessage newMessage(LocalizableMessageDescriptor descriptor, |
| | | Object... args) |
| | | { |
| | | if (locale == null) locale = Locale.getDefault(); |
| | | if (classLoader == null) |
| | | { |
| | | return ResourceBundle.getBundle(this.rbBase, locale); |
| | | } |
| | | else |
| | | { |
| | | return ResourceBundle.getBundle(this.rbBase, locale, classLoader); |
| | | } |
| | | return MESSAGE_FACTORY.newMessage(descriptor, args); |
| | | } |
| | | |
| | | |
| | | |
| | | // String for accessing backing resource bundle. |
| | | private final String rbBase; |
| | | |
| | | // Used for accessing format string from the resource bundle. |
| | | private final String key; |
| | | |
| | | /* |
| | | * The class loader to be used to retrieve the ResourceBundle. If null |
| | | * the default class loader will be used. |
| | | */ |
| | | private final ClassLoader classLoader; |
| | | |
| | | // It's ok if there are race conditions. |
| | | private CachedFormatString cachedFormatString = null; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a parameterized message descriptor. |
| | | * |
| | |
| | | * @param classLoader |
| | | * the class loader to be used to get the ResourceBundle |
| | | */ |
| | | private MessageDescriptor(String rbBase, String key, |
| | | private LocalizableMessageDescriptor(String rbBase, String key, |
| | | ClassLoader classLoader) |
| | | { |
| | | this.rbBase = rbBase; |
| | |
| | | this.classLoader = classLoader; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the format string which should be used when creating the |
| | | * string representation of this message using the specified locale. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @return The format string. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public String getFormatString(Locale locale) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(locale); |
| | | |
| | | // Fast path. |
| | | final CachedFormatString cfs = cachedFormatString; |
| | | if (cfs != null && cfs.locale == locale) |
| | | { |
| | | return cfs.formatString; |
| | | } |
| | | |
| | | // There's a potential race condition here but it's benign - we'll |
| | | // just do a bit more work than needed. |
| | | final ResourceBundle bundle = getBundle(locale); |
| | | final String formatString = bundle.getString(key); |
| | | cachedFormatString = new CachedFormatString(locale, formatString); |
| | | |
| | | return formatString; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether or not this descriptor format string should be |
| | | * processed by {@code Formatter} during string rendering. |
| | | * |
| | | * @return {@code true} if a {@code Formatter} should be used, |
| | | * otherwise {@code false}. |
| | | */ |
| | | public abstract boolean requiresFormatter(); |
| | | |
| | | |
| | | |
| | | private ResourceBundle getBundle(Locale locale) |
| | | { |
| | | if (locale == null) |
| | | { |
| | | locale = Locale.getDefault(); |
| | | } |
| | | if (classLoader == null) |
| | | { |
| | | return ResourceBundle.getBundle(this.rbBase, locale); |
| | | } |
| | | else |
| | | { |
| | | return ResourceBundle.getBundle(this.rbBase, locale, classLoader); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the format string which should be used when creating the |
| | | * string representation of this message using the default locale. |
| | | * |
| | | * @return The format string. |
| | | */ |
| | | final String getFormatString() |
| | | { |
| | | return getFormatString(Locale.getDefault()); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.security.cert.CertificateFactory; |
| | | import java.security.cert.X509Certificate; |
| | | |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | /** |
| | | * Provides a wrapper class that collects all of the JVM vendor |
| | |
| | | X500SignerCons = |
| | | X500SignerClass.getConstructor(Signature.class, X500NameClass); |
| | | } catch (ClassNotFoundException e) { |
| | | Message msg = ERR_CERTMGR_CLASS_NOT_FOUND.get(e.getMessage()); |
| | | LocalizableMessage msg = ERR_CERTMGR_CLASS_NOT_FOUND.get(e.getMessage()); |
| | | throw new ExceptionInInitializerError(msg.toString()); |
| | | } catch (SecurityException e) { |
| | | Message msg = ERR_CERTMGR_SECURITY.get(e.getMessage()); |
| | | LocalizableMessage msg = ERR_CERTMGR_SECURITY.get(e.getMessage()); |
| | | throw new ExceptionInInitializerError(msg.toString()); |
| | | } catch (NoSuchMethodException e) { |
| | | Message msg = ERR_CERTMGR_NO_METHOD.get(e.getMessage()); |
| | | LocalizableMessage msg = ERR_CERTMGR_NO_METHOD.get(e.getMessage()); |
| | | throw new ExceptionInInitializerError(msg.toString()); |
| | | } |
| | | } |
| | |
| | | String alias, char[] pwd, String dn) throws KeyStoreException { |
| | | if(!certReqAllowed) { |
| | | String vendor = System.getProperty("java.vendor"); |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_CERTMGR_CERT_SIGN_REQ_NOT_SUPPORTED.get(vendor); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | |
| | | PrintStream printStream = |
| | | new PrintStream(new FileOutputStream(csrFile.getAbsolutePath())); |
| | | if(keyStore == null) { |
| | | Message msg = ERR_CERTMGR_KEYSTORE_NONEXISTANT.get(); |
| | | LocalizableMessage msg = ERR_CERTMGR_KEYSTORE_NONEXISTANT.get(); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | PrivateKey privateKey = getPrivateKey(keyStore, alias, pwd); |
| | | if(privateKey == null) { |
| | | Message msg = ERR_CERTMGR_PRIVATE_KEY.get(alias); |
| | | LocalizableMessage msg = ERR_CERTMGR_PRIVATE_KEY.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | Certificate cert = keyStore.getCertificate(alias); |
| | | if(cert == null) { |
| | | Message msg = ERR_CERTMGR_ALIAS_NO_CERTIFICATE.get(alias); |
| | | LocalizableMessage msg = ERR_CERTMGR_ALIAS_NO_CERTIFICATE.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | Signature signature = Signature.getInstance(SIG_ALGORITHM); |
| | |
| | | print.invoke(request, printStream); |
| | | printStream.close(); |
| | | } catch (Exception e) { |
| | | Message msg = ERR_CERTMGR_CERT_REQUEST.get(alias,e.getMessage()); |
| | | LocalizableMessage msg = ERR_CERTMGR_CERT_REQUEST.get(alias,e.getMessage()); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | return csrFile; |
| | |
| | | String alias, char[] pwd) throws KeyStoreException { |
| | | try { |
| | | if(ks == null) { |
| | | Message msg = ERR_CERTMGR_KEYSTORE_NONEXISTANT.get(); |
| | | LocalizableMessage msg = ERR_CERTMGR_KEYSTORE_NONEXISTANT.get(); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | ks.deleteEntry(alias); |
| | |
| | | ks.store(fs, pwd); |
| | | fs.close(); |
| | | } catch (Exception e) { |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_CERTMGR_DELETE_ALIAS.get(alias,e.getMessage()); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | |
| | | } |
| | | //Do not support certificate replies. |
| | | if (ks.entryInstanceOf(alias ,KeyStore.PrivateKeyEntry.class)) { |
| | | Message msg = ERR_CERTMGR_CERT_REPLIES_INVALID.get(alias); |
| | | LocalizableMessage msg = ERR_CERTMGR_CERT_REPLIES_INVALID.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } else if(!ks.containsAlias(alias) || |
| | | ks.entryInstanceOf(alias, |
| | | KeyStore.TrustedCertificateEntry.class)) |
| | | trustedCert(alias, cf, ks, inStream); |
| | | else { |
| | | Message msg = ERR_CERTMGR_ALIAS_INVALID.get(alias); |
| | | LocalizableMessage msg = ERR_CERTMGR_ALIAS_INVALID.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | FileOutputStream fileOutStream = new FileOutputStream(ksPath); |
| | |
| | | fileOutStream.close(); |
| | | inStream.close(); |
| | | } catch (Exception e) { |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_CERTMGR_ADD_CERT.get(alias, e.getMessage()); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | |
| | | ks = KeyStore.getInstance(ksType); |
| | | ks.load(null, pwd); |
| | | } else if(ks.containsAlias(alias)) { |
| | | Message msg = ERR_CERTMGR_ALIAS_ALREADY_EXISTS.get(alias); |
| | | LocalizableMessage msg = ERR_CERTMGR_ALIAS_ALREADY_EXISTS.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | Object keypair = |
| | |
| | | ks.store(fileOutStream, pwd); |
| | | fileOutStream.close(); |
| | | } catch (Exception e) { |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_CERTMGR_GEN_SELF_SIGNED_CERT.get(alias, e.getMessage()); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | |
| | | KeyStore ks, InputStream in) throws KeyStoreException { |
| | | try { |
| | | if (ks.containsAlias(alias) == true) { |
| | | Message msg = ERR_CERTMGR_ALIAS_ALREADY_EXISTS.get(alias); |
| | | LocalizableMessage msg = ERR_CERTMGR_ALIAS_ALREADY_EXISTS.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | X509Certificate cert = (X509Certificate) cf.generateCertificate(in); |
| | |
| | | cert.verify(cert.getPublicKey()); |
| | | ks.setCertificateEntry(alias, cert); |
| | | } catch (Exception e) { |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_CERTMGR_TRUSTED_CERT.get(alias,e.getMessage()); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | |
| | | PrivateKey key = null; |
| | | try { |
| | | if(!ks.containsAlias(alias)) { |
| | | Message msg = ERR_CERTMGR_ALIAS_DOES_NOT_EXIST.get(alias); |
| | | LocalizableMessage msg = ERR_CERTMGR_ALIAS_DOES_NOT_EXIST.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | if(!ks.entryInstanceOf(alias, KeyStore.PrivateKeyEntry.class) && |
| | | !ks.entryInstanceOf(alias, KeyStore.SecretKeyEntry.class)) { |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_CERTMGR_ALIAS_INVALID_ENTRY_TYPE.get(alias); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | key = (PrivateKey)ks.getKey(alias, pwd); |
| | | } catch (Exception e) { |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_CERTMGR_GET_KEY.get(alias,e.getMessage()); |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | |
| | | import java.util.zip.Deflater; |
| | | import java.util.zip.Inflater; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.*; |
| | | |
| | | |
| | | |
| | |
| | | * @return The human-readable message generated for the provided |
| | | * exception. |
| | | */ |
| | | public static Message getExceptionMessage(Throwable t) |
| | | public static LocalizableMessage getExceptionMessage(Throwable t) |
| | | { |
| | | if (t instanceof LocalizableException) |
| | | { |
| | |
| | | { |
| | | final StackTraceElement[] stackElements = t.getStackTrace(); |
| | | |
| | | final MessageBuilder message = new MessageBuilder(); |
| | | final LocalizableMessageBuilder message = new LocalizableMessageBuilder(); |
| | | message.append("NullPointerException("); |
| | | message.append(stackElements[0].getFileName()); |
| | | message.append(":"); |
| | |
| | | |
| | | message.append(")"); |
| | | |
| | | return Message.raw(message.toString()); |
| | | return LocalizableMessage.raw(message.toString()); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (length % 2 == 1) |
| | | { |
| | | final Message message = ERR_HEX_DECODE_INVALID_LENGTH |
| | | final LocalizableMessage message = ERR_HEX_DECODE_INVALID_LENGTH |
| | | .get(hexString); |
| | | throw new ParseException(message.toString(), 0); |
| | | } |
| | |
| | | b = (byte) 0xF0; |
| | | break; |
| | | default: |
| | | final Message message = ERR_HEX_DECODE_INVALID_CHARACTER.get( |
| | | final LocalizableMessage message = ERR_HEX_DECODE_INVALID_CHARACTER.get( |
| | | new String(new char[] { c1, c2 }), c1); |
| | | throw new ParseException(message.toString(), 0); |
| | | } |
| | |
| | | b |= 0x0F; |
| | | break; |
| | | default: |
| | | final Message message = ERR_HEX_DECODE_INVALID_CHARACTER.get( |
| | | final LocalizableMessage message = ERR_HEX_DECODE_INVALID_CHARACTER.get( |
| | | new String(new char[] { c1, c2 }), c1); |
| | | throw new ParseException(message.toString(), 0); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | final Message message = ERR_INVALID_ESCAPE_CHAR.get(reader |
| | | final LocalizableMessage message = ERR_INVALID_ESCAPE_CHAR.get(reader |
| | | .getString(), c1); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | // comprise the escaped value. |
| | | if (reader.remaining() == 0) |
| | | { |
| | | final Message message = ERR_HEX_DECODE_INVALID_LENGTH.get(reader |
| | | final LocalizableMessage message = ERR_HEX_DECODE_INVALID_LENGTH.get(reader |
| | | .getString()); |
| | | |
| | | throw DecodeException.error(message); |
| | |
| | | b |= 0x0F; |
| | | break; |
| | | default: |
| | | final Message message = ERR_HEX_DECODE_INVALID_CHARACTER.get( |
| | | final LocalizableMessage message = ERR_HEX_DECODE_INVALID_CHARACTER.get( |
| | | new String(new char[] { c1, c2 }), c1); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import org.opends.sdk.requests.SearchRequest; |
| | | import org.opends.sdk.responses.*; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | c = attributeDescription.charAt(i); |
| | | if (c != ' ') |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_INTERNAL_WHITESPACE |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_INTERNAL_WHITESPACE |
| | | .get(attributeDescription); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // contained whitespace. |
| | | if (i == length) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_EMPTY |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_EMPTY |
| | | .get(attributeDescription); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | ASCIICharProp cp = ASCIICharProp.valueOf(c); |
| | | if (cp == null) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | cp = ASCIICharProp.valueOf(c); |
| | | if (!cp.isKeyChar()) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | cp = ASCIICharProp.valueOf(c); |
| | | if (c != '.' && !cp.isDigit()) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | |
| | | if (oid.length() == 0) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_NO_TYPE |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_NO_TYPE |
| | | .get(attributeDescription); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_TYPE_NOT_FOUND |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_TYPE_NOT_FOUND |
| | | .get(attributeDescription, e.getMessageObject()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | cp = ASCIICharProp.valueOf(c); |
| | | if (!cp.isKeyChar()) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | |
| | | if (option.length() == 0) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_EMPTY_OPTION |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_EMPTY_OPTION |
| | | .get(attributeDescription); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | cp = ASCIICharProp.valueOf(c); |
| | | if (!cp.isKeyChar()) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_ILLEGAL_CHARACTER |
| | | .get(attributeDescription, c, i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | |
| | | if (option.length() == 0) |
| | | { |
| | | final Message message = ERR_ATTRIBUTE_DESCRIPTION_EMPTY_OPTION |
| | | final LocalizableMessage message = ERR_ATTRIBUTE_DESCRIPTION_EMPTY_OPTION |
| | | .get(attributeDescription); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | import org.opends.sdk.requests.*; |
| | | import org.opends.sdk.responses.*; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.sdk.schema.Schema; |
| | | import org.opends.sdk.schema.UnknownSchemaElementException; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = ERR_DN_TYPE_NOT_FOUND.get(reader |
| | | final LocalizableMessage message = ERR_DN_TYPE_NOT_FOUND.get(reader |
| | | .getString(), e.getMessageObject()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizableException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | public final class DecodeException extends IOException implements |
| | | LocalizableException |
| | | { |
| | | private final Message message; |
| | | private final LocalizableMessage message; |
| | | |
| | | private final boolean isFatal; |
| | | |
| | |
| | | * The message that explains the problem that occurred. |
| | | * @return The new fatal decode exception. |
| | | */ |
| | | public static DecodeException fatalError(Message message) |
| | | public static DecodeException fatalError(LocalizableMessage message) |
| | | { |
| | | return new DecodeException(message, true, null); |
| | | } |
| | |
| | | * The underlying cause of this exception. |
| | | * @return The new fatal decode exception. |
| | | */ |
| | | public static DecodeException fatalError(Message message, |
| | | public static DecodeException fatalError(LocalizableMessage message, |
| | | Throwable cause) |
| | | { |
| | | return new DecodeException(message, true, cause); |
| | |
| | | * The message that explains the problem that occurred. |
| | | * @return The new non-fatal decode exception. |
| | | */ |
| | | public static DecodeException error(Message message) |
| | | public static DecodeException error(LocalizableMessage message) |
| | | { |
| | | return new DecodeException(message, false, null); |
| | | } |
| | |
| | | * The underlying cause of this exception. |
| | | * @return The new non-fatal decode exception. |
| | | */ |
| | | public static DecodeException error(Message message, Throwable cause) |
| | | public static DecodeException error(LocalizableMessage message, Throwable cause) |
| | | { |
| | | return new DecodeException(message, false, cause); |
| | | } |
| | |
| | | |
| | | |
| | | // Construction is provided via factory methods. |
| | | private DecodeException(Message message, boolean isFatal, |
| | | private DecodeException(LocalizableMessage message, boolean isFatal, |
| | | Throwable cause) |
| | | { |
| | | super(message.toString(), cause); |
| | |
| | | /** |
| | | * Returns the message that explains the problem that occurred. |
| | | * |
| | | * @return Message of the problem |
| | | * @return LocalizableMessage of the problem |
| | | */ |
| | | public Message getMessageObject() |
| | | public LocalizableMessage getMessageObject() |
| | | { |
| | | return message; |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.schema.ObjectClass; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | if ((string.length() > 1) && string.startsWith("'") |
| | | && string.endsWith("'")) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_ENCLOSED_IN_APOSTROPHES |
| | | LocalizableMessage message = ERR_LDAP_FILTER_ENCLOSED_IN_APOSTROPHES |
| | | .get(string); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | Message message = ERR_LDAP_FILTER_MISMATCHED_PARENTHESES.get( |
| | | LocalizableMessage message = ERR_LDAP_FILTER_MISMATCHED_PARENTHESES.get( |
| | | string, 1, string.length()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if (beginIndex >= endIndex) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_STRING_NULL.get(); |
| | | LocalizableMessage message = ERR_LDAP_FILTER_STRING_NULL.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | if ((string.charAt(index + 1) != '(') |
| | | || (string.charAt(endIndex - 1) != ')')) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_COMPOUND_MISSING_PARENTHESES |
| | | LocalizableMessage message = ERR_LDAP_FILTER_COMPOUND_MISSING_PARENTHESES |
| | | .get(string, index, endIndex - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // the binary value. |
| | | if ((i + 2) >= valueBytes.length) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | string, startIndex + i + 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | byteValue = (byte) 0xF0; |
| | | break; |
| | | default: |
| | | Message message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | string, startIndex + i + 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | byteValue |= (byte) 0x0F; |
| | | break; |
| | | default: |
| | | Message message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get( |
| | | string, startIndex + i + 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // can help make the switch statement more efficient. We'll fall |
| | | // through to the default clause to reject them. |
| | | default: |
| | | Message message = ERR_LDAP_FILTER_INVALID_CHAR_IN_ATTR_TYPE |
| | | LocalizableMessage message = ERR_LDAP_FILTER_INVALID_CHAR_IN_ATTR_TYPE |
| | | .get(attrType, String.valueOf(attrType.charAt(i)), i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | int colonPos = string.indexOf(':', startIndex); |
| | | if (colonPos < 0) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_EXTENSIBLE_MATCH_NO_COLON |
| | | LocalizableMessage message = ERR_LDAP_FILTER_EXTENSIBLE_MATCH_NO_COLON |
| | | .get(string, startIndex); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // description and/or a matching rule ID. |
| | | if ((attributeDescription == null) && (matchingRule == null)) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR |
| | | LocalizableMessage message = ERR_LDAP_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR |
| | | .get(string, startIndex); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if ((string.charAt(startIndex) != '(') |
| | | || (string.charAt(endIndex - 1) != ')')) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_COMPOUND_MISSING_PARENTHESES |
| | | LocalizableMessage message = ERR_LDAP_FILTER_COMPOUND_MISSING_PARENTHESES |
| | | .get(string, startIndex, endIndex); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | else if (pendingOpens < 0) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_NO_CORRESPONDING_OPEN_PARENTHESIS |
| | | LocalizableMessage message = ERR_LDAP_FILTER_NO_CORRESPONDING_OPEN_PARENTHESIS |
| | | .get(string, i); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | } |
| | | else if (pendingOpens <= 0) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_COMPOUND_MISSING_PARENTHESES |
| | | LocalizableMessage message = ERR_LDAP_FILTER_COMPOUND_MISSING_PARENTHESES |
| | | .get(string, startIndex, endIndex); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // components. The list of open parenthesis positions must be empty. |
| | | if (pendingOpens != 0) |
| | | { |
| | | Message message = ERR_LDAP_FILTER_NO_CORRESPONDING_CLOSE_PARENTHESIS |
| | | LocalizableMessage message = ERR_LDAP_FILTER_NO_CORRESPONDING_CLOSE_PARENTHESIS |
| | | .get(string, openIndex); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if (s == i) |
| | | { |
| | | // A zero length substring. |
| | | Message message = ERR_LDAP_FILTER_BAD_SUBSTRING.get( |
| | | LocalizableMessage message = ERR_LDAP_FILTER_BAD_SUBSTRING.get( |
| | | string, string.subSequence(startIndex, endIndex)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| File was renamed from sdk/src/com/sun/opends/sdk/util/LocalizableException.java |
| | |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | package com.sun.opends.sdk.util; |
| | | package org.opends.sdk; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * |
| | | * @return The message that explains the problem that occurred. |
| | | */ |
| | | Message getMessageObject(); |
| | | LocalizableMessage getMessageObject(); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.sdk; |
| | | |
| | | |
| | | |
| | | import java.util.Formattable; |
| | | import java.util.Formatter; |
| | | import java.util.IllegalFormatException; |
| | | import java.util.Locale; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizableMessageDescriptor; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A localizable message whose {@code String} representation can be |
| | | * retrieved in one or more locales. A message is localized each time it |
| | | * is converted to a {@code String} using one of its {@link #toString} |
| | | * methods. |
| | | * <p> |
| | | * Localizable messages are particularly useful in situations where a |
| | | * message a destined for multiple recipients, potentially in different |
| | | * locales. For example, a server application may record a message in |
| | | * its log file using its default locale, but also send the same message |
| | | * to the client using the client's locale (if known). |
| | | * <p> |
| | | * In most cases messages are intended for use in a locale-sensitive |
| | | * manner although this class defines convenience methods for creating |
| | | * uninternationalized messages whose {@code String} representation is |
| | | * always the same regardless of the requested locale. |
| | | * <p> |
| | | * This class implements {@code CharSequence} so that messages can be |
| | | * supplied as arguments to other messages. This way messages can be |
| | | * composed of fragments of other messages if necessary. |
| | | * |
| | | * @see LocalizableMessageBuilder |
| | | */ |
| | | public final class LocalizableMessage implements CharSequence, Formattable, |
| | | Comparable<LocalizableMessage> |
| | | { |
| | | static |
| | | { |
| | | LocalizableMessageDescriptor.MESSAGE_FACTORY = new LocalizableMessageDescriptor.MessageFactory() |
| | | { |
| | | |
| | | public LocalizableMessage newMessage(LocalizableMessageDescriptor descriptor, |
| | | Object... args) |
| | | { |
| | | return new LocalizableMessage(descriptor, args); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Represents an empty message string. |
| | | */ |
| | | public static final LocalizableMessage EMPTY = LocalizableMessage.raw(""); |
| | | |
| | | // Variable used to workaround a bug in AIX Java 1.6 |
| | | // TODO: remove this code once the JDK issue referenced in 3077 is |
| | | // closed. |
| | | private static final boolean IS_AIX_POST5 = isAIXPost5(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an uninternationalized message whose {@code String} |
| | | * representation is always the same regardless of the requested |
| | | * locale. |
| | | * <p> |
| | | * Note that the types for {@code args} must be consistent with any |
| | | * argument specifiers appearing in {@code formatString} according to |
| | | * the rules of {@link java.util.Formatter}. A mismatch in type |
| | | * information will cause this message to render without argument |
| | | * substitution. Before using this method you should be sure that the |
| | | * message you are creating is not locale sensitive. If it is locale |
| | | * sensitive consider defining an appropriate |
| | | * {@link LocalizableMessageDescriptor}. |
| | | * |
| | | * @param formatString |
| | | * The raw message format string. |
| | | * @param args |
| | | * The raw message parameters. |
| | | * @return An uninternationalized messages whose {@code String} |
| | | * representation is always the same regardless of the |
| | | * requested locale. |
| | | * @throws NullPointerException |
| | | * If {@code formatString} was {@code null}. |
| | | */ |
| | | public static LocalizableMessage raw(CharSequence formatString, Object... args) |
| | | { |
| | | Validator.ensureNotNull(formatString); |
| | | return new LocalizableMessageDescriptor.Raw(formatString).get(args); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new message whose content is the {@code String} |
| | | * representation of the provided {@code Object}. |
| | | * |
| | | * @param object |
| | | * The object to be converted to a message, may be {@code |
| | | * null}. |
| | | * @return The new message. |
| | | */ |
| | | public static LocalizableMessage valueOf(Object object) |
| | | { |
| | | if (object instanceof LocalizableMessage) |
| | | { |
| | | return (LocalizableMessage) object; |
| | | } |
| | | else if (object instanceof LocalizableMessageBuilder) |
| | | { |
| | | return ((LocalizableMessageBuilder) object).toMessage(); |
| | | } |
| | | else |
| | | { |
| | | return new LocalizableMessageDescriptor.Raw(String.valueOf(object)).get(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns whether we are running post 1.5 on AIX or not. |
| | | * |
| | | * @return {@code true} if we are running post 1.5 on AIX and {@code |
| | | * false} otherwise. |
| | | */ |
| | | private static boolean isAIXPost5() |
| | | { |
| | | // TODO: remove this code once the JDK issue referenced in 3077 is |
| | | // closed. |
| | | boolean isJDK15 = false; |
| | | try |
| | | { |
| | | final String javaRelease = System.getProperty("java.version"); |
| | | isJDK15 = javaRelease.startsWith("1.5"); |
| | | } |
| | | catch (final Throwable t) |
| | | { |
| | | System.err.println("Cannot get the java version: " + t); |
| | | } |
| | | final boolean isAIX = "aix".equalsIgnoreCase(System |
| | | .getProperty("os.name")); |
| | | return !isJDK15 && isAIX; |
| | | } |
| | | |
| | | |
| | | |
| | | // Descriptor of this message. |
| | | private final LocalizableMessageDescriptor descriptor; |
| | | |
| | | // Values used to replace argument specifiers in the format string. |
| | | private final Object[] args; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new parameterized message instance. See the class header |
| | | * for instructions on how to create messages outside of this package. |
| | | * |
| | | * @param descriptor |
| | | * The message descriptor. |
| | | * @param args |
| | | * The message parameters. |
| | | */ |
| | | private LocalizableMessage(LocalizableMessageDescriptor descriptor, Object... args) |
| | | { |
| | | this.descriptor = descriptor; |
| | | this.args = args; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code char} value at the specified index of the |
| | | * {@code String} representation of this message in the default |
| | | * locale. |
| | | * |
| | | * @param index |
| | | * The index of the {@code char} value to be returned. |
| | | * @return The specified {@code char} value. |
| | | * @throws IndexOutOfBoundsException |
| | | * If the {@code index} argument is negative or not less |
| | | * than {@code length()}. |
| | | */ |
| | | public char charAt(int index) throws IndexOutOfBoundsException |
| | | { |
| | | return charAt(Locale.getDefault(), index); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code char} value at the specified index of the |
| | | * {@code String} representation of this message in the specified |
| | | * locale. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @param index |
| | | * The index of the {@code char} value to be returned. |
| | | * @return The specified {@code char} value. |
| | | * @throws IndexOutOfBoundsException |
| | | * If the {@code index} argument is negative or not less |
| | | * than {@code length()}. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public char charAt(Locale locale, int index) |
| | | throws IndexOutOfBoundsException, NullPointerException |
| | | { |
| | | return toString(locale).charAt(index); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Compares this message with the specified message for order in the |
| | | * default locale. Returns a negative integer, zero, or a positive |
| | | * integer as this object is less than, equal to, or greater than the |
| | | * specified object. |
| | | * |
| | | * @param message |
| | | * The message to be compared. |
| | | * @return A negative integer, zero, or a positive integer as this |
| | | * object is less than, equal to, or greater than the |
| | | * specified object. |
| | | */ |
| | | public int compareTo(LocalizableMessage message) |
| | | { |
| | | return toString().compareTo(message.toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns {@code true} if the provided object is a message whose |
| | | * {@code String} representation is equal to the {@code String} |
| | | * representation of this message in the default locale. |
| | | * |
| | | * @param o |
| | | * The object to be compared for equality with this message. |
| | | * @return {@code true} if this message is the equal to {@code o}, |
| | | * otherwise {@code false}. |
| | | */ |
| | | public boolean equals(Object o) |
| | | { |
| | | if (this == o) |
| | | { |
| | | return true; |
| | | } |
| | | else if (o instanceof LocalizableMessage) |
| | | { |
| | | final LocalizableMessage message = (LocalizableMessage) o; |
| | | return toString().equals(message.toString()); |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Formats this message using the provided {@link Formatter}. |
| | | * |
| | | * @param formatter |
| | | * The {@link Formatter}. |
| | | * @param flags |
| | | * The flags modify the output format. The value is |
| | | * interpreted as a bitmask. Any combination of the following |
| | | * flags may be set: |
| | | * {@link java.util.FormattableFlags#LEFT_JUSTIFY}, |
| | | * {@link java.util.FormattableFlags#UPPERCASE}, and |
| | | * {@link java.util.FormattableFlags#ALTERNATE}. If no flags |
| | | * are set, the default formatting of the implementing class |
| | | * will apply. |
| | | * @param width |
| | | * The minimum number of characters to be written to the |
| | | * output. If the length of the converted value is less than |
| | | * the {@code width} then the output will be padded by white |
| | | * space until the total number of characters equals width. |
| | | * The padding is at the beginning by default. If the |
| | | * {@link java.util.FormattableFlags#LEFT_JUSTIFY} flag is |
| | | * set then the padding will be at the end. If {@code width} |
| | | * is {@code -1} then there is no minimum. |
| | | * @param precision |
| | | * The maximum number of characters to be written to the |
| | | * output. The precision is applied before the width, thus |
| | | * the output will be truncated to {@code precision} |
| | | * characters even if the {@code width} is greater than the |
| | | * {@code precision}. If {@code precision} is {@code -1} then |
| | | * there is no explicit limit on the number of characters. |
| | | * @throws IllegalFormatException |
| | | * If any of the parameters are invalid. For specification |
| | | * of all possible formatting errors, see the <a |
| | | * href="../util/Formatter.html#detail">Details</a> section |
| | | * of the formatter class specification. |
| | | */ |
| | | public void formatTo(Formatter formatter, int flags, int width, |
| | | int precision) throws IllegalFormatException |
| | | { |
| | | // Ignores flags, width and precision for now. |
| | | // see javadoc for Formattable |
| | | final Locale l = formatter.locale(); |
| | | formatter.format(l, descriptor.getFormatString(l), args); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the hash code value for this message calculated using the |
| | | * hash code of the {@code String} representation of this message in |
| | | * the default locale. |
| | | * |
| | | * @return The hash code value for this message. |
| | | */ |
| | | public int hashCode() |
| | | { |
| | | return toString().hashCode(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the length of the {@code String} representation of this |
| | | * message in the default locale. |
| | | * |
| | | * @return The length of the {@code String} representation of this |
| | | * message in the default locale. |
| | | */ |
| | | public int length() |
| | | { |
| | | return length(Locale.getDefault()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the length of the {@code String} representation of this |
| | | * message in the specified locale. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @return The length of the {@code String} representation of this |
| | | * message in the specified locale. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public int length(Locale locale) throws NullPointerException |
| | | { |
| | | return toString(locale).length(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a new {@code CharSequence} which is a subsequence of the |
| | | * {@code String} representation of this message in the default |
| | | * locale. The subsequence starts with the {@code char} value at the |
| | | * specified index and ends with the {@code char} value at index |
| | | * {@code end - 1} . The length (in {@code char}s) of the returned |
| | | * sequence is {@code end - start}, so if {@code start == end} then an |
| | | * empty sequence is returned. |
| | | * |
| | | * @param start |
| | | * The start index, inclusive. |
| | | * @param end |
| | | * The end index, exclusive. |
| | | * @return The specified subsequence. |
| | | * @throws IndexOutOfBoundsException |
| | | * If {@code start} or {@code end} are negative, if {@code |
| | | * end} is greater than {@code length()}, or if {@code |
| | | * start} is greater than {@code end}. |
| | | */ |
| | | public CharSequence subSequence(int start, int end) |
| | | throws IndexOutOfBoundsException |
| | | { |
| | | return subSequence(Locale.getDefault(), start, end); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a new {@code CharSequence} which is a subsequence of the |
| | | * {@code String} representation of this message in the specified |
| | | * locale. The subsequence starts with the {@code char} value at the |
| | | * specified index and ends with the {@code char} value at index |
| | | * {@code end - 1} . The length (in {@code char}s) of the returned |
| | | * sequence is {@code end - start}, so if {@code start == end} then an |
| | | * empty sequence is returned. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @param start |
| | | * The start index, inclusive. |
| | | * @param end |
| | | * The end index, exclusive. |
| | | * @return The specified subsequence. |
| | | * @throws IndexOutOfBoundsException |
| | | * If {@code start} or {@code end} are negative, if {@code |
| | | * end} is greater than {@code length()}, or if {@code |
| | | * start} is greater than {@code end}. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public CharSequence subSequence(Locale locale, int start, int end) |
| | | throws IndexOutOfBoundsException, NullPointerException |
| | | { |
| | | return toString(locale).subSequence(start, end); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code String} representation of this message in the |
| | | * default locale. |
| | | * |
| | | * @return The {@code String} representation of this message. |
| | | */ |
| | | public String toString() |
| | | { |
| | | return toString(Locale.getDefault()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code String} representation of this message in the |
| | | * specified locale. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @return The {@code String} representation of this message. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public String toString(Locale locale) throws NullPointerException |
| | | { |
| | | String s; |
| | | final String fmt = descriptor.getFormatString(locale); |
| | | if (descriptor.requiresFormatter()) |
| | | { |
| | | try |
| | | { |
| | | // TODO: remove this code once the JDK issue referenced in 3077 |
| | | // is closed. |
| | | if (IS_AIX_POST5) |
| | | { |
| | | // Java 6 in AIX Formatter does not handle properly |
| | | // Formattable arguments; this code is a workaround for the |
| | | // problem. |
| | | boolean changeType = false; |
| | | for (final Object o : args) |
| | | { |
| | | if (o instanceof Formattable) |
| | | { |
| | | changeType = true; |
| | | break; |
| | | } |
| | | } |
| | | if (changeType) |
| | | { |
| | | final Object[] newArgs = new Object[args.length]; |
| | | for (int i = 0; i < args.length; i++) |
| | | { |
| | | if (args[i] instanceof Formattable) |
| | | { |
| | | newArgs[i] = args[i].toString(); |
| | | } |
| | | else |
| | | { |
| | | newArgs[i] = args[i]; |
| | | } |
| | | } |
| | | s = new Formatter(locale).format(locale, fmt, newArgs) |
| | | .toString(); |
| | | } |
| | | else |
| | | { |
| | | s = new Formatter(locale).format(locale, fmt, args) |
| | | .toString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | s = new Formatter(locale).format(locale, fmt, args) |
| | | .toString(); |
| | | } |
| | | } |
| | | catch (final IllegalFormatException e) |
| | | { |
| | | // This should not happend with any of our internal messages. |
| | | // However, this may happen for raw messages that have a |
| | | // mismatch between argument specifier type and argument type. |
| | | s = fmt; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | s = fmt; |
| | | } |
| | | if (s == null) |
| | | { |
| | | s = ""; |
| | | } |
| | | return s; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.sdk; |
| | | |
| | | |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A mutable sequence of localizable messages and their parameters. As |
| | | * messages are appended they are translated to their string |
| | | * representation for storage using the locale specified in the |
| | | * constructor. |
| | | * <p> |
| | | * Note that before you use this class you should consider whether it is |
| | | * appropriate. In general composing messages by appending message to |
| | | * each other may not produce a message that is formatted appropriately |
| | | * for all locales. |
| | | * <p> |
| | | * It is usually better to create messages by composition. In other |
| | | * words you should create a base message that contains one or more |
| | | * string argument specifiers (%s) and define other message objects to |
| | | * use as replacement variables. In this way language translators have a |
| | | * change to reformat the message for a particular locale if necessary. |
| | | * |
| | | * @see LocalizableMessage |
| | | */ |
| | | public final class LocalizableMessageBuilder implements Appendable, CharSequence, |
| | | Serializable |
| | | { |
| | | |
| | | private static final long serialVersionUID = -3292823563904285315L; |
| | | |
| | | // Used internally to store appended messages. |
| | | private final List<LocalizableMessage> messages = new LinkedList<LocalizableMessage>(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new message builder whose content is initially empty. |
| | | */ |
| | | public LocalizableMessageBuilder() |
| | | { |
| | | // Nothing to do. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new message builder whose content is initially equal to |
| | | * the provided message. |
| | | * |
| | | * @param message |
| | | * The initial content of the message builder. |
| | | * @throws NullPointerException |
| | | * If {@code message} was {@code null}. |
| | | */ |
| | | public LocalizableMessageBuilder(LocalizableMessage message) throws NullPointerException |
| | | { |
| | | append(message); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new message builder whose content is initially equal to |
| | | * the provided message builder. |
| | | * |
| | | * @param builder |
| | | * The initial content of the message builder. |
| | | * @throws NullPointerException |
| | | * If {@code builder} was {@code null}. |
| | | */ |
| | | public LocalizableMessageBuilder(LocalizableMessageBuilder builder) |
| | | { |
| | | for (final LocalizableMessage message : builder.messages) |
| | | { |
| | | this.messages.add(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new message builder whose content is initially equal to |
| | | * the {@code String} representation of the provided {@code Object}. |
| | | * |
| | | * @param object |
| | | * The initial content of the message builder, may be {@code |
| | | * null}. |
| | | */ |
| | | public LocalizableMessageBuilder(Object object) |
| | | { |
| | | append(object); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends the provided character to this message builder. |
| | | * |
| | | * @param c |
| | | * The character to be appended. |
| | | * @return A reference to this message builder. |
| | | */ |
| | | public LocalizableMessageBuilder append(char c) |
| | | { |
| | | return append(LocalizableMessage.valueOf(c)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends the provided character sequence to this message builder. |
| | | * |
| | | * @param cs |
| | | * The character sequence to be appended. |
| | | * @return A reference to this message builder. |
| | | * @throws NullPointerException |
| | | * If {@code cs} was {@code null}. |
| | | */ |
| | | public LocalizableMessageBuilder append(CharSequence cs) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(cs); |
| | | return append((Object) cs); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends a subsequence of the provided character sequence to this |
| | | * message builder. |
| | | * <p> |
| | | * An invocation of this method of the form {@code append(cs, start, |
| | | * end)}, behaves in exactly the same way as the invocation |
| | | * |
| | | * <pre> |
| | | * append(cs.subSequence(start, end)) |
| | | * </pre> |
| | | * |
| | | * @param cs |
| | | * The character sequence to be appended. |
| | | * @param start |
| | | * The index of the first character in the subsequence. |
| | | * @param end |
| | | * The index of the character following the last character in |
| | | * the subsequence. |
| | | * @return A reference to this message builder. |
| | | * @throws IndexOutOfBoundsException |
| | | * If {@code start} or {@code end} are negative, {@code |
| | | * start} is greater than {@code end}, or {@code end} is |
| | | * greater than {@code csq.length()}. |
| | | * @throws NullPointerException |
| | | * If {@code cs} was {@code null}. |
| | | */ |
| | | public LocalizableMessageBuilder append(CharSequence cs, int start, int end) |
| | | throws IndexOutOfBoundsException, NullPointerException |
| | | { |
| | | return append(cs.subSequence(start, end)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends the provided integer to this message builder. |
| | | * |
| | | * @param value |
| | | * The integer to be appended. |
| | | * @return A reference to this message builder. |
| | | */ |
| | | public LocalizableMessageBuilder append(int value) |
| | | { |
| | | return append(LocalizableMessage.valueOf(value)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends the provided message to this message builder. |
| | | * |
| | | * @param message |
| | | * The message to be appended. |
| | | * @return A reference to this message builder. |
| | | * @throws NullPointerException |
| | | * If {@code message} was {@code null}. |
| | | */ |
| | | public LocalizableMessageBuilder append(LocalizableMessage message) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(message); |
| | | messages.add(message); |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Appends the {@code String} representation of the provided {@code |
| | | * Object} to this message builder. |
| | | * |
| | | * @param object |
| | | * The object to be appended, may be {@code null}. |
| | | * @return A reference to this message builder. |
| | | */ |
| | | public LocalizableMessageBuilder append(Object object) |
| | | { |
| | | return append(LocalizableMessage.valueOf(object)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code char} value at the specified index of the |
| | | * {@code String} representation of this message builder in the |
| | | * default locale. |
| | | * |
| | | * @param index |
| | | * The index of the {@code char} value to be returned. |
| | | * @return The specified {@code char} value. |
| | | * @throws IndexOutOfBoundsException |
| | | * If the {@code index} argument is negative or not less |
| | | * than {@code length()}. |
| | | */ |
| | | public char charAt(int index) throws IndexOutOfBoundsException |
| | | { |
| | | return charAt(Locale.getDefault(), index); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code char} value at the specified index of the |
| | | * {@code String} representation of this message builder in the |
| | | * specified locale. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @param index |
| | | * The index of the {@code char} value to be returned. |
| | | * @return The specified {@code char} value. |
| | | * @throws IndexOutOfBoundsException |
| | | * If the {@code index} argument is negative or not less |
| | | * than {@code length()}. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public char charAt(Locale locale, int index) |
| | | throws IndexOutOfBoundsException, NullPointerException |
| | | { |
| | | return toString(locale).charAt(index); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the length of the {@code String} representation of this |
| | | * message builder in the default locale. |
| | | * |
| | | * @return The length of the {@code String} representation of this |
| | | * message builder in the default locale. |
| | | */ |
| | | public int length() |
| | | { |
| | | return length(Locale.getDefault()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the length of the {@code String} representation of this |
| | | * message builder in the specified locale. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @return The length of the {@code String} representation of this |
| | | * message builder in the specified locale. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public int length(Locale locale) throws NullPointerException |
| | | { |
| | | return toString(locale).length(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a new {@code CharSequence} which is a subsequence of the |
| | | * {@code String} representation of this message builder in the |
| | | * default locale. The subsequence starts with the {@code char} value |
| | | * at the specified index and ends with the {@code char} value at |
| | | * index {@code end - 1} . The length (in {@code char}s) of the |
| | | * returned sequence is {@code end - start}, so if {@code start == |
| | | * end} then an empty sequence is returned. |
| | | * |
| | | * @param start |
| | | * The start index, inclusive. |
| | | * @param end |
| | | * The end index, exclusive. |
| | | * @return The specified subsequence. |
| | | * @throws IndexOutOfBoundsException |
| | | * If {@code start} or {@code end} are negative, if {@code |
| | | * end} is greater than {@code length()}, or if {@code |
| | | * start} is greater than {@code end}. |
| | | */ |
| | | public CharSequence subSequence(int start, int end) |
| | | throws IndexOutOfBoundsException |
| | | { |
| | | return subSequence(Locale.getDefault(), start, end); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a new {@code CharSequence} which is a subsequence of the |
| | | * {@code String} representation of this message builder in the |
| | | * specified locale. The subsequence starts with the {@code char} |
| | | * value at the specified index and ends with the {@code char} value |
| | | * at index {@code end - 1} . The length (in {@code char}s) of the |
| | | * returned sequence is {@code end - start}, so if {@code start == |
| | | * end} then an empty sequence is returned. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @param start |
| | | * The start index, inclusive. |
| | | * @param end |
| | | * The end index, exclusive. |
| | | * @return The specified subsequence. |
| | | * @throws IndexOutOfBoundsException |
| | | * If {@code start} or {@code end} are negative, if {@code |
| | | * end} is greater than {@code length()}, or if {@code |
| | | * start} is greater than {@code end}. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public CharSequence subSequence(Locale locale, int start, int end) |
| | | throws IndexOutOfBoundsException, NullPointerException |
| | | { |
| | | return toString(locale).subSequence(start, end); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@link LocalizableMessage} representation of this message builder. |
| | | * Subsequent changes to this message builder will not modify the |
| | | * returned {@code LocalizableMessage}. |
| | | * |
| | | * @return The {@code LocalizableMessage} representation of this message builder. |
| | | */ |
| | | public LocalizableMessage toMessage() |
| | | { |
| | | if (messages.isEmpty()) |
| | | { |
| | | return LocalizableMessage.EMPTY; |
| | | } |
| | | |
| | | final int sz = messages.size(); |
| | | final StringBuffer fmtString = new StringBuffer(sz * 2); |
| | | for (int i = 0; i < sz; i++) |
| | | { |
| | | fmtString.append("%s"); |
| | | } |
| | | |
| | | return LocalizableMessage.raw(fmtString, messages.toArray()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code String} representation of this message builder |
| | | * in the default locale. |
| | | * |
| | | * @return The {@code String} representation of this message builder. |
| | | */ |
| | | public String toString() |
| | | { |
| | | return toString(Locale.getDefault()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the {@code String} representation of this message builder |
| | | * in the specified locale. |
| | | * |
| | | * @param locale |
| | | * The locale. |
| | | * @return The {@code String} representation of this message builder. |
| | | * @throws NullPointerException |
| | | * If {@code locale} was {@code null}. |
| | | */ |
| | | public String toString(Locale locale) |
| | | { |
| | | final StringBuilder builder = new StringBuilder(); |
| | | for (final LocalizableMessage message : messages) |
| | | { |
| | | builder.append(message.toString(locale)); |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | |
| | | } |
| File was renamed from sdk/src/com/sun/opends/sdk/util/LocalizedIllegalArgumentException.java |
| | |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.sun.opends.sdk.util; |
| | | package org.opends.sdk; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | IllegalArgumentException implements LocalizableException |
| | | { |
| | | // The I18N message associated with this exception. |
| | | private final Message message; |
| | | private final LocalizableMessage message; |
| | | |
| | | |
| | | |
| | |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | */ |
| | | public LocalizedIllegalArgumentException(Message message) |
| | | public LocalizedIllegalArgumentException(LocalizableMessage message) |
| | | { |
| | | super(String.valueOf(message)); |
| | | this.message = message; |
| | |
| | | * permitted, and indicates that the cause is nonexistent or |
| | | * unknown. |
| | | */ |
| | | public LocalizedIllegalArgumentException(Message message, |
| | | public LocalizedIllegalArgumentException(LocalizableMessage message, |
| | | Throwable cause) |
| | | { |
| | | super(String.valueOf(message), cause); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getMessageObject() |
| | | public LocalizableMessage getMessageObject() |
| | | { |
| | | return this.message; |
| | | } |
| | |
| | | import org.opends.sdk.schema.Schema; |
| | | import org.opends.sdk.schema.UnknownSchemaElementException; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = ERR_RDN_TYPE_NOT_FOUND.get(rdn, e |
| | | final LocalizableMessage message = ERR_RDN_TYPE_NOT_FOUND.get(rdn, e |
| | | .getMessageObject()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // that would be invalid. |
| | | if (reader.remaining() == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_END_WITH_ATTR_NAME |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_END_WITH_ATTR_NAME |
| | | .get(reader.getString(), attribute.getNameOrOID()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | char c; |
| | | if ((c = reader.read()) != '=') |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_NO_EQUAL.get(reader |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_NO_EQUAL.get(reader |
| | | .getString(), attribute.getNameOrOID(), c); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS |
| | | .get(reader.getString(), reader.pos() - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | else if (!isDigit(c)) |
| | | { |
| | | // This must have been an illegal character. |
| | | final Message message = ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER |
| | | .get(reader.getString(), reader.pos() - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR |
| | | .get(reader.getString(), c, reader.pos() - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if (!isAlpha(c) && !isDigit(c) && c != '-') |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR |
| | | .get(reader.getString(), c, reader.pos() - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR.get( |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR.get( |
| | | reader.getString(), c, reader.pos() - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | reader.mark(); |
| | | if (reader.remaining() < 2) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT |
| | | .get(reader.getString()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_INVALID_HEX_DIGIT |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_INVALID_HEX_DIGIT |
| | | .get(reader.getString(), c); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_INVALID_HEX_DIGIT |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_INVALID_HEX_DIGIT |
| | | .get(reader.getString(), c); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT |
| | | .get(reader.getString()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_INVALID_HEX_DIGIT |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_INVALID_HEX_DIGIT |
| | | .get(reader.getString(), c); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_DN_ATTR_VALUE_DECODE_FAILURE |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_VALUE_DECODE_FAILURE |
| | | .get(reader.getString(), String.valueOf(e)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if (bytes.length() == 0) |
| | | { |
| | | // We don't allow an empty attribute value. |
| | | final Message message = ERR_ATTR_SYNTAX_DN_INVALID_REQUIRES_ESCAPE_CHAR |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_INVALID_REQUIRES_ESCAPE_CHAR |
| | | .get(reader.getString(), reader.pos()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | * @return The new error result code. |
| | | */ |
| | | private static ResultCode registerErrorResultCode(int intValue, |
| | | Message name) |
| | | LocalizableMessage name) |
| | | { |
| | | ResultCode t = new ResultCode(intValue, name, true); |
| | | ELEMENTS[intValue] = t; |
| | |
| | | * @return The new success result code. |
| | | */ |
| | | private static ResultCode registerSuccessResultCode(int intValue, |
| | | Message name) |
| | | LocalizableMessage name) |
| | | { |
| | | ResultCode t = new ResultCode(intValue, name, false); |
| | | ELEMENTS[intValue] = t; |
| | |
| | | |
| | | if (resultCode == null) |
| | | { |
| | | resultCode = new ResultCode(intValue, Message.raw("undefined(" |
| | | resultCode = new ResultCode(intValue, LocalizableMessage.raw("undefined(" |
| | | + intValue + ")"), true); |
| | | } |
| | | |
| | |
| | | |
| | | private final int intValue; |
| | | |
| | | private final Message name; |
| | | private final LocalizableMessage name; |
| | | |
| | | private final boolean exceptional; |
| | | |
| | | |
| | | |
| | | // Prevent direct instantiation. |
| | | private ResultCode(int intValue, Message name, boolean exceptional) |
| | | private ResultCode(int intValue, LocalizableMessage name, boolean exceptional) |
| | | { |
| | | this.intValue = intValue; |
| | | this.name = name; |
| | |
| | | * |
| | | * @return The short human-readable name of this result code. |
| | | */ |
| | | public Message getName() |
| | | public LocalizableMessage getName() |
| | | { |
| | | return name; |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.requests.Requests; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.logging.Level; |
| | | |
| | | import org.opends.sdk.ByteSequenceReader; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | // Read just the type. |
| | | if (reader.remaining() <= 0) |
| | | { |
| | | Message message = ERR_ASN1_TRUCATED_TYPE_BYTE.get(); |
| | | LocalizableMessage message = ERR_ASN1_TRUCATED_TYPE_BYTE.get(); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | int type = reader.get(); |
| | |
| | | |
| | | if (peekLength != 1) |
| | | { |
| | | Message message = ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | | if (reader.remaining() < peekLength) |
| | | { |
| | | Message message = ERR_ASN1_BOOLEAN_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_BOOLEAN_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | { |
| | | if (readerStack.isEmpty()) |
| | | { |
| | | Message message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | | LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | | throw new IllegalStateException(message.toString()); |
| | | } |
| | | |
| | |
| | | |
| | | if ((peekLength < 1) || (peekLength > 4)) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | |
| | | if ((peekLength < 1) || (peekLength > 8)) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | | if (reader.remaining() < peekLength) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // Make sure that the decoded length is exactly zero byte. |
| | | if (peekLength != 0) |
| | | { |
| | | Message message = ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | |
| | | if (reader.remaining() < peekLength) |
| | | { |
| | | Message message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // Copy the value. |
| | | if (reader.remaining() < peekLength) |
| | | { |
| | | Message message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | |
| | | if (reader.remaining() < peekLength) |
| | | { |
| | | Message message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | |
| | | if (reader.remaining() < peekLength) |
| | | { |
| | | Message message = ERR_ASN1_SEQUENCE_SET_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_SEQUENCE_SET_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | |
| | | if (reader.remaining() < peekLength) |
| | | { |
| | | Message message = ERR_ASN1_SKIP_TRUNCATED_VALUE.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_SKIP_TRUNCATED_VALUE.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | { |
| | | if (throwEofException) |
| | | { |
| | | Message message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get(); |
| | | LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get(); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | return false; |
| | |
| | | int lengthBytesNeeded = peekLength; |
| | | if (lengthBytesNeeded > 4) |
| | | { |
| | | Message message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES |
| | | LocalizableMessage message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES |
| | | .get(lengthBytesNeeded); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | { |
| | | if (throwEofException) |
| | | { |
| | | Message message = ERR_ASN1_TRUNCATED_LENGTH_BYTES |
| | | LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTES |
| | | .get(lengthBytesNeeded); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) |
| | | { |
| | | Message message = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | LocalizableMessage message = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | { |
| | | if (throwEofException) |
| | | { |
| | | Message message = ERR_ASN1_TRUCATED_TYPE_BYTE.get(); |
| | | LocalizableMessage message = ERR_ASN1_TRUCATED_TYPE_BYTE.get(); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | return false; |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.SizeLimitInputStream; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | |
| | | |
| | | if (peekLength != 1) |
| | | { |
| | | Message message = ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | | int readByte = in.read(); |
| | | if (readByte == -1) |
| | | { |
| | | Message message = ERR_ASN1_BOOLEAN_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_BOOLEAN_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | { |
| | | if (streamStack.isEmpty()) |
| | | { |
| | | Message message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | | LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | | throw new IllegalStateException(message.toString()); |
| | | } |
| | | |
| | |
| | | |
| | | if ((peekLength < 1) || (peekLength > 4)) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | |
| | | if ((peekLength < 1) || (peekLength > 8)) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | int readByte = in.read(); |
| | | if (readByte == -1) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | int readByte = in.read(); |
| | | if (readByte == -1) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // Make sure that the decoded length is exactly zero byte. |
| | | if (peekLength != 0) |
| | | { |
| | | Message message = ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | bytesRead = in.read(value, peekLength - bytesNeeded, bytesNeeded); |
| | | if (bytesRead < 0) |
| | | { |
| | | Message message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | bytesRead = builder.append(in, bytesNeeded); |
| | | if (bytesRead < 0) |
| | | { |
| | | Message message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | .read(buffer, peekLength - bytesNeeded, bytesNeeded); |
| | | if (bytesRead < 0) |
| | | { |
| | | Message message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | LocalizableMessage message = ERR_ASN1_OCTET_STRING_TRUNCATED_VALUE |
| | | .get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | long bytesSkipped = in.skip(peekLength); |
| | | if (bytesSkipped != peekLength) |
| | | { |
| | | Message message = ERR_ASN1_SKIP_TRUNCATED_VALUE.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_SKIP_TRUNCATED_VALUE.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | state = ELEMENT_READ_STATE_NEED_TYPE; |
| | |
| | | state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES; |
| | | if (throwEofException) |
| | | { |
| | | Message message = ERR_ASN1_TRUNCATED_LENGTH_BYTES |
| | | LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTES |
| | | .get(lengthBytesNeeded); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) |
| | | { |
| | | Message message = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | LocalizableMessage message = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | { |
| | | if (throwEofException) |
| | | { |
| | | Message message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get(); |
| | | LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get(); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | return false; |
| | |
| | | lengthBytesNeeded = peekLength; |
| | | if (lengthBytesNeeded > 4) |
| | | { |
| | | Message message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES |
| | | LocalizableMessage message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES |
| | | .get(lengthBytesNeeded); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES; |
| | | if (throwEofException) |
| | | { |
| | | Message message = ERR_ASN1_TRUNCATED_LENGTH_BYTES |
| | | LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTES |
| | | .get(lengthBytesNeeded); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) |
| | | { |
| | | Message message = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | LocalizableMessage message = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | { |
| | | if (throwEofException) |
| | | { |
| | | Message message = ERR_ASN1_TRUCATED_TYPE_BYTE.get(); |
| | | LocalizableMessage message = ERR_ASN1_TRUCATED_TYPE_BYTE.get(); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | return false; |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.ByteSequenceOutputStream; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | { |
| | | if (stackDepth < 0) |
| | | { |
| | | Message message = ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED.get(); |
| | | LocalizableMessage message = ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED.get(); |
| | | throw new IllegalStateException(message.toString()); |
| | | } |
| | | |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | if (peekType() != expectedType) |
| | | { |
| | | Message message = ERR_ASN1_UNEXPECTED_TAG.get(expectedType, |
| | | LocalizableMessage message = ERR_ASN1_UNEXPECTED_TAG.get(expectedType, |
| | | peekType()); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | { |
| | | if (value != null) |
| | | { |
| | | Message message = ERR_ACCTUSABLEREQ_CONTROL_HAS_VALUE.get(); |
| | | LocalizableMessage message = ERR_ACCTUSABLEREQ_CONTROL_HAS_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | if (value == null) |
| | | { |
| | | // The response control must always have a value. |
| | | Message message = ERR_ACCTUSABLERES_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_ACCTUSABLERES_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | secondsBeforeUnlock); |
| | | |
| | | default: |
| | | Message message = ERR_ACCTUSABLERES_UNKNOWN_VALUE_ELEMENT_TYPE |
| | | LocalizableMessage message = ERR_ACCTUSABLERES_UNKNOWN_VALUE_ELEMENT_TYPE |
| | | .get(byteToHex(reader.peekType())); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "AccountUsabilityControl.ResponseDecoder", "decode", e); |
| | | |
| | | Message message = ERR_ACCTUSABLERES_DECODE_ERROR |
| | | LocalizableMessage message = ERR_ACCTUSABLERES_DECODE_ERROR |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.Filter; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.ldap.LDAPUtils; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_LDAPASSERT_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_LDAPASSERT_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | { |
| | | if (value != null) |
| | | { |
| | | Message message = ERR_AUTHZIDREQ_CONTROL_HAS_VALUE.get(); |
| | | LocalizableMessage message = ERR_AUTHZIDREQ_CONTROL_HAS_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_AUTHZIDRESP_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_AUTHZIDRESP_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_ECN_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_ECN_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | { |
| | | if (changeType != PersistentSearchChangeType.MODIFY_DN) |
| | | { |
| | | Message message = ERR_ECN_ILLEGAL_PREVIOUS_DN.get(String |
| | | LocalizableMessage message = ERR_ECN_ILLEGAL_PREVIOUS_DN.get(String |
| | | .valueOf(changeType)); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "EntryChangeNotificationControl.Decoder", "decode", e); |
| | | |
| | | Message message = ERR_ECN_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = ERR_ECN_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.AttributeType; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | authzDN = authzIDString.substring(3); |
| | | else |
| | | { |
| | | Message message = INFO_GETEFFECTIVERIGHTS_INVALID_AUTHZID |
| | | LocalizableMessage message = INFO_GETEFFECTIVERIGHTS_INVALID_AUTHZID |
| | | .get(lowerAuthzIDString); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = INFO_GETEFFECTIVERIGHTS_DECODE_ERROR.get(e |
| | | LocalizableMessage message = INFO_GETEFFECTIVERIGHTS_DECODE_ERROR.get(e |
| | | .getMessage()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import org.opends.sdk.ldap.LDAPUtils; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | public LocalizedIllegalArgumentException visitAndFilter(Filter p, |
| | | List<Filter> subFilters) |
| | | { |
| | | Message message = ERR_MVFILTER_BAD_FILTER_AND.get(p.toString()); |
| | | LocalizableMessage message = ERR_MVFILTER_BAD_FILTER_AND.get(p.toString()); |
| | | return new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | { |
| | | if (dnAttributes) |
| | | { |
| | | Message message = ERR_MVFILTER_BAD_FILTER_EXT.get(p.toString()); |
| | | LocalizableMessage message = ERR_MVFILTER_BAD_FILTER_EXT.get(p.toString()); |
| | | return new LocalizedIllegalArgumentException(message); |
| | | } |
| | | else |
| | |
| | | public LocalizedIllegalArgumentException visitNotFilter(Filter p, |
| | | Filter subFilter) |
| | | { |
| | | Message message = ERR_MVFILTER_BAD_FILTER_NOT.get(p.toString()); |
| | | LocalizableMessage message = ERR_MVFILTER_BAD_FILTER_NOT.get(p.toString()); |
| | | return new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | public LocalizedIllegalArgumentException visitOrFilter(Filter p, |
| | | List<Filter> subFilters) |
| | | { |
| | | Message message = ERR_MVFILTER_BAD_FILTER_OR.get(p.toString()); |
| | | LocalizableMessage message = ERR_MVFILTER_BAD_FILTER_OR.get(p.toString()); |
| | | return new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | public LocalizedIllegalArgumentException visitUnrecognizedFilter( |
| | | Filter p, byte filterTag, ByteSequence filterBytes) |
| | | { |
| | | Message message = ERR_MVFILTER_BAD_FILTER_UNRECOGNIZED.get(p |
| | | LocalizableMessage message = ERR_MVFILTER_BAD_FILTER_UNRECOGNIZED.get(p |
| | | .toString(), filterTag); |
| | | return new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_MATCHEDVALUES_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_MATCHEDVALUES_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | reader.readStartSequence(); |
| | | if (!reader.hasNextElement()) |
| | | { |
| | | Message message = ERR_MATCHEDVALUES_NO_FILTERS.get(); |
| | | LocalizableMessage message = ERR_MATCHEDVALUES_NO_FILTERS.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("MatchedValuesControl.Decoder", |
| | | "decode", e); |
| | | |
| | | Message message = ERR_MATCHEDVALUES_CANNOT_DECODE_VALUE_AS_SEQUENCE |
| | | LocalizableMessage message = ERR_MATCHEDVALUES_CANNOT_DECODE_VALUE_AS_SEQUENCE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_LDAP_PAGED_RESULTS_DECODE_NULL.get(); |
| | | LocalizableMessage message = ERR_LDAP_PAGED_RESULTS_DECODE_NULL.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("PagedResultsControl.Decoder", |
| | | "decode", e); |
| | | |
| | | Message message = ERR_LDAP_PAGED_RESULTS_DECODE_SEQUENCE |
| | | LocalizableMessage message = ERR_LDAP_PAGED_RESULTS_DECODE_SEQUENCE |
| | | .get(String.valueOf(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("PagedResultsControl.Decoder", |
| | | "decode", e); |
| | | |
| | | Message message = ERR_LDAP_PAGED_RESULTS_DECODE_SIZE.get(String |
| | | LocalizableMessage message = ERR_LDAP_PAGED_RESULTS_DECODE_SIZE.get(String |
| | | .valueOf(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("PagedResultsControl.Decoder", |
| | | "decode", e); |
| | | |
| | | Message message = ERR_LDAP_PAGED_RESULTS_DECODE_COOKIE |
| | | LocalizableMessage message = ERR_LDAP_PAGED_RESULTS_DECODE_COOKIE |
| | | .get(String.valueOf(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("PagedResultsControl.Decoder", |
| | | "decode", e); |
| | | |
| | | Message message = ERR_LDAP_PAGED_RESULTS_DECODE_SEQUENCE |
| | | LocalizableMessage message = ERR_LDAP_PAGED_RESULTS_DECODE_SEQUENCE |
| | | .get(String.valueOf(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Message message = ERR_PWEXPIRED_CONTROL_INVALID_VALUE.get(); |
| | | LocalizableMessage message = ERR_PWEXPIRED_CONTROL_INVALID_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_PWEXPIRING_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_PWEXPIRING_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "PasswordExpiringControl.Decoder", "decode", e); |
| | | |
| | | Message message = ERR_PWEXPIRING_CANNOT_DECODE_SECONDS_UNTIL_EXPIRATION |
| | | LocalizableMessage message = ERR_PWEXPIRING_CANNOT_DECODE_SECONDS_UNTIL_EXPIRATION |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | { |
| | | if (value != null) |
| | | { |
| | | Message message = ERR_PWPOLICYREQ_CONTROL_HAS_VALUE.get(); |
| | | LocalizableMessage message = ERR_PWPOLICYREQ_CONTROL_HAS_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | if (value == null) |
| | | { |
| | | // The response control must always have a value. |
| | | Message message = ERR_PWPOLICYRES_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_PWPOLICYRES_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | warningValue = (int) reader.readInteger(); |
| | | if (warningType == null) |
| | | { |
| | | Message message = ERR_PWPOLICYRES_INVALID_WARNING_TYPE |
| | | LocalizableMessage message = ERR_PWPOLICYRES_INVALID_WARNING_TYPE |
| | | .get(byteToHex(reader.peekType())); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | errorType = PasswordPolicyErrorType.valueOf(errorValue); |
| | | if (errorType == null) |
| | | { |
| | | Message message = ERR_PWPOLICYRES_INVALID_ERROR_TYPE |
| | | LocalizableMessage message = ERR_PWPOLICYRES_INVALID_ERROR_TYPE |
| | | .get(errorValue); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "PasswordPolicyControl.ResponseDecoder", "decode", e); |
| | | |
| | | Message message = ERR_PWPOLICYRES_DECODE_ERROR |
| | | LocalizableMessage message = ERR_PWPOLICYRES_DECODE_ERROR |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | PasswordPolicyErrorType e = ELEMENTS[intValue]; |
| | | if (e == null) |
| | | { |
| | | e = new PasswordPolicyErrorType(intValue, Message |
| | | e = new PasswordPolicyErrorType(intValue, LocalizableMessage |
| | | .raw("undefined(" + intValue + ")")); |
| | | } |
| | | return e; |
| | |
| | | |
| | | |
| | | private static PasswordPolicyErrorType register(int intValue, |
| | | Message name) |
| | | LocalizableMessage name) |
| | | { |
| | | PasswordPolicyErrorType t = new PasswordPolicyErrorType(intValue, |
| | | name); |
| | |
| | | |
| | | private final int intValue; |
| | | |
| | | private final Message name; |
| | | private final LocalizableMessage name; |
| | | |
| | | |
| | | |
| | | private PasswordPolicyErrorType(int intValue, Message name) |
| | | private PasswordPolicyErrorType(int intValue, LocalizableMessage name) |
| | | { |
| | | this.intValue = intValue; |
| | | this.name = name; |
| | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | PasswordPolicyWarningType e = ELEMENTS[intValue]; |
| | | if (e == null) |
| | | { |
| | | e = new PasswordPolicyWarningType(intValue, Message |
| | | e = new PasswordPolicyWarningType(intValue, LocalizableMessage |
| | | .raw("undefined(" + intValue + ")")); |
| | | } |
| | | return e; |
| | |
| | | |
| | | |
| | | private static PasswordPolicyWarningType register(int intValue, |
| | | Message name) |
| | | LocalizableMessage name) |
| | | { |
| | | PasswordPolicyWarningType t = new PasswordPolicyWarningType( |
| | | intValue, name); |
| | |
| | | |
| | | private final int intValue; |
| | | |
| | | private final Message name; |
| | | private final LocalizableMessage name; |
| | | |
| | | |
| | | |
| | | private PasswordPolicyWarningType(int intValue, Message name) |
| | | private PasswordPolicyWarningType(int intValue, LocalizableMessage name) |
| | | { |
| | | this.intValue = intValue; |
| | | this.name = name; |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_PSEARCH_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_PSEARCH_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "PersistentSearchControl.Decoder", "decode", e); |
| | | |
| | | Message message = ERR_PSEARCH_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = ERR_PSEARCH_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | |
| | | import org.opends.sdk.responses.SearchResultEntry; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_POSTREADREQ_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_POSTREADREQ_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "PersistentSearchControl.RequestDecoder", "decode", ae); |
| | | |
| | | Message message = ERR_POSTREADREQ_CANNOT_DECODE_VALUE.get(ae |
| | | LocalizableMessage message = ERR_POSTREADREQ_CANNOT_DECODE_VALUE.get(ae |
| | | .getMessage()); |
| | | throw DecodeException.error(message, ae); |
| | | } |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_POSTREADRESP_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_POSTREADRESP_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "PersistentSearchControl.ResponseDecoder", "decode", le); |
| | | |
| | | Message message = ERR_POSTREADRESP_CANNOT_DECODE_VALUE.get(le |
| | | LocalizableMessage message = ERR_POSTREADRESP_CANNOT_DECODE_VALUE.get(le |
| | | .getMessage()); |
| | | throw DecodeException.error(message, le); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | |
| | | import org.opends.sdk.responses.SearchResultEntry; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_PREREADREQ_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_PREREADREQ_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("PreReadControl.RequestDecoder", |
| | | "decode", ae); |
| | | |
| | | Message message = ERR_PREREADREQ_CANNOT_DECODE_VALUE.get(ae |
| | | LocalizableMessage message = ERR_PREREADREQ_CANNOT_DECODE_VALUE.get(ae |
| | | .getMessage()); |
| | | throw DecodeException.error(message, ae); |
| | | } |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_PREREADRESP_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_PREREADRESP_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "PersistentSearchControl.ResponseDecoder", "decode", le); |
| | | |
| | | Message message = ERR_PREREADRESP_CANNOT_DECODE_VALUE.get(le |
| | | LocalizableMessage message = ERR_PREREADRESP_CANNOT_DECODE_VALUE.get(le |
| | | .getMessage()); |
| | | throw DecodeException.error(message, le); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | { |
| | | if (!isCritical) |
| | | { |
| | | Message message = ERR_PROXYAUTH1_CONTROL_NOT_CRITICAL.get(); |
| | | LocalizableMessage message = ERR_PROXYAUTH1_CONTROL_NOT_CRITICAL.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_PROXYAUTH1_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_PROXYAUTH1_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("ProxiedAuthV1Control.Decoder", |
| | | "decode", e); |
| | | |
| | | Message message = ERR_PROXYAUTH1_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = ERR_PROXYAUTH1_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | { |
| | | if (!isCritical) |
| | | { |
| | | Message message = ERR_PROXYAUTH2_CONTROL_NOT_CRITICAL.get(); |
| | | LocalizableMessage message = ERR_PROXYAUTH2_CONTROL_NOT_CRITICAL.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if (value == null) |
| | | { |
| | | Message message = ERR_PROXYAUTH2_NO_CONTROL_VALUE.get(); |
| | | LocalizableMessage message = ERR_PROXYAUTH2_NO_CONTROL_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("ProxiedAuthV2Control.Decoder", |
| | | "decode", e); |
| | | |
| | | Message message = ERR_PROXYAUTH2_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = ERR_PROXYAUTH2_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = INFO_SORTREQ_CONTROL_NO_VALUE.get(); |
| | | LocalizableMessage message = INFO_SORTREQ_CONTROL_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | reader.readStartSequence(); |
| | | if (!reader.hasNextElement()) |
| | | { |
| | | Message message = INFO_SORTREQ_CONTROL_NO_SORT_KEYS.get(); |
| | | LocalizableMessage message = INFO_SORTREQ_CONTROL_NO_SORT_KEYS.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = INFO_SORTREQ_CONTROL_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = INFO_SORTREQ_CONTROL_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = INFO_SORTRES_CONTROL_NO_VALUE.get(); |
| | | LocalizableMessage message = INFO_SORTRES_CONTROL_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = INFO_SORTRES_CONTROL_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = INFO_SORTRES_CONTROL_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | { |
| | | if (token.length() == 0) |
| | | { |
| | | Message message = INFO_SORTREQ_CONTROL_NO_ATTR_NAME |
| | | LocalizableMessage message = INFO_SORTREQ_CONTROL_NO_ATTR_NAME |
| | | .get(sortOrderString); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | } |
| | | else if (colonPos == 0) |
| | | { |
| | | Message message = INFO_SORTREQ_CONTROL_NO_ATTR_NAME |
| | | LocalizableMessage message = INFO_SORTREQ_CONTROL_NO_ATTR_NAME |
| | | .get(sortOrderString); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else if (colonPos == (token.length() - 1)) |
| | | { |
| | | Message message = INFO_SORTREQ_CONTROL_NO_MATCHING_RULE |
| | | LocalizableMessage message = INFO_SORTREQ_CONTROL_NO_MATCHING_RULE |
| | | .get(sortOrderString); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | if (value != null) |
| | | { |
| | | Message message = ERR_SUBTREE_DELETE_INVALID_CONTROL_VALUE |
| | | LocalizableMessage message = ERR_SUBTREE_DELETE_INVALID_CONTROL_VALUE |
| | | .get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = INFO_VLVREQ_CONTROL_NO_VALUE.get(); |
| | | LocalizableMessage message = INFO_VLVREQ_CONTROL_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = INFO_VLVREQ_CONTROL_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = INFO_VLVREQ_CONTROL_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | { |
| | | if (value == null) |
| | | { |
| | | Message message = INFO_VLVRES_CONTROL_NO_VALUE.get(); |
| | | LocalizableMessage message = INFO_VLVRES_CONTROL_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = INFO_VLVRES_CONTROL_CANNOT_DECODE_VALUE |
| | | LocalizableMessage message = INFO_VLVRES_CONTROL_CANNOT_DECODE_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | return new GreaterThanOrEqual(assertionValue); |
| | | |
| | | default: |
| | | Message message = INFO_VLVREQ_CONTROL_INVALID_TARGET_TYPE |
| | | LocalizableMessage message = INFO_VLVREQ_CONTROL_INVALID_TARGET_TYPE |
| | | .get(byteToHex(targetType)); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.ResultCode; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | |
| | | import org.opends.sdk.responses.Responses; |
| | | import org.opends.sdk.responses.Result; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = ERR_EXTOP_CANCEL_CANNOT_DECODE_REQUEST_VALUE |
| | | LocalizableMessage message = ERR_EXTOP_CANCEL_CANNOT_DECODE_REQUEST_VALUE |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.ResultCode; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.requests.AbstractExtendedRequest; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | if (!resultCode.isExceptional() |
| | | && ((responseValue == null) || (responseValue.length() <= 0))) |
| | | { |
| | | throw DecodeException.error(Message |
| | | throw DecodeException.error(LocalizableMessage |
| | | .raw("Empty response value")); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | throw DecodeException.error(Message |
| | | throw DecodeException.error(LocalizableMessage |
| | | .raw("Error decoding response value"), e); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.ResultCode; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | |
| | | import org.opends.sdk.responses.Responses; |
| | | import org.opends.sdk.responses.Result; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | if (requestValue == null) |
| | | { |
| | | // The request must always have a value. |
| | | Message message = ERR_GET_SYMMETRIC_KEY_NO_VALUE.get(); |
| | | LocalizableMessage message = ERR_GET_SYMMETRIC_KEY_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing( |
| | | "GetSymmetricKeyRequest.Operation", "decodeRequest", ae); |
| | | |
| | | Message message = ERR_GET_SYMMETRIC_KEY_ASN1_DECODE_EXCEPTION |
| | | LocalizableMessage message = ERR_GET_SYMMETRIC_KEY_ASN1_DECODE_EXCEPTION |
| | | .get(ae.getMessage()); |
| | | throw DecodeException.error(message, ae); |
| | | } |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.ResultCode; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.asn1.ASN1; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.requests.AbstractExtendedRequest; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = ERR_EXTOP_PASSMOD_CANNOT_DECODE_REQUEST |
| | | LocalizableMessage message = ERR_EXTOP_PASSMOD_CANNOT_DECODE_REQUEST |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | Message message = ERR_EXTOP_PASSMOD_CANNOT_DECODE_REQUEST |
| | | LocalizableMessage message = ERR_EXTOP_PASSMOD_CANNOT_DECODE_REQUEST |
| | | .get(getExceptionMessage(e)); |
| | | throw DecodeException.error(message, e); |
| | | } |
| | |
| | | import org.opends.sdk.requests.AbstractExtendedRequest; |
| | | import org.opends.sdk.responses.AbstractExtendedResult; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | Message message = ERR_PWPSTATE_EXTOP_DECODE_FAILURE |
| | | LocalizableMessage message = ERR_PWPSTATE_EXTOP_DECODE_FAILURE |
| | | .get(getExceptionMessage(ioe)); |
| | | throw DecodeException.error(message, ioe); |
| | | } |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | Message message = ERR_PWPSTATE_EXTOP_DECODE_FAILURE |
| | | LocalizableMessage message = ERR_PWPSTATE_EXTOP_DECODE_FAILURE |
| | | .get(getExceptionMessage(ioe)); |
| | | throw DecodeException.error(message, ioe); |
| | | } |
| | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1Reader; |
| | | import org.opends.sdk.asn1.AbstractASN1Reader; |
| | | |
| | | import com.sun.grizzly.streams.StreamReader; |
| | | import com.sun.grizzly.utils.PoolableObject; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | |
| | | public ChildSequenceLimiter endSequence() throws DecodeException |
| | | { |
| | | Message message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | | LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get(); |
| | | throw new IllegalStateException(message.toString()); |
| | | } |
| | | |
| | |
| | | |
| | | if (peekLength != 1) |
| | | { |
| | | Message message = ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | |
| | | if ((peekLength < 1) || (peekLength > 4)) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | |
| | | if ((peekLength < 1) || (peekLength > 8)) |
| | | { |
| | | Message message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | // Make sure that the decoded length is exactly zero byte. |
| | | if (peekLength != 0) |
| | | { |
| | | Message message = ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength); |
| | | LocalizableMessage message = ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | |
| | |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) |
| | | { |
| | | Message m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get( |
| | | LocalizableMessage m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get( |
| | | peekLength, maxElementSize); |
| | | throw DecodeException.fatalError(m); |
| | | } |
| | |
| | | lengthBytesNeeded = peekLength; |
| | | if (lengthBytesNeeded > 4) |
| | | { |
| | | Message message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES |
| | | LocalizableMessage message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES |
| | | .get(lengthBytesNeeded); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) |
| | | { |
| | | Message m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get( |
| | | LocalizableMessage m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED.get( |
| | | peekLength, maxElementSize); |
| | | throw DecodeException.fatalError(m); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteStringBuilder; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.asn1.ASN1Writer; |
| | | import org.opends.sdk.asn1.AbstractASN1Writer; |
| | | |
| | | import com.sun.grizzly.streams.StreamWriter; |
| | | import com.sun.grizzly.utils.PoolableObject; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | |
| | | public SequenceBuffer endSequence() throws IOException |
| | | { |
| | | Message message = ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED.get(); |
| | | LocalizableMessage message = ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED.get(); |
| | | throw new IllegalStateException(message.toString()); |
| | | } |
| | | |
| | |
| | | import com.sun.grizzly.filterchain.StreamTransformerFilter; |
| | | import com.sun.grizzly.ssl.*; |
| | | import com.sun.grizzly.streams.StreamWriter; |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | import org.opends.sdk.sasl.GenericSASLBindRequest; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.requests.Request; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | public UnexpectedRequestException(int messageID, Request request) |
| | | { |
| | | super(Message.raw("Unexpected LDAP request: id=%d, message=%s", |
| | | super(LocalizableMessage.raw("Unexpected LDAP request: id=%d, message=%s", |
| | | messageID, request).toString()); |
| | | this.messageID = messageID; |
| | | this.request = request; |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.responses.Response; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | public UnexpectedResponseException(int messageID, Response response) |
| | | { |
| | | super(Message.raw("Unexpected LDAP response: id=%d, message=%s", |
| | | super(LocalizableMessage.raw("Unexpected LDAP response: id=%d, message=%s", |
| | | messageID, response).toString()); |
| | | this.messageID = messageID; |
| | | this.response = response; |
| | |
| | | public UnsupportedMessageException(int id, byte tag, |
| | | ByteString content) |
| | | { |
| | | super(com.sun.opends.sdk.util.Message.raw( |
| | | super(org.opends.sdk.LocalizableMessage.raw( |
| | | "Unsupported LDAP message: id=%d, tag=%d, content=%s", id, tag, |
| | | content).toString()); |
| | | this.id = id; |
| | |
| | | final int colonPos = ldifLine.indexOf(":"); |
| | | if (colonPos <= 0) |
| | | { |
| | | final Message message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | final LocalizableMessage message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | record.lineNumber, ldifLine); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | catch (final LocalizedIllegalArgumentException e) |
| | | { |
| | | // The value did not have a valid base64-encoding. |
| | | final Message message = ERR_LDIF_COULD_NOT_BASE64_DECODE_ATTR |
| | | final LocalizableMessage message = ERR_LDIF_COULD_NOT_BASE64_DECODE_ATTR |
| | | .get(entryDN.toString(), record.lineNumber, ldifLine, e |
| | | .getMessageObject()); |
| | | throw DecodeException.error(message); |
| | |
| | | catch (final Exception e) |
| | | { |
| | | // The URL was malformed or had an invalid protocol. |
| | | final Message message = ERR_LDIF_INVALID_URL.get(entryDN |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_URL.get(entryDN |
| | | .toString(), record.lineNumber, attrName, String |
| | | .valueOf(e)); |
| | | throw DecodeException.error(message); |
| | |
| | | { |
| | | // We were unable to read the contents of that URL for some |
| | | // reason. |
| | | final Message message = ERR_LDIF_URL_IO_ERROR.get(entryDN |
| | | final LocalizableMessage message = ERR_LDIF_URL_IO_ERROR.get(entryDN |
| | | .toString(), record.lineNumber, attrName, String |
| | | .valueOf(contentURL), String.valueOf(e)); |
| | | throw DecodeException.error(message); |
| | |
| | | else if (isContinuationLine(line)) |
| | | { |
| | | // Fatal: got a continuation line at the start of the record. |
| | | final Message message = ERR_LDIF_INVALID_LEADING_SPACE.get( |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_LEADING_SPACE.get( |
| | | lineNumber, line); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | if (validateSchema |
| | | && attributeDescription.containsOption("binary")) |
| | | { |
| | | final Message message = ERR_LDIF_INVALID_ATTR_OPTION.get(entry |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_ATTR_OPTION.get(entry |
| | | .getName().toString(), record.lineNumber, attrDescr); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | { |
| | | if (validateSchema) |
| | | { |
| | | final MessageBuilder invalidReason = new MessageBuilder(); |
| | | final LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | if (!attributeDescription.getAttributeType().getSyntax() |
| | | .valueIsAcceptable(value, invalidReason)) |
| | | { |
| | | final Message message = WARN_LDIF_VALUE_VIOLATES_SYNTAX.get( |
| | | final LocalizableMessage message = WARN_LDIF_VALUE_VIOLATES_SYNTAX.get( |
| | | entry.getName().toString(), record.lineNumber, value |
| | | .toString(), attrDescr, invalidReason); |
| | | throw DecodeException.error(message); |
| | |
| | | { |
| | | if (validateSchema) |
| | | { |
| | | final MessageBuilder invalidReason = new MessageBuilder(); |
| | | final LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | if (!attributeDescription.getAttributeType().getSyntax() |
| | | .valueIsAcceptable(value, invalidReason)) |
| | | { |
| | | final Message message = WARN_LDIF_VALUE_VIOLATES_SYNTAX.get( |
| | | final LocalizableMessage message = WARN_LDIF_VALUE_VIOLATES_SYNTAX.get( |
| | | entry.getName().toString(), record.lineNumber, value |
| | | .toString(), attrDescr, invalidReason); |
| | | throw DecodeException.error(message); |
| | |
| | | |
| | | if (!attribute.add(value)) |
| | | { |
| | | final Message message = WARN_LDIF_DUPLICATE_ATTR.get(entry |
| | | final LocalizableMessage message = WARN_LDIF_DUPLICATE_ATTR.get(entry |
| | | .getName().toString(), record.lineNumber, attrDescr, |
| | | value.toString()); |
| | | throw DecodeException.error(message); |
| | |
| | | |
| | | if (attributeDescription.getAttributeType().isSingleValue()) |
| | | { |
| | | final Message message = ERR_LDIF_MULTIPLE_VALUES_FOR_SINGLE_VALUED_ATTR |
| | | final LocalizableMessage message = ERR_LDIF_MULTIPLE_VALUES_FOR_SINGLE_VALUED_ATTR |
| | | .get(entry.getName().toString(), record.lineNumber, |
| | | attrDescr); |
| | | throw DecodeException.error(message); |
| | |
| | | int colonPos = ldifLine.indexOf(":"); |
| | | if (colonPos <= 0) |
| | | { |
| | | final Message message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | final LocalizableMessage message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | record.lineNumber, ldifLine.toString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | colonPos = ldifLine.indexOf(":"); |
| | | if (colonPos <= 0) |
| | | { |
| | | final Message message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | final LocalizableMessage message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | record.lineNumber, ldifLine.toString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | if (!attrName.equals("dn")) |
| | | { |
| | | final Message message = ERR_LDIF_NO_DN.get(record.lineNumber, |
| | | final LocalizableMessage message = ERR_LDIF_NO_DN.get(record.lineNumber, |
| | | ldifLine.toString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | catch (final LocalizedIllegalArgumentException e) |
| | | { |
| | | // The value did not have a valid base64-encoding. |
| | | final Message message = ERR_LDIF_COULD_NOT_BASE64_DECODE_DN |
| | | final LocalizableMessage message = ERR_LDIF_COULD_NOT_BASE64_DECODE_DN |
| | | .get(record.lineNumber, ldifLine, e.getMessageObject()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | } |
| | | catch (final LocalizedIllegalArgumentException e) |
| | | { |
| | | final Message message = ERR_LDIF_INVALID_DN.get( |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_DN.get( |
| | | record.lineNumber, ldifLine, e.getMessageObject()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | final int colonPos = ldifLine.indexOf(":"); |
| | | if (colonPos <= 0) |
| | | { |
| | | final Message message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | final LocalizableMessage message = ERR_LDIF_NO_ATTR_NAME.get( |
| | | record.lineNumber, ldifLine); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | if (colonPos == length - 1) |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = Message |
| | | final LocalizableMessage message = LocalizableMessage |
| | | .raw("Malformed changetype attribute"); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | { |
| | | // The value did not have a valid base64-encoding. |
| | | // FIXME: improve error. |
| | | final Message message = Message |
| | | final LocalizableMessage message = LocalizableMessage |
| | | .raw("Malformed base64 changetype attribute"); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | final void rejectLDIFRecord(LDIFRecord record, Message message) |
| | | final void rejectLDIFRecord(LDIFRecord record, LocalizableMessage message) |
| | | throws DecodeException |
| | | { |
| | | // FIXME: not yet implemented. |
| | |
| | | |
| | | |
| | | |
| | | final void skipLDIFRecord(LDIFRecord record, Message message) |
| | | final void skipLDIFRecord(LDIFRecord record, LocalizableMessage message) |
| | | { |
| | | // FIXME: not yet implemented. |
| | | } |
| | |
| | | import org.opends.sdk.requests.Requests; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | if (record == null) |
| | | { |
| | | // No change record found. |
| | | Message message = WARN_READ_LDIF_RECORD_NO_CHANGE_RECORD_FOUND |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_NO_CHANGE_RECORD_FOUND |
| | | .get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if (reader.readChangeRecord() != null) |
| | | { |
| | | // Multiple change records found. |
| | | Message message = WARN_READ_LDIF_RECORD_MULTIPLE_CHANGE_RECORDS_FOUND |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_MULTIPLE_CHANGE_RECORDS_FOUND |
| | | .get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | catch (IOException e) |
| | | { |
| | | // This should never happen for a String based reader. |
| | | Message message = WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR.get(e |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR.get(e |
| | | .getMessage()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // Skip if branch containing the entry DN is excluded. |
| | | if (isBranchExcluded(entryDN)) |
| | | { |
| | | final Message message = Message |
| | | final LocalizableMessage message = LocalizableMessage |
| | | .raw("Skipping entry because it is in excluded branch"); |
| | | skipLDIFRecord(record, message); |
| | | continue; |
| | |
| | | if (!record.iterator.hasNext()) |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = Message.raw("Missing changetype"); |
| | | final LocalizableMessage message = LocalizableMessage.raw("Missing changetype"); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = ERR_LDIF_INVALID_CHANGETYPE_ATTRIBUTE |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_CHANGETYPE_ATTRIBUTE |
| | | .get(pair.value, "add, delete, modify, moddn, modrdn"); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | if (record.iterator.hasNext()) |
| | | { |
| | | // FIXME: include line number in error. |
| | | final Message message = ERR_LDIF_INVALID_DELETE_ATTRIBUTES.get(); |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_DELETE_ATTRIBUTES.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = ERR_LDIF_INVALID_MODIFY_ATTRIBUTE.get( |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_MODIFY_ATTRIBUTE.get( |
| | | pair.key, "add, delete, replace, increment"); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | if (validateSchema |
| | | && attributeDescription.containsOption("binary")) |
| | | { |
| | | final Message message = ERR_LDIF_INVALID_ATTR_OPTION.get( |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_ATTR_OPTION.get( |
| | | entryDN.toString(), record.lineNumber, pair.value); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | if (!attributeDescription2.equals(attributeDescription)) |
| | | { |
| | | // TODO: include line number. |
| | | final Message message = ERR_LDIF_INVALID_CHANGERECORD_ATTRIBUTE |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_CHANGERECORD_ATTRIBUTE |
| | | .get(attributeDescription2.toString(), |
| | | attributeDescription.toString()); |
| | | throw DecodeException.error(message); |
| | |
| | | if (!record.iterator.hasNext()) |
| | | { |
| | | // TODO: include line number. |
| | | final Message message = ERR_LDIF_NO_MOD_DN_ATTRIBUTES.get(); |
| | | final LocalizableMessage message = ERR_LDIF_NO_MOD_DN_ATTRIBUTES.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | if (!toLowerCase(pair.key).equals("newrdn")) |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = Message.raw("Missing newrdn"); |
| | | final LocalizableMessage message = LocalizableMessage.raw("Missing newrdn"); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final LocalizedIllegalArgumentException e) |
| | | { |
| | | final Message message = ERR_LDIF_INVALID_DN.get( |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_DN.get( |
| | | record.lineNumber, ldifLine, e.getMessageObject()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | if (!record.iterator.hasNext()) |
| | | { |
| | | // TODO: include line number. |
| | | final Message message = ERR_LDIF_NO_DELETE_OLDRDN_ATTRIBUTE.get(); |
| | | final LocalizableMessage message = ERR_LDIF_NO_DELETE_OLDRDN_ATTRIBUTE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | if (!toLowerCase(pair.key).equals("deleteoldrdn")) |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = Message.raw("Missing deleteoldrdn"); |
| | | final LocalizableMessage message = LocalizableMessage.raw("Missing deleteoldrdn"); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = ERR_LDIF_INVALID_DELETE_OLDRDN_ATTRIBUTE |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_DELETE_OLDRDN_ATTRIBUTE |
| | | .get(pair.value); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | if (!toLowerCase(pair.key).equals("newsuperior")) |
| | | { |
| | | // FIXME: improve error. |
| | | final Message message = Message.raw("Missing newsuperior"); |
| | | final LocalizableMessage message = LocalizableMessage.raw("Missing newsuperior"); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final LocalizedIllegalArgumentException e) |
| | | { |
| | | final Message message = ERR_LDIF_INVALID_DN.get( |
| | | final LocalizableMessage message = ERR_LDIF_INVALID_DN.get( |
| | | record.lineNumber, ldifLine, e.getMessageObject()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.schema.Schema; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | if (entry == null) |
| | | { |
| | | // No change record found. |
| | | Message message = WARN_READ_LDIF_RECORD_NO_CHANGE_RECORD_FOUND |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_NO_CHANGE_RECORD_FOUND |
| | | .get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if (reader.readEntry() != null) |
| | | { |
| | | // Multiple change records found. |
| | | Message message = WARN_READ_LDIF_RECORD_MULTIPLE_CHANGE_RECORDS_FOUND |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_MULTIPLE_CHANGE_RECORDS_FOUND |
| | | .get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | catch (IOException e) |
| | | { |
| | | // This should never happen for a String based reader. |
| | | Message message = WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR.get(e |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_UNEXPECTED_IO_ERROR.get(e |
| | | .getMessage()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // Skip if branch containing the entry DN is excluded. |
| | | if (isBranchExcluded(entryDN)) |
| | | { |
| | | final Message message = Message |
| | | final LocalizableMessage message = LocalizableMessage |
| | | .raw("Skipping entry because it is in excluded branch"); |
| | | skipLDIFRecord(record, message); |
| | | continue; |
| | |
| | | // Skip if the entry is excluded by any filters. |
| | | if (isEntryExcluded(entry)) |
| | | { |
| | | final Message message = Message |
| | | final LocalizableMessage message = LocalizableMessage |
| | | .raw("Skipping entry due to exclusing filters"); |
| | | skipLDIFRecord(record, message); |
| | | continue; |
| | |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | import org.opends.sdk.schema.ObjectClass; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | import org.opends.sdk.schema.ObjectClass; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.sdk.AttributeDescription; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.controls.Control; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.sdk.AttributeDescription; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.controls.Control; |
| | | import org.opends.sdk.ldif.ChangeRecord; |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.ResultCode; |
| | | import org.opends.sdk.controls.Control; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.RDN; |
| | | import org.opends.sdk.controls.Control; |
| | | import org.opends.sdk.ldif.ChangeRecord; |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.RDN; |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.Change; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.ModificationType; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.controls.Control; |
| | | import org.opends.sdk.ldif.ChangeRecord; |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.opends.sdk.Change; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LinkedAttribute; |
| | | import org.opends.sdk.ModificationType; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | import org.opends.sdk.ldif.ChangeRecord; |
| | | import org.opends.sdk.ldif.LDIFChangeRecordReader; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | // Wrong change type. |
| | | Message message = WARN_READ_LDIF_RECORD_CHANGE_RECORD_WRONG_TYPE |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_CHANGE_RECORD_WRONG_TYPE |
| | | .get("add"); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | else |
| | | { |
| | | // Wrong change type. |
| | | Message message = WARN_READ_LDIF_RECORD_CHANGE_RECORD_WRONG_TYPE |
| | | LocalizableMessage message = WARN_READ_LDIF_RECORD_CHANGE_RECORD_WRONG_TYPE |
| | | .get("modify"); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | |
| | | import java.util.Collection; |
| | | |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.DereferenceAliasesPolicy; |
| | | import org.opends.sdk.Filter; |
| | | import org.opends.sdk.SearchScope; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.controls.Control; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.DereferenceAliasesPolicy; |
| | | import org.opends.sdk.Filter; |
| | | import org.opends.sdk.SearchScope; |
| | | import org.opends.sdk.*; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.controls.Control; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | import org.opends.sdk.*; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | import org.opends.sdk.controls.Control; |
| | | import org.opends.sdk.schema.ObjectClass; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.schema.ObjectClass; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message |
| | |
| | | void handle(AuthorizeCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(ChoiceCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(ConfirmationCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(LanguageCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(NameCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(PasswordCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(RealmCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(RealmChoiceCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(TextInputCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | void handle(TextOutputCallback callback) |
| | | throws UnsupportedCallbackException |
| | | { |
| | | com.sun.opends.sdk.util.Message message = |
| | | org.opends.sdk.LocalizableMessage message = |
| | | INFO_SASL_UNSUPPORTED_CALLBACK.get(getSASLBindRequest() |
| | | .getSASLMechanism(), String.valueOf(callback)); |
| | | throw new UnsupportedCallbackException(callback, message.toString()); |
| | |
| | | |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | import com.sun.security.auth.callback.TextCallbackHandler; |
| | | import com.sun.security.auth.module.Krb5LoginModule; |
| | |
| | | } |
| | | |
| | | // This should not happen. Must be a bug. |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_SASL_CONTEXT_CREATE_ERROR.get(SASL_MECHANISM_GSSAPI, |
| | | getExceptionMessage(e)); |
| | | throw new SaslException(msg.toString(), e.getCause()); |
| | |
| | | } |
| | | |
| | | // This should not happen. Must be a bug. |
| | | Message msg = |
| | | LocalizableMessage msg = |
| | | ERR_SASL_PROTOCOL_ERROR.get(SASL_MECHANISM_GSSAPI, |
| | | getExceptionMessage(e)); |
| | | throw new SaslException(msg.toString(), e.getCause()); |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | if (superiorTypeOID != null) |
| | |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUPERIOR_TYPE |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUPERIOR_TYPE |
| | | .get(getNameOrOID(), superiorTypeOID); |
| | | throw new SchemaException(message); |
| | | } |
| | |
| | | // collective, then so must the subordinate type be collective. |
| | | if (superiorType.getUsage() != getUsage()) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_SUPERIOR_USAGE |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_SUPERIOR_USAGE |
| | | .get(getNameOrOID(), getUsage().toString(), superiorType |
| | | .getNameOrOID()); |
| | | throw new SchemaException(message); |
| | |
| | | |
| | | if (superiorType.isCollective() != isCollective()) |
| | | { |
| | | Message message; |
| | | LocalizableMessage message; |
| | | if (isCollective()) |
| | | { |
| | | message = WARN_ATTR_SYNTAX_ATTRTYPE_COLLECTIVE_FROM_NONCOLLECTIVE |
| | |
| | | // never fail since the core schema is non-strict and will |
| | | // substitute the syntax if required. |
| | | syntax = Schema.getCoreSchema().getSyntax(syntaxOID); |
| | | final Message message = WARN_ATTR_TYPE_NOT_DEFINED.get( |
| | | final LocalizableMessage message = WARN_ATTR_TYPE_NOT_DEFINED.get( |
| | | getNameOrOID(), syntaxOID, syntax.toString()); |
| | | warnings.add(message); |
| | | } |
| | |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_EQUALITY_MR |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_EQUALITY_MR |
| | | .get(getNameOrOID(), equalityMatchingRuleOID); |
| | | throw new SchemaException(message); |
| | | } |
| | |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_ORDERING_MR |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_ORDERING_MR |
| | | .get(getNameOrOID(), orderingMatchingRuleOID); |
| | | throw new SchemaException(message); |
| | | } |
| | |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUBSTRING_MR |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUBSTRING_MR |
| | | .get(getNameOrOID(), substringMatchingRuleOID); |
| | | throw new SchemaException(message); |
| | | } |
| | |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_APPROXIMATE_MR |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_APPROXIMATE_MR |
| | | .get(getNameOrOID(), approximateMatchingRuleOID); |
| | | throw new SchemaException(message); |
| | | } |
| | |
| | | if (isCollective() |
| | | && getUsage() != AttributeUsage.USER_APPLICATIONS) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_COLLECTIVE_IS_OPERATIONAL |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_COLLECTIVE_IS_OPERATIONAL |
| | | .get(getNameOrOID()); |
| | | warnings.add(message); |
| | | } |
| | |
| | | if (isNoUserModification() |
| | | && getUsage() == AttributeUsage.USER_APPLICATIONS) |
| | | { |
| | | final Message message = WARN_ATTR_SYNTAX_ATTRTYPE_NO_USER_MOD_NOT_OPERATIONAL |
| | | final LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_NO_USER_MOD_NOT_OPERATIONAL |
| | | .get(getNameOrOID()); |
| | | warnings.add(message); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | // This means that the definition was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("AttributeTypeSyntax", |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | && !usageStr.equalsIgnoreCase("distributedoperation") |
| | | && !usageStr.equalsIgnoreCase("dsaoperation")) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_ATTRIBUTE_USAGE.get( |
| | | String.valueOf(oid), usageStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("AttributeTypeSyntax", |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | case '$': |
| | | break readScheme; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_AUTHPW_INVALID_SCHEME_CHAR.get(pos); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | // The scheme must consist of at least one character. |
| | | if (scheme.length() == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_AUTHPW_NO_SCHEME.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_AUTHPW_NO_SCHEME.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_AUTHPW_NO_SCHEME_SEPARATOR.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_AUTHPW_INVALID_AUTH_INFO_CHAR.get(pos); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | // The authInfo element must consist of at least one character. |
| | | if (scheme.length() == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_AUTHPW_NO_AUTH_INFO.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_AUTHPW_NO_AUTH_INFO.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_AUTHPW_NO_AUTH_INFO_SEPARATOR.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_AUTHPW_INVALID_AUTH_VALUE_CHAR.get(pos); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | // The authValue element must consist of at least one character. |
| | | if (scheme.length() == 0) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_AUTHPW_NO_AUTH_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_AUTHPW_INVALID_TRAILING_CHAR.get(pos); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the binary syntax. |
| | | return true; |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | final int length = valueString.length(); |
| | | if (length < 3) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_BIT_STRING_TOO_SHORT.get(value.toString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | || valueString.charAt(length - 2) != '\'' |
| | | || valueString.charAt(length - 1) != 'B') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_BIT_STRING_NOT_QUOTED.get(value.toString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | // These characters are fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_BIT_STRING_INVALID_BIT.get(value |
| | | .toString(), String.valueOf(valueString.charAt(i))); |
| | | throw DecodeException.error(message); |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String valueString = value.toString().toUpperCase(); |
| | | |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String valueString = value.toString().toUpperCase(); |
| | | |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | // This is not a valid character for an IA5 string. If strict |
| | | // syntax enforcement is enabled, then we'll throw an exception. |
| | | // Otherwise, we'll get rid of the character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_IA5_ILLEGAL_CHARACTER.get( |
| | | value.toString(), String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | // This is not a valid character for an IA5 string. If strict |
| | | // syntax enforcement is enabled, then we'll throw an exception. |
| | | // Otherwise, we'll get rid of the character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_IA5_ILLEGAL_CHARACTER.get( |
| | | value.toString(), String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | // This is not a valid character for an IA5 string. If strict |
| | | // syntax enforcement is enabled, then we'll throw an exception. |
| | | // Otherwise, we'll get rid of the character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_IA5_ILLEGAL_CHARACTER.get( |
| | | value.toString(), String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | // This is not a valid character for an IA5 string. If strict |
| | | // syntax enforcement is enabled, then we'll throw an exception. |
| | | // Otherwise, we'll get rid of the character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_IA5_ILLEGAL_CHARACTER.get( |
| | | value.toString(), String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the certificate list syntax. |
| | | return true; |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the certificate pair syntax. |
| | | return true; |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the certificate syntax. |
| | | return true; |
| | |
| | | |
| | | |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | */ |
| | | public ConflictingSchemaElementException(Message message) |
| | | public ConflictingSchemaElementException(LocalizableMessage message) |
| | | { |
| | | super(message); |
| | | } |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | // Package private so that we can check for warnings in the unit |
| | | // tests. |
| | | static final List<Message> CORE_SCHEMA_WARNINGS = |
| | | new LinkedList<Message>(); |
| | | static final List<LocalizableMessage> CORE_SCHEMA_WARNINGS = |
| | | new LinkedList<LocalizableMessage>(); |
| | | |
| | | static |
| | | { |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String stringValue = toLowerCase(value.toString()); |
| | | if (stringValue.length() != 2) |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | // Get the objectclass with the specified OID. If it does not exist |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_STRUCTURAL_CLASS.get( |
| | | definition, structuralClassOID); |
| | | throw new SchemaException(message, e); |
| | | } |
| | | if (structuralClass.getObjectClassType() != ObjectClassType.STRUCTURAL) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_STRUCTURAL_CLASS_NOT_STRUCTURAL.get( |
| | | definition, structuralClass.getOID(), structuralClass |
| | | .getNameOrOID(), structuralClass |
| | |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | // This isn't good because it is an unknown auxiliary class. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_AUXILIARY_CLASS.get( |
| | | definition, oid); |
| | | throw new SchemaException(message, e); |
| | |
| | | if (objectClass.getObjectClassType() != ObjectClassType.AUXILIARY) |
| | | { |
| | | // This isn't good because it isn't an auxiliary class. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_AUXILIARY_CLASS_NOT_AUXILIARY.get( |
| | | definition, structuralClass.getOID(), structuralClass |
| | | .getObjectClassType().toString()); |
| | |
| | | // This isn't good because it means that the DIT content rule |
| | | // requires an attribute type that we don't know anything |
| | | // about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR.get(definition, |
| | | oid); |
| | | throw new SchemaException(message, e); |
| | |
| | | // This isn't good because it means that the DIT content rule |
| | | // requires an attribute type that we don't know anything |
| | | // about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR.get(definition, |
| | | oid); |
| | | throw new SchemaException(message, e); |
| | |
| | | // This isn't good because it means that the DIT content rule |
| | | // requires an attribute type that we don't know anything |
| | | // about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR.get( |
| | | definition, oid); |
| | | throw new SchemaException(message, e); |
| | |
| | | { |
| | | if (structuralClass.isRequired(t)) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_PROHIBITED_REQUIRED_BY_STRUCTURAL.get( |
| | | definition, t.getNameOrOID(), structuralClass |
| | | .getNameOrOID()); |
| | |
| | | { |
| | | if (oc.isRequired(t)) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_PROHIBITED_REQUIRED_BY_AUXILIARY.get( |
| | | definition, t.getNameOrOID(), oc.getNameOrOID()); |
| | | throw new SchemaException(message); |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeDITContentRule method to determine if the |
| | | // value is acceptable. |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_DCR_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("DITConentRuleSyntax", |
| | | "valueIsAcceptable", e); |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("DITContentRuleSyntax", |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | try |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_UNKNOWN_NAME_FORM.get(definition, |
| | | nameFormOID); |
| | | throw new SchemaException(message, e); |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_UNKNOWN_RULE_ID.get(definition, id); |
| | | throw new SchemaException(message, e); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeDITStructureRule method to determine if the |
| | | // value is acceptable. |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_DSR_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("DITStructureRuleSyntax", |
| | | "valueIsAcceptable", e); |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("DITStructureRuleSyntax", |
| | |
| | | |
| | | if (nameForm == null) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_NO_NAME_FORM.get(definition); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("DITStructureRuleSyntax", |
| | |
| | | import java.util.StringTokenizer; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String stringValue = toLowerCase(value.toString()); |
| | | final StringTokenizer tokenizer = |
| | |
| | | import static com.sun.opends.sdk.messages.Messages.*; |
| | | import static com.sun.opends.sdk.util.StringPrepProfile.*; |
| | | |
| | | import org.opends.sdk.Assertion; |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | | |
| | |
| | | // This means that the value was empty or contained only |
| | | // whitespace. |
| | | // That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS.get(definition, |
| | | (reader.pos() - 1), String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | if (value.length() > 0 |
| | | || schema.getSchemaCompatOptions() |
| | |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.RDN.AVA; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string version of the provided value. |
| | | final String valueStr = toLowerCase(value.toString()); |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // The value is acceptable if it belongs to the set. |
| | | final boolean isAllowed = entries.contains(normalize(value)); |
| | | |
| | | if (!isAllowed) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_INVALID_VALUE.get(value |
| | | .toString(), oid); |
| | | invalidReason.append(message); |
| | |
| | | import java.util.HashSet; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string representation of the value and find its |
| | | // length. |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the fax syntax. |
| | | return true; |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | final int length = valueString.length(); |
| | | if (length < 11) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_TOO_SHORT.get(valueString); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("GeneralizedTimeSyntax", |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_YEAR.get( |
| | | valueString, String.valueOf(valueString.charAt(i))); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_MONTH.get( |
| | | valueString, valueString.substring(4, 6)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_MONTH.get( |
| | | valueString, valueString.substring(4, 6)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_MONTH.get( |
| | | valueString, valueString.substring(4, 6)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(6, 8)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(6, 8)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(6, 8)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(6, 8)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(6, 8)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_HOUR.get( |
| | | valueString, valueString.substring(8, 10)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_HOUR.get( |
| | | valueString, valueString.substring(8, 10)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_HOUR.get( |
| | | valueString, valueString.substring(8, 10)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_HOUR.get( |
| | | valueString, valueString.substring(8, 10)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | // must be a digit between 0 and 9. |
| | | if (length < 13) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(m1), 10); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_MINUTE.get( |
| | | valueString, valueString.substring(10, 12)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | { |
| | | // This should only happen if the provided date wasn't legal |
| | | // (e.g., September 31). |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_TIME.get( |
| | | valueString, String.valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(m1), 10); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | |
| | | // This should only happen if the provided date wasn't legal |
| | | // (e.g., September 31). |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_TIME.get( |
| | | valueString, String.valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(m1), 10); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | hour, minute, second, 3600000); |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(m1), 10); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | // must be a digit between 0 and 9. |
| | | if (length < 15) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(s1), 12); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_MINUTE.get( |
| | | valueString, valueString.substring(12, 14)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | // must be a 0. |
| | | if (length < 15) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(s1), 12); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | |
| | | if (valueString.charAt(13) != '0') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_SECOND.get( |
| | | valueString, valueString.substring(12, 14)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | |
| | | // This should only happen if the provided date wasn't legal |
| | | // (e.g., September 31). |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_TIME.get( |
| | | valueString, String.valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(s1), 12); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | |
| | | // This should only happen if the provided date wasn't legal |
| | | // (e.g., September 31). |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_TIME.get( |
| | | valueString, String.valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(s1), 12); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | hour, minute, second, 60000); |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(s1), 12); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | { |
| | | // This should only happen if the provided date wasn't legal |
| | | // (e.g., September 31). |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_TIME.get( |
| | | valueString, String.valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR |
| | | .get(valueString, String |
| | | .valueOf(valueString.charAt(14)), 14); |
| | |
| | | { |
| | | // This should only happen if the provided date wasn't legal |
| | | // (e.g., September 31). |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_TIME.get( |
| | | valueString, String.valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR |
| | | .get(valueString, String |
| | | .valueOf(valueString.charAt(14)), 14); |
| | |
| | | } |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_CHAR.get( |
| | | valueString, String.valueOf(valueString.charAt(14)), 14); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | // This is only acceptable if we're at the end of the value. |
| | | if (i != value.length() - 1) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_FRACTION_CHAR |
| | | .get(value, String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break outerLoop; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_FRACTION_CHAR |
| | | .get(value, String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | |
| | | if (fractionBuffer.length() == 2) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_EMPTY_FRACTION.get(value); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("GeneralizedTimeSyntax", |
| | |
| | | |
| | | if (timeZone == null) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_NO_TIME_ZONE_INFO |
| | | .get(value); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | |
| | | // This should only happen if the provided date wasn't legal |
| | | // (e.g., September 31). |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_ILLEGAL_TIME.get(value, |
| | | String.valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | final String offSetStr = value.substring(startPos); |
| | | if (offSetStr.length() != 3 && offSetStr.length() != 5) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get(value, |
| | | offSetStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get(value, |
| | | offSetStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get(value, |
| | | offSetStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get(value, |
| | | offSetStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get(value, |
| | | offSetStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get( |
| | | value, offSetStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get(value, |
| | | offSetStr); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | | |
| | |
| | | * valid criteria, or <CODE>false</CODE> if not. |
| | | */ |
| | | static boolean criteriaIsValid(String criteria, String valueStr, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // See if the criteria starts with a '!'. If so, then just evaluate |
| | | // everything after that as a criteria. |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string version of the provided value. |
| | | final String valueStr = toLowerCase(value.toString()); |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will allow any value that does not contain any non-ASCII |
| | | // characters. Empty values are acceptable as well. |
| | |
| | | if ((b & 0x7F) != b) |
| | | { |
| | | |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_IA5_ILLEGAL_CHARACTER.get( |
| | | value.toString(), String.valueOf(b)); |
| | | invalidReason.append(message); |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("IntegerEqualityMatchingRule", |
| | | "normalizeAttributeValue", e); |
| | | |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_ILLEGAL_INTEGER.get(value.toString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | "IntegerFirstComponentEqualityMatchingRule", "getAssertion", |
| | | e); |
| | | |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_EMR_INTFIRSTCOMP_FIRST_COMPONENT_NOT_INT.get(value |
| | | .toString()); |
| | | throw DecodeException.error(message); |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS.get(definition, |
| | | (reader.pos() - 1), String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | StaticUtils.DEBUG_LOG.throwing("IntegerOrderingMatchingRule", |
| | | "normalizeAttributeValue", e); |
| | | |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_ILLEGAL_INTEGER.get(value.toString()); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String valueString = value.toString(); |
| | | final int length = valueString.length(); |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the fax syntax. |
| | | return true; |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeNameForm method to determine if the value is |
| | | // acceptable. |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRSYNTAX_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("LDAPSyntaxDescriptionSyntax", |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRSYNTAX_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("LDAPSyntaxDescriptionSyntax", |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_PATTERN |
| | | .get(oid, pattern); |
| | | final DecodeException de = |
| | |
| | | { |
| | | if (entry.equals(values.get(j))) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_DUPLICATE_VALUE |
| | | .get(oid, entry, j); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.opends.sdk.Assertion; |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | // Try finding an implementation in the core schema |
| | |
| | | if (impl == null) |
| | | { |
| | | impl = Schema.getDefaultMatchingRule().impl; |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_MATCHING_RULE_NOT_IMPLEMENTED.get(oid, Schema |
| | | .getDefaultMatchingRule().getOID()); |
| | | warnings.add(message); |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_UNKNOWN_SYNTAX.get(getNameOrOID(), |
| | | syntaxOID); |
| | | throw new SchemaException(message, e); |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeMatchingRule method to determine if the value |
| | | // is acceptable. |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_MR_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_MR_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("MatchingRuleSyntax", |
| | | "valueIsAcceptable", e); |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("MatchingRuleSyntax", |
| | |
| | | // Make sure that a syntax was specified. |
| | | if (syntax == null) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_NO_SYNTAX.get(definition); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("MatchingRuleSyntax", |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | try |
| | |
| | | { |
| | | // This is bad because the matching rule use is associated with a |
| | | // matching rule that we don't know anything about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_MATCHING_RULE.get(definition, |
| | | oid); |
| | | throw new SchemaException(message, e); |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, attribute); |
| | | throw new SchemaException(message, e); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeAttributeType method to determine if the |
| | | // value is acceptable. |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_MRUSE_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("MatchingRuleUseSyntax", |
| | | "valueIsAcceptable", e); |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("MatchingRuleUseSyntax", |
| | |
| | | // Make sure that the set of attributes was defined. |
| | | if (attributes == null || attributes.size() == 0) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_NO_ATTR.get(definition); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("MatchingRuleUseSyntax", |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DN; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String valueString = value.toString().trim(); |
| | | final int valueLength = valueString.length(); |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | try |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_STRUCTURAL_CLASS.get(oid, |
| | | structuralClassOID); |
| | | throw new SchemaException(message, e); |
| | |
| | | { |
| | | // This is bad because the associated structural class type is not |
| | | // structural. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_STRUCTURAL_CLASS_NOT_STRUCTURAL |
| | | .get(oid, structuralClass.getOID(), structuralClass |
| | | .getNameOrOID(), String.valueOf(structuralClass |
| | |
| | | { |
| | | // This isn't good because it means that the name form requires |
| | | // an attribute type that we don't know anything about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR.get( |
| | | this.oid, oid); |
| | | throw new SchemaException(message, e); |
| | |
| | | // This isn't good because it means that the name form |
| | | // requires an attribute type that we don't know anything |
| | | // about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR.get( |
| | | this.oid, oid); |
| | | throw new SchemaException(message, e); |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeNameForm method to determine if the value is |
| | | // acceptable. |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("NameFormSyntax", |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), c); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("NameFormSyntax", |
| | |
| | | // it cannot be valid. |
| | | if (structuralClass == null) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_NO_STRUCTURAL_CLASS |
| | | .get(definition); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | |
| | | if (requiredAttributes == null || requiredAttributes.size() == 0) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_NO_REQUIRED_ATTR.get(definition); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("NameFormSyntax", |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String valueString = value.toString(); |
| | | final int length = valueString.length(); |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | if (validated) |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_SUPERIOR_CLASS.get( |
| | | oid, superClassOid); |
| | | throw new SchemaException(message, e); |
| | |
| | | // classes. |
| | | if (superiorType != ObjectClassType.ABSTRACT) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_INVALID_SUPERIOR_TYPE.get( |
| | | oid, objectClassType.toString(), superiorType |
| | | .toString(), superiorClass.getNameOrOID()); |
| | |
| | | if (superiorType != ObjectClassType.ABSTRACT |
| | | && superiorType != ObjectClassType.AUXILIARY) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_INVALID_SUPERIOR_TYPE.get( |
| | | oid, objectClassType.toString(), superiorType |
| | | .toString(), superiorClass.getNameOrOID()); |
| | |
| | | if (superiorType != ObjectClassType.ABSTRACT |
| | | && superiorType != ObjectClassType.STRUCTURAL) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_INVALID_SUPERIOR_TYPE.get( |
| | | oid, objectClassType.toString(), superiorType |
| | | .toString(), superiorClass.getNameOrOID()); |
| | |
| | | // in the superior chain. |
| | | if (!derivesTop) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_STRUCTURAL_SUPERIOR_NOT_TOP |
| | | .get(oid); |
| | | throw new SchemaException(message); |
| | |
| | | // This isn't good because it means that the objectclass |
| | | // requires an attribute type that we don't know anything |
| | | // about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_REQUIRED_ATTR.get( |
| | | oid, requiredAttribute); |
| | | throw new SchemaException(message, e); |
| | |
| | | // This isn't good because it means that the objectclass |
| | | // requires an attribute type that we don't know anything |
| | | // about. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_OPTIONAL_ATTR.get( |
| | | oid, optionalAttribute); |
| | | throw new SchemaException(message, e); |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeObjectClass method to determine if the value |
| | | // is acceptable. |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_EMPTY_VALUE.get(); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("ObjectClassSyntax", |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | final DecodeException e = DecodeException.error(message); |
| | | StaticUtils.DEBUG_LOG.throwing("ObjectClassSyntax", |
| | |
| | | |
| | | import static com.sun.opends.sdk.messages.Messages.*; |
| | | |
| | | import org.opends.sdk.Assertion; |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.*; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | | |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS.get(definition, |
| | | (reader.pos() - 1), String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the octet string syntax. |
| | | return true; |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Check to see if the provided value was null. If so, then that's |
| | | // not acceptable. |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll allow any value. |
| | | return true; |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will accept any value for this syntax. |
| | | return true; |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Check to see if the provided value was null. If so, then that's |
| | | // not acceptable. |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will accept any value for this syntax. |
| | | return true; |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final String strValue = value.toString(); |
| | | final boolean matches = pattern.matcher(strValue).matches(); |
| | | if (!matches) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_VALUE.get(strValue, |
| | | pattern.pattern()); |
| | | invalidReason.append(message); |
| | |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.responses.SearchResultEntry; |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | |
| | | * Server. |
| | | */ |
| | | public static Schema getSchema(Connection connection, String dn, |
| | | List<Message> warnings) throws ErrorResultException, |
| | | List<LocalizableMessage> warnings) throws ErrorResultException, |
| | | InterruptedException, LocalizedIllegalArgumentException, |
| | | SchemaNotFoundException |
| | | { |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.*; |
| | | |
| | |
| | | { |
| | | // This means that the definition was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_ATTRIBUTE_USAGE.get( |
| | | String.valueOf(oid), usageStr); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_DCR_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_DSR_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DSR_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | |
| | | if (nameForm == null) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_NO_NAME_FORM.get(definition); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_MR_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_MR_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // Make sure that a syntax was specified. |
| | | if (syntax == null) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_NO_SYNTAX.get(definition); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = ERR_ATTR_SYNTAX_MRUSE_EMPTY_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // Make sure that the set of attributes was defined. |
| | | if (attributes == null || attributes.size() == 0) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_NO_ATTR.get(definition); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), c); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // it cannot be valid. |
| | | if (structuralClass == null) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_NO_STRUCTURAL_CLASS |
| | | .get(definition); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | |
| | | if (requiredAttributes == null || requiredAttributes.size() == 0) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_NO_REQUIRED_ATTR.get(definition); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | { |
| | | // This means that the value was empty or contained only |
| | | // whitespace. That is illegal. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRSYNTAX_EMPTY_VALUE.get(); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRSYNTAX_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, (reader.pos() - 1), String.valueOf(c)); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_TOKEN.get(tokenName); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | * contained in this schema builder as well as the same set of |
| | | * schema compatibility options |
| | | */ |
| | | public Schema toSchema(List<Message> errorMessages) |
| | | public Schema toSchema(List<LocalizableMessage> errorMessages) |
| | | { |
| | | if (errorMessages == null) |
| | | { |
| | | errorMessages = new LinkedList<Message>(); |
| | | errorMessages = new LinkedList<LocalizableMessage>(); |
| | | } |
| | | |
| | | validate(errorMessages); |
| | |
| | | numericOID2AttributeTypes.get(attribute.getOID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_ATTRIBUTE_OID.get(attribute |
| | | .getNameOrOID(), attribute.getOID(), |
| | | conflictingAttribute.getNameOrOID()); |
| | |
| | | numericOID2ContentRules.get(rule.getStructuralClassOID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_DIT_CONTENT_RULE.get(rule |
| | | .getNameOrOID(), rule.getStructuralClassOID(), |
| | | conflictingRule.getNameOrOID()); |
| | |
| | | conflictingRule = id2StructureRules.get(rule.getRuleID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_DIT_STRUCTURE_RULE_ID.get(rule |
| | | .getNameOrRuleID(), rule.getRuleID(), conflictingRule |
| | | .getNameOrRuleID()); |
| | |
| | | conflictingRule = numericOID2MatchingRules.get(rule.getOID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_MR_OID.get(rule.getNameOrOID(), rule |
| | | .getOID(), conflictingRule.getNameOrOID()); |
| | | throw new ConflictingSchemaElementException(message); |
| | |
| | | numericOID2MatchingRuleUses.get(use.getMatchingRuleOID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_MATCHING_RULE_USE.get(use |
| | | .getNameOrOID(), use.getMatchingRuleOID(), |
| | | conflictingUse.getNameOrOID()); |
| | |
| | | conflictingForm = numericOID2NameForms.get(form.getOID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_NAME_FORM_OID.get(form |
| | | .getNameOrOID(), form.getOID(), conflictingForm |
| | | .getNameOrOID()); |
| | |
| | | conflictingOC = numericOID2ObjectClasses.get(oc.getOID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_OBJECTCLASS_OID.get(oc |
| | | .getNameOrOID(), oc.getOID(), conflictingOC |
| | | .getNameOrOID()); |
| | |
| | | conflictingSyntax = numericOID2Syntaxes.get(syntax.getOID()); |
| | | if (!overwrite) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_SYNTAX_OID.get(syntax.toString(), |
| | | syntax.getOID(), conflictingSyntax.getOID()); |
| | | throw new ConflictingSchemaElementException(message); |
| | |
| | | |
| | | |
| | | |
| | | private synchronized void validate(List<Message> warnings) |
| | | private synchronized void validate(List<LocalizableMessage> warnings) |
| | | { |
| | | // Verify all references in all elements |
| | | for (final Syntax syntax : numericOID2Syntaxes.values().toArray( |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | abstract void validate(List<Message> warnings, Schema schema) |
| | | abstract void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import com.sun.opends.sdk.util.LocalizableException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | LocalizableException |
| | | { |
| | | // The I18N message associated with this exception. |
| | | private final Message message; |
| | | private final LocalizableMessage message; |
| | | |
| | | |
| | | |
| | |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | */ |
| | | public SchemaException(Message message) |
| | | public SchemaException(LocalizableMessage message) |
| | | { |
| | | super(String.valueOf(message)); |
| | | this.message = message; |
| | |
| | | * permitted, and indicates that the cause is nonexistent or |
| | | * unknown. |
| | | */ |
| | | public SchemaException(Message message, Throwable cause) |
| | | public SchemaException(LocalizableMessage message, Throwable cause) |
| | | { |
| | | super(String.valueOf(message), cause); |
| | | this.message = message; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getMessageObject() |
| | | public LocalizableMessage getMessageObject() |
| | | { |
| | | return this.message; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import com.sun.opends.sdk.util.LocalizableException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizableException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | LocalizableException |
| | | { |
| | | // The I18N message associated with this exception. |
| | | private final Message message; |
| | | private final LocalizableMessage message; |
| | | |
| | | |
| | | |
| | |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | */ |
| | | public SchemaNotFoundException(Message message) |
| | | public SchemaNotFoundException(LocalizableMessage message) |
| | | { |
| | | super(String.valueOf(message)); |
| | | this.message = message; |
| | |
| | | * permitted, and indicates that the cause is nonexistent or |
| | | * unknown. |
| | | */ |
| | | public SchemaNotFoundException(Message message, Throwable cause) |
| | | public SchemaNotFoundException(LocalizableMessage message, Throwable cause) |
| | | { |
| | | super(String.valueOf(message), cause); |
| | | this.message = message; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Message getMessageObject() |
| | | public LocalizableMessage getMessageObject() |
| | | { |
| | | return this.message; |
| | | } |
| | |
| | | import java.util.*; |
| | | |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | |
| | | |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | |
| | | if (length == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_OID_NO_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | && c != '_') |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_CONSECUTIVE_PERIODS.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | |
| | | if (length == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_OID_NO_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_OID_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | && c != '_') |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | { |
| | | if (!isDigit(c)) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OID_ILLEGAL_CHARACTER.get(reader |
| | | .getString(), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | char c = reader.read(); |
| | | if (c != '\'') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_QUOTE_AT_POS.get(reader.pos() - 1, |
| | | String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | && c != '.') |
| | | { |
| | | // This is an illegal character. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID.get(String |
| | | .valueOf(c), reader.pos() - 1); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | final char c = reader.read(); |
| | | if (c != '\'') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_QUOTE_AT_POS.get(reader.pos() - 1, |
| | | String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | |
| | | if (length == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_RULE_ID_NO_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_RULE_ID_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final NumberFormatException e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_RULE_ID_INVALID.get(ruleID); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | if (token == null && reader.remaining() > 0) |
| | | { |
| | | reader.reset(); |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UNEXPECTED_CLOSE_PARENTHESIS.get(length); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | } |
| | | catch (final StringIndexOutOfBoundsException e) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_TRUNCATED_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.messages.Messages; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get the string representation of the value and check its length. |
| | | // A zero-length value is acceptable. A one-length value is |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the supported algorithm syntax. |
| | | return true; |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | |
| | | * with this syntax, or {@code false} if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | return impl.valueIsAcceptable(schema, value, invalidReason); |
| | | } |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<Message> warnings, Schema schema) |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | throws SchemaException |
| | | { |
| | | this.schema = schema; |
| | |
| | | final String value = values.next(); |
| | | if (value.equals(oid)) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_CYCLIC_SUB_SYNTAX.get(oid); |
| | | throw new SchemaException(message); |
| | | } |
| | | if (!schema.hasSyntax(value)) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UNKNOWN_SUB_SYNTAX.get(oid, value); |
| | | throw new SchemaException(message); |
| | | } |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_PATTERN |
| | | .get(oid, value); |
| | | throw new SchemaException(message); |
| | |
| | | if (impl == null) |
| | | { |
| | | impl = Schema.getDefaultSyntax().impl; |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_NOT_IMPLEMENTED.get(oid, Schema |
| | | .getDefaultSyntax().getOID()); |
| | | warnings.add(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get(impl |
| | | .getEqualityMatchingRule(), impl.getName()); |
| | | warnings.add(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get(impl |
| | | .getOrderingMatchingRule(), impl.getName()); |
| | | warnings.add(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get(impl |
| | | .getSubstringMatchingRule(), impl.getName()); |
| | | warnings.add(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE.get(impl |
| | | .getApproximateMatchingRule(), impl.getName()); |
| | | warnings.add(message); |
| | |
| | | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * with this syntax, or {@code false} if not. |
| | | */ |
| | | boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason); |
| | | LocalizableMessageBuilder invalidReason); |
| | | } |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // No matter what, the value can't be empty or null. |
| | | String valueStr; |
| | |
| | | // acceptable. |
| | | if (valueStr.charAt(0) != '+') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_TELEPHONE_NO_PLUS.get(valueStr); |
| | | invalidReason.append(message); |
| | | return false; |
| | |
| | | } |
| | | else if (!isSeparator(c)) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_TELEPHONE_ILLEGAL_CHAR.get(valueStr, |
| | | String.valueOf(c), i); |
| | | invalidReason.append(message); |
| | |
| | | |
| | | if (!digitSeen) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_TELEPHONE_NO_DIGITS.get(valueStr); |
| | | invalidReason.append(message); |
| | | return false; |
| | |
| | | } |
| | | |
| | | // If we made it here, then we didn't find any digits. |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_TELEPHONE_NO_DIGITS.get(valueStr); |
| | | invalidReason.append(message); |
| | | return false; |
| | |
| | | import java.util.HashSet; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string representation of the value and find its |
| | | // length. |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a string representation of the value and find its length. |
| | | final String valueString = value.toString(); |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | |
| | | |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_CANNOT_PARSE.get(valueString, String |
| | | .valueOf(e)); |
| | | final DecodeException de = DecodeException.error(message, e); |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get the value as a string and verify that it is at least long |
| | | // enough for "YYYYMMDDhhmmZ", which is the shortest allowed value. |
| | |
| | | final int length = valueString.length(); |
| | | if (length < 11) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_TOO_SHORT.get(valueString); |
| | | invalidReason.append(message); |
| | | return false; |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_YEAR.get(valueString, |
| | | String.valueOf(valueString.charAt(i))); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get(valueString, |
| | | valueString.substring(2, 4)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get(valueString, |
| | | valueString.substring(2, 4)); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get(valueString, |
| | | valueString.substring(2, 4)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(valueString, |
| | | valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(valueString, |
| | | valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(valueString, |
| | | valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(valueString, |
| | | valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get(valueString, |
| | | valueString.substring(6, 8)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get(valueString, |
| | | valueString.substring(6, 8)); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get(valueString, |
| | | valueString.substring(6, 8)); |
| | | invalidReason.append(message); |
| | |
| | | // must be a digit between 0 and 9. |
| | | if (length < 11) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, |
| | | String.valueOf(m1), 8); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MINUTE.get(valueString, |
| | | valueString.substring(8, 10)); |
| | | invalidReason.append(message); |
| | |
| | | break; |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, String |
| | | .valueOf(m1), 8); |
| | | invalidReason.append(message); |
| | |
| | | // must be a digit between 0 and 9. |
| | | if (length < 13) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, |
| | | String.valueOf(s1), 10); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_SECOND.get(valueString, |
| | | valueString.substring(10, 12)); |
| | | invalidReason.append(message); |
| | |
| | | if (length < 13) |
| | | { |
| | | |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, |
| | | String.valueOf(s1), 10); |
| | | invalidReason.append(message); |
| | |
| | | |
| | | if (valueString.charAt(11) != '0') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_SECOND.get(valueString, |
| | | valueString.substring(10, 12)); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, |
| | | String.valueOf(s1), 10); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, |
| | | String.valueOf(s1), 10); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, String |
| | | .valueOf(s1), 10); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, |
| | | String.valueOf(valueString.charAt(12)), 12); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | else |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, |
| | | String.valueOf(valueString.charAt(12)), 12); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, String |
| | | .valueOf(valueString.charAt(12)), 12); |
| | | invalidReason.append(message); |
| | |
| | | * or <CODE>false</CODE> if it is not. |
| | | */ |
| | | private boolean hasValidOffset(String value, int startPos, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | final int offsetLength = value.length() - startPos; |
| | | if (offsetLength < 2) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_TOO_SHORT.get(value); |
| | | invalidReason.append(message); |
| | | return false; |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, value |
| | | .substring(startPos, startPos + offsetLength)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, value |
| | | .substring(startPos, startPos + offsetLength)); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, value |
| | | .substring(startPos, startPos + offsetLength)); |
| | | invalidReason.append(message); |
| | |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, value |
| | | .substring(startPos, startPos + offsetLength)); |
| | | invalidReason.append(message); |
| | |
| | | } |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, value |
| | | .substring(startPos, startPos + offsetLength)); |
| | | invalidReason.append(message); |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | if (value.length() != 36) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value.toString(), |
| | | value.length()); |
| | | throw DecodeException.error(message); |
| | |
| | | case 23: |
| | | if (c != '-') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value.toString(), |
| | | i, String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | builder.append('f'); |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value.toString(), |
| | | i, String.valueOf(value.byteAt(i))); |
| | | throw DecodeException.error(message); |
| | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.ByteString; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | if (value.length() != 36) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value.toString(), |
| | | value.length()); |
| | | throw DecodeException.error(message); |
| | |
| | | case 23: |
| | | if (c != '-') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value.toString(), |
| | | i, String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | |
| | | builder.append('f'); |
| | | break; |
| | | default: |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value.toString(), |
| | | i, String.valueOf(value.byteAt(i))); |
| | | throw DecodeException.error(message); |
| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | * use with this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will only accept values that look like valid UUIDs. This means |
| | | // that all values must be in the form |
| | |
| | | |
| | | |
| | | |
| | | import com.sun.opends.sdk.util.LocalizedIllegalArgumentException; |
| | | import com.sun.opends.sdk.util.Message; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | */ |
| | | public UnknownSchemaElementException(Message message) |
| | | public UnknownSchemaElementException(LocalizableMessage message) |
| | | { |
| | | super(message); |
| | | } |
| | |
| | | |
| | | import org.opends.sdk.ByteSequence; |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizableMessageBuilder; |
| | | |
| | | import com.sun.opends.sdk.util.Message; |
| | | import com.sun.opends.sdk.util.MessageBuilder; |
| | | |
| | | |
| | | |
| | |
| | | // Make sure that there actually is a value to decode. |
| | | if (userPasswordValue == null || userPasswordValue.length() == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_USERPW_NO_VALUE.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_USERPW_NO_VALUE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | // brace. |
| | | if (userPasswordValue.charAt(0) != '{') |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_USERPW_NO_OPENING_BRACE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | final int closePos = userPasswordValue.indexOf('}'); |
| | | if (closePos < 0) |
| | | { |
| | | final Message message = |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_USERPW_NO_CLOSING_BRACE.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | |
| | | if (schemeName.length() == 0) |
| | | { |
| | | final Message message = ERR_ATTR_SYNTAX_USERPW_NO_SCHEME.get(); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_USERPW_NO_SCHEME.get(); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | public boolean valueIsAcceptable(Schema schema, ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We have to accept any value here because in many cases the value |
| | | // will not have been encoded by the time this method is called. |