@Test public void testAuthorizeCheck() { final Long tabId = new Long(1); context.checking(new Expectations() { { oneOf(principalMock).getAccountId(); will(returnValue(TEST_ACCOUNTID)); oneOf(tabPermissionMock).canChangeTabLayout(TEST_ACCOUNTID, tabId, true); will(returnValue(true)); } }); SetTabLayoutRequest currentRequest = new SetTabLayoutRequest(Layout.TWOCOLUMN, tabId); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, principalMock); sut.authorize(currentContext); context.assertIsSatisfied(); }
@Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { SetTabLayoutRequest currentRequest = (SetTabLayoutRequest) inActionContext.getParams(); try { if (!tabPermission.canChangeTabLayout(inActionContext.getPrincipal().getAccountId(), currentRequest .getTabId(), true)) { throw new Exception(); } } catch (Exception ex) { logger.info("Authorization to change tab layout failed for this request"); throw new AuthorizationException("Authorization to change tab layout failed for this request", ex); } }
SetTabLayoutAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { SetTabLayoutRequest currentRequest = (SetTabLayoutRequest) inActionContext.getParams(); try { if (!tabPermission.canChangeTabLayout(inActionContext.getPrincipal().getAccountId(), currentRequest .getTabId(), true)) { throw new Exception(); } } catch (Exception ex) { logger.info("Authorization to change tab layout failed for this request"); throw new AuthorizationException("Authorization to change tab layout failed for this request", ex); } } }
SetTabLayoutAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { SetTabLayoutRequest currentRequest = (SetTabLayoutRequest) inActionContext.getParams(); try { if (!tabPermission.canChangeTabLayout(inActionContext.getPrincipal().getAccountId(), currentRequest .getTabId(), true)) { throw new Exception(); } } catch (Exception ex) { logger.info("Authorization to change tab layout failed for this request"); throw new AuthorizationException("Authorization to change tab layout failed for this request", ex); } } SetTabLayoutAuthorization(final TabPermission inTabPermission); }
SetTabLayoutAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { SetTabLayoutRequest currentRequest = (SetTabLayoutRequest) inActionContext.getParams(); try { if (!tabPermission.canChangeTabLayout(inActionContext.getPrincipal().getAccountId(), currentRequest .getTabId(), true)) { throw new Exception(); } } catch (Exception ex) { logger.info("Authorization to change tab layout failed for this request"); throw new AuthorizationException("Authorization to change tab layout failed for this request", ex); } } SetTabLayoutAuthorization(final TabPermission inTabPermission); @Override void authorize(final PrincipalActionContext inActionContext); }
SetTabLayoutAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { SetTabLayoutRequest currentRequest = (SetTabLayoutRequest) inActionContext.getParams(); try { if (!tabPermission.canChangeTabLayout(inActionContext.getPrincipal().getAccountId(), currentRequest .getTabId(), true)) { throw new Exception(); } } catch (Exception ex) { logger.info("Authorization to change tab layout failed for this request"); throw new AuthorizationException("Authorization to change tab layout failed for this request", ex); } } SetTabLayoutAuthorization(final TabPermission inTabPermission); @Override void authorize(final PrincipalActionContext inActionContext);  }