@Override public void startElement(String name, Attributes attrs) { if (name.equals("Owner")) { owner = new GSOwner(); } else if (name.equals("Entries")) { accessControlList = new GSAccessControlList(); accessControlList.setOwner(owner); insideACL = true; } else if (name.equals("Scope")) { scopeType = attrs.getValue("type"); if (scopeType.equals("UserById")) { currentGrantee = new UserByIdGrantee(); } else if (scopeType.equals("UserByEmail")) { currentGrantee = new UserByEmailAddressGrantee(); } else if (scopeType.equals("GroupById")) { currentGrantee = new GroupByIdGrantee(); } else if (scopeType.equals("GroupByEmail")) { currentGrantee = new GroupByEmailAddressGrantee(); } else if (scopeType.equals("GroupByDomain")) { currentGrantee = new GroupByDomainGrantee(); } else if (scopeType.equals("AllUsers")) { currentGrantee = new AllUsersGrantee(); } else if (scopeType.equals("AllAuthenticatedUsers")) { currentGrantee = new AllAuthenticatedUsersGrantee(); } } }
@Override public void startElement(String name, Attributes attrs) { if (name.equals("Owner")) { owner = new GSOwner(); } else if (name.equals("Entries")) { accessControlList = new GSAccessControlList(); accessControlList.setOwner(owner); insideACL = true; } else if (name.equals("Scope")) { scopeType = attrs.getValue("type"); if (scopeType.equals("UserById")) { currentGrantee = new UserByIdGrantee(); } else if (scopeType.equals("UserByEmail")) { currentGrantee = new UserByEmailAddressGrantee(); } else if (scopeType.equals("GroupById")) { currentGrantee = new GroupByIdGrantee(); } else if (scopeType.equals("GroupByEmail")) { currentGrantee = new GroupByEmailAddressGrantee(); } else if (scopeType.equals("GroupByDomain")) { currentGrantee = new GroupByDomainGrantee(); } else if (scopeType.equals("AllUsers")) { currentGrantee = new AllUsersGrantee(); } else if (scopeType.equals("AllAuthenticatedUsers")) { currentGrantee = new AllAuthenticatedUsersGrantee(); } } }
@Override public void setConfiguration(final Path container, final LoggingConfiguration configuration) throws BackgroundException { try { // Logging target bucket final GSBucketLoggingStatus status = new GSBucketLoggingStatus( StringUtils.isNotBlank(configuration.getLoggingTarget()) ? configuration.getLoggingTarget() : container.getName(), null); if(configuration.isEnabled()) { status.setLogfilePrefix(PreferencesFactory.get().getProperty("google.logging.prefix")); } // Grant write for Google to logging target bucket final AccessControlList acl = session.getClient().getBucketAcl(container.getName()); final GroupByEmailAddressGrantee grantee = new GroupByEmailAddressGrantee( "cloud-storage-analytics@google.com"); if(!acl.getPermissionsForGrantee(grantee).contains(Permission.PERMISSION_WRITE)) { acl.grantPermission(grantee, Permission.PERMISSION_WRITE); session.getClient().putBucketAcl(container.getName(), acl); } session.getClient().setBucketLoggingStatusImpl(container.getName(), status); } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Failure to write attributes of {0}", e); } } }
list.grantPermission(new GroupByEmailAddressGrantee(userAndRole.getUser().getIdentifier()), Permission.parsePermission(userAndRole.getRole().getName()));