Friday, June 28, 2013

HTTP Authentication for HttpURLConnection

Here is the piece of code which you can use for HTTP Authentication while connecting to CQ url:

                final String login ="admin";
                final String password ="admin";
                Authenticator.setDefault(new Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication (login, password.toCharArray());

              String webPage ="http://localhost:8502/etc/workflow/models/translation?path=test";
              URL url = new URL(webPage);
              URLConnection urlConnection = url.openConnection();

No comments:

Post a Comment