out.print("version=" + URLEncoder.encode(version) + '&'); out.print("username=" + URLEncoder.encode(user) + '&'); out.print("password=" + URLEncoder.encode(password));
out.print("version=" + URLEncoder.encode(version,"UTF-8") + '&'); out.print("username=" + URLEncoder.encode(user,"UTF-8") + '&'); out.print("password=" + URLEncoder.encode(password,"UTF-8"));
    private UserAuthData getDNfromRemote(String version, String user, String password)        throws NamingException, IOException {        debug(">getDNfromRemote(" + version + ", " + user + ", " + password + ")");        // Connect to url and do our stuff...        URL url = new URL(remoteurl);        HttpURLConnection connection = (HttpURLConnection) url.openConnection();        connection.setDoOutput(true);        connection.setRequestMethod("POST");        {            PrintWriter out = new PrintWriter(connection.getOutputStream());            out.print("version=" + URLEncoder.encode(version) + '&');            out.print("username=" + URLEncoder.encode(user) + '&');            out.print("password=" + URLEncoder.encode(password));            out.close();        }        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));        if ((in.readLine().indexOf("status=200 OK") >= 0) &&                (in.readLine().indexOf("result=grant") >= 0)) {            String dname = "";            String email = null;            final String preFix = "dn-";            while (true) {                final String line = in.readLine();                if (line == null) {                    break;                }                line.trim();                if (line.indexOf('=') > 0) {                    if (line.indexOf(preFix) == 0) {                        if (line.substring(preFix.length()).indexOf("email") == 0) {                            email = line.substring(preFix.length() + 6);                        } else {                            if (dname.length() > 0) {                                dname += ", ";                            }                            dname += line.substring(preFix.length());                        }                    } else {                        dname += line;                    }                }            }            UserAuthData ret = new UserAuthData();            ret.setDN(dname);            ret.setEmail(email);            debug("<getDNfromRemote");            return ret;        }        debug("<getDNfromRemote");        return null;    }