@Test public void authorizePass() { final List<Long> admins = new ArrayList<Long>(); admins.add(6L); context.checking(new Expectations() { { allowing(actionContext).getPrincipal(); will(returnValue(principal)); allowing(principal).getId(); will(returnValue(userId)); oneOf(systemAdministratorMapper).execute(null); will(returnValue(admins)); } }); sut.authorize(actionContext); context.assertIsSatisfied(); }
@Override public void authorize(final PrincipalActionContext inActionContext) { Long personId = inActionContext.getPrincipal().getId(); List<Long> administrators = systemAdministratorMapper.execute(null); if (!administrators.contains(personId)) { throw new AuthorizationException("Insufficient permissions."); } }
CurrentUserIsSystemAdministratorAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long personId = inActionContext.getPrincipal().getId(); List<Long> administrators = systemAdministratorMapper.execute(null); if (!administrators.contains(personId)) { throw new AuthorizationException("Insufficient permissions."); } } }
CurrentUserIsSystemAdministratorAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long personId = inActionContext.getPrincipal().getId(); List<Long> administrators = systemAdministratorMapper.execute(null); if (!administrators.contains(personId)) { throw new AuthorizationException("Insufficient permissions."); } } CurrentUserIsSystemAdministratorAuthorization(
            final DomainMapper<Serializable, List<Long>> inSystemAdministratorMapper); }
CurrentUserIsSystemAdministratorAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long personId = inActionContext.getPrincipal().getId(); List<Long> administrators = systemAdministratorMapper.execute(null); if (!administrators.contains(personId)) { throw new AuthorizationException("Insufficient permissions."); } } CurrentUserIsSystemAdministratorAuthorization(
            final DomainMapper<Serializable, List<Long>> inSystemAdministratorMapper); @Override void authorize(final PrincipalActionContext inActionContext); }
CurrentUserIsSystemAdministratorAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) { Long personId = inActionContext.getPrincipal().getId(); List<Long> administrators = systemAdministratorMapper.execute(null); if (!administrators.contains(personId)) { throw new AuthorizationException("Insufficient permissions."); } } CurrentUserIsSystemAdministratorAuthorization(
            final DomainMapper<Serializable, List<Long>> inSystemAdministratorMapper); @Override void authorize(final PrincipalActionContext inActionContext);  }