@Test void testWithSuccessfulAuthorization() throws IOException { dummyUriAuthorizationFilter.ensureUserIsAuthorized(request, response); Mockito.verify(authorizationChecker) .ensureUserIsAuthorized(Mockito.eq(request), Mockito.any(), Mockito.eq(SPACE_GUID), Mockito.any()); }
@Override public final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response) throws IOException { String spaceGuid = extractAndLogSpaceGuid(request); try { authorizationChecker.ensureUserIsAuthorized(request, SecurityContextUtil.getUserInfo(), spaceGuid, null); return true; } catch (ResponseStatusException e) { logUnauthorizedRequest(request, e); response.sendError(e.getStatus() .value(), MessageFormat.format(Messages.NOT_AUTHORIZED_TO_OPERATE_IN_SPACE_WITH_GUID_0, spaceGuid)); return false; } }
SpaceGuidBasedAuthorizationFilter implements UriAuthorizationFilter { @Override public final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response) throws IOException { String spaceGuid = extractAndLogSpaceGuid(request); try { authorizationChecker.ensureUserIsAuthorized(request, SecurityContextUtil.getUserInfo(), spaceGuid, null); return true; } catch (ResponseStatusException e) { logUnauthorizedRequest(request, e); response.sendError(e.getStatus() .value(), MessageFormat.format(Messages.NOT_AUTHORIZED_TO_OPERATE_IN_SPACE_WITH_GUID_0, spaceGuid)); return false; } } }
SpaceGuidBasedAuthorizationFilter implements UriAuthorizationFilter { @Override public final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response) throws IOException { String spaceGuid = extractAndLogSpaceGuid(request); try { authorizationChecker.ensureUserIsAuthorized(request, SecurityContextUtil.getUserInfo(), spaceGuid, null); return true; } catch (ResponseStatusException e) { logUnauthorizedRequest(request, e); response.sendError(e.getStatus() .value(), MessageFormat.format(Messages.NOT_AUTHORIZED_TO_OPERATE_IN_SPACE_WITH_GUID_0, spaceGuid)); return false; } } SpaceGuidBasedAuthorizationFilter(AuthorizationChecker authorizationChecker); }
SpaceGuidBasedAuthorizationFilter implements UriAuthorizationFilter { @Override public final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response) throws IOException { String spaceGuid = extractAndLogSpaceGuid(request); try { authorizationChecker.ensureUserIsAuthorized(request, SecurityContextUtil.getUserInfo(), spaceGuid, null); return true; } catch (ResponseStatusException e) { logUnauthorizedRequest(request, e); response.sendError(e.getStatus() .value(), MessageFormat.format(Messages.NOT_AUTHORIZED_TO_OPERATE_IN_SPACE_WITH_GUID_0, spaceGuid)); return false; } } SpaceGuidBasedAuthorizationFilter(AuthorizationChecker authorizationChecker); @Override final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response); }
SpaceGuidBasedAuthorizationFilter implements UriAuthorizationFilter { @Override public final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response) throws IOException { String spaceGuid = extractAndLogSpaceGuid(request); try { authorizationChecker.ensureUserIsAuthorized(request, SecurityContextUtil.getUserInfo(), spaceGuid, null); return true; } catch (ResponseStatusException e) { logUnauthorizedRequest(request, e); response.sendError(e.getStatus() .value(), MessageFormat.format(Messages.NOT_AUTHORIZED_TO_OPERATE_IN_SPACE_WITH_GUID_0, spaceGuid)); return false; } } SpaceGuidBasedAuthorizationFilter(AuthorizationChecker authorizationChecker); @Override final boolean ensureUserIsAuthorized(HttpServletRequest request, HttpServletResponse response);  }