/** * Constructs a grantee with the given canonical ID. * @param identifier Canonical ID */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
public String toXml() throws TransformerException, ParserConfigurationException, FactoryConfigurationError { return toXMLBuilder().asString(); }
currentGrantee = new CanonicalGrantee(); currentGrantee.setIdentifier(elementText); } else if (name.equals("EmailAddress")) { ((CanonicalGrantee) currentGrantee).setDisplayName(elementText);
} else if ("addCanonicalGrantee".equals(e.getActionCommand())) { int rowIndex = canonicalGranteeTableModel.addGrantee( new CanonicalGrantee("NewCanonicalId"), Permission.PERMISSION_READ); canonicalGranteeTable.setRowSelectionInterval(rowIndex, rowIndex); } else if ("removeCanonicalGrantee".equals(e.getActionCommand())) {
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 list ACL from server * @return Editable ACL */ protected Acl convert(final AccessControlList list) { if(log.isDebugEnabled()) { try { log.debug(list.toXml()); } catch(ServiceException e) { log.error(e.getMessage()); } } Acl acl = new Acl(); acl.setOwner(new Acl.CanonicalUser(list.getOwner().getId(), list.getOwner().getDisplayName())); for(GrantAndPermission grant : list.getGrantAndPermissions()) { Acl.Role role = new Acl.Role(grant.getPermission().toString()); if(grant.getGrantee() instanceof CanonicalGrantee) { acl.addAll(new Acl.CanonicalUser(grant.getGrantee().getIdentifier(), ((CanonicalGrantee) grant.getGrantee()).getDisplayName(), false), role); } else if(grant.getGrantee() instanceof EmailAddressGrantee) { acl.addAll(new Acl.EmailUser(grant.getGrantee().getIdentifier()), role); } else if(grant.getGrantee() instanceof GroupGrantee) { acl.addAll(new Acl.GroupUser(grant.getGrantee().getIdentifier()), role); } } return acl; }
currentGrantee = new CanonicalGrantee(); currentGrantee.setIdentifier(elementText); } else if (name.equals("EmailAddress")) { ((CanonicalGrantee) currentGrantee).setDisplayName(elementText);
} else if ("addCanonicalGrantee".equals(e.getActionCommand())) { int rowIndex = canonicalGranteeTableModel.addGrantee( new CanonicalGrantee("NewCanonicalId"), Permission.PERMISSION_READ); canonicalGranteeTable.setRowSelectionInterval(rowIndex, rowIndex); } else if ("removeCanonicalGrantee".equals(e.getActionCommand())) {
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; }
currentGrantee = new CanonicalGrantee(); currentGrantee.setIdentifier(elementText); } else if (name.equals("EmailAddress")) { currentGrantee.setIdentifier(elementText); } else if (name.equals("DisplayName")) { ((CanonicalGrantee) currentGrantee).setDisplayName(elementText); } else if (name.equals("Permission")) { currentPermission = Permission.parsePermission(elementText);
public boolean grantAcl(S3Object object) throws ServiceException, InterruptedException { if(Strings.isNullOrEmpty(s3Acl)){ return true; } for (int i = 0; i < s3AclRetries; ++i) { try { AccessControlList acl = s3Service.getObjectAcl(object.getBucketName(), object.getKey()); for (String id : s3Acl.split(",")) { acl.grantPermission(new CanonicalGrantee(id), Permission.PERMISSION_READ); } s3Service.putObjectAcl(object.getBucketName(), object.getKey(), acl); return true; } catch (Exception e) { log.error("Exception while granting ACL: " + e.getMessage(), e); Thread.sleep(1000 * (i + 1)); } } return false; } }
public String toXml() throws TransformerException, ParserConfigurationException, FactoryConfigurationError { return toXMLBuilder().asString(); }
/** * Constructs a grantee with the given canonical ID. * @param identifier Canonical ID */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
currentGrantee = new CanonicalGrantee(); currentGrantee.setIdentifier(elementText); } else if (name.equals("EmailAddress")) { currentGrantee.setIdentifier(elementText); } else if (name.equals("DisplayName")) { ((CanonicalGrantee) currentGrantee).setDisplayName(elementText); } else if (name.equals("Permission")) { currentPermission = Permission.parsePermission(elementText);
acl.grantPermission(new CanonicalGrantee("AWS member's ID"), Permission.PERMISSION_READ_ACP); acl.grantPermission(new CanonicalGrantee("AWS member's ID"), Permission.PERMISSION_WRITE_ACP);
acl.setOwner(owner); GranteeInterface grantee = new CanonicalGrantee(); grantee.setIdentifier("zzz"); acl.grantPermission(grantee, Permission.PERMISSION_WRITE); grantee = new CanonicalGrantee(); grantee.setIdentifier("abc"); ((CanonicalGrantee)grantee).setDisplayName("jamesmurty"); acl.grantPermission(grantee, Permission.PERMISSION_FULL_CONTROL); grantee = new CanonicalGrantee(); grantee.setIdentifier("aaa"); acl.grantPermission(grantee, Permission.PERMISSION_READ);
if(null != owner) { list.setOwner(new S3Owner(owner.getIdentifier(), owner.getDisplayName())); list.grantPermission(new CanonicalGrantee(owner.getIdentifier()), Permission.PERMISSION_FULL_CONTROL); list.grantPermission(new CanonicalGrantee(userAndRole.getUser().getIdentifier()), Permission.parsePermission(userAndRole.getRole().getName()));
acl.setOwner(owner); GranteeInterface grantee = new CanonicalGrantee(); grantee.setIdentifier("zzz"); acl.grantPermission(grantee, Permission.PERMISSION_WRITE); grantee = new CanonicalGrantee(); grantee.setIdentifier("abc"); ((CanonicalGrantee)grantee).setDisplayName("jamesmurty"); acl.grantPermission(grantee, Permission.PERMISSION_FULL_CONTROL); grantee = new CanonicalGrantee(); grantee.setIdentifier("aaa"); acl.grantPermission(grantee, Permission.PERMISSION_READ);
acl.grantPermission(new CanonicalGrantee("AWS member's ID"), Permission.PERMISSION_READ_ACP); acl.grantPermission(new CanonicalGrantee("AWS member's ID"), Permission.PERMISSION_WRITE_ACP);