@Override public ReadableBlobMeta getBlobMeta(String key) throws AuthorizationException, KeyNotFoundException { ReadableBlobMeta reableMeta = null; if (allBlobs.containsKey(key)) { reableMeta = new ReadableBlobMeta(); reableMeta.set_settable(allBlobs.get(key)); } return reableMeta; }
public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SETTABLE: if (value == null) { unset_settable(); } else { set_settable((SettableBlobMeta)value); } break; case VERSION: if (value == null) { unset_version(); } else { set_version((java.lang.Long)value); } break; } }
@Override public ReadableBlobMeta getBlobMeta(String key, Subject who) throws AuthorizationException, KeyNotFoundException { who = checkAndGetSubject(who); validateKey(key); SettableBlobMeta meta = getStoredBlobMeta(key); aclHandler.validateUserCanReadMeta(meta.get_acl(), who, key); ReadableBlobMeta rbm = new ReadableBlobMeta(); rbm.set_settable(meta); try { BlobStoreFile pf = hbs.read(DATA_PREFIX + key); rbm.set_version(pf.getModTime()); } catch (IOException e) { throw new RuntimeException(e); } return rbm; }
@Override public ReadableBlobMeta getBlobMeta(String key, Subject who) throws AuthorizationException, KeyNotFoundException { validateKey(key); if (!checkForBlobOrDownload(key)) { checkForBlobUpdate(key); } SettableBlobMeta meta = getStoredBlobMeta(key); _aclHandler.validateUserCanReadMeta(meta.get_acl(), who, key); ReadableBlobMeta rbm = new ReadableBlobMeta(); rbm.set_settable(meta); try { LocalFsBlobStoreFile pf = fbs.read(DATA_PREFIX + key); rbm.set_version(pf.getModTime()); } catch (IOException e) { throw new RuntimeException(e); } return rbm; }
@Test(expected = AuthorizationException.class) public void testFailAcls() throws Exception { Map<String, Object> conf = new HashMap(); // set clean time really high so doesn't kick in conf.put(DaemonConfig.SUPERVISOR_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS, 60 * 60 * 1000); // enable blobstore acl validation conf.put(Config.STORM_BLOBSTORE_ACL_VALIDATION_ENABLED, true); String topo1 = "topo1"; String key1 = "key1"; TestLocalizer localizer = new TestLocalizer(conf, baseDir.toString()); ReadableBlobMeta rbm = new ReadableBlobMeta(); // set acl so user doesn't have read access AccessControl acl = new AccessControl(AccessControlType.USER, BlobStoreAclHandler.ADMIN); acl.set_name(user1); rbm.set_settable(new SettableBlobMeta(Arrays.asList(acl))); when(mockblobstore.getBlobMeta(anyString())).thenReturn(rbm); when(mockblobstore.getBlob(key1)).thenReturn(new TestInputStreamWithMeta(1)); File user1Dir = localizer.getLocalUserFileCacheDir(user1); assertTrue("failed to create user dir", user1Dir.mkdirs()); LocalAssignment topo1Assignment = new LocalAssignment(topo1, Collections.emptyList()); topo1Assignment.set_owner(user1); PortAndAssignment topo1Pna = new PortAndAssignmentImpl(1, topo1Assignment); // This should throw AuthorizationException because auth failed localizer.getBlob(new LocalResource(key1, false, false), topo1Pna, null); }
rbm.set_settable(new SettableBlobMeta(WORLD_EVERYTHING)); when(mockblobstore.getBlobMeta(key1)).thenReturn(rbm); when(mockblobstore.getBlob(key1)).thenReturn(new TestInputStreamWithMeta(1));
rbm.set_settable(new SettableBlobMeta(WORLD_EVERYTHING)); when(mockblobstore.getBlobMeta(anyString())).thenReturn(rbm);
rbm.set_settable(new SettableBlobMeta(WORLD_EVERYTHING)); when(mockblobstore.getBlobMeta(key1)).thenReturn(rbm);
rbm.set_settable(new SettableBlobMeta(WORLD_EVERYTHING)); when(mockblobstore.getBlobMeta(key1)).thenReturn(rbm);
public void setFieldValue(_Fields field, Object value) { switch (field) { case SETTABLE: if (value == null) { unset_settable(); } else { set_settable((SettableBlobMeta)value); } break; case VERSION: if (value == null) { unset_version(); } else { set_version((Long)value); } break; } }
@Override public ReadableBlobMeta getBlobMeta(String key, Subject who) throws AuthorizationException, KeyNotFoundException { who = checkAndGetSubject(who); validateKey(key); SettableBlobMeta meta = getStoredBlobMeta(key); aclHandler.validateUserCanReadMeta(meta.get_acl(), who, key); ReadableBlobMeta rbm = new ReadableBlobMeta(); rbm.set_settable(meta); try { BlobStoreFile pf = hbs.read(DATA_PREFIX + key); rbm.set_version(pf.getModTime()); } catch (IOException e) { throw new RuntimeException(e); } return rbm; }
@Override public ReadableBlobMeta getBlobMeta(String key, Subject who) throws AuthorizationException, KeyNotFoundException { validateKey(key); if(!checkForBlobOrDownload(key)) { checkForBlobUpdate(key); } SettableBlobMeta meta = getStoredBlobMeta(key); _aclHandler.validateUserCanReadMeta(meta.get_acl(), who, key); ReadableBlobMeta rbm = new ReadableBlobMeta(); rbm.set_settable(meta); try { LocalFsBlobStoreFile pf = fbs.read(DATA_PREFIX+key); rbm.set_version(pf.getModTime()); } catch (IOException e) { throw new RuntimeException(e); } return rbm; }