@Test public void testGetResponse() throws Exception { RestCommunicationHandler.getResponse("https: }
public static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth) throws IOException { if(doAuth && (encodedAuth == null || encodedAuth.trim().length() == 0) ){ throw new IllegalArgumentException("Authorization cretentials missing"); } ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth){ conn.setRequestProperty("Authorization", authType + encodedAuth); } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); }
RestCommunicationHandler { public static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth) throws IOException { if(doAuth && (encodedAuth == null || encodedAuth.trim().length() == 0) ){ throw new IllegalArgumentException("Authorization cretentials missing"); } ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth){ conn.setRequestProperty("Authorization", authType + encodedAuth); } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } }
RestCommunicationHandler { public static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth) throws IOException { if(doAuth && (encodedAuth == null || encodedAuth.trim().length() == 0) ){ throw new IllegalArgumentException("Authorization cretentials missing"); } ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth){ conn.setRequestProperty("Authorization", authType + encodedAuth); } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } private  RestCommunicationHandler(); }
RestCommunicationHandler { public static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth) throws IOException { if(doAuth && (encodedAuth == null || encodedAuth.trim().length() == 0) ){ throw new IllegalArgumentException("Authorization cretentials missing"); } ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth){ conn.setRequestProperty("Authorization", authType + encodedAuth); } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } private  RestCommunicationHandler(); static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth); static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred); }
RestCommunicationHandler { public static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth) throws IOException { if(doAuth && (encodedAuth == null || encodedAuth.trim().length() == 0) ){ throw new IllegalArgumentException("Authorization cretentials missing"); } ProxyUtil.disableCertificates(); ProxyUtil.setProxy(); StringBuilder stb = new StringBuilder(); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("GET"); conn.setRequestProperty("Content-Type", "application/json"); if(doAuth){ conn.setRequestProperty("Authorization", authType + encodedAuth); } BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); String output; while ((output = br.readLine()) != null) { stb.append(output); } conn.disconnect(); return stb.toString(); } private  RestCommunicationHandler(); static String getResponse(String urlStr, Boolean doAuth, String authType, String encodedAuth); static String postRequest(String urlStr, Boolean doAuth, String encodedAuth, String jsonCred);  }