| | |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | MessageBuilder invalidReason) |
| | | { |
| | | // We have to accept any value here because in many cases the value will not |
| | |
| | | * @return <CODE>true</CODE> if the value appears to be encoded using the |
| | | * user password syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public static boolean isEncoded(ByteString value) |
| | | public static boolean isEncoded(ByteSequence value) |
| | | { |
| | | // If the value is null or empty, then it's not. |
| | | byte[] valueBytes; |
| | | if ((value == null) || ((valueBytes = value.value()).length == 0)) |
| | | if ((value == null) || value.length() == 0) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If the value doesn't start with an opening curly brace, then it's not. |
| | | if (valueBytes[0] != '{') |
| | | if (value.byteAt(0) != '{') |
| | | { |
| | | return false; |
| | | } |
| | |
| | | // There must be a corresponding closing curly brace, and there must be at |
| | | // least one character inside the brace. |
| | | int closingBracePos = -1; |
| | | for (int i=1; i < valueBytes.length; i++) |
| | | for (int i=1; i < value.length(); i++) |
| | | { |
| | | if (valueBytes[i] == '}') |
| | | if (value.byteAt(i) == '}') |
| | | { |
| | | closingBracePos = i; |
| | | break; |
| | |
| | | |
| | | |
| | | // The closing curly brace must not be the last character of the password. |
| | | if (closingBracePos == (valueBytes.length - 1)) |
| | | if (closingBracePos == (value.length() - 1)) |
| | | { |
| | | return false; |
| | | } |