public String toString() { return "S3Owner [name=" + getDisplayName() + ",id=" + getId() + "]"; }
@Override public boolean equals(Object obj) { if (!(obj instanceof Owner)) { return false; } Owner otherOwner = (Owner)obj; String otherOwnerId = otherOwner.getId(); String otherOwnerName = otherOwner.getDisplayName(); String thisOwnerId = this.getId(); String thisOwnerName = this.getDisplayName(); if (otherOwnerId == null) otherOwnerId = ""; if (otherOwnerName == null) otherOwnerName = ""; if (thisOwnerId == null) thisOwnerId = ""; if (thisOwnerName == null) thisOwnerName = ""; return (otherOwnerId.equals(thisOwnerId) && otherOwnerName.equals(thisOwnerName)); }
/** * Since there is no group in S3 acl, the owner is reused as the group. This method calls the * S3 API and requires additional permissions aside from just read only. This method is best * effort and will continue with default permissions (no owner, no group, 0700). * * @return the permissions associated with this under storage system */ private ObjectPermissions getPermissionsInternal() { short bucketMode = DEFAULT_MODE; String accountOwner = DEFAULT_OWNER; // if ACL enabled try to inherit bucket acl for all the objects. if (Boolean.parseBoolean(mConf.get(PropertyKey.UNDERFS_S3A_INHERIT_ACL))) { try { Owner owner = mClient.getS3AccountOwner(); AccessControlList acl = mClient.getBucketAcl(mBucketName); bucketMode = S3AUtils.translateBucketAcl(acl, owner.getId()); if (mConf.isSet(PropertyKey.UNDERFS_GCS_OWNER_ID_TO_USERNAME_MAPPING)) { accountOwner = CommonUtils.getValueFromStaticMapping( mConf.get(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING), owner.getId()); } else { // If there is no user-defined mapping, use display name or id. accountOwner = owner.getDisplayName() != null ? owner.getDisplayName() : owner.getId(); } } catch (AmazonClientException e) { LOG.warn("Failed to inherit bucket ACLs, proceeding with defaults. {}", e.getMessage()); } } return new ObjectPermissions(accountOwner, accountOwner, bucketMode); }
static AccessControlList grantFullControlToBucketOwner(ServerSideEncryptingAmazonS3 s3Client, String bucket) { final AccessControlList acl = s3Client.getBucketAcl(bucket); acl.grantAllPermissions(new Grant(new CanonicalGrantee(acl.getOwner().getId()), Permission.FullControl)); return acl; }
attributes.put("s3.bucket", versionSummary.getBucketName()); if (versionSummary.getOwner() != null) { // We may not have permission to read the owner attributes.put("s3.owner", versionSummary.getOwner().getId());
@Override public String toString() { return "S3Owner [name=" + getDisplayName() + ",id=" + getId() + "]"; }
@Override public boolean equals(Object obj) { if (!(obj instanceof Owner)) { return false; } Owner otherOwner = (Owner) obj; String otherOwnerId = otherOwner.getId(); String otherOwnerName = otherOwner.getDisplayName(); String thisOwnerId = this.getId(); String thisOwnerName = this.getDisplayName(); if (otherOwnerId == null) otherOwnerId = ""; if (otherOwnerName == null) otherOwnerName = ""; if (thisOwnerId == null) thisOwnerId = ""; if (thisOwnerName == null) thisOwnerName = ""; return (otherOwnerId.equals(thisOwnerId) && otherOwnerName.equals(thisOwnerName)); }
public String toString() { return "S3Owner [name=" + getDisplayName() + ",id=" + getId() + "]"; }
@Override public String toString() { return "S3Owner [name=" + getDisplayName() + ",id=" + getId() + "]"; }
@Override protected void setup(Configuration conf) throws IOException { try { s3 = clientCache.get(S3ClientKey.create(conf)); if (!S3StoragePlugin.NONE_PROVIDER.equals(conf.get(S3Constants.AWS_CREDENTIALS_PROVIDER))) { ownerId = s3.getS3AccountOwner().getId(); } } catch (ExecutionException e) { if(e.getCause() != null && e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } } }
@Override public boolean equals(Object obj) { if (!(obj instanceof Owner)) { return false; } Owner otherOwner = (Owner) obj; String otherOwnerId = otherOwner.getId(); String otherOwnerName = otherOwner.getDisplayName(); String thisOwnerId = this.getId(); String thisOwnerName = this.getDisplayName(); if (otherOwnerId == null) otherOwnerId = ""; if (otherOwnerName == null) otherOwnerName = ""; if (thisOwnerId == null) thisOwnerId = ""; if (thisOwnerName == null) thisOwnerName = ""; return (otherOwnerId.equals(thisOwnerId) && otherOwnerName.equals(thisOwnerName)); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Owner)) { return false; } Owner otherOwner = (Owner)obj; String otherOwnerId = otherOwner.getId(); String otherOwnerName = otherOwner.getDisplayName(); String thisOwnerId = this.getId(); String thisOwnerName = this.getDisplayName(); if (otherOwnerId == null) otherOwnerId = ""; if (otherOwnerName == null) otherOwnerName = ""; if (thisOwnerId == null) thisOwnerId = ""; if (thisOwnerName == null) thisOwnerName = ""; return (otherOwnerId.equals(thisOwnerId) && otherOwnerName.equals(thisOwnerName)); }
/** * have almost one of the permission set in the parameter permissions * * @param permissions almost one * @return */ private boolean hasPermission(EnumSet<Permission> permissions) { for (Grant grant : acl.getGrantsAsList()) if (grant.getGrantee().getIdentifier().equals(owner.getId()) && permissions.contains(grant.getPermission())) return true; return false; }
@SuppressWarnings("unchecked") @Override public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) { if (type != S3FileStoreAttributeView.class) throw new IllegalArgumentException("FileStoreAttributeView of type '" + type.getName() + "' is not supported."); Bucket buck = getBucket(); Owner owner = buck.getOwner(); return (V) new S3FileStoreAttributeView(buck.getCreationDate(), buck.getName(), owner.getId(), owner.getDisplayName()); }
public static Owner copyOf(com.amazonaws.services.s3.model.Owner owner) { return builder().withName(owner.getDisplayName()).withId(owner.getId()).build(); }
static AccessControlList grantFullControlToBucketOwner(ServerSideEncryptingAmazonS3 s3Client, String bucket) { final AccessControlList acl = s3Client.getBucketAcl(bucket); acl.grantAllPermissions(new Grant(new CanonicalGrantee(acl.getOwner().getId()), Permission.FullControl)); return acl; }
@Override public void write(DataOutput out) throws IOException { Text.writeString(out, getBucketName()); Text.writeString(out, getKey()); Text.writeString(out, getETag()); Text.writeString(out, getStorageClass()); Text.writeString(out, getOwner().getId()); Text.writeString(out, getOwner().getDisplayName()); out.writeLong(getSize()); out.writeLong(getLastModified().getTime()); }
private ObjectAcl syncAclFromS3Acl(AccessControlList s3Acl) { ObjectAcl syncAcl = new ObjectAcl(); syncAcl.setOwner(s3Acl.getOwner().getId()); for (Grant grant : s3Acl.getGrantsAsList()) { Grantee grantee = grant.getGrantee(); if (grantee instanceof GroupGrantee || grantee.getTypeIdentifier().equals(ACL_GROUP_TYPE)) syncAcl.addGroupGrant(grantee.getIdentifier(), grant.getPermission().toString()); else if (grantee instanceof CanonicalGrantee || grantee.getTypeIdentifier().equals(ACL_CANONICAL_USER_TYPE)) syncAcl.addUserGrant(grantee.getIdentifier(), grant.getPermission().toString()); } return syncAcl; }