@Override public List<Acl.User> getAvailableAclUsers() { final List<Acl.User> users = new ArrayList<Acl.User>(Arrays.asList( new Acl.CanonicalUser(), new Acl.GroupUser(Acl.GroupUser.AUTHENTICATED, false), new Acl.GroupUser(Acl.GroupUser.EVERYONE, false)) ); users.add(new Acl.EmailUser() { @Override public String getPlaceholder() { return LocaleFactory.localizedString("Google Account Email Address", "S3"); } }); // Google Apps customers can associate their email accounts with an Internet domain name. When you do // this, each email account takes the form username@yourdomain.com. You can specify a scope by using // any Internet domain name that is associated with a Google Apps account. users.add(new Acl.DomainUser(StringUtils.EMPTY) { @Override public String getPlaceholder() { return LocaleFactory.localizedString("Google Apps Domain", "S3"); } }); users.add(new Acl.EmailGroupUser(StringUtils.EMPTY, true) { @Override public String getPlaceholder() { return LocaleFactory.localizedString("Google Group Email Address", "S3"); } }); return users; }
/** * @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; }
@Override public Acl getDefault(final Local file) { final Permission permission; if(PreferencesFactory.get().getBoolean("queue.upload.permissions.default")) { if(file.isFile()) { permission = new Permission( PreferencesFactory.get().getInteger("queue.upload.permissions.file.default")); } else { permission = new Permission( PreferencesFactory.get().getInteger("queue.upload.permissions.folder.default")); } } else { // Read permissions from local file permission = file.attributes().getPermission(); } final Acl acl = new Acl(); if(permission.getOther().implies(Permission.Action.read)) { acl.addAll(new Acl.GroupUser(Acl.GroupUser.EVERYONE), new Acl.Role(Acl.Role.READ)); } if(permission.getGroup().implies(Permission.Action.read)) { acl.addAll(new Acl.GroupUser(Acl.GroupUser.AUTHENTICATED), new Acl.Role(Acl.Role.READ)); } if(permission.getGroup().implies(Permission.Action.write)) { acl.addAll(new Acl.GroupUser(Acl.GroupUser.AUTHENTICATED), new Acl.Role(Acl.Role.WRITE)); } return acl; } }
switch(response.getBucketType()) { case allPublic: folder.attributes().setAcl(new Acl(new Acl.GroupUser(Acl.GroupUser.EVERYONE, false), new Acl.Role(Acl.Role.READ)));
@Override public Acl getPermission(final Path file) throws BackgroundException { try { if(containerService.isContainer(file)) { final CloudBlobContainer container = session.getClient() .getContainerReference(containerService.getContainer(file).getName()); final BlobContainerPermissions permissions = container.downloadPermissions(null, null, context); final Acl acl = new Acl(); if(permissions.getPublicAccess().equals(BlobContainerPublicAccessType.BLOB) || permissions.getPublicAccess().equals(BlobContainerPublicAccessType.CONTAINER)) { acl.addAll(new Acl.GroupUser(Acl.GroupUser.EVERYONE, false), new Acl.Role(Acl.Role.READ)); } return acl; } return Acl.EMPTY; } catch(URISyntaxException e) { throw new NotfoundException(e.getMessage(), e); } catch(StorageException e) { throw new AzureExceptionMappingService().map("Failure to read attributes of {0}", e, file); } }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); for(B2BucketResponse bucket : session.getClient().listBuckets()) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(bucket.getBucketId()); switch(bucket.getBucketType()) { case allPublic: attributes.setAcl(new Acl(new Acl.GroupUser(Acl.GroupUser.EVERYONE, false), new Acl.Role(Acl.Role.READ))); break; } buckets.add(new Path(PathNormalizer.normalize(bucket.getBucketName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); } listener.chunk(directory, buckets); return buckets; } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
@Override public Name getLocation(final Path file) { final Path container = containerService.getContainer(file); if(container.isRoot()) { return unknown; } for(Acl.UserAndRole role : container.attributes().getAcl().asList()) { if(role.getUser().equals(new Acl.GroupUser(Acl.GroupUser.EVERYONE))) { if(role.getRole().equals(new Acl.Role(Acl.Role.READ))) { return new B2BucketTypeName(BucketType.allPublic); } } } return new B2BucketTypeName(BucketType.allPrivate); }
@Override public List<Acl.User> getAvailableAclUsers() { return new ArrayList<Acl.User>(Arrays.asList( new Acl.CanonicalUser(), new Acl.GroupUser(Acl.GroupUser.EVERYONE, false), new Acl.EmailUser() { @Override public String getPlaceholder() { return LocaleFactory.localizedString("Amazon Customer Email Address", "S3"); } }) ); } }
@Override public List<Acl.User> getAvailableAclUsers() { return new ArrayList<Acl.User>(Collections.singletonList( new Acl.GroupUser(Acl.GroupUser.EVERYONE, false)) ); }
@Override public String getPlaceholder() { return LocaleFactory.localizedString(this.getIdentifier(), "S3"); } }
@Override public List<Acl.User> getAvailableAclUsers() { return new ArrayList<Acl.User>(Collections.singletonList( new Acl.GroupUser(Acl.GroupUser.EVERYONE, false)) ); }