@Test( expectedExceptions = ForbiddenException.class, expectedExceptionsMessageRegExp = "User is not authorized to perform this operation" ) public void shouldThrowForbiddenExceptionWhenRequestedUnknownMethod() throws Exception { final GenericResourceMethod mock = mock(GenericResourceMethod.class); Method getServiceDescriptor = AuditService.class.getMethod("getServiceDescriptor"); when(mock.getMethod()).thenReturn(getServiceDescriptor); filter.filter(mock, new Object[] {}); }
@Override protected void filter(GenericResourceMethod GenericResourceMethod, Object[] arguments) throws ApiException { String methodName = GenericResourceMethod.getMethod().getName(); if ("downloadReport".equals(methodName)) { EnvironmentContext.getCurrent() .getSubject() .checkPermission(SystemDomain.DOMAIN_ID, null, MANAGE_SYSTEM_ACTION); } else { throw new ForbiddenException("User is not authorized to perform this operation"); } }
AuditServicePermissionsFilter extends CheMethodInvokerFilter { @Override protected void filter(GenericResourceMethod GenericResourceMethod, Object[] arguments) throws ApiException { String methodName = GenericResourceMethod.getMethod().getName(); if ("downloadReport".equals(methodName)) { EnvironmentContext.getCurrent() .getSubject() .checkPermission(SystemDomain.DOMAIN_ID, null, MANAGE_SYSTEM_ACTION); } else { throw new ForbiddenException("User is not authorized to perform this operation"); } } }
AuditServicePermissionsFilter extends CheMethodInvokerFilter { @Override protected void filter(GenericResourceMethod GenericResourceMethod, Object[] arguments) throws ApiException { String methodName = GenericResourceMethod.getMethod().getName(); if ("downloadReport".equals(methodName)) { EnvironmentContext.getCurrent() .getSubject() .checkPermission(SystemDomain.DOMAIN_ID, null, MANAGE_SYSTEM_ACTION); } else { throw new ForbiddenException("User is not authorized to perform this operation"); } }  }
AuditServicePermissionsFilter extends CheMethodInvokerFilter { @Override protected void filter(GenericResourceMethod GenericResourceMethod, Object[] arguments) throws ApiException { String methodName = GenericResourceMethod.getMethod().getName(); if ("downloadReport".equals(methodName)) { EnvironmentContext.getCurrent() .getSubject() .checkPermission(SystemDomain.DOMAIN_ID, null, MANAGE_SYSTEM_ACTION); } else { throw new ForbiddenException("User is not authorized to perform this operation"); } }   }
AuditServicePermissionsFilter extends CheMethodInvokerFilter { @Override protected void filter(GenericResourceMethod GenericResourceMethod, Object[] arguments) throws ApiException { String methodName = GenericResourceMethod.getMethod().getName(); if ("downloadReport".equals(methodName)) { EnvironmentContext.getCurrent() .getSubject() .checkPermission(SystemDomain.DOMAIN_ID, null, MANAGE_SYSTEM_ACTION); } else { throw new ForbiddenException("User is not authorized to perform this operation"); } }    }