class SpaceNameBasedAuthorizationFilter implements UriAuthorizationFilter {

    @Override
    public final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response) throws IOException {
        CloudTarget target = extractAndLogTarget(request);
        try {
            authorizationChecker.ensureUserIsAuthorized(request, SecurityContextUtil.getUserInfo(), target, null);
            return true;
        } catch (ResponseStatusException e) {
            logUnauthorizedRequest(request, e);
            response.sendError(HttpStatus.UNAUTHORIZED.value(),
                               MessageFormat.format(Messages.NOT_AUTHORIZED_TO_OPERATE_IN_ORGANIZATION_0_AND_SPACE_1,
                                                    target.getOrganizationName(), target.getSpaceName()));
            return false;
        }
    }

    public  SpaceNameBasedAuthorizationFilter(AuthorizationChecker authorizationChecker);

}