class AuthorizationChecker {

    boolean checkPermissions(UserInfo userInfo, String orgName, String spaceName, boolean readOnly) {
        if (hasAdminScope(userInfo)) {
            return true;
        }
        // TODO a lot of cpu time is lost in the getControllerClient method
        CloudControllerClient client = clientProvider.getControllerClient(userInfo.getName());
        UUID userGuid = UUID.fromString(userInfo.getId());
        // TODO and some more cpu time in hasPermissions
        return hasPermissions(client, userGuid, orgName, spaceName, readOnly) && hasAccess(client, orgName, spaceName);
    }

    @Inject public  AuthorizationChecker(CloudControllerClientProvider clientProvider, ApplicationConfiguration applicationConfiguration);

}