private String cipherDoFinal(Cipher cipher, String base64Encoded) {
   try {
     byte[] encrypted = cipher.doFinal(Base64.decode(base64Encoded));
     return Base64.encodeToString(encrypted);
   } catch (BadPaddingException e) {
     throw new RuntimeException(e);
   } catch (IllegalBlockSizeException e) {
     throw new RuntimeException(e);
   }
 }
  public void authenticate(String uname, String paswd, String uri) {
    String encoded = Base64.encodeToString((uname + ":" + paswd).getBytes());

    try {
      URL url = new URL(uri);
      try {
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("Authorization", "Basic " + encoded);
        System.out.println("response " + conn.getResponseCode());
        new Display().displayBuffer(conn.getInputStream());
      } catch (IOException e) {
        System.out.println("HttpBasicAuth IOException");
        e.printStackTrace();
      }
    } catch (MalformedURLException e) {
      System.out.println("HttpBasicAuth MalformedURLException");
      e.printStackTrace();
    }
  }