RBACRestrictor implements Restrictor { @Override public boolean isOperationAllowed(ObjectName objectName, String operation) { boolean allowed = delegate.isOperationAllowed(objectName, operation); if (allowed) { allowed = mBeanInvoker.canInvoke(objectName, operation); } LOG.debug("isOperationAllowed(objectName = {}, operation = {}) = {}", objectName, operation, 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 isOperationAllowed() throws Exception { RBACRestrictor restrictor = new RBACRestrictor(new Configuration()); assertThat(restrictor.isOperationAllowed(new ObjectName("hawtio:type=Test"), "allowed()"), is(true)); assertThat(restrictor.isOperationAllowed(new ObjectName("hawtio:type=Test"), "notAllowed()"), is(false)); assertThat(restrictor.isOperationAllowed(new ObjectName("hawtio:type=Test"), "error()"), is(false)); assertThat(restrictor.isOperationAllowed(new ObjectName("hawtio:type=NoSuchType"), "noInstance()"), is(false)); assertThat(restrictor.isOperationAllowed(new ObjectName("hawtio:type=Test"), "allowed(boolean,long,java.lang.String)"), is(true)); assertThat(restrictor.isOperationAllowed(new ObjectName("hawtio:type=Test"), "notAllowed(boolean,long,java.lang.String)"), is(false)); }