Tabnine Logo
AccessControlList.hasPermission
Code IndexAdd Tabnine to your IDE (free)

How to use
hasPermission
method
in
org.jclouds.s3.domain.AccessControlList

Best Java code snippets using org.jclouds.s3.domain.AccessControlList.hasPermission (Showing top 20 results out of 315)

origin: Nextdoor/bender

@Override
public ContainerAccess getContainerAccess(String container) {
 AccessControlList acl = sync.getBucketACL(container);
 if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ)) {
   return ContainerAccess.PUBLIC_READ;
 } else {
   return ContainerAccess.PRIVATE;
 }
}
origin: org.apache.jclouds.api/s3

@Override
public ContainerAccess getContainerAccess(String container) {
 AccessControlList acl = sync.getBucketACL(container);
 if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ)) {
   return ContainerAccess.PUBLIC_READ;
 } else {
   return ContainerAccess.PRIVATE;
 }
}
origin: jclouds/legacy-jclouds

/**
* @param grantee
* @param permission
* @return true if the grantee has the given permission.
*/
public boolean hasPermission(Grantee grantee, String permission) {
 return hasPermission(grantee.getIdentifier(), permission);
}
origin: org.apache.jclouds.api/s3

@Override
public BlobAccess getBlobAccess(String container, String name) {
 AccessControlList acl = sync.getObjectACL(container, name);
 if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ)) {
   return BlobAccess.PUBLIC_READ;
 } else {
   return BlobAccess.PRIVATE;
 }
}
origin: apache/jclouds

/**
* @param grantee
* @param permission
* @return true if the grantee has the given permission.
*/
public boolean hasPermission(Grantee grantee, String permission) {
 return hasPermission(grantee.getIdentifier(), permission);
}
origin: Nextdoor/bender

/**
* @param grantee
* @param permission
* @return true if the grantee has the given permission.
*/
public boolean hasPermission(Grantee grantee, String permission) {
 return hasPermission(grantee.getIdentifier(), permission);
}
origin: apache/jclouds

@Override
public ContainerAccess getContainerAccess(String container) {
 AccessControlList acl = sync.getBucketACL(container);
 if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ)) {
   return ContainerAccess.PUBLIC_READ;
 } else {
   return ContainerAccess.PRIVATE;
 }
}
origin: apache/jclouds

@Override
public BlobAccess getBlobAccess(String container, String name) {
 AccessControlList acl = sync.getObjectACL(container, name);
 if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ)) {
   return BlobAccess.PUBLIC_READ;
 } else {
   return BlobAccess.PRIVATE;
 }
}
origin: org.apache.jclouds.api/s3

/**
* @param grantee
* @param permission
* @return true if the grantee has the given permission.
*/
public boolean hasPermission(Grantee grantee, String permission) {
 return hasPermission(grantee.getIdentifier(), permission);
}
origin: org.jclouds.api/s3

/**
* @param grantee
* @param permission
* @return true if the grantee has the given permission.
*/
public boolean hasPermission(Grantee grantee, String permission) {
 return hasPermission(grantee.getIdentifier(), permission);
}
origin: jclouds/legacy-jclouds

@Override
public ListenableFuture<String> putBlob(String container, Blob blob, PutOptions overrides) {
 // TODO: Make use of options overrides
 PutObjectOptions options = new PutObjectOptions();
 try {
   AccessControlList acl = bucketAcls.getUnchecked(container);
   if (acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
    options.withAcl(CannedAccessPolicy.PUBLIC_READ);
 } catch (CacheLoader.InvalidCacheLoadException e) {
   // nulls not permitted from cache loader
 }
 return async.putObject(container, blob2Object.apply(blob), options);
}
origin: jclouds/legacy-jclouds

private void checkGrants(AccessControlList acl) {
 String ownerId = acl.getOwner().getId();
 assertEquals(acl.getGrants().size(), 4, acl.toString());
 assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL), acl.toString());
 assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ), acl.toString());
 assertTrue(acl.hasPermission(ownerId, Permission.WRITE_ACP), acl.toString());
 // EmailAddressGrantee is replaced by a CanonicalUserGrantee, so we cannot test by email addr
 assertTrue(acl.hasPermission(TEST_ACL_ID, Permission.READ_ACP), acl.toString());
}
origin: jclouds/legacy-jclouds

