@Test public void testYarnACLsEnabled() throws Exception { Configuration conf = new YarnConfiguration(); conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true); conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin"); TimelineACLsManager timelineACLsManager = new TimelineACLsManager(conf); TimelineEntity entity = new TimelineEntity(); entity.addPrimaryFilter( TimelineStore.SystemFilter.ENTITY_OWNER .toString(), "owner"); Assert.assertTrue( "Owner should be allowed to access", timelineACLsManager.checkAccess( UserGroupInformation.createRemoteUser("owner"), entity)); Assert.assertFalse( "Other shouldn't be allowed to access", timelineACLsManager.checkAccess( UserGroupInformation.createRemoteUser("other"), entity)); Assert.assertTrue( "Admin should be allowed to access", timelineACLsManager.checkAccess( UserGroupInformation.createRemoteUser("admin"), entity)); }
public boolean checkAccess(UserGroupInformation callerUGI, TimelineEntity entity) throws YarnException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Verifying the access of " + (callerUGI == null ? null : callerUGI.getShortUserName()) + " on the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType())); } if (!adminAclsManager.areACLsEnabled()) { return true; } Set<Object> values = entity.getPrimaryFilters().get( SystemFilter.ENTITY_OWNER.toString()); if (values == null || values.size() != 1) { throw new YarnException("Owner information of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()) + " is corrupted."); } String owner = values.iterator().next().toString(); if (callerUGI != null && (adminAclsManager.isAdmin(callerUGI) || callerUGI.getShortUserName().equals(owner))) { return true; } return false; }
TimelineACLsManager { public boolean checkAccess(UserGroupInformation callerUGI, TimelineEntity entity) throws YarnException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Verifying the access of " + (callerUGI == null ? null : callerUGI.getShortUserName()) + " on the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType())); } if (!adminAclsManager.areACLsEnabled()) { return true; } Set<Object> values = entity.getPrimaryFilters().get( SystemFilter.ENTITY_OWNER.toString()); if (values == null || values.size() != 1) { throw new YarnException("Owner information of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()) + " is corrupted."); } String owner = values.iterator().next().toString(); if (callerUGI != null && (adminAclsManager.isAdmin(callerUGI) || callerUGI.getShortUserName().equals(owner))) { return true; } return false; } }
TimelineACLsManager { public boolean checkAccess(UserGroupInformation callerUGI, TimelineEntity entity) throws YarnException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Verifying the access of " + (callerUGI == null ? null : callerUGI.getShortUserName()) + " on the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType())); } if (!adminAclsManager.areACLsEnabled()) { return true; } Set<Object> values = entity.getPrimaryFilters().get( SystemFilter.ENTITY_OWNER.toString()); if (values == null || values.size() != 1) { throw new YarnException("Owner information of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()) + " is corrupted."); } String owner = values.iterator().next().toString(); if (callerUGI != null && (adminAclsManager.isAdmin(callerUGI) || callerUGI.getShortUserName().equals(owner))) { return true; } return false; } TimelineACLsManager(Configuration conf); }
TimelineACLsManager { public boolean checkAccess(UserGroupInformation callerUGI, TimelineEntity entity) throws YarnException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Verifying the access of " + (callerUGI == null ? null : callerUGI.getShortUserName()) + " on the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType())); } if (!adminAclsManager.areACLsEnabled()) { return true; } Set<Object> values = entity.getPrimaryFilters().get( SystemFilter.ENTITY_OWNER.toString()); if (values == null || values.size() != 1) { throw new YarnException("Owner information of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()) + " is corrupted."); } String owner = values.iterator().next().toString(); if (callerUGI != null && (adminAclsManager.isAdmin(callerUGI) || callerUGI.getShortUserName().equals(owner))) { return true; } return false; } TimelineACLsManager(Configuration conf); boolean checkAccess(UserGroupInformation callerUGI,
      TimelineEntity entity); @Private @VisibleForTesting AdminACLsManager setAdminACLsManager(AdminACLsManager adminAclsManager); }
TimelineACLsManager { public boolean checkAccess(UserGroupInformation callerUGI, TimelineEntity entity) throws YarnException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Verifying the access of " + (callerUGI == null ? null : callerUGI.getShortUserName()) + " on the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType())); } if (!adminAclsManager.areACLsEnabled()) { return true; } Set<Object> values = entity.getPrimaryFilters().get( SystemFilter.ENTITY_OWNER.toString()); if (values == null || values.size() != 1) { throw new YarnException("Owner information of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()) + " is corrupted."); } String owner = values.iterator().next().toString(); if (callerUGI != null && (adminAclsManager.isAdmin(callerUGI) || callerUGI.getShortUserName().equals(owner))) { return true; } return false; } TimelineACLsManager(Configuration conf); boolean checkAccess(UserGroupInformation callerUGI,
      TimelineEntity entity); @Private @VisibleForTesting AdminACLsManager setAdminACLsManager(AdminACLsManager adminAclsManager);  }