private static boolean isUserIdInGrantee(GranteeInterface grantee, String userId) { return grantee.getIdentifier().equals(userId) || grantee.equals(GroupGrantee.ALL_USERS) || grantee.equals(GroupGrantee.AUTHENTICATED_USERS); }
for (GrantAndPermission gp : acl.getGrantAndPermissions()) { Permission perm = gp.getPermission(); GranteeInterface grantee = gp.getGrantee(); if (perm.equals(Permission.PERMISSION_READ)) { if (isUserIdInGrantee(grantee, userId)) { } else if (perm.equals(Permission.PERMISSION_WRITE)) { if (isUserIdInGrantee(grantee, userId)) { } else if (perm.equals(Permission.PERMISSION_FULL_CONTROL)) { if (isUserIdInGrantee(grantee, userId)) {
/** * 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 static String getAclDescription(AccessControlList acl) { if (acl == null) { return ACL_UNKNOWN_DESCRIPTION; } for (GrantAndPermission gap: acl.getGrantAndPermissions()) { if (GroupGrantee.ALL_USERS.equals(gap.getGrantee()) && Permission.PERMISSION_READ.equals(gap.getPermission())) { return ACL_PUBLIC_DESCRIPTION; } } if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(acl)) { return ACL_PUBLIC_DESCRIPTION; } return ACL_PRIVATE_DESCRIPTION; }
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()); } });
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(); } }
/** * Constructs an email grantee with the given email address. * @param emailAddress Email address */ public EmailAddressGrantee(String emailAddress) { this.setIdentifier(emailAddress); }
/** * @return true if this ACL can be set via an HTTP header, rather than via an XML document. */ public boolean isRESTHeaderACL() { return getValueForRESTHeaderACL() != null; }
/** * Constructs a grantee with the given canonical ID. * @param identifier Canonical ID */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
/** * 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 static String getAclDescription(AccessControlList acl) { if (acl == null) { return ACL_UNKNOWN_DESCRIPTION; } for (GrantAndPermission gap: acl.getGrantAndPermissions()) { if (GroupGrantee.ALL_USERS.equals(gap.getGrantee()) && Permission.PERMISSION_READ.equals(gap.getPermission())) { return ACL_PUBLIC_DESCRIPTION; } } if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(acl)) { return ACL_PUBLIC_DESCRIPTION; } return ACL_PRIVATE_DESCRIPTION; }
public boolean equals(Object obj) { return (obj instanceof GrantAndPermission && this.getGrantee().equals(((GrantAndPermission)obj).getGrantee()) && this.getPermission().equals(((GrantAndPermission)obj).getPermission()) ); }
/** * 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 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(); } }
/** * Constructs an email grantee with the given email address. * @param emailAddress Email address */ public EmailAddressGrantee(String emailAddress) { this.setIdentifier(emailAddress); }
/** * @return true if this ACL can be set via an HTTP header, rather than via an XML document. */ public boolean isRESTHeaderACL() { return getValueForRESTHeaderACL() != null; }
/** * Constructs a grantee with the given canonical ID. * @param identifier Canonical ID */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
/** * @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; }