@Test public void testAuthorizeForPersonStream() { context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue(new StreamPopularHashTagsRequest(ScopeType.PERSON, "accountid"))); } }); sut.authorize(actionContext); context.assertIsSatisfied(); }
@Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { StreamPopularHashTagsRequest request = (StreamPopularHashTagsRequest) inActionContext.getParams(); if (request.getStreamEntityScopeType() == ScopeType.GROUP) { DomainGroupModelView group = groupsMapper.fetchUniqueResult(request.getStreamEntityUniqueKey()); if (!group.isPublic()) { Set<Long> groupsUserCanAccess = groupAccessMapper.execute(inActionContext.getPrincipal().getId()); if (!groupsUserCanAccess.contains(group.getId())) { throw new AuthorizationException(inActionContext.getPrincipal().getAccountId() + " cannot access popular hashtags for group with short name " + group.getShortName()); } } } }
StreamPopularHashTagsAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { StreamPopularHashTagsRequest request = (StreamPopularHashTagsRequest) inActionContext.getParams(); if (request.getStreamEntityScopeType() == ScopeType.GROUP) { DomainGroupModelView group = groupsMapper.fetchUniqueResult(request.getStreamEntityUniqueKey()); if (!group.isPublic()) { Set<Long> groupsUserCanAccess = groupAccessMapper.execute(inActionContext.getPrincipal().getId()); if (!groupsUserCanAccess.contains(group.getId())) { throw new AuthorizationException(inActionContext.getPrincipal().getAccountId() + " cannot access popular hashtags for group with short name " + group.getShortName()); } } } } }
StreamPopularHashTagsAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { StreamPopularHashTagsRequest request = (StreamPopularHashTagsRequest) inActionContext.getParams(); if (request.getStreamEntityScopeType() == ScopeType.GROUP) { DomainGroupModelView group = groupsMapper.fetchUniqueResult(request.getStreamEntityUniqueKey()); if (!group.isPublic()) { Set<Long> groupsUserCanAccess = groupAccessMapper.execute(inActionContext.getPrincipal().getId()); if (!groupsUserCanAccess.contains(group.getId())) { throw new AuthorizationException(inActionContext.getPrincipal().getAccountId() + " cannot access popular hashtags for group with short name " + group.getShortName()); } } } } StreamPopularHashTagsAuthorization(final GetDomainGroupsByShortNames inGroupsMapper,
            final GetPrivateCoordinatedAndFollowedGroupIdsForUser inGroupAccessMapper); }
StreamPopularHashTagsAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { StreamPopularHashTagsRequest request = (StreamPopularHashTagsRequest) inActionContext.getParams(); if (request.getStreamEntityScopeType() == ScopeType.GROUP) { DomainGroupModelView group = groupsMapper.fetchUniqueResult(request.getStreamEntityUniqueKey()); if (!group.isPublic()) { Set<Long> groupsUserCanAccess = groupAccessMapper.execute(inActionContext.getPrincipal().getId()); if (!groupsUserCanAccess.contains(group.getId())) { throw new AuthorizationException(inActionContext.getPrincipal().getAccountId() + " cannot access popular hashtags for group with short name " + group.getShortName()); } } } } StreamPopularHashTagsAuthorization(final GetDomainGroupsByShortNames inGroupsMapper,
            final GetPrivateCoordinatedAndFollowedGroupIdsForUser inGroupAccessMapper); @Override void authorize(final PrincipalActionContext inActionContext); }
StreamPopularHashTagsAuthorization implements AuthorizationStrategy<PrincipalActionContext> { @Override public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException { StreamPopularHashTagsRequest request = (StreamPopularHashTagsRequest) inActionContext.getParams(); if (request.getStreamEntityScopeType() == ScopeType.GROUP) { DomainGroupModelView group = groupsMapper.fetchUniqueResult(request.getStreamEntityUniqueKey()); if (!group.isPublic()) { Set<Long> groupsUserCanAccess = groupAccessMapper.execute(inActionContext.getPrincipal().getId()); if (!groupsUserCanAccess.contains(group.getId())) { throw new AuthorizationException(inActionContext.getPrincipal().getAccountId() + " cannot access popular hashtags for group with short name " + group.getShortName()); } } } } StreamPopularHashTagsAuthorization(final GetDomainGroupsByShortNames inGroupsMapper,
            final GetPrivateCoordinatedAndFollowedGroupIdsForUser inGroupAccessMapper); @Override void authorize(final PrincipalActionContext inActionContext);  }