public void setUserinfo(String p_userinfo) throws MalformedURIException {

    if (p_userinfo == null) {
      m_userinfo = null;
    }
    else {
      if (m_host == null) {
        throw new MalformedURIException(
            Messages.getString("URI.userinfoCannotBeSetWhenHostIsNull")); //$NON-NLS-1$
      }

      // userinfo can contain alphanumerics, mark characters, escaped
      // and ';',':','&','=','+','$',','
      int index = 0;
      int end = p_userinfo.length();
      char testChar = '\0';

      while (index < end) {
        testChar = p_userinfo.charAt(index);

        if (testChar == '%') {
          if (index + 2 >= end || !isHex(p_userinfo.charAt(index + 1)) ||
              !isHex(p_userinfo.charAt(index + 2))) {
            throw new MalformedURIException(
                Messages.getString("URI.userinfoContainsInvalidEscapeSequence")); //$NON-NLS-1$
          }
        }
        else
        if (!isUnreservedCharacter(testChar) &&
            USERINFO_CHARACTERS.indexOf(testChar) == -1) {
          throw new MalformedURIException(
              MessageFormat.format(Messages.getString("URI.userinfoContainsInvalidCharacter"), new Object[] { String.valueOf(testChar) } ) ); //$NON-NLS-1$
        }

        index++;
      }
    }

    m_userinfo = p_userinfo;
  }