RBACRestrictor implements Restrictor { @Override public boolean isAttributeReadAllowed(ObjectName objectName, String attribute) { boolean allowed = delegate.isAttributeReadAllowed(objectName, attribute); if (allowed) { allowed = mBeanInvoker.isReadAllowed(objectName, attribute); } LOG.debug("isAttributeReadAllowed(objectName = {}, attribute = {}) = {}", objectName, attribute, allowed); return allowed; } RBACRestrictor(Configuration config); @Override boolean isOperationAllowed(ObjectName objectName, String operation); @Override boolean isAttributeReadAllowed(ObjectName objectName, String attribute); @Override boolean isAttributeWriteAllowed(ObjectName objectName, String attribute); @Override boolean isHttpMethodAllowed(HttpMethod method); @Override boolean isTypeAllowed(RequestType type); @Override boolean isRemoteAccessAllowed(String... hostOrAddress); @Override boolean isOriginAllowed(String origin, boolean strictCheck);  }
@Test public void isAttributeReadAllowed() throws Exception { RBACRestrictor restrictor = new RBACRestrictor(new Configuration()); assertThat(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Runtime"), "VmName"), is(true)); assertThat(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"), "Verbose"), is(true)); assertThat(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Runtime"), "VmVersion"), is(false)); assertThat(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Runtime"), "xxx"), is(false)); assertThat(restrictor.isAttributeReadAllowed(new ObjectName("hawtio:type=NoSuchType"), "Whatever"), is(false)); }