case ' ':
case '$':
break readScheme;
default:
Message message = ERR_ATTR_SYNTAX_AUTHPW_INVALID_SCHEME_CHAR.get(pos);
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
}
// The scheme must consist of at least one character.
if (scheme.length() == 0)
{
Message message = ERR_ATTR_SYNTAX_AUTHPW_NO_SCHEME.get();
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
// Ignore any spaces before the dollar sign separator. Then read the dollar
// sign and ignore any trailing spaces.
while ((pos < length) && (authPasswordValue.charAt(pos) == ' '))
{
pos++;
}
if ((pos < length) && (authPasswordValue.charAt(pos) == '$'))
{
pos++;
}
else
{
Message message = ERR_ATTR_SYNTAX_AUTHPW_NO_SCHEME_SEPARATOR.get();
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
while ((pos < length) && (authPasswordValue.charAt(pos) == ' '))
{
pos++;
}
// The next component must be the authInfo element, containing only
// printable characters other than the dollar sign and space character.
readAuthInfo:
while (pos < length)
{
char c = authPasswordValue.charAt(pos);
if ((c == ' ') || (c == '$'))
{
break readAuthInfo;
}
else if (PrintableString.isPrintableCharacter(c))
{
authInfo.append(c);
pos++;
}
else
{
Message message =
ERR_ATTR_SYNTAX_AUTHPW_INVALID_AUTH_INFO_CHAR.get(pos);
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
}
// The authInfo element must consist of at least one character.
if (scheme.length() == 0)
{
Message message = ERR_ATTR_SYNTAX_AUTHPW_NO_AUTH_INFO.get();
throw new DirectoryException(
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
// Ignore any spaces before the dollar sign separator. Then read the dollar
// sign and ignore any trailing spaces.
while ((pos < length) && (authPasswordValue.charAt(pos) == ' '))
{
pos++;
}
if ((pos < length) && (authPasswordValue.charAt(pos) == '$'))
{
pos++;
}
else
{
Message message = ERR_ATTR_SYNTAX_AUTHPW_NO_AUTH_INFO_SEPARATOR.get();
throw new DirectoryException(
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
while ((pos < length) && (authPasswordValue.charAt(pos) == ' '))
{
pos++;
}
// The final component must be the authValue element, containing only
// printable characters other than the dollar sign and space character.
while (pos < length)
{
char c = authPasswordValue.charAt(pos);
if ((c == ' ') || (c == '$'))
{
break ;
}
else if (PrintableString.isPrintableCharacter(c))
{
authValue.append(c);
pos++;
}
else
{
Message message =
ERR_ATTR_SYNTAX_AUTHPW_INVALID_AUTH_VALUE_CHAR.get(pos);
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
}
// The authValue element must consist of at least one character.
if (scheme.length() == 0)
{
Message message = ERR_ATTR_SYNTAX_AUTHPW_NO_AUTH_VALUE.get();
throw new DirectoryException(
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
// The only characters remaining must be whitespace.
while (pos < length)
{
char c = authPasswordValue.charAt(pos);
if (c == ' ')
{
pos++;
}
else
{
Message message = ERR_ATTR_SYNTAX_AUTHPW_INVALID_TRAILING_CHAR.get(pos);
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
}