@Test(expected = NotfoundException.class) public void testReadNotFoundContainer() throws Exception { final Host host = new Host(new AzureProtocol(), "kahy9boj3eib.blob.core.windows.net", new Credentials( System.getProperties().getProperty("azure.account"), System.getProperties().getProperty("azure.key") )); final AzureSession session = new AzureSession(host); new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener()).connect(session, PathCache.empty(), new DisabledCancelCallback()); final Path container = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.volume, Path.Type.directory)); final AzureAclPermissionFeature f = new AzureAclPermissionFeature(session, null); f.getPermission(container); }
@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); } }
AzureAclPermissionFeature extends DefaultAclFeature implements AclPermission { @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); } } }
AzureAclPermissionFeature extends DefaultAclFeature implements AclPermission { @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); } } AzureAclPermissionFeature(final AzureSession session, final OperationContext context); }
AzureAclPermissionFeature extends DefaultAclFeature implements AclPermission { @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); } } AzureAclPermissionFeature(final AzureSession session, final OperationContext context); @Override List<Acl.Role> getAvailableAclRoles(final List<Path> files); @Override List<Acl.User> getAvailableAclUsers(); @Override Acl getPermission(final Path file); @Override void setPermission(final Path file, final Acl acl); }
AzureAclPermissionFeature extends DefaultAclFeature implements AclPermission { @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); } } AzureAclPermissionFeature(final AzureSession session, final OperationContext context); @Override List<Acl.Role> getAvailableAclRoles(final List<Path> files); @Override List<Acl.User> getAvailableAclUsers(); @Override Acl getPermission(final Path file); @Override void setPermission(final Path file, final Acl acl);  }