private void checkGrants(AccessControlList acl) {
 String ownerId = acl.getOwner().getId();
 assertEquals(acl.getGrants().size(), 4, acl.toString());
 assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL), acl.toString());
 assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ), acl.toString());
 assertTrue(acl.hasPermission(ownerId, Permission.WRITE_ACP), acl.toString());
 // EmailAddressGrantee is replaced by a CanonicalUserGrantee, so we cannot test by email addr
 assertTrue(acl.hasPermission(StubS3AsyncClient.TEST_ACL_ID, Permission.READ_ACP), acl.toString());
}
origin: jclouds/legacy-jclouds

 public void run() {
   try {
    AccessControlList acl = getApi().getBucketACL(bucketName + "eu");
    assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ), acl.toString());
   } catch (Exception e) {
    Throwables.propagateIfPossible(e);
   }
 }
});
origin: jclouds/legacy-jclouds

 public void run() {
   try {
    AccessControlList acl = getApi().getObjectACL(containerName, publicReadObjectKey);
    assertEquals(acl.getGrants().size(), 2);
    assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 1);
    assertNotNull(acl.getOwner());
    String ownerId = acl.getOwner().getId();
    assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL));
    assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ));
   } catch (Exception e) {
    Throwables.propagateIfPossible(e);
   }
 }
});
origin: apache/jclouds

 public void run() {
   try {
    AccessControlList acl = getApi().getBucketACL(bucketName + "eu");
    assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ), acl.toString());
   } catch (Exception e) {
    Throwables.propagateIfPossible(e);
   }
 }
});
origin: jclouds/legacy-jclouds

 private ListenableFuture<String> putBlobWithReducedRedundancy(String container, Blob blob) {
  AWSS3PutObjectOptions options = new AWSS3PutObjectOptions();
  try {
    AccessControlList acl = bucketAcls.getUnchecked(container);
    if (acl != null && acl.hasPermission(AccessControlList.GroupGranteeURI.ALL_USERS,
                      AccessControlList.Permission.READ)) {
     options.withAcl(CannedAccessPolicy.PUBLIC_READ);
    }
    options.storageClass(ObjectMetadata.StorageClass.REDUCED_REDUNDANCY);
  } catch (CacheLoader.InvalidCacheLoadException e) {
    // nulls not permitted from cache loader
  }
  return getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getAsyncApi().putObject(container,
       blob2Object.apply(blob), options);
}
origin: jclouds/legacy-jclouds

@Test
public void testAccessControlListOwnerOnly() throws HttpException {
 String ownerId = "1a405254c932b52e5b5caaa88186bc431a1bacb9ece631f835daddaf0c47677c";
 AccessControlList acl = createParser().parse(Strings2.toInputStream(aclOwnerOnly));
 assertEquals(acl.getOwner().getId(), ownerId);
 assertEquals(acl.getOwner().getDisplayName(), "jamesmurty");
 assertEquals(acl.getPermissions(ownerId).size(), 1);
 assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL));
 assertEquals(acl.getGrants().size(), 1);
 assertEquals(acl.getPermissions(GroupGranteeURI.ALL_USERS).size(), 0);
 assertEquals(acl.getPermissions(GroupGranteeURI.AUTHENTICATED_USERS).size(), 0);
 assertEquals(acl.getPermissions(GroupGranteeURI.LOG_DELIVERY).size(), 0);
}
origin: jclouds/legacy-jclouds

public void testPrivateAclIsDefaultForBucket() throws InterruptedException, ExecutionException, TimeoutException,
   IOException {
 String bucketName = getContainerName();
 try {
   AccessControlList acl = getApi().getBucketACL(bucketName);
   assertEquals(acl.getGrants().size(), 1);
   assertNotNull(acl.getOwner());
   String ownerId = acl.getOwner().getId();
   assertTrue(acl.hasPermission(ownerId, Permission.FULL_CONTROL));
 } finally {
   returnContainer(bucketName);
 }
}
origin: jclouds/legacy-jclouds

public void testPublicReadAccessPolicy() throws Exception {
 String bucketName = getScratchContainerName();
 try {
   getApi().putBucketInRegion(null, bucketName, withBucketAcl(CannedAccessPolicy.PUBLIC_READ));
   AccessControlList acl = getApi().getBucketACL(bucketName);
   assertTrue(acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ), acl.toString());
   // TODO: I believe that the following should work based on the above acl assertion passing.
   // However, it fails on 403
   // URL url = new URL(String.format("http://%s.s3.amazonaws.com", bucketName));
   // Utils.toStringAndClose(url.openStream());
 } finally {
   destroyContainer(bucketName);
 }
}
org.jclouds.s3.domainAccessControlListhasPermission

Popular methods of AccessControlList

  • <init>
  • addPermission
    Add a permission for the given grantee.
  • getGrants
  • getOwner
  • getPermissions
  • toString
  • findGrantsForGrantee
    Find all the grants for a given grantee, identified by an ID which allows all Grantee types to be se
  • revokePermission
    Revoke a permission for the given grantee, if this specific permission was granted. Note that you mu
  • setOwner
  • fromCannedAccessPolicy
    Converts a canned access control policy into the equivalent access control list.
  • revokeAllPermissions
    Revoke all the permissions granted to the given grantee.
  • revokeAllPermissions

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JTextField (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now