AssetManagerWithSecurity extends AssetManagerDecorator<TieredStorageAssetManager> { @Override public Opt<Asset> getAsset(Version version, String mpId, String mpElementId) { if (isAuthorized(mpId, READ_ACTION)) { return super.getAsset(version, mpId, mpElementId); } return chuck(new UnauthorizedException(format("Not allowed to read assets of snapshot %s, version=%s", mpId, version))); } AssetManagerWithSecurity(
      TieredStorageAssetManager delegate,
      AuthorizationService authSvc,
      SecurityService secSvc,
      final boolean includeAPIRoles,
      final boolean includeCARoles,
      final boolean includeUIRoles); @Override Snapshot takeSnapshot(String owner, MediaPackage mp); @Override void setAvailability(Version version, String mpId, Availability availability); @Override boolean setProperty(Property property); @Override Opt<Asset> getAsset(Version version, String mpId, String mpElementId); @Override AQueryBuilder createQuery(); @Override List<Property> selectProperties(final String mediaPackageId, String namespace); static final String WRITE_ACTION; static final String READ_ACTION; static final String SECURITY_NAMESPACE; }
@Test @Parameters public void testGetAsset(final AccessControlList acl, User user, boolean assertAccess) throws Exception { final Snapshot snapshot = createSnapshot(acl); runWith(user, assertAccess, new P1Lazy<Unit>() { @Override public Unit get1() { assertTrue(am.getAsset( snapshot.getVersion(), snapshot.getMediaPackage().getIdentifier().toString(), snapshot.getMediaPackage().getElements()[0].getIdentifier()).isSome()); return Unit.unit; } }); }