@Test public void testNoClientOnRequestBadDefaultClient() { final AsyncClient client1 = namedMockAsyncClient(NAME); final AsyncClient client2 = namedMockAsyncClient(CLIENT_NAME); final Clients clients = new Clients(client1, client2); final WebContext context = mockWebContext(); expectedEx.expect(TechnicalException.class); expectedEx.expectMessage("No client found for name: " + FAKE_VALUE); finder.find(clients, context, FAKE_VALUE); }
@Override public List<C> find(Clients<C, ?> clients, WebContext<?> context, String clientNames) { final List<C> result = new ArrayList<>(); if (CommonHelper.isNotBlank(clientNames)) { final List<String> names = Arrays.asList(clientNames.split(Pac4jConstants.ELEMENT_SEPRATOR)); final String clientNameOnRequest = context.getRequestParameter(clients.getClientNameParameter()); if (clientNameOnRequest != null) { final C client = clients.findClient(context); final String nameFound = client.getName(); boolean found = false; for (final String name : names) { if (CommonHelper.areEqualsIgnoreCaseAndTrim(name, nameFound)) { result.add(client); found = true; break; } } if (!found) { throw new TechnicalException("Client not allowed: " + nameFound); } } else { for (final String name : names) { final C client = clients.findClient(name); result.add(client); } } } return result; }
DefaultClientFinder implements ClientFinder<C> { @Override public List<C> find(Clients<C, ?> clients, WebContext<?> context, String clientNames) { final List<C> result = new ArrayList<>(); if (CommonHelper.isNotBlank(clientNames)) { final List<String> names = Arrays.asList(clientNames.split(Pac4jConstants.ELEMENT_SEPRATOR)); final String clientNameOnRequest = context.getRequestParameter(clients.getClientNameParameter()); if (clientNameOnRequest != null) { final C client = clients.findClient(context); final String nameFound = client.getName(); boolean found = false; for (final String name : names) { if (CommonHelper.areEqualsIgnoreCaseAndTrim(name, nameFound)) { result.add(client); found = true; break; } } if (!found) { throw new TechnicalException("Client not allowed: " + nameFound); } } else { for (final String name : names) { final C client = clients.findClient(name); result.add(client); } } } return result; } }
DefaultClientFinder implements ClientFinder<C> { @Override public List<C> find(Clients<C, ?> clients, WebContext<?> context, String clientNames) { final List<C> result = new ArrayList<>(); if (CommonHelper.isNotBlank(clientNames)) { final List<String> names = Arrays.asList(clientNames.split(Pac4jConstants.ELEMENT_SEPRATOR)); final String clientNameOnRequest = context.getRequestParameter(clients.getClientNameParameter()); if (clientNameOnRequest != null) { final C client = clients.findClient(context); final String nameFound = client.getName(); boolean found = false; for (final String name : names) { if (CommonHelper.areEqualsIgnoreCaseAndTrim(name, nameFound)) { result.add(client); found = true; break; } } if (!found) { throw new TechnicalException("Client not allowed: " + nameFound); } } else { for (final String name : names) { final C client = clients.findClient(name); result.add(client); } } } return result; }  }
DefaultClientFinder implements ClientFinder<C> { @Override public List<C> find(Clients<C, ?> clients, WebContext<?> context, String clientNames) { final List<C> result = new ArrayList<>(); if (CommonHelper.isNotBlank(clientNames)) { final List<String> names = Arrays.asList(clientNames.split(Pac4jConstants.ELEMENT_SEPRATOR)); final String clientNameOnRequest = context.getRequestParameter(clients.getClientNameParameter()); if (clientNameOnRequest != null) { final C client = clients.findClient(context); final String nameFound = client.getName(); boolean found = false; for (final String name : names) { if (CommonHelper.areEqualsIgnoreCaseAndTrim(name, nameFound)) { result.add(client); found = true; break; } } if (!found) { throw new TechnicalException("Client not allowed: " + nameFound); } } else { for (final String name : names) { final C client = clients.findClient(name); result.add(client); } } } return result; }  @Override List<C> find(Clients<C, ?> clients, WebContext<?> context, String clientNames); }
DefaultClientFinder implements ClientFinder<C> { @Override public List<C> find(Clients<C, ?> clients, WebContext<?> context, String clientNames) { final List<C> result = new ArrayList<>(); if (CommonHelper.isNotBlank(clientNames)) { final List<String> names = Arrays.asList(clientNames.split(Pac4jConstants.ELEMENT_SEPRATOR)); final String clientNameOnRequest = context.getRequestParameter(clients.getClientNameParameter()); if (clientNameOnRequest != null) { final C client = clients.findClient(context); final String nameFound = client.getName(); boolean found = false; for (final String name : names) { if (CommonHelper.areEqualsIgnoreCaseAndTrim(name, nameFound)) { result.add(client); found = true; break; } } if (!found) { throw new TechnicalException("Client not allowed: " + nameFound); } } else { for (final String name : names) { final C client = clients.findClient(name); result.add(client); } } } return result; }  @Override List<C> find(Clients<C, ?> clients, WebContext<?> context, String clientNames);  }