Search in sources :

Example 1 with OzoneObj

use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.

the class TestOzoneManagerListVolumes method setVolumeAcl.

/**
 * Helper function to set volume ACL.
 */
private static void setVolumeAcl(ObjectStore objectStore, String volumeName, String aclString) throws IOException {
    OzoneObj obj = OzoneObjInfo.Builder.newBuilder().setVolumeName(volumeName).setResType(OzoneObj.ResourceType.VOLUME).setStoreType(OZONE).build();
    Assert.assertTrue(objectStore.setAcl(obj, OzoneAcl.parseAcls(aclString)));
}
Also used : OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj)

Example 2 with OzoneObj

use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.

the class TestOzoneManagerHAWithACL method testSetPrefixAcl.

public void testSetPrefixAcl() throws Exception {
    OzoneBucket ozoneBucket = setupBucket();
    String remoteUserName = "remoteUser";
    String prefixName = RandomStringUtils.randomAlphabetic(5) + "/";
    OzoneAcl defaultUserAcl = new OzoneAcl(USER, remoteUserName, READ, DEFAULT);
    OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.PREFIX).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).setPrefixName(prefixName).build();
    testSetAcl(remoteUserName, ozoneObj, defaultUserAcl);
}
Also used : OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl)

Example 3 with OzoneObj

use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.

the class TestOzoneManagerHAWithACL method testAddKeyAcl.

public void testAddKeyAcl() throws Exception {
    OzoneBucket ozoneBucket = setupBucket();
    String remoteUserName = "remoteUser";
    OzoneAcl userAcl = new OzoneAcl(USER, remoteUserName, READ, DEFAULT);
    String key = createKey(ozoneBucket);
    OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.KEY).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).setKeyName(key).build();
    testAddAcl(remoteUserName, ozoneObj, userAcl);
}
Also used : OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl)

Example 4 with OzoneObj

use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.

the class TestOzoneManagerHAWithACL method testRemoveBucketAcl.

public void testRemoveBucketAcl() throws Exception {
    OzoneBucket ozoneBucket = setupBucket();
    String remoteUserName = "remoteUser";
    OzoneAcl defaultUserAcl = new OzoneAcl(USER, remoteUserName, READ, DEFAULT);
    OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.BUCKET).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).build();
    testRemoveAcl(remoteUserName, ozoneObj, defaultUserAcl);
}
Also used : OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl)

Example 5 with OzoneObj

use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.

the class TestOzoneManagerHAWithACL method testRemovePrefixAcl.

public void testRemovePrefixAcl() throws Exception {
    OzoneBucket ozoneBucket = setupBucket();
    String remoteUserName = "remoteUser";
    String prefixName = RandomStringUtils.randomAlphabetic(5) + "/";
    OzoneAcl userAcl = new OzoneAcl(USER, remoteUserName, READ, ACCESS);
    OzoneAcl userAcl1 = new OzoneAcl(USER, "remote", READ, ACCESS);
    OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.PREFIX).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).setPrefixName(prefixName).build();
    ObjectStore objectStore = getObjectStore();
    boolean result = objectStore.addAcl(ozoneObj, userAcl);
    Assert.assertTrue(result);
    result = objectStore.addAcl(ozoneObj, userAcl1);
    Assert.assertTrue(result);
    result = objectStore.removeAcl(ozoneObj, userAcl);
    Assert.assertTrue(result);
    // try removing already removed acl.
    result = objectStore.removeAcl(ozoneObj, userAcl);
    Assert.assertFalse(result);
    result = objectStore.removeAcl(ozoneObj, userAcl1);
    Assert.assertTrue(result);
}
Also used : OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneObj(org.apache.hadoop.ozone.security.acl.OzoneObj) ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OzoneAcl(org.apache.hadoop.ozone.OzoneAcl)

Aggregations

OzoneObj (org.apache.hadoop.ozone.security.acl.OzoneObj)46 OzoneAcl (org.apache.hadoop.ozone.OzoneAcl)26 Test (org.junit.Test)19 OzoneBucket (org.apache.hadoop.ozone.client.OzoneBucket)15 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 OzoneVolume (org.apache.hadoop.ozone.client.OzoneVolume)7 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)7 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)7 ObjectStore (org.apache.hadoop.ozone.client.ObjectStore)5 OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)5 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)5 OzoneObjInfo (org.apache.hadoop.ozone.security.acl.OzoneObjInfo)5 BitSet (java.util.BitSet)4 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)4 ObjectParser (org.apache.hadoop.ozone.om.request.util.ObjectParser)4 BucketArgs (org.apache.hadoop.ozone.client.BucketArgs)3 VolumeArgs (org.apache.hadoop.ozone.client.VolumeArgs)3 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)3 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)3