short mode = (short) 0; for (GrantAndPermission gp : acl.getGrantAndPermissions()) { Permission perm = gp.getPermission(); GranteeInterface grantee = gp.getGrantee(); if (perm.equals(Permission.PERMISSION_READ)) { if (isUserIdInGrantee(grantee, userId)) {
/** * Revokes the permissions of a grantee by removing the grantee from the ACL. * * @param grantee * the grantee to remove from this ACL. */ public void revokeAllPermissions(GranteeInterface grantee) { List<GrantAndPermission> grantsToRemove = new ArrayList<GrantAndPermission>(); for (GrantAndPermission gap: grants) { if (gap.getGrantee().equals(grantee)) { grantsToRemove.add(gap); } } grants.removeAll(grantsToRemove); }
/** * Adds a grantee to the ACL with the given permission. If this ACL already contains the grantee * (ie the same grantee object) the permission for the grantee will be updated. * * @param grantee * the grantee to whom the permission will apply * @param permission * the permission to apply to the grantee. */ public void grantPermission(GranteeInterface grantee, Permission permission) { grants.add(new GrantAndPermission(grantee, permission)); }
/** * Revokes the permissions of a grantee by removing the grantee from the ACL. * * @param grantee * the grantee to remove from this ACL. */ public void revokeAllPermissions(GranteeInterface grantee) { List<GrantAndPermission> grantsToRemove = new ArrayList<GrantAndPermission>(); for (GrantAndPermission gap: grants) { if (gap.getGrantee().equals(grantee)) { grantsToRemove.add(gap); } } grants.removeAll(grantsToRemove); }
/** * Adds a grantee to the ACL with the given permission. If this ACL already contains the grantee * (ie the same grantee object) the permission for the grantee will be updated. * * @param grantee * the grantee to whom the permission will apply * @param permission * the permission to apply to the grantee. */ public void grantPermission(GranteeInterface grantee, Permission permission) { grants.add(new GrantAndPermission(grantee, permission)); }
public boolean equals(Object obj) { return (obj instanceof GrantAndPermission && this.getGrantee().equals(((GrantAndPermission)obj).getGrantee()) && this.getPermission().equals(((GrantAndPermission)obj).getPermission()) ); }
public int compare(Object o1, Object o2) { GrantAndPermission g1 = (GrantAndPermission) o1; GrantAndPermission g2 = (GrantAndPermission) o2; return g1.getGrantee().getIdentifier().compareToIgnoreCase( g2.getGrantee().getIdentifier()); } });
currentPermission = Permission.parsePermission(elementText); } else if (name.equals("Grant")) { GrantAndPermission grantAndPermission = new GrantAndPermission( currentGrantee, currentPermission); ((S3BucketLoggingStatus)bucketLoggingStatus).addTargetGrant(grantAndPermission);
public boolean equals(Object obj) { return (obj instanceof GrantAndPermission && this.getGrantee().equals(((GrantAndPermission)obj).getGrantee()) && this.getPermission().equals(((GrantAndPermission)obj).getPermission()) ); }
public GranteeInterface getGrantee(int index) { GrantAndPermission originalGAP = (GrantAndPermission) currentGrantees.get(index); Object updatedGrantee = super.getValueAt(index, 0); if (updatedGrantee instanceof GroupGrantee) { // We can return this as-is, because GroupGrantees are actually stored in the table. return (GroupGrantee) updatedGrantee; } else { // Non-group Grantees are stored as Strings in the table, so update the original's ID. originalGAP.getGrantee().setIdentifier((String) updatedGrantee); return originalGAP.getGrantee(); } }
currentPermission = Permission.parsePermission(elementText); } else if (name.equals("Grant")) { GrantAndPermission grantAndPermission = new GrantAndPermission( currentGrantee, currentPermission); ((S3BucketLoggingStatus)bucketLoggingStatus).addTargetGrant(grantAndPermission);
/** * Adds a set of grantee/permission pairs to the ACL, where each item in the set is a * {@link GrantAndPermission} object. * * @param grantAndPermissions * the grant and permission combinations to add. */ public void grantAllPermissions(GrantAndPermission[] grantAndPermissions) { for(GrantAndPermission gap : grantAndPermissions) { grantPermission(gap.getGrantee(), gap.getPermission()); } }
public int compare(Object o1, Object o2) { GrantAndPermission g1 = (GrantAndPermission) o1; GrantAndPermission g2 = (GrantAndPermission) o2; return g1.getGrantee().getIdentifier().compareToIgnoreCase( g2.getGrantee().getIdentifier()); } });
public int addGrantee(GranteeInterface grantee, Permission permission) { GrantAndPermission gap = new GrantAndPermission(grantee, permission); int insertRow = Collections.binarySearch(currentGrantees, gap, new Comparator() { public int compare(Object o1, Object o2) { GrantAndPermission g1 = (GrantAndPermission) o1; GrantAndPermission g2 = (GrantAndPermission) o2; return g1.getGrantee().getIdentifier().compareToIgnoreCase( g2.getGrantee().getIdentifier()); } }); if (insertRow >= 0) { // We already have an item with this key, but that's OK. } else { insertRow = (-insertRow) - 1; } // New object to insert. currentGrantees.add(insertRow, gap); if (grantee instanceof GroupGrantee) { this.insertRow(insertRow, new Object[] {grantee, permission}); } else if (grantee instanceof CanonicalGrantee) { CanonicalGrantee canonicalGrantee = (CanonicalGrantee) grantee; this.insertRow(insertRow, new Object[] {canonicalGrantee.getIdentifier(), canonicalGrantee.getDisplayName(), permission}); } else { this.insertRow(insertRow, new Object[] {grantee.getIdentifier(), permission}); } return insertRow; }
/** * Adds a set of grantee/permission pairs to the ACL, where each item in the set is a * {@link GrantAndPermission} object. * * @param grantAndPermissions * the grant and permission combinations to add. */ public void grantAllPermissions(GrantAndPermission[] grantAndPermissions) { for(GrantAndPermission gap : grantAndPermissions) { grantPermission(gap.getGrantee(), gap.getPermission()); } }
public GranteeInterface getGrantee(int index) { GrantAndPermission originalGAP = (GrantAndPermission) currentGrantees.get(index); Object updatedGrantee = super.getValueAt(index, 0); if (updatedGrantee instanceof GroupGrantee) { // We can return this as-is, because GroupGrantees are actually stored in the table. return (GroupGrantee) updatedGrantee; } else { // Non-group Grantees are stored as Strings in the table, so update the original's ID. originalGAP.getGrantee().setIdentifier((String) updatedGrantee); return originalGAP.getGrantee(); } }
public int addGrantee(GranteeInterface grantee, Permission permission) { GrantAndPermission gap = new GrantAndPermission(grantee, permission); int insertRow = Collections.binarySearch(currentGrantees, gap, new Comparator() { public int compare(Object o1, Object o2) { GrantAndPermission g1 = (GrantAndPermission) o1; GrantAndPermission g2 = (GrantAndPermission) o2; return g1.getGrantee().getIdentifier().compareToIgnoreCase( g2.getGrantee().getIdentifier()); } }); if (insertRow >= 0) { // We already have an item with this key, but that's OK. } else { insertRow = (-insertRow) - 1; } // New object to insert. currentGrantees.add(insertRow, gap); if (grantee instanceof GroupGrantee) { this.insertRow(insertRow, new Object[] {grantee, permission}); } else if (grantee instanceof CanonicalGrantee) { CanonicalGrantee canonicalGrantee = (CanonicalGrantee) grantee; this.insertRow(insertRow, new Object[] {canonicalGrantee.getIdentifier(), canonicalGrantee.getDisplayName(), permission}); } else { this.insertRow(insertRow, new Object[] {grantee.getIdentifier(), permission}); } return insertRow; }
/** * @param grantee * the grantee to whom the permission will apply * @return list of permissions assigned to the given grantee in this ACL */ public List<Permission> getPermissionsForGrantee(GranteeInterface grantee) { List<Permission> permissions = new ArrayList<Permission>(); for (GrantAndPermission gap: grants) { if (gap.getGrantee().equals(grantee)) { permissions.add(gap.getPermission()); } } return permissions; }
/** * @param grantee * the grantee to whom the permission will apply * @return list of permissions assigned to the given grantee in this ACL */ public List<Permission> getPermissionsForGrantee(GranteeInterface grantee) { List<Permission> permissions = new ArrayList<Permission>(); for (GrantAndPermission gap: grants) { if (gap.getGrantee().equals(grantee)) { permissions.add(gap.getPermission()); } } return permissions; }
/** * @param permission Permission * @return list of grantees assigned the given permission in this ACL */ public List<GranteeInterface> getGranteesWithPermission(Permission permission) { List<GranteeInterface> grantees = new ArrayList<GranteeInterface>(); for (GrantAndPermission gap: grants) { if (gap.getPermission().equals(permission)) { grantees.add(gap.getGrantee()); } } return grantees; }