| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.sdk; |
| | |
| | | // Skip over any spaces at the beginning. |
| | | reader.skipWhitespaces(); |
| | | |
| | | if (reader.remaining() == 0) |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_NO_NAME |
| | | .get(reader.getString()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | | final AttributeType attribute = readAttributeName(reader, schema); |
| | | |
| | | // Skip over any spaces if we have. |
| | | reader.skipWhitespaces(); |
| | | |
| | | // Make sure that we're not at the end of the DN string because |
| | | // that would be invalid. |
| | | if (reader.remaining() == 0) |
| | |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | | // Skip over any spaces if we have. |
| | | reader.skipWhitespaces(); |
| | | |
| | | // The next character must be an equal sign. If it is not, then |
| | | // that's an error. |
| | | char c; |
| | |
| | | { |
| | | final LocalizableMessage message = ERR_HEX_DECODE_INVALID_LENGTH |
| | | .get(hexBuffer); |
| | | DecodeException.error(message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | int pos = 0; |
| | |
| | | { |
| | | final LocalizableMessage msg = ERR_ATTR_SYNTAX_DN_ESCAPED_HEX_VALUE_INVALID |
| | | .get(reader.getString()); |
| | | DecodeException.error(msg); |
| | | throw DecodeException.error(msg); |
| | | } |
| | | |
| | | // Check the next byte for hex. |
| | | final char c2 = reader.read(); |
| | | if (isHexDigit(c2)) |
| | |
| | | { |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ESCAPED_HEX_VALUE_INVALID |
| | | .get(reader.getString()); |
| | | DecodeException.error(message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (isDigit(c)) |
| | | { |
| | | boolean lastWasPeriod = false; |
| | | while (reader.remaining() > 0 && (c = reader.read()) != '=') |
| | | while (reader.remaining() > 0) |
| | | { |
| | | if (c == '.') |
| | | c = reader.read(); |
| | | |
| | | if (c == '=' || c == ' ') |
| | | { |
| | | // This signals the end of the OID. |
| | | break; |
| | | } |
| | | else if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | |
| | | while (reader.remaining() > 0) |
| | | { |
| | | c = reader.read(); |
| | | if (length == 0 && !isAlpha(c)) |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR |
| | | .get(reader.getString(), c, reader.pos() - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | |
| | | if (c == '=') |
| | | if (c == '=' || c == ' ') |
| | | { |
| | | // End of the attribute. |
| | | // This signals the end of the OID. |
| | | break; |
| | | } |
| | | else if (c == ' ') |
| | | { |
| | | // Got a whitespace.It MUST be the end of the attribute |
| | | // Make sure that the next non-whitespace character is '='. |
| | | reader.skipWhitespaces(); |
| | | // Read back the next char. |
| | | c = reader.read(); |
| | | if (c == '=') |
| | | { |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal character. |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_DN_ATTR_ILLEGAL_CHAR |
| | | .get(reader.getString(), c, reader.pos() - 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | } |
| | | else if (!isAlpha(c) && !isDigit(c) && c != '-') |
| | | { |
| | | // This is an illegal character. |