Loading cadc-access-control/src/main/java/ca/nrc/cadc/ac/client/GMSClient.java +32 −63 Original line number Original line Diff line number Diff line Loading @@ -629,46 +629,30 @@ public class GMSClient implements TransferListener // reset the state of the cache // reset the state of the cache clearCache(); clearCache(); HttpURLConnection conn = HttpDelete delete = new HttpDelete(removeGroupMemberURL, true); (HttpURLConnection) removeGroupMemberURL.openConnection(); delete.setSSLSocketFactory(getSSLSocketFactory()); conn.setRequestMethod("DELETE"); delete.run(); SSLSocketFactory sf = getSSLSocketFactory(); if ((sf != null) && ((conn instanceof HttpsURLConnection))) { ((HttpsURLConnection) conn) .setSSLSocketFactory(getSSLSocketFactory()); } // Try to handle anonymous access and throw AccessControlException int responseCode = -1; try { responseCode = conn.getResponseCode(); } catch (Exception ignore) {} if (responseCode != 200) Throwable error = delete.getThrowable(); if (error != null) { { String errMessage = NetUtil.getErrorBody(conn); // transfer returns a -1 code for anonymous access. log.debug("removeGroupMember response " + responseCode + ": " + if ((delete.getResponseCode() == -1) || errMessage); (delete.getResponseCode() == 401) || (delete.getResponseCode() == 403)) if ((responseCode == -1) || (responseCode == 401) || (responseCode == 403)) { { throw new AccessControlException(errMessage); throw new AccessControlException(error.getMessage()); } } if (responseCode == 400) if (delete.getResponseCode() == 400) { { throw new IllegalArgumentException(errMessage); throw new IllegalArgumentException(error.getMessage()); } } if (responseCode == 404) if (delete.getResponseCode() == 404) { { throw new GroupNotFoundException(errMessage); throw new GroupNotFoundException(error.getMessage()); } } throw new IOException(errMessage); throw new IOException(error); } } } } Loading Loading @@ -698,49 +682,34 @@ public class GMSClient implements TransferListener // reset the state of the cache // reset the state of the cache clearCache(); clearCache(); HttpURLConnection conn = HttpDelete delete = new HttpDelete(removeUserMemberURL, true); (HttpURLConnection) removeUserMemberURL.openConnection(); delete.setSSLSocketFactory(getSSLSocketFactory()); conn.setRequestMethod("DELETE"); delete.run(); SSLSocketFactory sf = getSSLSocketFactory(); if ((sf != null) && ((conn instanceof HttpsURLConnection))) { ((HttpsURLConnection) conn) .setSSLSocketFactory(getSSLSocketFactory()); } // Try to handle anonymous access and throw AccessControlException int responseCode = -1; try { responseCode = conn.getResponseCode(); } catch (Exception ignore) {} if (responseCode != 200) Throwable error = delete.getThrowable(); if (error != null) { { String errMessage = NetUtil.getErrorBody(conn); // transfer returns a -1 code for anonymous access. log.debug("removeUserMember response " + responseCode + ": " + if ((delete.getResponseCode() == -1) || errMessage); (delete.getResponseCode() == 401) || (delete.getResponseCode() == 403)) if ((responseCode == -1) || (responseCode == 401) || (responseCode == 403)) { { throw new AccessControlException(errMessage); throw new AccessControlException(error.getMessage()); } } if (responseCode == 400) if (delete.getResponseCode() == 400) { { throw new IllegalArgumentException(errMessage); throw new IllegalArgumentException(error.getMessage()); } } if (responseCode == 404) if (delete.getResponseCode() == 404) { { String errMessage = error.getMessage(); if (errMessage != null && errMessage.toLowerCase().contains("user")) if (errMessage != null && errMessage.toLowerCase().contains("user")) throw new UserNotFoundException(errMessage); throw new UserNotFoundException(errMessage); else else throw new GroupNotFoundException(errMessage); throw new GroupNotFoundException(errMessage); } } throw new IOException(errMessage); throw new IOException(error); } } } } Loading Loading
cadc-access-control/src/main/java/ca/nrc/cadc/ac/client/GMSClient.java +32 −63 Original line number Original line Diff line number Diff line Loading @@ -629,46 +629,30 @@ public class GMSClient implements TransferListener // reset the state of the cache // reset the state of the cache clearCache(); clearCache(); HttpURLConnection conn = HttpDelete delete = new HttpDelete(removeGroupMemberURL, true); (HttpURLConnection) removeGroupMemberURL.openConnection(); delete.setSSLSocketFactory(getSSLSocketFactory()); conn.setRequestMethod("DELETE"); delete.run(); SSLSocketFactory sf = getSSLSocketFactory(); if ((sf != null) && ((conn instanceof HttpsURLConnection))) { ((HttpsURLConnection) conn) .setSSLSocketFactory(getSSLSocketFactory()); } // Try to handle anonymous access and throw AccessControlException int responseCode = -1; try { responseCode = conn.getResponseCode(); } catch (Exception ignore) {} if (responseCode != 200) Throwable error = delete.getThrowable(); if (error != null) { { String errMessage = NetUtil.getErrorBody(conn); // transfer returns a -1 code for anonymous access. log.debug("removeGroupMember response " + responseCode + ": " + if ((delete.getResponseCode() == -1) || errMessage); (delete.getResponseCode() == 401) || (delete.getResponseCode() == 403)) if ((responseCode == -1) || (responseCode == 401) || (responseCode == 403)) { { throw new AccessControlException(errMessage); throw new AccessControlException(error.getMessage()); } } if (responseCode == 400) if (delete.getResponseCode() == 400) { { throw new IllegalArgumentException(errMessage); throw new IllegalArgumentException(error.getMessage()); } } if (responseCode == 404) if (delete.getResponseCode() == 404) { { throw new GroupNotFoundException(errMessage); throw new GroupNotFoundException(error.getMessage()); } } throw new IOException(errMessage); throw new IOException(error); } } } } Loading Loading @@ -698,49 +682,34 @@ public class GMSClient implements TransferListener // reset the state of the cache // reset the state of the cache clearCache(); clearCache(); HttpURLConnection conn = HttpDelete delete = new HttpDelete(removeUserMemberURL, true); (HttpURLConnection) removeUserMemberURL.openConnection(); delete.setSSLSocketFactory(getSSLSocketFactory()); conn.setRequestMethod("DELETE"); delete.run(); SSLSocketFactory sf = getSSLSocketFactory(); if ((sf != null) && ((conn instanceof HttpsURLConnection))) { ((HttpsURLConnection) conn) .setSSLSocketFactory(getSSLSocketFactory()); } // Try to handle anonymous access and throw AccessControlException int responseCode = -1; try { responseCode = conn.getResponseCode(); } catch (Exception ignore) {} if (responseCode != 200) Throwable error = delete.getThrowable(); if (error != null) { { String errMessage = NetUtil.getErrorBody(conn); // transfer returns a -1 code for anonymous access. log.debug("removeUserMember response " + responseCode + ": " + if ((delete.getResponseCode() == -1) || errMessage); (delete.getResponseCode() == 401) || (delete.getResponseCode() == 403)) if ((responseCode == -1) || (responseCode == 401) || (responseCode == 403)) { { throw new AccessControlException(errMessage); throw new AccessControlException(error.getMessage()); } } if (responseCode == 400) if (delete.getResponseCode() == 400) { { throw new IllegalArgumentException(errMessage); throw new IllegalArgumentException(error.getMessage()); } } if (responseCode == 404) if (delete.getResponseCode() == 404) { { String errMessage = error.getMessage(); if (errMessage != null && errMessage.toLowerCase().contains("user")) if (errMessage != null && errMessage.toLowerCase().contains("user")) throw new UserNotFoundException(errMessage); throw new UserNotFoundException(errMessage); else else throw new GroupNotFoundException(errMessage); throw new GroupNotFoundException(errMessage); } } throw new IOException(errMessage); throw new IOException(error); } } } } Loading