### Question:
CollectClientConnectionsFilter implements org.forgerock.http.Filter, Closeable { String[] extractUsernamePassword(Request request) throws ResourceException { if (authConfig.isCustomHeadersAuthenticationSupported()) { final String userName = request.getHeaders().getFirst(authConfig.getCustomHeaderUsername()); final String password = request.getHeaders().getFirst(authConfig.getCustomHeaderPassword()); if (userName != null && password != null) { return new String[] { userName, password }; } } if (authConfig.isBasicAuthenticationSupported()) { String httpBasicAuthHeader = request.getHeaders().getFirst(HTTP_BASIC_AUTH_HEADER); if (httpBasicAuthHeader != null) { String[] userCredentials = parseUsernamePassword(httpBasicAuthHeader); if (userCredentials != null) { return userCredentials; } } } return null; } CollectClientConnectionsFilter(ServerContext serverContext, HTTPConnectionHandler connectionHandler,
      HTTPAuthenticationConfig authenticationConfig); @Override Promise<Response, NeverThrowsException> filter(Context context, Request request, Handler next); @Override void close();  }### Answer:
@Test public void extractUsernamePasswordHttpBasicAuthWillAcceptUserAgent() throws Exception { authConfig.setBasicAuthenticationSupported(true); final Request request = new Request(); request.getHeaders().add(HTTP_BASIC_AUTH_HEADER, "Basic " + BASE64_USERPASS); assertThat(filter.extractUsernamePassword(request)).containsExactly(USERNAME, PASSWORD); }
@Test public void extractUsernamePasswordCustomHeaders() throws Exception { final String customHeaderUsername = "X-OpenIDM-Username"; final String customHeaderPassword = "X-OpenIDM-Password"; authConfig.setCustomHeadersAuthenticationSupported(true); authConfig.setCustomHeaderUsername(customHeaderUsername); authConfig.setCustomHeaderPassword(customHeaderPassword); final Request request = new Request(); request.getHeaders().add(customHeaderUsername, USERNAME); request.getHeaders().add(customHeaderPassword, PASSWORD); assertThat(filter.extractUsernamePassword(request)).containsExactly(USERNAME, PASSWORD); }