Loading projects/cadcAccessControl/src/ca/nrc/cadc/ac/client/GMSClient.java +12 −9 Original line number Original line Diff line number Diff line Loading @@ -78,6 +78,7 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.MalformedURLException; import java.net.URL; import java.net.URL; import java.net.URLEncoder; import java.net.URLEncoder; import java.nio.charset.Charset; import java.security.AccessControlContext; import java.security.AccessControlContext; import java.security.AccessControlException; import java.security.AccessControlException; import java.security.AccessController; import java.security.AccessController; Loading Loading @@ -313,15 +314,13 @@ public class GMSClient URL getGroupNamesURL = new URL(this.baseURL + "/groups"); URL getGroupNamesURL = new URL(this.baseURL + "/groups"); log.debug("getGroupNames request to " + getGroupNamesURL.toString()); log.debug("getGroupNames request to " + getGroupNamesURL.toString()); HttpURLConnection conn = HttpURLConnection conn = (HttpURLConnection) getGroupNamesURL.openConnection(); (HttpURLConnection) getGroupNamesURL.openConnection(); conn.setRequestMethod("GET"); conn.setRequestMethod("GET"); SSLSocketFactory sf = getSSLSocketFactory(); SSLSocketFactory sf = getSSLSocketFactory(); if ((sf != null) && ((conn instanceof HttpsURLConnection))) if ((sf != null) && ((conn instanceof HttpsURLConnection))) { { ((HttpsURLConnection) conn) ((HttpsURLConnection) conn).setSSLSocketFactory(sf); .setSSLSocketFactory(sf); } } int responseCode = -1; int responseCode = -1; try try Loading @@ -332,11 +331,12 @@ public class GMSClient { { throw new AccessControlException(e.getMessage()); throw new AccessControlException(e.getMessage()); } } log.debug("getGroupNames response " + responseCode); if (responseCode != 200) if (responseCode != 200) { { String errMessage = NetUtil.getErrorBody(conn); String errMessage = NetUtil.getErrorBody(conn); log.debug("deleteGroup response " + responseCode + ": " + log.debug("getGroupNames response " + responseCode + ": " + errMessage); errMessage); if ((responseCode == 401) || (responseCode == 403) || if ((responseCode == 401) || (responseCode == 403) || Loading @@ -351,17 +351,20 @@ public class GMSClient throw new IOException("HttpResponse (" + responseCode + ") - " + errMessage); throw new IOException("HttpResponse (" + responseCode + ") - " + errMessage); } } log.error("Content-Length: " + conn.getHeaderField("Content-Length")); log.error("Content-Type: " + conn.getHeaderField("Content-Type")); try try { { List<String> groupNames = new ArrayList<String>(); List<String> groupNames = new ArrayList<String>(); Reader ioReader = new InputStreamReader(conn.getInputStream()); CsvReader reader = new CsvReader(conn.getInputStream(), ',', Charset.forName("UTF-8")); BufferedReader br = new BufferedReader(ioReader); if (reader.readRecord()) CsvReader reader = new CsvReader(br); { for (int i = 0; i < reader.getColumnCount(); i++) for (int i = 0; i < reader.getColumnCount(); i++) { { groupNames.add(reader.get(i)); groupNames.add(reader.get(i)); } } } return groupNames; return groupNames; } } Loading Loading
projects/cadcAccessControl/src/ca/nrc/cadc/ac/client/GMSClient.java +12 −9 Original line number Original line Diff line number Diff line Loading @@ -78,6 +78,7 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.MalformedURLException; import java.net.URL; import java.net.URL; import java.net.URLEncoder; import java.net.URLEncoder; import java.nio.charset.Charset; import java.security.AccessControlContext; import java.security.AccessControlContext; import java.security.AccessControlException; import java.security.AccessControlException; import java.security.AccessController; import java.security.AccessController; Loading Loading @@ -313,15 +314,13 @@ public class GMSClient URL getGroupNamesURL = new URL(this.baseURL + "/groups"); URL getGroupNamesURL = new URL(this.baseURL + "/groups"); log.debug("getGroupNames request to " + getGroupNamesURL.toString()); log.debug("getGroupNames request to " + getGroupNamesURL.toString()); HttpURLConnection conn = HttpURLConnection conn = (HttpURLConnection) getGroupNamesURL.openConnection(); (HttpURLConnection) getGroupNamesURL.openConnection(); conn.setRequestMethod("GET"); conn.setRequestMethod("GET"); SSLSocketFactory sf = getSSLSocketFactory(); SSLSocketFactory sf = getSSLSocketFactory(); if ((sf != null) && ((conn instanceof HttpsURLConnection))) if ((sf != null) && ((conn instanceof HttpsURLConnection))) { { ((HttpsURLConnection) conn) ((HttpsURLConnection) conn).setSSLSocketFactory(sf); .setSSLSocketFactory(sf); } } int responseCode = -1; int responseCode = -1; try try Loading @@ -332,11 +331,12 @@ public class GMSClient { { throw new AccessControlException(e.getMessage()); throw new AccessControlException(e.getMessage()); } } log.debug("getGroupNames response " + responseCode); if (responseCode != 200) if (responseCode != 200) { { String errMessage = NetUtil.getErrorBody(conn); String errMessage = NetUtil.getErrorBody(conn); log.debug("deleteGroup response " + responseCode + ": " + log.debug("getGroupNames response " + responseCode + ": " + errMessage); errMessage); if ((responseCode == 401) || (responseCode == 403) || if ((responseCode == 401) || (responseCode == 403) || Loading @@ -351,17 +351,20 @@ public class GMSClient throw new IOException("HttpResponse (" + responseCode + ") - " + errMessage); throw new IOException("HttpResponse (" + responseCode + ") - " + errMessage); } } log.error("Content-Length: " + conn.getHeaderField("Content-Length")); log.error("Content-Type: " + conn.getHeaderField("Content-Type")); try try { { List<String> groupNames = new ArrayList<String>(); List<String> groupNames = new ArrayList<String>(); Reader ioReader = new InputStreamReader(conn.getInputStream()); CsvReader reader = new CsvReader(conn.getInputStream(), ',', Charset.forName("UTF-8")); BufferedReader br = new BufferedReader(ioReader); if (reader.readRecord()) CsvReader reader = new CsvReader(br); { for (int i = 0; i < reader.getColumnCount(); i++) for (int i = 0; i < reader.getColumnCount(); i++) { { groupNames.add(reader.get(i)); groupNames.add(reader.get(i)); } } } return groupNames; return groupNames; } } Loading