/** * Get memberships for the current user (subject). * * @param role * @return A list of groups for which the current user has the role. * @throws AccessControlException * @throws ca.nrc.cadc.ac.UserNotFoundException * @throws java.io.IOException */ public List<Group> getMemberships(Role role) throws UserNotFoundException, AccessControlException, IOException { return getMemberships(null, role); }
private static boolean isMember(GMSClient gmsClient, URI grantingGroup) throws AccessControlException { try { if (CredUtil.checkCredentials()) { List<Group> groups = gmsClient.getMemberships(Role.MEMBER); for (Group group : groups) { if (group.getID().getURI().equals(grantingGroup)) { log.debug("group match: " + grantingGroup); return true; } } } } catch (UserNotFoundException ex) { throw new RuntimeException("failed to find group memberships (unknown user)", ex); } catch (CertificateException ex) { throw new RuntimeException("failed to find group memberships (invalid proxy certficate)", ex); } catch (IOException ex) { throw new RuntimeException("failed to find group memberships", ex); } log.debug("no group match"); return false; } }