@Test public void utf8() throws Exception { final CredentialsVerifier<BasicUserInfo> utf8CredentialsVerifier = new CredentialsVerifier<BasicUserInfo>() { @Override public Single<BasicUserInfo> apply(final String userId, final String password) { if ("пароль".equals(password)) { return succeeded(new BasicUserInfo(userId)); } return failed(new AuthenticationException("Wrong password")); } @Override public Completable closeAsync() { return completed(); } }; StreamingHttpServiceFilter service = new BasicAuthHttpServiceFilter.Builder<>( utf8CredentialsVerifier, REALM_VALUE) .userInfoKey(USER_INFO_KEY) .setCharsetUtf8(true) .buildServer() .create(HELLO_WORLD_SERVICE); StreamingHttpResponse response = awaitIndefinitelyNonNull(service.handle(CONN_CTX, reqRespFactory.get("/path"), reqRespFactory)); assertEquals(UNAUTHORIZED, response.status()); assertEquals("Basic realm=\"" + REALM_VALUE + "\", charset=\"UTF-8\"", response.headers().get(WWW_AUTHENTICATE)); assertFalse(response.headers().contains(USER_ID_HEADER_NAME)); StreamingHttpRequest request = reqRespFactory.get("/path"); request.headers().set(AUTHORIZATION, "Basic " + base64("userId:пароль", UTF_8)); testAuthenticated(request, service); }
@Override public StreamingHttpServiceFilter create(final StreamingHttpService service) { return new BasicAuthStreamingHttpService<>(this, service); }
BasicAuthHttpServiceFilter implements StreamingHttpServiceFilterFactory, HttpExecutionStrategyInfluencer { @Override public StreamingHttpServiceFilter create(final StreamingHttpService service) { return new BasicAuthStreamingHttpService<>(this, service); } }
BasicAuthHttpServiceFilter implements StreamingHttpServiceFilterFactory, HttpExecutionStrategyInfluencer { @Override public StreamingHttpServiceFilter create(final StreamingHttpService service) { return new BasicAuthStreamingHttpService<>(this, service); } private  BasicAuthHttpServiceFilter(final CredentialsVerifier<UserInfo> credentialsVerifier,
                                       final String realm,
                                       final boolean proxy,
                                       @Nullable final Key<UserInfo> userInfoKey,
                                       final boolean utf8); }
BasicAuthHttpServiceFilter implements StreamingHttpServiceFilterFactory, HttpExecutionStrategyInfluencer { @Override public StreamingHttpServiceFilter create(final StreamingHttpService service) { return new BasicAuthStreamingHttpService<>(this, service); } private  BasicAuthHttpServiceFilter(final CredentialsVerifier<UserInfo> credentialsVerifier,
                                       final String realm,
                                       final boolean proxy,
                                       @Nullable final Key<UserInfo> userInfoKey,
                                       final boolean utf8); @Override StreamingHttpServiceFilter create(final StreamingHttpService service); @Override HttpExecutionStrategy influenceStrategy(final HttpExecutionStrategy strategy); }
BasicAuthHttpServiceFilter implements StreamingHttpServiceFilterFactory, HttpExecutionStrategyInfluencer { @Override public StreamingHttpServiceFilter create(final StreamingHttpService service) { return new BasicAuthStreamingHttpService<>(this, service); } private  BasicAuthHttpServiceFilter(final CredentialsVerifier<UserInfo> credentialsVerifier,
                                       final String realm,
                                       final boolean proxy,
                                       @Nullable final Key<UserInfo> userInfoKey,
                                       final boolean utf8); @Override StreamingHttpServiceFilter create(final StreamingHttpService service); @Override HttpExecutionStrategy influenceStrategy(final HttpExecutionStrategy strategy);  }