@Test void testWithSuccessfulAuthorization() throws IOException { dummyUriAuthorizationFilter.ensureUserIsAuthorized(request, response); Mockito.verify(authorizationChecker) .ensureUserIsAuthorized(Mockito.eq(request), Mockito.any(), Mockito.eq(new CloudTarget(ORGANIZATION_NAME, SPACE_NAME)), Mockito.any()); }
@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; } }
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; } } }
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; } } SpaceNameBasedAuthorizationFilter(AuthorizationChecker authorizationChecker); }
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; } } SpaceNameBasedAuthorizationFilter(AuthorizationChecker authorizationChecker); @Override final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response); }
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; } } SpaceNameBasedAuthorizationFilter(AuthorizationChecker authorizationChecker); @Override final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response);  }