jersey.repackaged.com.google.common.collect.Sets Java Examples

The following examples show how to use jersey.repackaged.com.google.common.collect.Sets. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SampleAuthorizationFilter.java    From doctorkafka with Apache License 2.0 6 votes vote down vote up
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
  String userHeader = requestContext.getHeaderString(USER_HEADER);
  String groupsHeader = requestContext.getHeaderString(GROUPS_HEADER);
  DrKafkaSecurityContext ctx = null;
  if (userHeader != null && groupsHeader != null) {
    Set<String> userGroups = new HashSet<>(Arrays.asList(groupsHeader.split(",")));
    SetView<String> intersection = Sets.intersection(allowedAdminGroups, userGroups);
    if (intersection.size() > 0) {
      ctx = new DrKafkaSecurityContext(new UserPrincipal(userHeader), ADMIN_ROLE_SET);
      requestContext.setSecurityContext(ctx);
      LOG.info("Received authenticated request, created context:" + ctx);
      return;
    }
  }
  
  ctx = new DrKafkaSecurityContext(new UserPrincipal(userHeader), EMPTY_ROLE_SET);
  requestContext.setSecurityContext(ctx);
  LOG.info("Received annonymous request, bypassing authorizer");
}
 
Example #2
Source File: GraphApiTest.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Test
public void getReachableNodes_areReturned() {
  Graph graph = graphApi.getReachableNodes(b,
      Lists.newArrayList(OwlRelationships.RDFS_SUBCLASS_OF.name()), Sets.newHashSet());
  assertThat(size(graph.getVertices()), is(1));
  assertThat(size(graph.getEdges()), is(0));
  graph = graphApi.getReachableNodes(c,
      Lists.newArrayList(OwlRelationships.OWL_EQUIVALENT_CLASS.name(),
          OwlRelationships.RDFS_SUBCLASS_OF.name()),
      Sets.newHashSet());
  assertThat(size(graph.getVertices()), is(1));
  assertThat(size(graph.getEdges()), is(0));
}
 
Example #3
Source File: GraphApiTest.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Test
public void getReachableNodes_nothingReturnedForFakeLabel() {
  Graph graph = graphApi.getReachableNodes(c,
      Lists.newArrayList(OwlRelationships.OWL_EQUIVALENT_CLASS.name(),
          OwlRelationships.RDFS_SUBCLASS_OF.name()),
      Sets.newHashSet("fakeLabel"));
  assertThat(size(graph.getVertices()), is(0));
  assertThat(size(graph.getEdges()), is(0));
}
 
Example #4
Source File: GraphApiTest.java    From SciGraph with Apache License 2.0 4 votes vote down vote up
@Test
public void getReachableNodes_traverseAllRels() {
  Graph graph = graphApi.getReachableNodes(c, Lists.newArrayList(), Sets.newHashSet());
  assertThat(size(graph.getVertices()), is(1));
  assertThat(size(graph.getEdges()), is(0));
}
 
Example #5
Source File: GraphApiTest.java    From SciGraph with Apache License 2.0 4 votes vote down vote up
@Test
public void getReachableNodes_fetchesAll() {
  Graph graph = graphApi.getReachableNodes(c, Lists.newArrayList("*"), Sets.newHashSet());
  assertThat(size(graph.getVertices()), is(2));
  assertThat(size(graph.getEdges()), is(0));
}
 
Example #6
Source File: GraphApiTest.java    From SciGraph with Apache License 2.0 4 votes vote down vote up
@Test
public void getReachableNodes_filtersCorrectly() {
  Graph graph = graphApi.getReachableNodes(c, Lists.newArrayList("*"), Sets.newHashSet("alabel"));
  assertThat(size(graph.getVertices()), is(1));
  assertThat(size(graph.getEdges()), is(0));
}
 
Example #7
Source File: Application.java    From boot-examples with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Class<?>> getClasses() {
    Set<Class<?>> classes = Sets.newHashSet();
    classes.add(GreetingEndpoint.class);
    return classes;
}