@Test public void authorizePass() { context.checking(new Expectations() { { allowing(groupIdtransformer).transform(actionContext); will(returnValue("5")); allowing(actionContext).getPrincipal(); will(returnValue(principal)); allowing(principal).getId(); will(returnValue(userId)); allowing(groupPermissionsChecker).hasGroupCoordinatorAccessRecursively(userId, 5L); will(returnValue(true)); } }); sut.authorize(actionContext); context.assertIsSatisfied(); }
@Override public void authorize(final PrincipalActionContext inActionContext) { Long groupId = Long.valueOf((String) groupIdtransformer.transform(inActionContext)); Long personId = inActionContext.getPrincipal().getId(); if (!groupPermissionsChecker.hasGroupCoordinatorAccessRecursively(personId, groupId)) { throw new AuthorizationException("Insufficient permissions to update group."); } }
CurrentUserGroupCoordinatorRecursivelyAuthorization implements
        AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long groupId = Long.valueOf((String) groupIdtransformer.transform(inActionContext)); Long personId = inActionContext.getPrincipal().getId(); if (!groupPermissionsChecker.hasGroupCoordinatorAccessRecursively(personId, groupId)) { throw new AuthorizationException("Insufficient permissions to update group."); } } }
CurrentUserGroupCoordinatorRecursivelyAuthorization implements
        AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long groupId = Long.valueOf((String) groupIdtransformer.transform(inActionContext)); Long personId = inActionContext.getPrincipal().getId(); if (!groupPermissionsChecker.hasGroupCoordinatorAccessRecursively(personId, groupId)) { throw new AuthorizationException("Insufficient permissions to update group."); } } CurrentUserGroupCoordinatorRecursivelyAuthorization(final RequestTransformer inOrgIdtransformer,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupPermissionsChecker); }
CurrentUserGroupCoordinatorRecursivelyAuthorization implements
        AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long groupId = Long.valueOf((String) groupIdtransformer.transform(inActionContext)); Long personId = inActionContext.getPrincipal().getId(); if (!groupPermissionsChecker.hasGroupCoordinatorAccessRecursively(personId, groupId)) { throw new AuthorizationException("Insufficient permissions to update group."); } } CurrentUserGroupCoordinatorRecursivelyAuthorization(final RequestTransformer inOrgIdtransformer,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupPermissionsChecker); @Override void authorize(final PrincipalActionContext inActionContext); }
CurrentUserGroupCoordinatorRecursivelyAuthorization implements
        AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long groupId = Long.valueOf((String) groupIdtransformer.transform(inActionContext)); Long personId = inActionContext.getPrincipal().getId(); if (!groupPermissionsChecker.hasGroupCoordinatorAccessRecursively(personId, groupId)) { throw new AuthorizationException("Insufficient permissions to update group."); } } CurrentUserGroupCoordinatorRecursivelyAuthorization(final RequestTransformer inOrgIdtransformer,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupPermissionsChecker); @Override void authorize(final PrincipalActionContext inActionContext);  }