code: public static String stringTo8859_1(String str)
              throws UnsupportedEncodingException {
          if (str == null) {
              return "";
          }
  
          return new String(str.getBytes("UTF8"), "8859_1");
      }
docs: Used to convert username-value, passwd or realm to 8859_1 encoding
  if all chars in string are within the 8859_1 (Latin 1) encoding range.
  
  @param str a non-null String
  @return a non-null String containing the 8859_1 encoded string
  @throws AuthenticationException