@Test(expected = ForbiddenException.class) public void automationClientRejectsClientsWithoutAutomation() { Client clientWithoutAutomation = new Client(3423, "clientWithoutAutomation", null, null, null, null, null, null, null, null, true, false ); when(securityContext.getUserPrincipal()).thenReturn( SimplePrincipal.of("CN=clientWithoutAutomation")); when(clientDAO.getClientByName("clientWithoutAutomation")) .thenReturn(Optional.of(clientWithoutAutomation)); factory.provide(request, httpServletRequest); }
public AutomationClient provide(ContainerRequest containerRequest, HttpServletRequest httpServletRequest) { Client client = super.provide(containerRequest, httpServletRequest); return Optional.ofNullable(AutomationClient.of(client)) .orElseThrow(() -> new ForbiddenException( format("Client %s not authorized as a AutomationClient", client.getName()))); }
AutomationClientAuthFactory extends ClientAuthFactory { public AutomationClient provide(ContainerRequest containerRequest, HttpServletRequest httpServletRequest) { Client client = super.provide(containerRequest, httpServletRequest); return Optional.ofNullable(AutomationClient.of(client)) .orElseThrow(() -> new ForbiddenException( format("Client %s not authorized as a AutomationClient", client.getName()))); } }
AutomationClientAuthFactory extends ClientAuthFactory { public AutomationClient provide(ContainerRequest containerRequest, HttpServletRequest httpServletRequest) { Client client = super.provide(containerRequest, httpServletRequest); return Optional.ofNullable(AutomationClient.of(client)) .orElseThrow(() -> new ForbiddenException( format("Client %s not authorized as a AutomationClient", client.getName()))); } @Inject  AutomationClientAuthFactory(ClientDAOFactory clientDAOFactory,
      KeywhizConfig keywhizConfig); @VisibleForTesting  AutomationClientAuthFactory(ClientDAO clientDAO,
      ClientAuthConfig clientAuthConfig); }
AutomationClientAuthFactory extends ClientAuthFactory { public AutomationClient provide(ContainerRequest containerRequest, HttpServletRequest httpServletRequest) { Client client = super.provide(containerRequest, httpServletRequest); return Optional.ofNullable(AutomationClient.of(client)) .orElseThrow(() -> new ForbiddenException( format("Client %s not authorized as a AutomationClient", client.getName()))); } @Inject  AutomationClientAuthFactory(ClientDAOFactory clientDAOFactory,
      KeywhizConfig keywhizConfig); @VisibleForTesting  AutomationClientAuthFactory(ClientDAO clientDAO,
      ClientAuthConfig clientAuthConfig); AutomationClient provide(ContainerRequest containerRequest,
      HttpServletRequest httpServletRequest); }
AutomationClientAuthFactory extends ClientAuthFactory { public AutomationClient provide(ContainerRequest containerRequest, HttpServletRequest httpServletRequest) { Client client = super.provide(containerRequest, httpServletRequest); return Optional.ofNullable(AutomationClient.of(client)) .orElseThrow(() -> new ForbiddenException( format("Client %s not authorized as a AutomationClient", client.getName()))); } @Inject  AutomationClientAuthFactory(ClientDAOFactory clientDAOFactory,
      KeywhizConfig keywhizConfig); @VisibleForTesting  AutomationClientAuthFactory(ClientDAO clientDAO,
      ClientAuthConfig clientAuthConfig); AutomationClient provide(ContainerRequest containerRequest,
      HttpServletRequest httpServletRequest);  }